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

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

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

Message.setMsgState介绍

[英]Set the current state of the message
[中]设置消息的当前状态

代码示例

代码示例来源: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. @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. HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString().toLowerCase() + UUID.randomUUID().toString());
  2. tokenFileUpdatedMessage.setMsgSubType(HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString());
  3. tokenFileUpdatedMessage.setMsgState(Message.MessageState.NEW);
  4. if (instanceType == InstanceType.CONTROLLER) {
  5. tokenFileUpdatedMessage.setTgtSessionId("*");

代码示例来源: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.PARTICIPANT);
  9. // #HELIX-0.6.7-WORKAROUND
  10. // Add this back when messaging to instances is ported to 0.6 branch
  11. //criteria.setDataSource(Criteria.DataSource.LIVEINSTANCES);
  12. criteria.setSessionSpecific(true);
  13. Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
  14. HelixMessageSubTypes.WORK_UNIT_RUNNER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
  15. shutdownRequest.setMsgSubType(HelixMessageSubTypes.WORK_UNIT_RUNNER_SHUTDOWN.toString());
  16. shutdownRequest.setMsgState(Message.MessageState.NEW);
  17. // Wait for 5 minutes
  18. final int timeout = 300000;
  19. // #HELIX-0.6.7-WORKAROUND
  20. // Temporarily bypass the default messaging service to allow upgrade to 0.6.7 which is missing support
  21. // for messaging to instances
  22. //int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
  23. // new NoopReplyHandler(), timeout);
  24. GobblinHelixMessagingService messagingService = new GobblinHelixMessagingService(this.multiManager.getJobClusterHelixManager());
  25. int messagesSent = messagingService.send(criteria, shutdownRequest,
  26. new NoopReplyHandler(), timeout);
  27. if (messagesSent == 0) {
  28. LOGGER.error(String.format("Failed to send the %s message to the participants", shutdownRequest.getMsgSubType()));
  29. }
  30. }

代码示例来源: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. /**
  2. * Instantiate a message
  3. * @param record a ZNRecord corresponding to a message
  4. */
  5. public Message(ZNRecord record) {
  6. super(record);
  7. if (getMsgState() == null) {
  8. setMsgState(MessageState.NEW);
  9. }
  10. if (getCreateTimeStamp() == 0) {
  11. _record.setLongField(Attributes.CREATE_TIMESTAMP.toString(), new Date().getTime());
  12. }
  13. }

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

  1. /**
  2. * Instantiate a message
  3. * @param record a ZNRecord corresponding to a message
  4. */
  5. public Message(ZNRecord record) {
  6. super(record);
  7. if (getMsgState() == null) {
  8. setMsgState(MessageState.NEW);
  9. }
  10. if (getCreateTimeStamp() == 0) {
  11. _record.setLongField(Attributes.CREATE_TIMESTAMP.toString(), new Date().getTime());
  12. }
  13. }

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

  1. private void markReadMessage(Message message, NotificationContext context,
  2. HelixManager manager) {
  3. message.setMsgState(MessageState.READ);
  4. message.setReadTimeStamp(new Date().getTime());
  5. message.setExecuteSessionId(context.getManager().getSessionId());
  6. _statusUpdateUtil.logInfo(message, HelixStateMachineEngine.class, "New Message", manager);
  7. }

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

  1. private void markReadMessage(Message message, NotificationContext context,
  2. HelixManager manager) {
  3. message.setMsgState(MessageState.READ);
  4. message.setReadTimeStamp(new Date().getTime());
  5. message.setExecuteSessionId(context.getManager().getSessionId());
  6. _statusUpdateUtil.logInfo(message, HelixStateMachineEngine.class, "New Message", manager);
  7. }

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

  1. /**
  2. * Instantiate a message
  3. * @param type {@link MessageType} as a string or a custom message type
  4. * @param msgId unique message identifier
  5. */
  6. public Message(String type, String msgId) {
  7. super(new ZNRecord(msgId));
  8. _record.setSimpleField(Attributes.MSG_TYPE.toString(), type);
  9. setMsgId(msgId);
  10. setMsgState(MessageState.NEW);
  11. _record.setLongField(Attributes.CREATE_TIMESTAMP.toString(), new Date().getTime());
  12. }

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

  1. /**
  2. * Instantiate a message
  3. * @param type {@link MessageType} as a string or a custom message type
  4. * @param msgId unique message identifier
  5. */
  6. public Message(String type, String msgId) {
  7. super(new ZNRecord(msgId));
  8. _record.setSimpleField(Attributes.MSG_TYPE.toString(), type);
  9. setMsgId(msgId);
  10. setMsgState(MessageState.NEW);
  11. _record.setLongField(Attributes.CREATE_TIMESTAMP.toString(), new Date().getTime());
  12. }

代码示例来源: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: 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.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: org.apache.helix/helix-core

  1. public void postTestMessage(String zkServer, String clusterName, String instanceName) {
  2. String msgSrc = "cm-instance-0";
  3. String msgId = "TestMessageId-2";
  4. Message message = new Message(MessageType.STATE_TRANSITION, msgId);
  5. message.setMsgId(msgId);
  6. message.setSrcName(msgSrc);
  7. message.setTgtName(instanceName);
  8. message.setMsgState(MessageState.NEW);
  9. message.setFromState("Slave");
  10. message.setToState("Master");
  11. message.setPartitionName("EspressoDB.partition-0." + instanceName);
  12. post(zkServer, message, clusterName, instanceName);
  13. }

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

  1. public void postTestMessage(String zkServer, String clusterName, String instanceName) {
  2. String msgSrc = "cm-instance-0";
  3. String msgId = "TestMessageId-2";
  4. Message message = new Message(MessageType.STATE_TRANSITION, msgId);
  5. message.setMsgId(msgId);
  6. message.setSrcName(msgSrc);
  7. message.setTgtName(instanceName);
  8. message.setMsgState(MessageState.NEW);
  9. message.setFromState("Slave");
  10. message.setToState("Master");
  11. message.setPartitionName("EspressoDB.partition-0." + instanceName);
  12. post(zkServer, message, clusterName, instanceName);
  13. }

代码示例来源: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. }

相关文章