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


Java Message.getToState方法代码示例

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


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

示例1: reportMessageStat

import org.apache.helix.model.Message; //导入方法依赖的package包/类
private void reportMessageStat(HelixManager manager, Message message, HelixTaskResult taskResult) {
  // report stat
  if (!message.getMsgType().equals(MessageType.STATE_TRANSITION.name())) {
    return;
  }
  long now = new Date().getTime();
  long msgReadTime = message.getReadTimeStamp();
  long msgExecutionStartTime = message.getExecuteStartTimeStamp();
  if (msgReadTime != 0 && msgExecutionStartTime != 0) {
    long totalDelay = now - msgReadTime;
    long executionDelay = now - msgExecutionStartTime;
    if (totalDelay > 0 && executionDelay > 0) {
      String fromState = message.getFromState();
      String toState = message.getToState();
      String transition = fromState + "--" + toState;

      StateTransitionContext cxt =
          new StateTransitionContext(manager.getClusterName(), manager.getInstanceName(),
              message.getResourceName(), transition);

      StateTransitionDataPoint data =
          new StateTransitionDataPoint(totalDelay, executionDelay, taskResult.isSuccess());
      _executor.getParticipantMonitor().reportTransitionStat(cxt, data);
    }
  } else {
    logger.warn("message read time and start execution time not recorded.");
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:HelixTask.java

示例2: doTransition

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public void doTransition(Message message, NotificationContext context) {
  // System.err.println("doReset() invoked");
  super.doTransition(message, context);
  String fromState = message.getFromState();
  String toState = message.getToState();
  if (fromState.equals("ERROR") && toState.equals("OFFLINE")) {
    _errToOfflineInvoked++;
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:11,代码来源:TestResetPartitionState.java

示例3: doTransition

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public void doTransition(Message message, NotificationContext context) {
  HelixManager manager = context.getManager();
  String clusterName = manager.getClusterName();

  String instance = message.getTgtName();
  String partitionName = message.getPartitionName();
  String fromState = message.getFromState();
  String toState = message.getToState();
  if (instance.equals("localhost_12919") && partitionName.equals("TestDB0_0")) {
    if (fromState.equals("SLAVE") && toState.equals("OFFLINE")) {
      slaveToOfflineCnt++;

      try {
        String command =
            "--zkSvr " + ZK_ADDR + " --enablePartition true " + clusterName
                + " localhost_12919 TestDB0 TestDB0_0";

        ClusterSetup.processCommandLineArgs(command.split("\\s+"));
      } catch (Exception e) {
        LOG.error("Exception in cluster setup", e);
      }

    } else if (slaveToOfflineCnt > 0 && fromState.equals("OFFLINE") && toState.equals("SLAVE")) {
      offlineToSlave++;
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:TestEnablePartitionDuringDisable.java

示例4: doTransition

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public void doTransition(Message message, NotificationContext context) {
  String fromState = message.getFromState();
  String toState = message.getToState();
  String partition = message.getPartitionName();

  String key = (fromState + "-" + toState).toUpperCase();
  if (_errPartitions.containsKey(key) && _errPartitions.get(key).contains(partition)) {
    String errMsg =
        "IGNORABLE: test throw exception in msgId: " + message.getId() + " for " + partition
            + " transit from " + fromState + " to " + toState;
    throw new RuntimeException(errMsg);
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:15,代码来源:ErrTransition.java

示例5: doTransition

import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Override
public void doTransition(Message message, NotificationContext context) {
  super.doTransition(message, context);
  String fromState = message.getFromState();
  String toState = message.getToState();
  if (fromState.equals("ERROR") && toState.equals("OFFLINE")) {
    // System.err.println("doReset() invoked");
    _errToOfflineInvoked.incrementAndGet();
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:11,代码来源:TestResetPartitionState.java

示例6: invoke

import org.apache.helix.model.Message; //导入方法依赖的package包/类
private void invoke(HelixManager manager, NotificationContext context,
    HelixTaskResult taskResult, Message message) throws IllegalAccessException,
    InvocationTargetException, InterruptedException, HelixRollbackException {
  _statusUpdateUtil.logInfo(message, HelixStateTransitionHandler.class,
      "Message handling invoking", manager);

  // by default, we invoke state transition function in state model
  Method methodToInvoke = null;
  String fromState = message.getFromState();
  String toState = message.getToState();
  methodToInvoke =
      _transitionMethodFinder.getMethodForTransition(_stateModel.getClass(),
                                                     fromState,
                                                     toState,
                                                     new Class[] { Message.class,
                                                         NotificationContext.class });
  if (methodToInvoke != null) {
    logger.info(String.format("Instance %s, partition %s received state transition from %s to %s on session %s, message id: %s",
                              message.getTgtName(),
                              message.getPartitionName(),
                              message.getFromState(),
                              message.getToState(),
                              message.getTgtSessionId(),
                              message.getMsgId()));

    if (_cancelled) {
      throw new HelixRollbackException(String.format(
          "Instance %s, partition %s state transition from %s to %s on session %s has been cancelled, message id: %s",
          message.getTgtName(), message.getPartitionName(), message.getFromState(),
          message.getToState(), message.getTgtSessionId(), message.getMsgId()));
    }

    if (_cancelled) {
      throw new HelixRollbackException(String.format(
          "Instance %s, partition %s state transition from %s to %s on session %s has been cancelled",
          message.getTgtName(), message.getPartitionName(), message.getFromState(),
          message.getToState(), message.getTgtSessionId()));
    }

    Object result = methodToInvoke.invoke(_stateModel, new Object[] { message, context });
    taskResult.setSuccess(true);
    String resultStr;
    if (result == null || result instanceof Void) {
      resultStr = "";
    } else {
      resultStr = result.toString();
    }
    taskResult.setInfo(resultStr);
  } else {
    String errorMessage =
        "Unable to find method for transition from " + fromState + " to " + toState + " in "
            + _stateModel.getClass();
    logger.error(errorMessage);
    taskResult.setSuccess(false);

    _statusUpdateUtil
        .logError(message, HelixStateTransitionHandler.class, errorMessage, manager);
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:60,代码来源:HelixStateTransitionHandler.java


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