本文整理汇总了Java中org.apache.helix.model.Message.getMsgId方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getMsgId方法的具体用法?Java Message.getMsgId怎么用?Java Message.getMsgId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.helix.model.Message
的用法示例。
在下文中一共展示了Message.getMsgId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMessageLogRecord
import org.apache.helix.model.Message; //导入方法依赖的package包/类
/**
* Create a ZNRecord for a message, which stores the content of the message (stored in
* simple fields) into the ZNRecord mapFields. In this way, the message update can be
* merged with the previous status update record in the zookeeper. See ZNRecord.merge()
* for more details.
*/
ZNRecord createMessageLogRecord(Message message) {
ZNRecord result = new ZNRecord(getStatusUpdateRecordName(message));
String mapFieldKey = "MESSAGE " + message.getMsgId();
result.setMapField(mapFieldKey, new TreeMap<String, String>());
// Store all the simple fields of the message in the new ZNRecord's map
// field.
for (String simpleFieldKey : message.getRecord().getSimpleFields().keySet()) {
result.getMapField(mapFieldKey).put(simpleFieldKey,
message.getRecord().getSimpleField(simpleFieldKey));
}
if (message.getResultMap() != null) {
result.setMapField("MessageResult", message.getResultMap());
}
return result;
}
示例2: createHandler
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public MessageHandler createHandler(Message message, NotificationContext context) {
String type = message.getMsgType();
if (!type.equals(getMessageType())) {
throw new HelixException("Unexpected msg type for message " + message.getMsgId() + " type:"
+ message.getMsgType());
}
return new DefaultControllerMessageHandler(message, context);
}
示例3: createHandler
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public MessageHandler createHandler(Message message, NotificationContext context) {
String type = message.getMsgType();
if (!type.equals(getMessageType())) {
throw new HelixException("Unexpected msg type for message " + message.getMsgId() + " type:"
+ message.getMsgType());
}
return new DefaultParticipantErrorMessageHandler(message, context, _manager);
}
示例4: createHandler
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public MessageHandler createHandler(Message message, NotificationContext context) {
String type = message.getMsgType();
if (!type.equals(getMessageType())) {
throw new HelixException("Unexpected msg type for message " + message.getMsgId() + " type:"
+ message.getMsgType());
}
return new DefaultSchedulerMessageHandler(message, context, _manager);
}
示例5: generateMessagesForController
import org.apache.helix.model.Message; //导入方法依赖的package包/类
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;
}
示例6: getStatusUpdateKey
import org.apache.helix.model.Message; //导入方法依赖的package包/类
private String getStatusUpdateKey(Message message) {
if (message.getMsgType().equalsIgnoreCase(MessageType.STATE_TRANSITION.name())) {
return message.getPartitionName();
}
return message.getMsgId();
}
示例7: getStatusUpdateRecordName
import org.apache.helix.model.Message; //导入方法依赖的package包/类
String getStatusUpdateRecordName(Message message) {
if (message.getMsgType().equalsIgnoreCase(MessageType.STATE_TRANSITION.name())) {
return message.getTgtSessionId() + "__" + message.getResourceName();
}
return message.getMsgId();
}
示例8: post
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public Representation post(Representation entity) {
try {
String clusterName = (String) getRequest().getAttributes().get("clusterName");
Form form = new Form(entity);
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
String msgTemplateString =
ClusterRepresentationUtil.getFormJsonParameterString(form, MESSAGETEMPLATE);
if (msgTemplateString == null) {
throw new HelixException("SchedulerTasksResource need to have MessageTemplate specified.");
}
Map<String, String> messageTemplate =
ClusterRepresentationUtil.getFormJsonParameters(form, MESSAGETEMPLATE);
String criteriaString = ClusterRepresentationUtil.getFormJsonParameterString(form, CRITERIA);
if (criteriaString == null) {
throw new HelixException("SchedulerTasksResource need to have Criteria specified.");
}
HelixDataAccessor accessor =
ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
LiveInstance leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
if (leader == null) {
throw new HelixException("There is no leader for the cluster " + clusterName);
}
Message schedulerMessage =
new Message(MessageType.SCHEDULER_MSG, UUID.randomUUID().toString());
schedulerMessage.getRecord().getSimpleFields().put(CRITERIA, criteriaString);
schedulerMessage.getRecord().getMapFields().put(MESSAGETEMPLATE, messageTemplate);
schedulerMessage.setTgtSessionId(leader.getSessionId());
schedulerMessage.setTgtName("CONTROLLER");
schedulerMessage.setSrcInstanceType(InstanceType.CONTROLLER);
String taskQueueName =
ClusterRepresentationUtil.getFormJsonParameterString(form, TASKQUEUENAME);
if (taskQueueName != null && taskQueueName.length() > 0) {
schedulerMessage.getRecord().setSimpleField(
DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE, taskQueueName);
}
accessor.setProperty(accessor.keyBuilder().controllerMessage(schedulerMessage.getMsgId()),
schedulerMessage);
Map<String, String> resultMap = new HashMap<String, String>();
resultMap.put("StatusUpdatePath", PropertyPathBuilder.controllerStatusUpdate(
clusterName, MessageType.SCHEDULER_MSG.name(), schedulerMessage.getMsgId()));
resultMap.put("MessageType", Message.MessageType.SCHEDULER_MSG.name());
resultMap.put("MsgId", schedulerMessage.getMsgId());
// Assemble the rest URL for task status update
String ipAddress = InetAddress.getLocalHost().getCanonicalHostName();
String url =
"http://" + ipAddress + ":" + getContext().getAttributes().get(RestAdminApplication.PORT)
+ "/clusters/" + clusterName + "/Controller/statusUpdates/SCHEDULER_MSG/"
+ schedulerMessage.getMsgId();
resultMap.put("statusUpdateUrl", url);
getResponse().setEntity(ClusterRepresentationUtil.ObjectToJson(resultMap),
MediaType.APPLICATION_JSON);
getResponse().setStatus(Status.SUCCESS_OK);
} catch (Exception e) {
getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
MediaType.APPLICATION_JSON);
getResponse().setStatus(Status.SUCCESS_OK);
LOG.error("", e);
}
return null;
}