@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)); } } }
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); }
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); }
@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)); } } }
@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)); } } }
message.setAttribute(Message.Attributes.ClusterEventName, eventType.name());
message.setAttribute(Message.Attributes.ClusterEventName, event.getEventType().name());