本文整理了Java中org.apache.helix.model.Message.setSrcName()
方法的一些代码示例,展示了Message.setSrcName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setSrcName()
方法的具体详情如下:
包路径:org.apache.helix.model.Message
类名称:Message
方法名:setSrcName
[英]Set the name of the source instance
[中]设置源实例的名称
代码示例来源:origin: apache/incubator-gobblin
private List<Message> generateMessagesForController(Message message) {
List<Message> messages = new ArrayList<Message>();
String id = UUID.randomUUID().toString();
Message newMessage = new Message(message.getRecord(), id);
newMessage.setMsgId(id);
newMessage.setSrcName(_manager.getInstanceName());
newMessage.setTgtName("Controller");
messages.add(newMessage);
return messages;
}
代码示例来源:origin: apache/incubator-gobblin
continue;
newMessage.setSrcName(srcInstanceName);
newMessage.setTgtName(tgtInstanceName);
newMessage.setResourceName(map.get("resourceName"));
代码示例来源:origin: org.apache.gobblin/gobblin-cluster
private List<Message> generateMessagesForController(Message message) {
List<Message> messages = new ArrayList<Message>();
String id = UUID.randomUUID().toString();
Message newMessage = new Message(message.getRecord(), id);
newMessage.setMsgId(id);
newMessage.setSrcName(_manager.getInstanceName());
newMessage.setTgtName("Controller");
messages.add(newMessage);
return messages;
}
代码示例来源:origin: com.linkedin.gobblin/gobblin-cluster
private List<Message> generateMessagesForController(Message message) {
List<Message> messages = new ArrayList<Message>();
String id = UUID.randomUUID().toString();
Message newMessage = new Message(message.getRecord(), id);
newMessage.setMsgId(id);
newMessage.setSrcName(_manager.getInstanceName());
newMessage.setTgtName("Controller");
messages.add(newMessage);
return messages;
}
代码示例来源:origin: apache/helix
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;
}
代码示例来源:origin: org.apache.helix/helix-core
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;
}
代码示例来源:origin: apache/helix
private void syncSessionToController(HelixManager manager) {
if (_lastSessionSyncTime == null ||
System.currentTimeMillis() - _lastSessionSyncTime > SESSION_SYNC_INTERVAL) { // > delay since last sync
HelixDataAccessor accessor = manager.getHelixDataAccessor();
PropertyKey key = new Builder(manager.getClusterName()).controllerMessage(SESSION_SYNC);
if (accessor.getProperty(key) == null) {
LOG.info(String.format("Participant %s syncs session with controller", manager.getInstanceName()));
Message msg = new Message(MessageType.PARTICIPANT_SESSION_CHANGE, SESSION_SYNC);
msg.setSrcName(manager.getInstanceName());
msg.setTgtSessionId("*");
msg.setMsgState(MessageState.NEW);
msg.setMsgId(SESSION_SYNC);
Criteria cr = new Criteria();
cr.setRecipientInstanceType(InstanceType.CONTROLLER);
cr.setSessionSpecific(false);
manager.getMessagingService().send(cr, msg);
_lastSessionSyncTime = System.currentTimeMillis();
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
private void syncSessionToController(HelixManager manager) {
if (_lastSessionSyncTime == null ||
System.currentTimeMillis() - _lastSessionSyncTime > SESSION_SYNC_INTERVAL) { // > delay since last sync
HelixDataAccessor accessor = manager.getHelixDataAccessor();
PropertyKey key = new Builder(manager.getClusterName()).controllerMessage(SESSION_SYNC);
if (accessor.getProperty(key) == null) {
LOG.info(String.format("Participant %s syncs session with controller", manager.getInstanceName()));
Message msg = new Message(MessageType.PARTICIPANT_SESSION_CHANGE, SESSION_SYNC);
msg.setSrcName(manager.getInstanceName());
msg.setTgtSessionId("*");
msg.setMsgState(MessageState.NEW);
msg.setMsgId(SESSION_SYNC);
Criteria cr = new Criteria();
cr.setRecipientInstanceType(InstanceType.CONTROLLER);
cr.setSessionSpecific(false);
manager.getMessagingService().send(cr, msg);
_lastSessionSyncTime = System.currentTimeMillis();
}
}
}
代码示例来源: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 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
private void sendNopMessageInternal() {
try {
Message nopMsg = new Message(MessageType.NO_OP, UUID.randomUUID().toString());
nopMsg.setSrcName(_manager.getInstanceName());
HelixDataAccessor accessor = _manager.getHelixDataAccessor();
Builder keyBuilder = accessor.keyBuilder();
if (_manager.getInstanceType() == InstanceType.CONTROLLER
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(InstanceType.CONTROLLER.name());
accessor.setProperty(keyBuilder.controllerMessage(nopMsg.getId()), nopMsg);
}
if (_manager.getInstanceType() == InstanceType.PARTICIPANT
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(_manager.getInstanceName());
accessor.setProperty(keyBuilder.message(nopMsg.getTgtName(), nopMsg.getId()), nopMsg);
}
} catch (Exception e) {
_logger.error(e.toString());
}
}
代码示例来源:origin: org.apache.helix/helix-core
private void sendNopMessageInternal() {
try {
Message nopMsg = new Message(MessageType.NO_OP, UUID.randomUUID().toString());
nopMsg.setSrcName(_manager.getInstanceName());
HelixDataAccessor accessor = _manager.getHelixDataAccessor();
Builder keyBuilder = accessor.keyBuilder();
if (_manager.getInstanceType() == InstanceType.CONTROLLER
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(InstanceType.CONTROLLER.name());
accessor.setProperty(keyBuilder.controllerMessage(nopMsg.getId()), nopMsg);
}
if (_manager.getInstanceType() == InstanceType.PARTICIPANT
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(_manager.getInstanceName());
accessor.setProperty(keyBuilder.message(nopMsg.getTgtName(), nopMsg.getId()), nopMsg);
}
} catch (Exception e) {
_logger.error(e.toString());
}
}
代码示例来源:origin: apache/helix
private void sendNopMessage() {
if (_manager.isConnected()) {
try {
Message nopMsg = new Message(MessageType.NO_OP, UUID.randomUUID().toString());
nopMsg.setSrcName(_manager.getInstanceName());
HelixDataAccessor accessor = _manager.getHelixDataAccessor();
Builder keyBuilder = accessor.keyBuilder();
if (_manager.getInstanceType() == InstanceType.CONTROLLER
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(InstanceType.CONTROLLER.name());
accessor.setProperty(keyBuilder.controllerMessage(nopMsg.getId()), nopMsg);
}
if (_manager.getInstanceType() == InstanceType.PARTICIPANT
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(_manager.getInstanceName());
accessor.setProperty(keyBuilder.message(nopMsg.getTgtName(), nopMsg.getId()), nopMsg);
}
logger.info("Send NO_OP message to " + nopMsg.getTgtName() + ", msgId: " + nopMsg.getId());
} catch (Exception e) {
logger.error(e.toString());
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
private void sendNopMessage() {
if (_manager.isConnected()) {
try {
Message nopMsg = new Message(MessageType.NO_OP, UUID.randomUUID().toString());
nopMsg.setSrcName(_manager.getInstanceName());
HelixDataAccessor accessor = _manager.getHelixDataAccessor();
Builder keyBuilder = accessor.keyBuilder();
if (_manager.getInstanceType() == InstanceType.CONTROLLER
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(InstanceType.CONTROLLER.name());
accessor.setProperty(keyBuilder.controllerMessage(nopMsg.getId()), nopMsg);
}
if (_manager.getInstanceType() == InstanceType.PARTICIPANT
|| _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
nopMsg.setTgtName(_manager.getInstanceName());
accessor.setProperty(keyBuilder.message(nopMsg.getTgtName(), nopMsg.getId()), nopMsg);
}
logger.info("Send NO_OP message to " + nopMsg.getTgtName() + ", msgId: " + nopMsg.getId());
} catch (Exception e) {
logger.error(e.toString());
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
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: 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: 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 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;
}
内容来源于网络,如有侵权,请联系作者删除!