Java Code Examples for org.apache.helix.model.Message#getMsgSubType()

The following examples show how to use org.apache.helix.model.Message#getMsgSubType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrokerUserDefinedMessageHandlerFactory.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@Override
public MessageHandler createHandler(Message message, NotificationContext context) {
  String msgSubType = message.getMsgSubType();
  switch (msgSubType) {
    case SegmentRefreshMessage.REFRESH_SEGMENT_MSG_SUB_TYPE:
      return new RefreshSegmentMessageHandler(new SegmentRefreshMessage(message), context);
    case TableConfigRefreshMessage.REFRESH_TABLE_CONFIG_MSG_SUB_TYPE:
      return new RefreshTableConfigMessageHandler(new TableConfigRefreshMessage(message), context);
    default:
      // NOTE: Log a warning and return no-op message handler for unsupported message sub-types. This can happen when
      //       a new message sub-type is added, and the sender gets deployed first while receiver is still running the
      //       old version.
      LOGGER.warn("Received message with unsupported sub-type: {}, using no-op message handler", msgSubType);
      return new NoOpMessageHandler(message, context);
  }
}
 
Example 2
Source File: TestHelixTaskExecutor.java    From helix with Apache License 2.0 5 votes vote down vote up
@Override
public MessageHandler createHandler(Message message, NotificationContext context) {
  // TODO Auto-generated method stub
  if (message.getMsgSubType() != null && message.getMsgSubType().equals("EXCEPTION")) {
    throw new HelixException("Test Message handler exception, can ignore");
  }
  _handlersCreated++;
  return new TestMessageHandler(message, context);
}
 
Example 3
Source File: SegmentRefreshMessage.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for the receiver.
 *
 * @param message The incoming message that has been received from helix.
 * @throws IllegalArgumentException if the message is not of right sub-type
 */
public SegmentRefreshMessage(Message message) {
  super(message.getRecord());
  if (!message.getMsgSubType().equals(REFRESH_SEGMENT_MSG_SUB_TYPE)) {
    throw new IllegalArgumentException("Invalid message subtype:" + message.getMsgSubType());
  }
}
 
Example 4
Source File: TableConfigRefreshMessage.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for the receiver.
 */
public TableConfigRefreshMessage(Message message) {
  super(message.getRecord());
  if (!message.getMsgSubType().equals(REFRESH_TABLE_CONFIG_MSG_SUB_TYPE)) {
    throw new IllegalArgumentException("Invalid message subtype:" + message.getMsgSubType());
  }
}
 
Example 5
Source File: SegmentMessageHandlerFactory.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@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:
      LOGGER.warn("Unsupported user defined message sub type: {} for segment: {}", msgSubType,
          message.getPartitionName());
      return new DefaultMessageHandler(message, _metrics, context);
  }
}
 
Example 6
Source File: SegmentReloadMessage.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
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");
}