本文整理汇总了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.");
}
}
示例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++;
}
}
示例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++;
}
}
}
示例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);
}
}
示例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();
}
}
示例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);
}
}