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

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

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

Message.getMsgSubType介绍

[英]Get the subtype of the message
[中]获取消息的子类型

代码示例

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

  1. /**
  2. * @param message The incoming message that has been received from helix.
  3. * @throws IllegalArgumentException if the message is not of right sub-type
  4. */
  5. public SegmentRefreshMessage(final Message message) {
  6. super(message.getRecord());
  7. if (!message.getMsgSubType().equals(REFRESH_SEGMENT_MSG_SUB_TYPE)) {
  8. throw new IllegalArgumentException("Invalid message subtype:" + message.getMsgSubType());
  9. }
  10. }

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

  1. public SegmentReloadMessage(Message message) {
  2. super(message.getRecord());
  3. String msgSubType = message.getMsgSubType();
  4. Preconditions.checkArgument(msgSubType.equals(RELOAD_SEGMENT_MSG_SUB_TYPE),
  5. "Invalid message sub type: " + msgSubType + " for SegmentReloadMessage");
  6. }
  7. }

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

  1. public TimeboundaryRefreshMessage(Message message) {
  2. super(message.getRecord());
  3. String msgSubType = message.getMsgSubType();
  4. Preconditions.checkArgument(msgSubType.equals(REFRESH_TIME_BOUNDARY_MSG_SUB_TYPE),
  5. "Invalid message sub type: " + msgSubType + " for TimeboundaryRefreshMessage");
  6. }
  7. }

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

  1. @Override
  2. public HelixTaskResult handleMessage() throws InterruptedException {
  3. log.warn(String
  4. .format("No handling setup for %s message of subtype: %s", Message.MessageType.USER_DEFINE_MSG.toString(),
  5. this._message.getMsgSubType()));
  6. HelixTaskResult helixTaskResult = new HelixTaskResult();
  7. helixTaskResult.setSuccess(true);
  8. return helixTaskResult;
  9. }

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

  1. @Override
  2. public HelixTaskResult handleMessage() throws InterruptedException {
  3. LOGGER.warn(String
  4. .format("No handling setup for %s message of subtype: %s", Message.MessageType.USER_DEFINE_MSG.toString(),
  5. this._message.getMsgSubType()));
  6. final HelixTaskResult helixTaskResult = new HelixTaskResult();
  7. helixTaskResult.setSuccess(true);
  8. return helixTaskResult;
  9. }

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

  1. @Override
  2. public HelixTaskResult handleMessage() throws InterruptedException {
  3. LOGGER.warn(String
  4. .format("No handling setup for %s message of subtype: %s", Message.MessageType.USER_DEFINE_MSG.toString(),
  5. this._message.getMsgSubType()));
  6. final HelixTaskResult helixTaskResult = new HelixTaskResult();
  7. helixTaskResult.setSuccess(true);
  8. return helixTaskResult;
  9. }

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

  1. @Override
  2. public HelixTaskResult handleMessage()
  3. throws InterruptedException {
  4. logger.warn(String.format("No handling setup for %s message of subtype: %s",
  5. Message.MessageType.USER_DEFINE_MSG.toString(), this._message.getMsgSubType()));
  6. HelixTaskResult helixTaskResult = new HelixTaskResult();
  7. helixTaskResult.setSuccess(true);
  8. return helixTaskResult;
  9. }

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

  1. @Override
  2. public MessageHandler createHandler(Message message, NotificationContext context) {
  3. String msgSubType = message.getMsgSubType();
  4. switch (msgSubType) {
  5. case TimeboundaryRefreshMessage.REFRESH_TIME_BOUNDARY_MSG_SUB_TYPE:
  6. LOGGER.info("time refresh msg received {} for table {}", message.getPartitionName());
  7. return new TimeboundaryRefreshMessageHandler(new TimeboundaryRefreshMessage(message), context);
  8. default:
  9. throw new UnsupportedOperationException("Unsupported user defined message sub type: " + msgSubType);
  10. }
  11. }

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

  1. @Override
  2. public HelixTaskResult handleMessage() throws InterruptedException {
  3. String messageSubType = this._message.getMsgSubType();
  4. if (messageSubType.equalsIgnoreCase(HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString())) {
  5. LOGGER.info("Handling message " + HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString());
  6. eventBus.post(new DelegationTokenUpdatedEvent());
  7. HelixTaskResult helixTaskResult = new HelixTaskResult();
  8. helixTaskResult.setSuccess(true);
  9. return helixTaskResult;
  10. }
  11. throw new IllegalArgumentException(String.format("Unknown %s message subtype: %s",
  12. Message.MessageType.USER_DEFINE_MSG.toString(), messageSubType));
  13. }

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

  1. @Override
  2. public HelixTaskResult handleMessage() throws InterruptedException {
  3. String messageSubType = this._message.getMsgSubType();
  4. if (messageSubType.equalsIgnoreCase(org.apache.gobblin.cluster.HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString())) {
  5. LOGGER.info("Handling message " + org.apache.gobblin.cluster.HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString());
  6. eventBus.post(new DelegationTokenUpdatedEvent());
  7. HelixTaskResult helixTaskResult = new HelixTaskResult();
  8. helixTaskResult.setSuccess(true);
  9. return helixTaskResult;
  10. }
  11. throw new IllegalArgumentException(String
  12. .format("Unknown %s message subtype: %s", Message.MessageType.USER_DEFINE_MSG.toString(), messageSubType));
  13. }

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

  1. @Override
  2. public HelixTaskResult handleMessage()
  3. throws InterruptedException {
  4. if (jobScheduler.isActive()) {
  5. // we want to make sure current node is in active state
  6. String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  7. log.info("{} ControllerUserDefinedMessage received : {}, type {}", this.serviceName, msg, _message.getMsgSubType());
  8. try {
  9. if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) {
  10. handleAdd(msg);
  11. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) {
  12. handleDelete(msg);
  13. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) {
  14. handleUpdate(msg);
  15. }
  16. } catch (IOException e) {
  17. log.error("Cannot process Helix message.", e);
  18. HelixTaskResult helixTaskResult = new HelixTaskResult();
  19. helixTaskResult.setSuccess(false);
  20. return helixTaskResult;
  21. }
  22. } else {
  23. String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  24. log.error("ControllerUserDefinedMessage received but ignored due to not in active mode: {}, type {}", msg,
  25. _message.getMsgSubType());
  26. }
  27. HelixTaskResult helixTaskResult = new HelixTaskResult();
  28. helixTaskResult.setSuccess(true);
  29. return helixTaskResult;
  30. }

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

  1. @Test(enabled = false)
  2. @Override
  3. public void assertMessageReception(Message message) {
  4. Assert.assertEquals(message.getMsgType(), GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE);
  5. Assert.assertEquals(message.getMsgSubType(), HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
  6. }
  7. }

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

  1. @Test(enabled = false)
  2. @Override
  3. public void assertMessageReception(Message message) {
  4. Assert.assertEquals(message.getMsgType(), GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE);
  5. Assert.assertEquals(message.getMsgSubType(), HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString());
  6. }

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

  1. @Test(enabled = false)
  2. @Override
  3. public void assertMessageReception(Message message) {
  4. Assert.assertEquals(message.getMsgType(), GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE);
  5. Assert.assertEquals(message.getMsgSubType(), HelixMessageSubTypes.WORK_UNIT_RUNNER_SHUTDOWN.toString());
  6. }
  7. }

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

  1. @Override
  2. public HelixTaskResult handleMessage()
  3. throws InterruptedException {
  4. String messageSubType = this._message.getMsgSubType();
  5. Preconditions.checkArgument(messageSubType
  6. .equalsIgnoreCase(HelixMessageSubTypes.WORK_UNIT_RUNNER_SHUTDOWN.toString()), String

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

  1. @Override
  2. public HelixTaskResult handleMessage() throws InterruptedException {
  3. String messageSubType = this._message.getMsgSubType();
  4. Preconditions.checkArgument(
  5. messageSubType.equalsIgnoreCase(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString()),

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

  1. @Override
  2. public MessageHandler createHandler(Message message, NotificationContext context) {
  3. String msgSubType = message.getMsgSubType();
  4. switch (msgSubType) {
  5. case SegmentRefreshMessage.REFRESH_SEGMENT_MSG_SUB_TYPE:
  6. return new SegmentRefreshMessageHandler(new SegmentRefreshMessage(message), _metrics, context);
  7. case SegmentReloadMessage.RELOAD_SEGMENT_MSG_SUB_TYPE:
  8. return new SegmentReloadMessageHandler(new SegmentReloadMessage(message), _metrics, context);
  9. default:
  10. throw new UnsupportedOperationException("Unsupported user defined message sub type: " + msgSubType);
  11. }
  12. }

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

相关文章