本文整理了Java中org.apache.helix.model.Message.setPartitionName()
方法的一些代码示例,展示了Message.setPartitionName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setPartitionName()
方法的具体详情如下:
包路径:org.apache.helix.model.Message
类名称:Message
方法名:setPartitionName
[英]Set the name of the partition this message concerns
[中]设置此消息所涉及的分区的名称
代码示例来源:origin: apache/incubator-gobblin
newMessage.setTgtName(tgtInstanceName);
newMessage.setResourceName(map.get("resourceName"));
newMessage.setPartitionName(map.get("partitionName"));
if (recipientCriteria.isSessionSpecific()) {
newMessage.setTgtSessionId(sessionIdMap.get(tgtInstanceName));
代码示例来源:origin: org.apache.helix/helix-core
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);
}
代码示例来源:origin: apache/helix
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);
}
代码示例来源:origin: org.apache.helix/helix-core
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);
}
代码示例来源:origin: apache/helix
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);
}
代码示例来源:origin: apache/helix
@Test()
public void testOnBecomeOfflineFromStandby() {
Message message = new Message(MessageType.STATE_TRANSITION, "0");
message.setPartitionName(clusterName);
message.setTgtName("controller_0");
stateModel.onBecomeOfflineFromStandby(message, null);
}
代码示例来源:origin: apache/helix
@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();
}
代码示例来源:origin: apache/helix
@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));
}
代码示例来源:origin: apache/helix
@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);
}
代码示例来源:origin: apache/helix
@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));
}
代码示例来源:origin: apache/helix
@Override public void doInject(ClusterDataCache cache) {
String topStateNode = null;
for (String instance : cfg.initialCurrentStates.keySet()) {
if (cfg.initialCurrentStates.get(instance).currentState.equals("MASTER")) {
topStateNode = instance;
break;
}
}
// Simulate the previous top state instance goes offline
if (topStateNode != null) {
long originalStartTime = cfg.currentStateWithMissingTopState.get(topStateNode).startTime;
// Inject a message that fit expectedDuration
Message message =
new Message(Message.MessageType.STATE_TRANSITION, "thisisafakemessage");
message.setTgtSessionId(SESSION_PREFIX + topStateNode.split("_")[1]);
message.setToState("MASTER");
message.setCreateTimeStamp(originalStartTime - messageTimeBeforeMasterless);
message.setTgtName(topStateNode);
message.setResourceName(TEST_RESOURCE);
message.setPartitionName(PARTITION);
cache.cacheMessages(Collections.singletonList(message));
}
}
}, 1, 0,
代码示例来源:origin: apache/helix
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);
}
代码示例来源:origin: org.apache.helix/helix-core
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);
}
代码示例来源:origin: apache/helix
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;
}
代码示例来源:origin: apache/helix
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) {
LogUtil.logInfo(logger, _eventId,
"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;
}
代码示例来源:origin: apache/helix
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);
}
代码示例来源:origin: org.apache.helix/helix-core
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;
}
代码示例来源:origin: apache/helix
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;
}
代码示例来源:origin: apache/helix
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;
}
代码示例来源:origin: apache/helix
private Message generateMessage(String from, String to) {
String uuid = UUID.randomUUID().toString();
Message message = new Message(Message.MessageType.STATE_TRANSITION, uuid);
message.setSrcName("ADMIN");
message.setTgtName(_participant.getInstanceName());
message.setMsgState(Message.MessageState.NEW);
message.setPartitionName("P");
message.setResourceName(WorkflowGenerator.DEFAULT_TGT_DB);
message.setFromState(from);
message.setToState(to);
message.setTgtSessionId(_participant.getSessionId());
message.setSrcSessionId(_manager.getSessionId());
message.setStateModelDef("OnlineOffline");
message.setStateModelFactoryName("DEFAULT");
return message;
}
内容来源于网络,如有侵权,请联系作者删除!