当前位置: 首页>>代码示例>>Java>>正文


Java Message.getMsgId方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:helix,代码行数:23,代码来源:StatusUpdateUtil.java

示例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);
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:DefaultControllerMessageHandlerFactory.java

示例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);
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:DefaultParticipantErrorMessageHandlerFactory.java

示例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);
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:DefaultSchedulerMessageHandlerFactory.java

示例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;
}
 
开发者ID:apache,项目名称:helix,代码行数:11,代码来源:DefaultMessagingService.java

示例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();
}
 
开发者ID:apache,项目名称:helix,代码行数:7,代码来源:StatusUpdateUtil.java

示例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();
}
 
开发者ID:apache,项目名称:helix,代码行数:7,代码来源:StatusUpdateUtil.java

示例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;
}
 
开发者ID:apache,项目名称:helix,代码行数:71,代码来源:SchedulerTasksResource.java


注:本文中的org.apache.helix.model.Message.getMsgId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。