本文整理了Java中org.apache.helix.model.Message.<init>()
方法的一些代码示例,展示了Message.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.<init>()
方法的具体详情如下:
包路径:org.apache.helix.model.Message
类名称:Message
方法名:<init>
[英]Instantiate a message
[中]实例化一条消息
代码示例来源:origin: apache/incubator-gobblin
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;
}
代码示例来源:origin: apache/incubator-gobblin
@VisibleForTesting
void sendShutdownRequest() {
Criteria criteria = new Criteria();
criteria.setInstanceName("%");
criteria.setResource("%");
criteria.setPartition("%");
criteria.setPartitionState("%");
criteria.setRecipientInstanceType(InstanceType.CONTROLLER);
criteria.setSessionSpecific(true);
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("*");
int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest);
if (messagesSent == 0) {
LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType()));
}
}
代码示例来源:origin: apache/incubator-gobblin
Message newMessage = new Message(message.getRecord(), id);
String srcInstanceName = _manager.getInstanceName();
String tgtInstanceName = map.get("instanceName");
代码示例来源:origin: apache/incubator-gobblin
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());
代码示例来源:origin: apache/incubator-gobblin
@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()));
}
}
代码示例来源:origin: apache/incubator-gobblin
@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.multiManager.getJobClusterHelixManager());
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()));
}
}
代码示例来源: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.gobblin/gobblin-cluster
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;
}
代码示例来源:origin: com.linkedin.gobblin/gobblin-cluster
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;
}
代码示例来源:origin: org.apache.helix/helix-core
public void postFaultInjectionMessage(String zkServer, String clusterName, String instanceName,
String payloadString, String partition) {
Message message = new Message("FaultInjection", UUID.randomUUID().toString());
if (payloadString != null) {
message.getRecord().setSimpleField("faultType", payloadString);
}
if (partition != null) {
message.setPartitionName(partition);
}
post(zkServer, message, clusterName, instanceName);
}
代码示例来源:origin: org.apache.helix/helix-core
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;
}
代码示例来源:origin: apache/helix
private static Message newMsg() {
Message msg = new Message(DUMMY_MSG_TYPE, UUID.randomUUID().toString());
msg.setTgtSessionId("*");
msg.setTgtName("localhost_12918");
return msg;
}
}
代码示例来源:origin: apache/helix
@Test()
public void testOnBecomeOfflineFromStandby() {
Message message = new Message(MessageType.STATE_TRANSITION, "0");
message.setPartitionName(clusterName);
message.setTgtName("controller_0");
stateModel.onBecomeOfflineFromStandby(message, null);
}
代码示例来源:origin: apache/helix
@Test()
public void testReset() {
Message message = new Message(MessageType.STATE_TRANSITION, "0");
message.setPartitionName(clusterName);
message.setTgtName("controller_0");
try {
stateModel.onBecomeLeaderFromStandby(message, new NotificationContext(null));
} catch (Exception e) {
LOG.error("Exception becoming leader from standby", e);
}
stateModel.reset();
}
代码示例来源:origin: apache/helix
@Test()
public void testOnBecomeStandbyFromLeader() {
Message message = new Message(MessageType.STATE_TRANSITION, "0");
message.setPartitionName(clusterName);
message.setTgtName("controller_0");
stateModel.onBecomeStandbyFromLeader(message, new NotificationContext(null));
}
代码示例来源:origin: apache/helix
@Test()
public void testRollbackOnError() {
Message message = new Message(MessageType.STATE_TRANSITION, "0");
message.setPartitionName(clusterName);
message.setTgtName("controller_0");
try {
stateModel.onBecomeLeaderFromStandby(message, new NotificationContext(null));
} catch (Exception e) {
LOG.error("Exception becoming leader from standby", e);
}
stateModel.rollbackOnError(message, new NotificationContext(null), null);
}
代码示例来源:origin: apache/helix
@Test()
public void testOnBecomeLeaderFromStandby() {
Message message = new Message(MessageType.STATE_TRANSITION, "0");
message.setPartitionName(clusterName);
message.setTgtName("controller_0");
try {
stateModel.onBecomeLeaderFromStandby(message, new NotificationContext(null));
} catch (Exception e) {
LOG.error("Exception becoming leader from standby", e);
}
stateModel.onBecomeStandbyFromLeader(message, new NotificationContext(null));
}
代码示例来源:origin: apache/helix
@Test()
public void testDistControllerStateModelFactory() {
DistClusterControllerStateModelFactory factory =
new DistClusterControllerStateModelFactory(zkAddr);
DistClusterControllerStateModel stateModel = factory.createNewStateModel("name", "key");
stateModel.onBecomeStandbyFromOffline(new Message(new ZNRecord("Test")), null);
}
}
代码示例来源:origin: apache/helix
public static Message createMessage(String msgId, String fromState, String toState,
String tgtName, String resourceName, String partitionName) {
Message msg = new Message(MessageType.STATE_TRANSITION, msgId);
msg.setFromState(fromState);
msg.setToState(toState);
msg.setTgtName(tgtName);
msg.setResourceName(resourceName);
msg.setPartitionName(partitionName);
msg.setStateModelDef("MasterSlave");
return msg;
}
代码示例来源:origin: apache/helix
protected Message createMessage(Message.MessageType type, String msgId, String fromState, String toState,
String resourceName, String tgtName) {
Message msg = new Message(type.toString(), msgId);
msg.setFromState(fromState);
msg.setToState(toState);
msg.getRecord().setSimpleField(Message.Attributes.RESOURCE_NAME.toString(), resourceName);
msg.setTgtName(tgtName);
return msg;
}
内容来源于网络,如有侵权,请联系作者删除!