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

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

本文整理了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

  1. @VisibleForTesting
  2. void sendShutdownRequest() {
  3. Criteria criteria = new Criteria();
  4. criteria.setInstanceName("%");
  5. criteria.setResource("%");
  6. criteria.setPartition("%");
  7. criteria.setPartitionState("%");
  8. criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
  9. criteria.setSessionSpecific(true);
  10. Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
  11. HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
  12. shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
  13. shutdownRequest.setMsgState(Message.MessageState.NEW);
  14. shutdownRequest.setTgtSessionId("*");
  15. int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest);
  16. if (messagesSent == 0) {
  17. LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
  18. }
  19. }

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

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

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

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

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

  1. @VisibleForTesting
  2. void sendShutdownRequest() {
  3. final Criteria criteria = new Criteria();
  4. criteria.setInstanceName("%");
  5. criteria.setResource("%");
  6. criteria.setPartition("%");
  7. criteria.setPartitionState("%");
  8. criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
  9. criteria.setSessionSpecific(true);
  10. final Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
  11. HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
  12. shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
  13. shutdownRequest.setMsgState(Message.MessageState.NEW);
  14. shutdownRequest.setTgtSessionId("*");
  15. // Wait for 5 minutes
  16. final int timeout = 300000;
  17. // Send shutdown request to Cluster master, which will send shutdown request to workers
  18. // Upon receiving shutdown response from workers, master will shut itself down and call back shutdownASG()
  19. final int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
  20. shutdownASG(),timeout);
  21. if (messagesSent == 0) {
  22. LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
  23. }
  24. }

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

  1. @VisibleForTesting
  2. public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
  3. InstanceType instanceType, HelixManager helixManager, Logger logger) {
  4. Criteria criteria = new Criteria();
  5. criteria.setInstanceName("%");
  6. criteria.setResource("%");
  7. criteria.setPartition("%");
  8. criteria.setPartitionState("%");
  9. criteria.setRecipientInstanceType(instanceType);
  10. criteria.setSessionSpecific(true);
  11. Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  12. message.setMsgSubType(messageSubType);
  13. message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  14. message.setMsgState(Message.MessageState.NEW);
  15. message.setTgtSessionId("*");
  16. int messagesSent = helixManager.getMessagingService().send(criteria, message);
  17. if (messagesSent == 0) {
  18. logger.error(String.format("Failed to send the %s message to the participants", message));
  19. }
  20. }
  21. }

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

  1. private static Message newMsg() {
  2. Message msg = new Message(DUMMY_MSG_TYPE, UUID.randomUUID().toString());
  3. msg.setTgtSessionId("*");
  4. msg.setTgtName("localhost_12918");
  5. return msg;
  6. }
  7. }

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

  1. @VisibleForTesting
  2. void sendShutdownRequest() {
  3. Criteria criteria = new Criteria();
  4. criteria.setInstanceName("%");
  5. criteria.setResource("%");
  6. criteria.setPartition("%");
  7. criteria.setPartitionState("%");
  8. criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
  9. criteria.setSessionSpecific(true);
  10. Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
  11. HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
  12. shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
  13. shutdownRequest.setMsgState(Message.MessageState.NEW);
  14. shutdownRequest.setTgtSessionId("*");
  15. int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest);
  16. if (messagesSent == 0) {
  17. LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
  18. }
  19. }

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

  1. @VisibleForTesting
  2. void sendShutdownRequest() {
  3. final Criteria criteria = new Criteria();
  4. criteria.setInstanceName("%");
  5. criteria.setResource("%");
  6. criteria.setPartition("%");
  7. criteria.setPartitionState("%");
  8. criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
  9. criteria.setSessionSpecific(true);
  10. final Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
  11. HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
  12. shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
  13. shutdownRequest.setMsgState(Message.MessageState.NEW);
  14. shutdownRequest.setTgtSessionId("*");
  15. // Wait for 5 minutes
  16. final int timeout = 300000;
  17. // Send shutdown request to Cluster master, which will send shutdown request to workers
  18. // Upon receiving shutdown response from workers, master will shut itself down and call back shutdownASG()
  19. final int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
  20. shutdownASG(),timeout);
  21. if (messagesSent == 0) {
  22. LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
  23. }
  24. }

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

  1. @VisibleForTesting
  2. void sendShutdownRequest() {
  3. final Criteria criteria = new Criteria();
  4. criteria.setInstanceName("%");
  5. criteria.setResource("%");
  6. criteria.setPartition("%");
  7. criteria.setPartitionState("%");
  8. criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
  9. criteria.setSessionSpecific(true);
  10. final Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
  11. HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
  12. shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
  13. shutdownRequest.setMsgState(Message.MessageState.NEW);
  14. shutdownRequest.setTgtSessionId("*");
  15. // Wait for 5 minutes
  16. final int timeout = 300000;
  17. // Send shutdown request to Cluster master, which will send shutdown request to workers
  18. // Upon receiving shutdown response from workers, master will shut itself down and call back shutdownASG()
  19. final int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
  20. shutdownASG(),timeout);
  21. if (messagesSent == 0) {
  22. LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
  23. }
  24. }

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

  1. private void syncSessionToController(HelixManager manager) {
  2. if (_lastSessionSyncTime == null ||
  3. System.currentTimeMillis() - _lastSessionSyncTime > SESSION_SYNC_INTERVAL) { // > delay since last sync
  4. HelixDataAccessor accessor = manager.getHelixDataAccessor();
  5. PropertyKey key = new Builder(manager.getClusterName()).controllerMessage(SESSION_SYNC);
  6. if (accessor.getProperty(key) == null) {
  7. LOG.info(String.format("Participant %s syncs session with controller", manager.getInstanceName()));
  8. Message msg = new Message(MessageType.PARTICIPANT_SESSION_CHANGE, SESSION_SYNC);
  9. msg.setSrcName(manager.getInstanceName());
  10. msg.setTgtSessionId("*");
  11. msg.setMsgState(MessageState.NEW);
  12. msg.setMsgId(SESSION_SYNC);
  13. Criteria cr = new Criteria();
  14. cr.setRecipientInstanceType(InstanceType.CONTROLLER);
  15. cr.setSessionSpecific(false);
  16. manager.getMessagingService().send(cr, msg);
  17. _lastSessionSyncTime = System.currentTimeMillis();
  18. }
  19. }
  20. }

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

  1. private void syncSessionToController(HelixManager manager) {
  2. if (_lastSessionSyncTime == null ||
  3. System.currentTimeMillis() - _lastSessionSyncTime > SESSION_SYNC_INTERVAL) { // > delay since last sync
  4. HelixDataAccessor accessor = manager.getHelixDataAccessor();
  5. PropertyKey key = new Builder(manager.getClusterName()).controllerMessage(SESSION_SYNC);
  6. if (accessor.getProperty(key) == null) {
  7. LOG.info(String.format("Participant %s syncs session with controller", manager.getInstanceName()));
  8. Message msg = new Message(MessageType.PARTICIPANT_SESSION_CHANGE, SESSION_SYNC);
  9. msg.setSrcName(manager.getInstanceName());
  10. msg.setTgtSessionId("*");
  11. msg.setMsgState(MessageState.NEW);
  12. msg.setMsgId(SESSION_SYNC);
  13. Criteria cr = new Criteria();
  14. cr.setRecipientInstanceType(InstanceType.CONTROLLER);
  15. cr.setSessionSpecific(false);
  16. manager.getMessagingService().send(cr, msg);
  17. _lastSessionSyncTime = System.currentTimeMillis();
  18. }
  19. }
  20. }

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

  1. @VisibleForTesting
  2. public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
  3. InstanceType instanceType, HelixManager helixManager, Logger logger) {
  4. Criteria criteria = new Criteria();
  5. criteria.setInstanceName("%");
  6. criteria.setResource("%");
  7. criteria.setPartition("%");
  8. criteria.setPartitionState("%");
  9. criteria.setRecipientInstanceType(instanceType);
  10. criteria.setSessionSpecific(true);
  11. Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  12. message.setMsgSubType(messageSubType);
  13. message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  14. message.setMsgState(Message.MessageState.NEW);
  15. message.setTgtSessionId("*");
  16. int messagesSent = helixManager.getMessagingService().send(criteria, message);
  17. if (messagesSent == 0) {
  18. logger.error(String.format("Failed to send the %s message to the participants", message));
  19. }
  20. }
  21. }

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

  1. @VisibleForTesting
  2. public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
  3. InstanceType instanceType, HelixManager helixManager, Logger logger) {
  4. Criteria criteria = new Criteria();
  5. criteria.setInstanceName("%");
  6. criteria.setResource("%");
  7. criteria.setPartition("%");
  8. criteria.setPartitionState("%");
  9. criteria.setRecipientInstanceType(instanceType);
  10. criteria.setSessionSpecific(true);
  11. Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  12. message.setMsgSubType(messageSubType);
  13. message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  14. message.setMsgState(Message.MessageState.NEW);
  15. message.setTgtSessionId("*");
  16. int messagesSent = helixManager.getMessagingService().send(criteria, message);
  17. if (messagesSent == 0) {
  18. logger.error(String.format("Failed to send the %s message to the participants", message));
  19. }
  20. }
  21. }

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

  1. @Override public void doInject(ClusterDataCache cache) {
  2. String topStateNode = null;
  3. for (String instance : cfg.initialCurrentStates.keySet()) {
  4. if (cfg.initialCurrentStates.get(instance).currentState.equals("MASTER")) {
  5. topStateNode = instance;
  6. break;
  7. }
  8. }
  9. // Simulate the previous top state instance goes offline
  10. if (topStateNode != null) {
  11. long originalStartTime = cfg.currentStateWithMissingTopState.get(topStateNode).startTime;
  12. // Inject a message that fit expectedDuration
  13. Message message =
  14. new Message(Message.MessageType.STATE_TRANSITION, "thisisafakemessage");
  15. message.setTgtSessionId(SESSION_PREFIX + topStateNode.split("_")[1]);
  16. message.setToState("MASTER");
  17. message.setCreateTimeStamp(originalStartTime - messageTimeBeforeMasterless);
  18. message.setTgtName(topStateNode);
  19. message.setResourceName(TEST_RESOURCE);
  20. message.setPartitionName(PARTITION);
  21. cache.cacheMessages(Collections.singletonList(message));
  22. }
  23. }
  24. }, 1, 0,

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

  1. public void post(String zkServer, Message message, String clusterName, String instanceName) {
  2. ZkClient client = new ZkClient(zkServer);
  3. client.setZkSerializer(new ZNRecordSerializer());
  4. String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
  5. client.delete(path);
  6. ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
  7. message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
  8. message.setTgtName(record.getId());
  9. // System.out.println(message);
  10. client.createPersistent(path, message.getRecord());
  11. }

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

  1. void sendMessage(String msgId, String instanceName, String fromState, String toState,
  2. String partitionKey, int partitionId) throws InterruptedException, JsonGenerationException,
  3. JsonMappingException, IOException {
  4. Message message = new Message(MessageType.STATE_TRANSITION, msgId);
  5. message.setMsgId(msgId);
  6. message.setSrcName(srcName);
  7. message.setTgtName(instanceName);
  8. message.setMsgState(MessageState.NEW);
  9. message.setFromState(fromState);
  10. message.setToState(toState);
  11. // message.setPartitionId(partitionId);
  12. message.setPartitionName(partitionKey);
  13. String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
  14. ObjectMapper mapper = new ObjectMapper();
  15. StringWriter sw = new StringWriter();
  16. mapper.writeValueUsingView(sw, message, Message.class);
  17. System.out.println(sw.toString());
  18. client.delete(path);
  19. Thread.sleep(10000);
  20. ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
  21. message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())
  22. .toString());
  23. client.createPersistent(path, message);
  24. }

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

  1. public void post(String zkServer, Message message, String clusterName, String instanceName) {
  2. HelixZkClient client = SharedZkClientFactory.getInstance().buildZkClient(new HelixZkClient.ZkConnectionConfig(
  3. zkServer));
  4. client.setZkSerializer(new ZNRecordSerializer());
  5. String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
  6. client.delete(path);
  7. ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
  8. message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
  9. message.setTgtName(record.getId());
  10. // System.out.println(message);
  11. client.createPersistent(path, message.getRecord());
  12. }

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

  1. private Message createStateTransitionMessage(HelixManager manager, Resource resource, String partitionName,
  2. String instanceName, String currentState, String nextState, String sessionId,
  3. String stateModelDefName) {
  4. String uuid = UUID.randomUUID().toString();
  5. Message message = new Message(MessageType.STATE_TRANSITION, uuid);
  6. message.setSrcName(manager.getInstanceName());
  7. message.setTgtName(instanceName);
  8. message.setMsgState(MessageState.NEW);
  9. message.setPartitionName(partitionName);
  10. message.setResourceName(resource.getResourceName());
  11. message.setFromState(currentState);
  12. message.setToState(nextState);
  13. message.setTgtSessionId(sessionId);
  14. message.setSrcSessionId(manager.getSessionId());
  15. message.setStateModelDef(stateModelDefName);
  16. message.setStateModelFactoryName(resource.getStateModelFactoryname());
  17. message.setBucketSize(resource.getBucketSize());
  18. if (resource.getResourceGroupName() != null) {
  19. message.setResourceGroupName(resource.getResourceGroupName());
  20. }
  21. if (resource.getResourceTag() != null) {
  22. message.setResourceTag(resource.getResourceTag());
  23. }
  24. return message;
  25. }

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

  1. private Message newMessage(String resourceName, String partitionName, String instanceName,
  2. String fromState, String toState) {
  3. String uuid = UUID.randomUUID().toString();
  4. Message message = new Message(MessageType.STATE_TRANSITION, uuid);
  5. message.setSrcName("controller");
  6. message.setTgtName(instanceName);
  7. message.setMsgState(MessageState.NEW);
  8. message.setResourceName(resourceName);
  9. message.setPartitionName(partitionName);
  10. message.setFromState(fromState);
  11. message.setToState(toState);
  12. message.setTgtSessionId("sessionId");
  13. message.setSrcSessionId("sessionId");
  14. message.setStateModelDef("MasterSlave");
  15. message.setStateModelFactoryName("DEFAULT");
  16. message.setBucketSize(0);
  17. return message;
  18. }

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

  1. private Message generateMessage(String from, String to) {
  2. String uuid = UUID.randomUUID().toString();
  3. Message message = new Message(Message.MessageType.STATE_TRANSITION, uuid);
  4. message.setSrcName("ADMIN");
  5. message.setTgtName(_participant.getInstanceName());
  6. message.setMsgState(Message.MessageState.NEW);
  7. message.setPartitionName("P");
  8. message.setResourceName(WorkflowGenerator.DEFAULT_TGT_DB);
  9. message.setFromState(from);
  10. message.setToState(to);
  11. message.setTgtSessionId(_participant.getSessionId());
  12. message.setSrcSessionId(_manager.getSessionId());
  13. message.setStateModelDef("OnlineOffline");
  14. message.setStateModelFactoryName("DEFAULT");
  15. return message;
  16. }

相关文章