org.apache.helix.model.Message.setTgtSessionId()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(17.0k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.apache.helix.model.Message.setTgtSessionId()方法的一些代码示例,展示了Message.setTgtSessionId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setTgtSessionId()方法的具体详情如下:
包路径:org.apache.helix.model.Message
类名称:Message
方法名:setTgtSessionId

Message.setTgtSessionId介绍

[英]Set the session identifier of the destination node
[中]设置目标节点的会话标识符

代码示例

代码示例来源:origin: apache/incubator-gobblin

@VisibleForTesting
void sendShutdownRequest() {
 Criteria criteria = new Criteria();
 criteria.setInstanceName("%");
 criteria.setResource("%");
 criteria.setPartition("%");
 criteria.setPartitionState("%");
 criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
 criteria.setSessionSpecific(true);
 Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
   HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
 shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
 shutdownRequest.setMsgState(Message.MessageState.NEW);
 shutdownRequest.setTgtSessionId("*");
 int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest);
 if (messagesSent == 0) {
  LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
 }
}

代码示例来源:origin: apache/incubator-gobblin

newMessage.setPartitionName(map.get("partitionName"));
if (recipientCriteria.isSessionSpecific()) {
 newMessage.setTgtSessionId(sessionIdMap.get(tgtInstanceName));

代码示例来源:origin: apache/incubator-gobblin

tokenFileUpdatedMessage.setMsgState(Message.MessageState.NEW);
if (instanceType == InstanceType.CONTROLLER) {
 tokenFileUpdatedMessage.setTgtSessionId("*");

代码示例来源:origin: apache/incubator-gobblin

@VisibleForTesting
void sendShutdownRequest() {
 final Criteria criteria = new Criteria();
 criteria.setInstanceName("%");
 criteria.setResource("%");
 criteria.setPartition("%");
 criteria.setPartitionState("%");
 criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
 criteria.setSessionSpecific(true);
 final Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
   HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
 shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
 shutdownRequest.setMsgState(Message.MessageState.NEW);
 shutdownRequest.setTgtSessionId("*");
 // Wait for 5 minutes
 final int timeout = 300000;
 // Send shutdown request to Cluster master, which will send shutdown request to workers
 // Upon receiving shutdown response from workers, master will shut itself down and call back shutdownASG()
 final int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
   shutdownASG(),timeout);
 if (messagesSent == 0) {
  LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
 }
}

代码示例来源:origin: apache/incubator-gobblin

@VisibleForTesting
 public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
   InstanceType instanceType, HelixManager helixManager, Logger logger) {
  Criteria criteria = new Criteria();
  criteria.setInstanceName("%");
  criteria.setResource("%");
  criteria.setPartition("%");
  criteria.setPartitionState("%");
  criteria.setRecipientInstanceType(instanceType);
  criteria.setSessionSpecific(true);

  Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  message.setMsgSubType(messageSubType);
  message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  message.setMsgState(Message.MessageState.NEW);
  message.setTgtSessionId("*");

  int messagesSent = helixManager.getMessagingService().send(criteria, message);
  if (messagesSent == 0) {
   logger.error(String.format("Failed to send the %s message to the participants", message));
  }
 }
}

代码示例来源:origin: apache/helix

private static Message newMsg() {
  Message msg = new Message(DUMMY_MSG_TYPE, UUID.randomUUID().toString());
  msg.setTgtSessionId("*");
  msg.setTgtName("localhost_12918");
  return msg;
 }
}

代码示例来源:origin: org.apache.gobblin/gobblin-yarn

@VisibleForTesting
void sendShutdownRequest() {
 Criteria criteria = new Criteria();
 criteria.setInstanceName("%");
 criteria.setResource("%");
 criteria.setPartition("%");
 criteria.setPartitionState("%");
 criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
 criteria.setSessionSpecific(true);
 Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
   HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
 shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
 shutdownRequest.setMsgState(Message.MessageState.NEW);
 shutdownRequest.setTgtSessionId("*");
 int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest);
 if (messagesSent == 0) {
  LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
 }
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-aws

@VisibleForTesting
void sendShutdownRequest() {
 final Criteria criteria = new Criteria();
 criteria.setInstanceName("%");
 criteria.setResource("%");
 criteria.setPartition("%");
 criteria.setPartitionState("%");
 criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
 criteria.setSessionSpecific(true);
 final Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
   HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
 shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
 shutdownRequest.setMsgState(Message.MessageState.NEW);
 shutdownRequest.setTgtSessionId("*");
 // Wait for 5 minutes
 final int timeout = 300000;
 // Send shutdown request to Cluster master, which will send shutdown request to workers
 // Upon receiving shutdown response from workers, master will shut itself down and call back shutdownASG()
 final int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
   shutdownASG(),timeout);
 if (messagesSent == 0) {
  LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
 }
}

代码示例来源:origin: org.apache.gobblin/gobblin-aws

