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

The following examples show how to use org.apache.helix.model.Message#getRecord() . 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: GobblinHelixMessagingService.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private List<Message> generateMessagesForController(Message message) {
  List<Message> messages = new ArrayList<Message>();
  String id = UUID.randomUUID().toString();
  Message newMessage = new Message(message.getRecord(), id);
  newMessage.setMsgId(id);
  newMessage.setSrcName(_manager.getInstanceName());
  newMessage.setTgtName("Controller");
  messages.add(newMessage);
  return messages;
}
 
Example 2
Source File: DefaultMessagingService.java    From helix with Apache License 2.0 5 votes vote down vote up
private List<Message> generateMessagesForParticipant(Criteria recipientCriteria, Message message,
    HelixDataAccessor targetDataAccessor) {
  List<Message> messages = new ArrayList<Message>();
  List<Map<String, String>> matchedList =
      _evaluator.evaluateCriteria(recipientCriteria, targetDataAccessor);

  if (!matchedList.isEmpty()) {
    Map<String, String> sessionIdMap = new HashMap<String, String>();
    if (recipientCriteria.isSessionSpecific()) {
      Builder keyBuilder = targetDataAccessor.keyBuilder();
      // For backward compatibility, allow partial read for the live instances.
      // Note that this may cause the pending message to be sent with null target session Id.
      List<LiveInstance> liveInstances =
          targetDataAccessor.getChildValues(keyBuilder.liveInstances(), false);

      for (LiveInstance liveInstance : liveInstances) {
        sessionIdMap.put(liveInstance.getInstanceName(), liveInstance.getEphemeralOwner());
      }
    }
    for (Map<String, String> map : matchedList) {
      String id = UUID.randomUUID().toString();
      Message newMessage = new Message(message.getRecord(), id);
      String srcInstanceName = _manager.getInstanceName();
      String tgtInstanceName = map.get("instanceName");
      // Don't send message to self
      if (recipientCriteria.isSelfExcluded() && srcInstanceName.equalsIgnoreCase(tgtInstanceName)) {
        continue;
      }
      newMessage.setSrcName(srcInstanceName);
      newMessage.setTgtName(tgtInstanceName);
      newMessage.setResourceName(map.get("resourceName"));
      newMessage.setPartitionName(map.get("partitionName"));
      if (recipientCriteria.isSessionSpecific()) {
        newMessage.setTgtSessionId(sessionIdMap.get(tgtInstanceName));
      }
      messages.add(newMessage);
    }
  }
  return messages;
}
 
Example 3
Source File: DefaultMessagingService.java    From helix with Apache License 2.0 5 votes vote down vote up
private List<Message> generateMessagesForController(Message message) {
  List<Message> messages = new ArrayList<Message>();
  String id = (message.getMsgId() == null) ? UUID.randomUUID().toString() : message.getMsgId();
  Message newMessage = new Message(message.getRecord(), id);
  newMessage.setMsgId(id);
  newMessage.setSrcName(_manager.getInstanceName());
  newMessage.setTgtName(InstanceType.CONTROLLER.name());
  messages.add(newMessage);
  return messages;
}
 
Example 4
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 5
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 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");
}