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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@Override
public HelixTaskResult handleMessage() throws InterruptedException {
 String messageSubType = this._message.getMsgSubType();
 if (messageSubType.equalsIgnoreCase(HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString())) {
  LOGGER.info("Handling message " + HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString());
  eventBus.post(new DelegationTokenUpdatedEvent());
  HelixTaskResult helixTaskResult = new HelixTaskResult();
  helixTaskResult.setSuccess(true);
  return helixTaskResult;
 }
 throw new IllegalArgumentException(String.format("Unknown %s message subtype: %s",
   Message.MessageType.USER_DEFINE_MSG.toString(), messageSubType));
}

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

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

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

@Override
public HelixTaskResult handleMessage()
  throws InterruptedException {
 if (jobScheduler.isActive()) {
  // we want to make sure current node is in active state
  String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  log.info("{} ControllerUserDefinedMessage received : {}, type {}", this.serviceName, msg, _message.getMsgSubType());
  try {
   if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) {
    handleAdd(msg);
   } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) {
    handleDelete(msg);
   } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) {
    handleUpdate(msg);
   }
  } catch (IOException e) {
   log.error("Cannot process Helix message.", e);
   HelixTaskResult helixTaskResult = new HelixTaskResult();
   helixTaskResult.setSuccess(false);
   return helixTaskResult;
  }
 } else {
  String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  log.error("ControllerUserDefinedMessage received but ignored due to not in active mode: {}, type {}", msg,
    _message.getMsgSubType());
 }
 HelixTaskResult helixTaskResult = new HelixTaskResult();
 helixTaskResult.setSuccess(true);
 return helixTaskResult;
}

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

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

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

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

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

@Test(enabled = false)
 @Override
 public void assertMessageReception(Message message) {
  Assert.assertEquals(message.getMsgType(), GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE);
  Assert.assertEquals(message.getMsgSubType(), HelixMessageSubTypes.WORK_UNIT_RUNNER_SHUTDOWN.toString());
 }
}

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

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

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

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

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

@Override
public MessageHandler createHandler(Message message, NotificationContext context) {
 String msgSubType = message.getMsgSubType();
 switch (msgSubType) {
  case SegmentRefreshMessage.REFRESH_SEGMENT_MSG_SUB_TYPE:
   return new SegmentRefreshMessageHandler(new SegmentRefreshMessage(message), _metrics, context);
  case SegmentReloadMessage.RELOAD_SEGMENT_MSG_SUB_TYPE:
   return new SegmentReloadMessageHandler(new SegmentReloadMessage(message), _metrics, context);
  default:
   throw new UnsupportedOperationException("Unsupported user defined message sub type: " + msgSubType);
 }
}

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

@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
void sendShutdownRequest() {
 Criteria criteria = new Criteria();
 criteria.setInstanceName("%");
 criteria.setResource("%");
 criteria.setPartition("%");
 criteria.setPartitionState("%");
 criteria.setRecipientInstanceType(InstanceType.PARTICIPANT);
 // #HELIX-0.6.7-WORKAROUND
 // Add this back when messaging to instances is ported to 0.6 branch
 //criteria.setDataSource(Criteria.DataSource.LIVEINSTANCES);
 criteria.setSessionSpecific(true);
 Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE,
   HelixMessageSubTypes.WORK_UNIT_RUNNER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString());
 shutdownRequest.setMsgSubType(HelixMessageSubTypes.WORK_UNIT_RUNNER_SHUTDOWN.toString());
 shutdownRequest.setMsgState(Message.MessageState.NEW);
 // Wait for 5 minutes
 final int timeout = 300000;
 // #HELIX-0.6.7-WORKAROUND
 // Temporarily bypass the default messaging service to allow upgrade to 0.6.7 which is missing support
 // for messaging to instances
 //int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest,
 //    new NoopReplyHandler(), timeout);
 GobblinHelixMessagingService messagingService = new GobblinHelixMessagingService(this.multiManager.getJobClusterHelixManager());
 int messagesSent = messagingService.send(criteria, shutdownRequest,
     new NoopReplyHandler(), timeout);
 if (messagesSent == 0) {
  LOGGER.error(String.format("Failed to send the %s message to the participants", shutdownRequest.getMsgSubType()));
 }
}

相关文章