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


Java Message.setPartitionName方法代码示例

本文整理汇总了Java中org.apache.helix.model.Message.setPartitionName方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setPartitionName方法的具体用法?Java Message.setPartitionName怎么用?Java Message.setPartitionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.model.Message的用法示例。


在下文中一共展示了Message.setPartitionName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessage

import org.apache.helix.model.Message; //导入方法依赖的package包/类
void sendMessage(String msgId, String instanceName, String fromState, String toState,
    String partitionKey, int partitionId) throws InterruptedException, JsonGenerationException,
    JsonMappingException, IOException {
  Message message = new Message(MessageType.STATE_TRANSITION, msgId);
  message.setMsgId(msgId);
  message.setSrcName(srcName);
  message.setTgtName(instanceName);
  message.setMsgState(MessageState.NEW);
  message.setFromState(fromState);
  message.setToState(toState);
  // message.setPartitionId(partitionId);
  message.setPartitionName(partitionKey);

  String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
  ObjectMapper mapper = new ObjectMapper();
  StringWriter sw = new StringWriter();
  mapper.writeValueUsingView(sw, message, Message.class);
  System.out.println(sw.toString());
  client.delete(path);

  Thread.sleep(10000);
  ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
  message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())
      .toString());
  client.createPersistent(path, message);
}
 
开发者ID:apache,项目名称:helix,代码行数:27,代码来源:MockController.java

示例2: newMessage

import org.apache.helix.model.Message; //导入方法依赖的package包/类
private Message newMessage(String resourceName, String partitionName, String instanceName,
    String fromState, String toState) {
  String uuid = UUID.randomUUID().toString();
  Message message = new Message(MessageType.STATE_TRANSITION, uuid);
  message.setSrcName("controller");
  message.setTgtName(instanceName);
  message.setMsgState(MessageState.NEW);
  message.setResourceName(resourceName);
  message.setPartitionName(partitionName);
  message.setFromState(fromState);
  message.setToState(toState);
  message.setTgtSessionId("sessionId");
  message.setSrcSessionId("sessionId");
  message.setStateModelDef("MasterSlave");
  message.setStateModelFactoryName("DEFAULT");
  message.setBucketSize(0);
  return message;
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:TestMsgSelectionStage.java

示例3: createStateTransitionMessage

import org.apache.helix.model.Message; //导入方法依赖的package包/类
private Message createStateTransitionMessage(HelixManager manager, Resource resource, String partitionName,
    String instanceName, String currentState, String nextState, String sessionId,
    String stateModelDefName) {
  String uuid = UUID.randomUUID().toString();
  Message message = new Message(MessageType.STATE_TRANSITION, uuid);
  message.setSrcName(manager.getInstanceName());
  message.setTgtName(instanceName);
  message.setMsgState(MessageState.NEW);
  message.setPartitionName(partitionName);
  message.setResourceName(resource.getResourceName());
  message.setFromState(currentState);
  message.setToState(nextState);
  message.setTgtSessionId(sessionId);
  message.setSrcSessionId(manager.getSessionId());
  message.setStateModelDef(stateModelDefName);
  message.setStateModelFactoryName(resource.getStateModelFactoryname());
  message.setBucketSize(resource.getBucketSize());

  if (resource.getResourceGroupName() != null) {
    message.setResourceGroupName(resource.getResourceGroupName());
  }
  if (resource.getResourceTag() != null) {
    message.setResourceTag(resource.getResourceTag());
  }

  return message;
}
 
开发者ID:apache,项目名称:helix,代码行数:28,代码来源:MessageGenerationPhase.java

示例4: createStateTransitionCancellationMessage

import org.apache.helix.model.Message; //导入方法依赖的package包/类
private Message createStateTransitionCancellationMessage(HelixManager manager, Resource resource,
    String partitionName, String instanceName, String sessionId, String stateModelDefName,
    String fromState, String toState, String nextState, Message cancellationMessage, boolean isCancellationEnabled,
    String currentState) {

  if (isCancellationEnabled && cancellationMessage == null) {
    logger.info("Send cancellation message of the state transition for " + resource.getResourceName() + "."
        + partitionName + " on " + instanceName + ", currentState: " + currentState + ", nextState: "
        + (nextState == null ? "N/A" : nextState));

    String uuid = UUID.randomUUID().toString();
    Message message = new Message(MessageType.STATE_TRANSITION_CANCELLATION, uuid);
    message.setSrcName(manager.getInstanceName());
    message.setTgtName(instanceName);
    message.setMsgState(MessageState.NEW);
    message.setPartitionName(partitionName);
    message.setResourceName(resource.getResourceName());
    message.setFromState(fromState);
    message.setToState(toState);
    message.setTgtSessionId(sessionId);
    message.setSrcSessionId(manager.getSessionId());
    message.setStateModelDef(stateModelDefName);
    message.setStateModelFactoryName(resource.getStateModelFactoryname());
    message.setBucketSize(resource.getBucketSize());
    return message;
  }

  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:30,代码来源:MessageGenerationPhase.java

示例5: BatchMessageHandler

import org.apache.helix.model.Message; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:BatchMessageHandler.java

示例6: postFaultInjectionMessage

import org.apache.helix.model.Message; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:MessagePoster.java

示例7: postTestMessage

import org.apache.helix.model.Message; //导入方法依赖的package包/类
public void postTestMessage(String zkServer, String clusterName, String instanceName) {
  String msgSrc = "cm-instance-0";
  String msgId = "TestMessageId-2";

  Message message = new Message(MessageType.STATE_TRANSITION, msgId);
  message.setMsgId(msgId);
  message.setSrcName(msgSrc);
  message.setTgtName(instanceName);
  message.setMsgState(MessageState.NEW);
  message.setFromState("Slave");
  message.setToState("Master");
  message.setPartitionName("EspressoDB.partition-0." + instanceName);

  post(zkServer, message, clusterName, instanceName);
}
 
开发者ID:apache,项目名称:helix,代码行数:16,代码来源:MessagePoster.java

示例8: testOnBecomeLeaderFromStandby

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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));
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:TestDistControllerStateModel.java

