use of org.apache.helix.model.Message in project incubator-gobblin by apache.
the class GobblinAWSClusterLauncher method sendShutdownRequest.
@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()));
}
}
use of org.apache.helix.model.Message in project incubator-gobblin by apache.
the class GobblinClusterManager method sendShutdownRequest.
@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.helixManager);
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()));
}
}
use of org.apache.helix.model.Message in project incubator-gobblin by apache.
the class YarnAppSecurityManager method sendTokenFileUpdatedMessage.
@VisibleForTesting
void sendTokenFileUpdatedMessage(InstanceType instanceType) {
Criteria criteria = new Criteria();
criteria.setInstanceName("%");
criteria.setResource("%");
criteria.setPartition("%");
criteria.setPartitionState("%");
criteria.setRecipientInstanceType(instanceType);
/**
* #HELIX-0.6.7-WORKAROUND
* Add back when LIVESTANCES messaging is ported to 0.6 branch
* if (instanceType == InstanceType.PARTICIPANT) {
* criteria.setDataSource(Criteria.DataSource.LIVEINSTANCES);
* }
*/
criteria.setSessionSpecific(true);
Message tokenFileUpdatedMessage = new Message(Message.MessageType.USER_DEFINE_MSG, HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString().toLowerCase() + UUID.randomUUID().toString());
tokenFileUpdatedMessage.setMsgSubType(HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString());
tokenFileUpdatedMessage.setMsgState(Message.MessageState.NEW);
if (instanceType == InstanceType.CONTROLLER) {
tokenFileUpdatedMessage.setTgtSessionId("*");
}
// #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, tokenFileUpdatedMessage);
GobblinHelixMessagingService messagingService = new GobblinHelixMessagingService(this.helixManager);
int messagesSent = messagingService.send(criteria, tokenFileUpdatedMessage);
LOGGER.info(String.format("Sent %d token file updated message(s) to the %s", messagesSent, instanceType));
}
use of org.apache.helix.model.Message in project helix by apache.
the class HelixTask method forwardRelayMessages.
private void forwardRelayMessages(HelixDataAccessor accessor, Message message, long taskCompletionTime) {
if (message.hasRelayMessages()) {
Map<String, Message> relayMessages = message.getRelayMessages();
Builder keyBuilder = accessor.keyBuilder();
// Ignore all relay messages if participant's session has changed.
if (!_manager.getSessionId().equals(message.getTgtSessionId())) {
logger.info("Session id has been changed, ignore all relay messages attached with " + message.getId());
return;
}
for (String instance : relayMessages.keySet()) {
Message msg = relayMessages.get(instance);
if (msg.getMsgSubType().equals(MessageType.RELAYED_MESSAGE.name())) {
msg.setRelayTime(taskCompletionTime);
if (msg.isExpired()) {
logger.info("Relay message expired, ignore " + msg.getId() + " to instance " + instance);
continue;
}
PropertyKey msgKey = keyBuilder.message(instance, msg.getId());
boolean success = accessor.getBaseDataAccessor().create(msgKey.getPath(), msg.getRecord(), AccessOption.PERSISTENT);
if (!success) {
logger.warn("Failed to send relay message " + msg.getId() + " to " + instance);
} else {
logger.info("Send relay message " + message.getId() + " to " + instance);
}
}
}
}
}
use of org.apache.helix.model.Message in project helix by apache.
the class HelixTask method sendReply.
private void sendReply(HelixDataAccessor accessor, Message message, HelixTaskResult taskResult) {
if (_message.getCorrelationId() != null && !message.getMsgType().equals(MessageType.TASK_REPLY.name())) {
logger.info("Sending reply for message " + message.getCorrelationId());
_statusUpdateUtil.logInfo(message, HelixTask.class, "Sending reply", _manager);
taskResult.getTaskResultMap().put("SUCCESS", "" + taskResult.isSuccess());
taskResult.getTaskResultMap().put("INTERRUPTED", "" + taskResult.isInterrupted());
if (!taskResult.isSuccess()) {
taskResult.getTaskResultMap().put("ERRORINFO", taskResult.getMessage());
}
Message replyMessage = Message.createReplyMessage(_message, _manager.getInstanceName(), taskResult.getTaskResultMap());
replyMessage.setSrcInstanceType(_manager.getInstanceType());
if (message.getSrcInstanceType() == InstanceType.PARTICIPANT) {
Builder keyBuilder = accessor.keyBuilder();
accessor.setProperty(keyBuilder.message(message.getMsgSrc(), replyMessage.getMsgId()), replyMessage);
} else if (message.getSrcInstanceType() == InstanceType.CONTROLLER) {
Builder keyBuilder = accessor.keyBuilder();
accessor.setProperty(keyBuilder.controllerMessage(replyMessage.getMsgId()), replyMessage);
}
_statusUpdateUtil.logInfo(message, HelixTask.class, "1 msg replied to " + replyMessage.getTgtName(), _manager);
}
}
Aggregations