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

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

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

Message.setAttribute介绍

[英]Add or change a message attribute
[中]添加或更改消息属性

代码示例

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

@VisibleForTesting
 public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
   InstanceType instanceType, HelixManager helixManager, Logger logger) {
  Criteria criteria = new Criteria();
  criteria.setInstanceName("%");
  criteria.setResource("%");
  criteria.setPartition("%");
  criteria.setPartitionState("%");
  criteria.setRecipientInstanceType(instanceType);
  criteria.setSessionSpecific(true);

  Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  message.setMsgSubType(messageSubType);
  message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  message.setMsgState(Message.MessageState.NEW);
  message.setTgtSessionId("*");

  int messagesSent = helixManager.getMessagingService().send(criteria, message);
  if (messagesSent == 0) {
   logger.error(String.format("Failed to send the %s message to the participants", message));
  }
 }
}

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

public BatchMessageHandler(Message msg, NotificationContext context, MessageHandlerFactory fty,
  BatchMessageWrapper wrapper, TaskExecutor executor) {
 super(msg, context);
 if (fty == null || executor == null) {
  throw new HelixException("MessageHandlerFactory | TaskExecutor can't be null");
 }
 _msgHandlerFty = fty;
 _batchMsgWrapper = wrapper;
 _executor = executor;
 // create sub-messages
 _subMessages = new ArrayList<Message>();
 List<String> partitionKeys = _message.getPartitionNames();
 for (String partitionKey : partitionKeys) {
  // assign a new message id, put batch-msg-id to parent-id field
  Message subMsg = new Message(_message.getRecord(), UUID.randomUUID().toString());
  subMsg.setPartitionName(partitionKey);
  subMsg.setAttribute(Attributes.PARENT_MSG_ID, _message.getId());
  subMsg.setBatchMessageMode(false);
  _subMessages.add(subMsg);
 }
 // create sub-message handlers
 _subMessageHandlers = createMsgHandlers(_subMessages, context);
}

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

public BatchMessageHandler(Message msg, NotificationContext context, MessageHandlerFactory fty,
  BatchMessageWrapper wrapper, TaskExecutor executor) {
 super(msg, context);
 if (fty == null || executor == null) {
  throw new HelixException("MessageHandlerFactory | TaskExecutor can't be null");
 }
 _msgHandlerFty = fty;
 _batchMsgWrapper = wrapper;
 _executor = executor;
 // create sub-messages
 _subMessages = new ArrayList<Message>();
 List<String> partitionKeys = _message.getPartitionNames();
 for (String partitionKey : partitionKeys) {
  // assign a new message id, put batch-msg-id to parent-id field
  Message subMsg = new Message(_message.getRecord(), UUID.randomUUID().toString());
  subMsg.setPartitionName(partitionKey);
  subMsg.setAttribute(Attributes.PARENT_MSG_ID, _message.getId());
  subMsg.setBatchMessageMode(false);
  _subMessages.add(subMsg);
 }
 // create sub-message handlers
 _subMessageHandlers = createMsgHandlers(_subMessages, context);
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-service

@VisibleForTesting
 public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
   InstanceType instanceType, HelixManager helixManager, Logger logger) {
  Criteria criteria = new Criteria();
  criteria.setInstanceName("%");
  criteria.setResource("%");
  criteria.setPartition("%");
  criteria.setPartitionState("%");
  criteria.setRecipientInstanceType(instanceType);
  criteria.setSessionSpecific(true);

  Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  message.setMsgSubType(messageSubType);
  message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  message.setMsgState(Message.MessageState.NEW);
  message.setTgtSessionId("*");

  int messagesSent = helixManager.getMessagingService().send(criteria, message);
  if (messagesSent == 0) {
   logger.error(String.format("Failed to send the %s message to the participants", message));
  }
 }
}

代码示例来源:origin: org.apache.gobblin/gobblin-service

@VisibleForTesting
 public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId,
   InstanceType instanceType, HelixManager helixManager, Logger logger) {
  Criteria criteria = new Criteria();
  criteria.setInstanceName("%");
  criteria.setResource("%");
  criteria.setPartition("%");
  criteria.setPartitionState("%");
  criteria.setRecipientInstanceType(instanceType);
  criteria.setSessionSpecific(true);

  Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId);
  message.setMsgSubType(messageSubType);
  message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal);
  message.setMsgState(Message.MessageState.NEW);
  message.setTgtSessionId("*");

  int messagesSent = helixManager.getMessagingService().send(criteria, message);
  if (messagesSent == 0) {
   logger.error(String.format("Failed to send the %s message to the participants", message));
  }
 }
}

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

message.setAttribute(Message.Attributes.ClusterEventName, eventType.name());

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

message.setAttribute(Message.Attributes.ClusterEventName, event.getEventType().name());

相关文章