示例9: testOnBecomeStandbyFromLeader

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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));
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:TestDistControllerStateModel.java

示例10: testOnBecomeOfflineFromStandby

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Test()
public void testOnBecomeOfflineFromStandby() {
  Message message = new Message(MessageType.STATE_TRANSITION, "0");
  message.setPartitionName(clusterName);
  message.setTgtName("controller_0");

  stateModel.onBecomeOfflineFromStandby(message, null);
}
 
开发者ID:apache,项目名称:helix,代码行数:9,代码来源:TestDistControllerStateModel.java

示例11: testRollbackOnError

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:TestDistControllerStateModel.java

示例12: testReset

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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();
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:TestDistControllerStateModel.java

示例13: createMessage

import org.apache.helix.model.Message; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:TestHelper.java

示例14: testInvocation

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Test()
public void testInvocation() throws Exception {
  HelixTaskExecutor executor = new HelixTaskExecutor();
  System.out.println("START TestCMTaskHandler.testInvocation()");
  Message message = new Message(MessageType.STATE_TRANSITION, "Some unique id");

  message.setSrcName("cm-instance-0");
  message.setTgtSessionId("1234");
  message.setFromState("Offline");
  message.setToState("Slave");
  message.setPartitionName("TestDB_0");
  message.setMsgId("Some unique message id");
  message.setResourceName("TestDB");
  message.setTgtName("localhost");
  message.setStateModelDef("MasterSlave");
  message.setStateModelFactoryName(HelixConstants.DEFAULT_STATE_MODEL_FACTORY);
  MockMasterSlaveStateModel stateModel = new MockMasterSlaveStateModel();
  NotificationContext context;
  MockManager manager = new MockManager("clusterName");
  HelixDataAccessor accessor = manager.getHelixDataAccessor();
  StateModelDefinition stateModelDef =
      new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
  Builder keyBuilder = accessor.keyBuilder();
  accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

  context = new NotificationContext(manager);
  CurrentState currentStateDelta = new CurrentState("TestDB");
  currentStateDelta.setState("TestDB_0", "OFFLINE");

  HelixStateTransitionHandler stHandler =
      new HelixStateTransitionHandler(null, stateModel, message, context, currentStateDelta);
  HelixTask handler;
  handler = new HelixTask(message, context, stHandler, executor);
  handler.call();
  AssertJUnit.assertTrue(stateModel.stateModelInvoked);
  System.out.println("END TestCMTaskHandler.testInvocation() at "
      + new Date(System.currentTimeMillis()));
}
 
开发者ID:apache,项目名称:helix,代码行数:39,代码来源:TestHelixTaskHandler.java

示例15: testStateMismatch

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Test
public void testStateMismatch() throws InterruptedException {
  // String controllerName = CONTROLLER_PREFIX + "_0";

  HelixManager manager = _controller; // _startCMResultMap.get(controllerName)._manager;
  HelixDataAccessor accessor = manager.getHelixDataAccessor();
  Builder kb = accessor.keyBuilder();
  ExternalView ev = accessor.getProperty(kb.externalView(TEST_DB));
  Map<String, LiveInstance> liveinstanceMap =
      accessor.getChildValuesMap(accessor.keyBuilder().liveInstances());

  for (String instanceName : liveinstanceMap.keySet()) {
    String sessionid = liveinstanceMap.get(instanceName).getSessionId();
    for (String partition : ev.getPartitionSet()) {
      if (ev.getStateMap(partition).containsKey(instanceName)) {
        String uuid = UUID.randomUUID().toString();
        Message message = new Message(MessageType.STATE_TRANSITION, uuid);
        boolean rand = new Random().nextInt(10) > 5;
        if (ev.getStateMap(partition).get(instanceName).equals("MASTER")) {
          message.setSrcName(manager.getInstanceName());
          message.setTgtName(instanceName);
          message.setMsgState(MessageState.NEW);
          message.setPartitionName(partition);
          message.setResourceName(TEST_DB);
          message.setFromState(rand ? "SLAVE" : "OFFLINE");
          message.setToState(rand ? "MASTER" : "SLAVE");
          message.setTgtSessionId(sessionid);
          message.setSrcSessionId(manager.getSessionId());
          message.setStateModelDef("MasterSlave");
          message.setStateModelFactoryName("DEFAULT");
        } else if (ev.getStateMap(partition).get(instanceName).equals("SLAVE")) {
          message.setSrcName(manager.getInstanceName());
          message.setTgtName(instanceName);
          message.setMsgState(MessageState.NEW);
          message.setPartitionName(partition);
          message.setResourceName(TEST_DB);
          message.setFromState(rand ? "MASTER" : "OFFLINE");
          message.setToState(rand ? "SLAVE" : "SLAVE");
          message.setTgtSessionId(sessionid);
          message.setSrcSessionId(manager.getSessionId());
          message.setStateModelDef("MasterSlave");
          message.setStateModelFactoryName("DEFAULT");
        }
        accessor.setProperty(accessor.keyBuilder().message(instanceName, message.getMsgId()),
            message);
      }
    }
  }
  Thread.sleep(3000);
  ExternalView ev2 = accessor.getProperty(kb.externalView(TEST_DB));
  Assert.assertTrue(ev.equals(ev2));
}
 
开发者ID:apache,项目名称:helix,代码行数:53,代码来源:TestMessagePartitionStateMismatch.java


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