@VisibleForTesting
void sendShutdownRequest() {
 final Criteria criteria = new Criteria();
 criteria.setInstanceName("%");
 criteria.setResource("%");
 criteria.setPartition("%");
 criteria.setPartitionState("%");
 criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
 criteria.setSessionSpecific(true);
 final Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
   HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
 shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
 shutdownRequest.setMsgState(Message.MessageState.NEW);
 shutdownRequest.setTgtSessionId("*");
 // Wait for 5 minutes
 final int timeout = 300000;
 // Send shutdown request to Cluster master, which will send shutdown request to workers
 // Upon receiving shutdown response from workers, master will shut itself down and call back shutdownASG()
 final int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
   shutdownASG(),timeout);
 if (messagesSent == 0) {
  LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
 }
}

代码示例来源:origin: org.apache.helix/helix-core

private void syncSessionToController(HelixManager manager) {
 if (_lastSessionSyncTime == null ||
     System.currentTimeMillis() - _lastSessionSyncTime > SESSION_SYNC_INTERVAL) { // > delay since last sync
  HelixDataAccessor accessor = manager.getHelixDataAccessor();
  PropertyKey key = new Builder(manager.getClusterName()).controllerMessage(SESSION_SYNC);
  if (accessor.getProperty(key) == null) {
   LOG.info(String.format("Participant %s syncs session with controller", manager.getInstanceName()));
   Message msg = new Message(MessageType.PARTICIPANT_SESSION_CHANGE, SESSION_SYNC);
   msg.setSrcName(manager.getInstanceName());
   msg.setTgtSessionId("*");
   msg.setMsgState(MessageState.NEW);
   msg.setMsgId(SESSION_SYNC);
   Criteria cr = new Criteria();
   cr.setRecipientInstanceType(InstanceType.CONTROLLER);
   cr.setSessionSpecific(false);
   manager.getMessagingService().send(cr, msg);
   _lastSessionSyncTime = System.currentTimeMillis();
  }
 }
}

代码示例来源:origin: apache/helix

private void syncSessionToController(HelixManager manager) {
 if (_lastSessionSyncTime == null ||
     System.currentTimeMillis() - _lastSessionSyncTime > SESSION_SYNC_INTERVAL) { // > delay since last sync
  HelixDataAccessor accessor = manager.getHelixDataAccessor();
  PropertyKey key = new Builder(manager.getClusterName()).controllerMessage(SESSION_SYNC);
  if (accessor.getProperty(key) == null) {
   LOG.info(String.format("Participant %s syncs session with controller", manager.getInstanceName()));
   Message msg = new Message(MessageType.PARTICIPANT_SESSION_CHANGE, SESSION_SYNC);
   msg.setSrcName(manager.getInstanceName());
   msg.setTgtSessionId("*");
   msg.setMsgState(MessageState.NEW);
   msg.setMsgId(SESSION_SYNC);
   Criteria cr = new Criteria();
   cr.setRecipientInstanceType(InstanceType.CONTROLLER);
   cr.setSessionSpecific(false);
   manager.getMessagingService().send(cr, msg);
   _lastSessionSyncTime = System.currentTimeMillis();
  }
 }
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-service

@VisibleForTesting
 public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
   InstanceType instanceType, HelixManager helixManager, Logger logger) {
  Criteria criteria = new Criteria();
  criteria.setInstanceName("%");
  criteria.setResource("%");
  criteria.setPartition("%");
  criteria.setPartitionState("%");
  criteria.setRecipientInstanceType(instanceType);
  criteria.setSessionSpecific(true);

  Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  message.setMsgSubType(messageSubType);
  message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  message.setMsgState(Message.MessageState.NEW);
  message.setTgtSessionId("*");

  int messagesSent = helixManager.getMessagingService().send(criteria, message);
  if (messagesSent == 0) {
   logger.error(String.format("Failed to send the %s message to the participants", message));
  }
 }
}

代码示例来源:origin: org.apache.gobblin/gobblin-service

@VisibleForTesting
 public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
   InstanceType instanceType, HelixManager helixManager, Logger logger) {
  Criteria criteria = new Criteria();
  criteria.setInstanceName("%");
  criteria.setResource("%");
  criteria.setPartition("%");
  criteria.setPartitionState("%");
  criteria.setRecipientInstanceType(instanceType);
  criteria.setSessionSpecific(true);

  Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  message.setMsgSubType(messageSubType);
  message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  message.setMsgState(Message.MessageState.NEW);
  message.setTgtSessionId("*");

  int messagesSent = helixManager.getMessagingService().send(criteria, message);
  if (messagesSent == 0) {
   logger.error(String.format("Failed to send the %s message to the participants", message));
  }
 }
}

代码示例来源:origin: apache/helix

@Override public void doInject(ClusterDataCache cache) {
  String topStateNode = null;
  for (String instance : cfg.initialCurrentStates.keySet()) {
   if (cfg.initialCurrentStates.get(instance).currentState.equals("MASTER")) {
    topStateNode = instance;
    break;
   }
  }
  // Simulate the previous top state instance goes offline
  if (topStateNode != null) {
   long originalStartTime = cfg.currentStateWithMissingTopState.get(topStateNode).startTime;
   // Inject a message that fit expectedDuration
   Message message =
     new Message(Message.MessageType.STATE_TRANSITION, "thisisafakemessage");
   message.setTgtSessionId(SESSION_PREFIX + topStateNode.split("_")[1]);
   message.setToState("MASTER");
   message.setCreateTimeStamp(originalStartTime - messageTimeBeforeMasterless);
   message.setTgtName(topStateNode);
   message.setResourceName(TEST_RESOURCE);
   message.setPartitionName(PARTITION);
   cache.cacheMessages(Collections.singletonList(message));
  }
 }
}, 1, 0,

代码示例来源:origin: org.apache.helix/helix-core

public void post(String zkServer, Message message, String clusterName, String instanceName) {
 ZkClient client = new ZkClient(zkServer);
 client.setZkSerializer(new ZNRecordSerializer());
 String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
 client.delete(path);
 ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
 message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
 message.setTgtName(record.getId());
 // System.out.println(message);
 client.createPersistent(path, message.getRecord());
}

代码示例来源:origin: apache/helix

void sendMessage(String msgId, String instanceName, String fromState, String toState,
  String partitionKey, int partitionId) throws InterruptedException, JsonGenerationException,
  JsonMappingException, IOException {
 Message message = new Message(MessageType.STATE_TRANSITION, msgId);
 message.setMsgId(msgId);
 message.setSrcName(srcName);
 message.setTgtName(instanceName);
 message.setMsgState(MessageState.NEW);
 message.setFromState(fromState);
 message.setToState(toState);
 // message.setPartitionId(partitionId);
 message.setPartitionName(partitionKey);
 String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
 ObjectMapper mapper = new ObjectMapper();
 StringWriter sw = new StringWriter();
 mapper.writeValueUsingView(sw, message, Message.class);
 System.out.println(sw.toString());
 client.delete(path);
 Thread.sleep(10000);
 ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
 message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())
   .toString());
 client.createPersistent(path, message);
}

代码示例来源:origin: apache/helix

public void post(String zkServer, Message message, String clusterName, String instanceName) {
 HelixZkClient client = SharedZkClientFactory.getInstance().buildZkClient(new HelixZkClient.ZkConnectionConfig(
   zkServer));
 client.setZkSerializer(new ZNRecordSerializer());
 String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
 client.delete(path);
 ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
 message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
 message.setTgtName(record.getId());
 // System.out.println(message);
 client.createPersistent(path, message.getRecord());
}

代码示例来源:origin: org.apache.helix/helix-core

private Message createStateTransitionMessage(HelixManager manager, Resource resource, String partitionName,
  String instanceName, String currentState, String nextState, String sessionId,
  String stateModelDefName) {
 String uuid = UUID.randomUUID().toString();
 Message message = new Message(MessageType.STATE_TRANSITION, uuid);
 message.setSrcName(manager.getInstanceName());
 message.setTgtName(instanceName);
 message.setMsgState(MessageState.NEW);
 message.setPartitionName(partitionName);
 message.setResourceName(resource.getResourceName());
 message.setFromState(currentState);
 message.setToState(nextState);
 message.setTgtSessionId(sessionId);
 message.setSrcSessionId(manager.getSessionId());
 message.setStateModelDef(stateModelDefName);
 message.setStateModelFactoryName(resource.getStateModelFactoryname());
 message.setBucketSize(resource.getBucketSize());
 if (resource.getResourceGroupName() != null) {
  message.setResourceGroupName(resource.getResourceGroupName());
 }
 if (resource.getResourceTag() != null) {
  message.setResourceTag(resource.getResourceTag());
 }
 return message;
}

代码示例来源:origin: apache/helix

private Message newMessage(String resourceName, String partitionName, String instanceName,
  String fromState, String toState) {
 String uuid = UUID.randomUUID().toString();
 Message message = new Message(MessageType.STATE_TRANSITION, uuid);
 message.setSrcName("controller");
 message.setTgtName(instanceName);
 message.setMsgState(MessageState.NEW);
 message.setResourceName(resourceName);
 message.setPartitionName(partitionName);
 message.setFromState(fromState);
 message.setToState(toState);
 message.setTgtSessionId("sessionId");
 message.setSrcSessionId("sessionId");
 message.setStateModelDef("MasterSlave");
 message.setStateModelFactoryName("DEFAULT");
 message.setBucketSize(0);
 return message;
}

代码示例来源:origin: apache/helix

private Message generateMessage(String from, String to) {
 String uuid = UUID.randomUUID().toString();
 Message message = new Message(Message.MessageType.STATE_TRANSITION, uuid);
 message.setSrcName("ADMIN");
 message.setTgtName(_participant.getInstanceName());
 message.setMsgState(Message.MessageState.NEW);
 message.setPartitionName("P");
 message.setResourceName(WorkflowGenerator.DEFAULT_TGT_DB);
 message.setFromState(from);
 message.setToState(to);
 message.setTgtSessionId(_participant.getSessionId());
 message.setSrcSessionId(_manager.getSessionId());
 message.setStateModelDef("OnlineOffline");
 message.setStateModelFactoryName("DEFAULT");
 return message;
}

相关文章