org.apache.helix.model.Message.getAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中org.apache.helix.model.Message.getAttribute()方法的一些代码示例,展示了Message.getAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getAttribute()方法的具体详情如下:
包路径:org.apache.helix.model.Message
类名称:Message
方法名:getAttribute

Message.getAttribute介绍

[英]Get the value of an attribute
[中]获取属性的值

代码示例

代码示例来源:origin: apache/incubator-gobblin

  1. @Override
  2. public HelixTaskResult handleMessage()
  3. throws InterruptedException {
  4. if (jobScheduler.isActive()) {
  5. // we want to make sure current node is in active state
  6. String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  7. log.info("{} ControllerUserDefinedMessage received : {}, type {}", this.serviceName, msg, _message.getMsgSubType());
  8. try {
  9. if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) {
  10. handleAdd(msg);
  11. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) {
  12. handleDelete(msg);
  13. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) {
  14. handleUpdate(msg);
  15. }
  16. } catch (IOException e) {
  17. log.error("Cannot process Helix message.", e);
  18. HelixTaskResult helixTaskResult = new HelixTaskResult();
  19. helixTaskResult.setSuccess(false);
  20. return helixTaskResult;
  21. }
  22. } else {
  23. String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  24. log.error("ControllerUserDefinedMessage received but ignored due to not in active mode: {}, type {}", msg,
  25. _message.getMsgSubType());
  26. }
  27. HelixTaskResult helixTaskResult = new HelixTaskResult();
  28. helixTaskResult.setSuccess(true);
  29. return helixTaskResult;
  30. }

代码示例来源:origin: apache/helix

  1. public GroupMessageInfo onCompleteSubMessage(Message subMessage) {
  2. String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID);
  3. GroupMessageInfo info = _groupMsgMap.get(parentMid);
  4. if (info != null) {
  5. int val = info._countDown.decrementAndGet();
  6. if (val <= 0) {
  7. return _groupMsgMap.remove(parentMid);
  8. }
  9. }
  10. return null;
  11. }

代码示例来源:origin: org.apache.helix/helix-core

  1. public GroupMessageInfo onCompleteSubMessage(Message subMessage) {
  2. String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID);
  3. GroupMessageInfo info = _groupMsgMap.get(parentMid);
  4. if (info != null) {
  5. int val = info._countDown.decrementAndGet();
  6. if (val <= 0) {
  7. return _groupMsgMap.remove(parentMid);
  8. }
  9. }
  10. return null;
  11. }

代码示例来源:origin: org.apache.helix/helix-core

  1. void addCurStateUpdate(Message subMessage, PropertyKey key, CurrentState delta) {
  2. String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID);
  3. GroupMessageInfo info = _groupMsgMap.get(parentMid);
  4. if (info != null) {
  5. info._curStateUpdateList.add(new CurrentStateUpdate(key, delta));
  6. }
  7. }
  8. }

代码示例来源:origin: apache/helix

  1. void addCurStateUpdate(Message subMessage, PropertyKey key, CurrentState delta) {
  2. String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID);
  3. GroupMessageInfo info = _groupMsgMap.get(parentMid);
  4. if (info != null) {
  5. info._curStateUpdateList.add(new CurrentStateUpdate(key, delta));
  6. }
  7. }
  8. }

代码示例来源:origin: apache/helix

  1. private static String instantiateByMessage(String string, Message message) {
  2. Matcher matcher = pattern.matcher(string);
  3. String result = string;
  4. while (matcher.find()) {
  5. String var = matcher.group();
  6. result =
  7. result.replace(var,
  8. message.getAttribute(Message.Attributes.valueOf(var.substring(1, var.length() - 1))));
  9. }
  10. return result;
  11. }

代码示例来源:origin: org.apache.helix/helix-core

  1. String instanceName = message.getAttribute(Message.Attributes.TGT_NAME);
  2. String resourceName = message.getAttribute(Message.Attributes.RESOURCE_NAME);

代码示例来源:origin: apache/helix

  1. String instanceName = message.getAttribute(Message.Attributes.TGT_NAME);
  2. String resourceName = message.getAttribute(Message.Attributes.RESOURCE_NAME);

代码示例来源:origin: com.linkedin.gobblin/gobblin-service

  1. @Override
  2. public HelixTaskResult handleMessage() throws InterruptedException {
  3. if (jobScheduler.isActive()) {
  4. String flowSpecUri = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  5. try {
  6. if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) {
  7. Spec spec = flowCatalog.getSpec(new URI(flowSpecUri));
  8. this.jobScheduler.onAddSpec(spec);
  9. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) {
  10. List<String> flowSpecUriParts = Splitter.on(":").omitEmptyStrings().trimResults().splitToList(flowSpecUri);
  11. this.jobScheduler.onDeleteSpec(new URI(flowSpecUriParts.get(0)), flowSpecUriParts.get(1));
  12. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) {
  13. Spec spec = flowCatalog.getSpec(new URI(flowSpecUri));
  14. this.jobScheduler.onUpdateSpec(spec);
  15. }
  16. } catch (SpecNotFoundException | URISyntaxException e) {
  17. LOGGER.error("Cannot process Helix message for flowSpecUri: " + flowSpecUri, e);
  18. }
  19. }
  20. HelixTaskResult helixTaskResult = new HelixTaskResult();
  21. helixTaskResult.setSuccess(true);
  22. return helixTaskResult;
  23. }

代码示例来源:origin: apache/helix

  1. private void finalCleanup(HelixTaskResult taskResult) {
  2. try {
  3. if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {
  4. removeMessageFromZk(_manager.getHelixDataAccessor(), _message);
  5. reportMessageStat(_manager, _message, taskResult);
  6. sendReply(getSrcClusterDataAccessor(_message), _message, taskResult);
  7. _executor.finishTask(this);
  8. }
  9. } catch (Exception e) {
  10. logger.error(String.format("Error to final clean up for message : %s", _message.getId()));
  11. }
  12. }
  13. }

代码示例来源:origin: org.apache.gobblin/gobblin-service

  1. @Override
  2. public HelixTaskResult handleMessage()
  3. throws InterruptedException {
  4. if (jobScheduler.isActive()) {
  5. // we want to make sure current node is in active state
  6. String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  7. log.info("{} ControllerUserDefinedMessage received : {}, type {}", this.serviceName, msg, _message.getMsgSubType());
  8. try {
  9. if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) {
  10. handleAdd(msg);
  11. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) {
  12. handleDelete(msg);
  13. } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) {
  14. handleUpdate(msg);
  15. }
  16. } catch (IOException e) {
  17. log.error("Cannot process Helix message.", e);
  18. HelixTaskResult helixTaskResult = new HelixTaskResult();
  19. helixTaskResult.setSuccess(false);
  20. return helixTaskResult;
  21. }
  22. } else {
  23. String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE);
  24. log.error("ControllerUserDefinedMessage received but ignored due to not in active mode: {}, type {}", msg,
  25. _message.getMsgSubType());
  26. }
  27. HelixTaskResult helixTaskResult = new HelixTaskResult();
  28. helixTaskResult.setSuccess(true);
  29. return helixTaskResult;
  30. }

代码示例来源:origin: apache/helix

  1. logger.info(
  2. "Message: {} (parent: {}) handling task for {}:{} completed at: {}, results: {}. FrameworkTime: {} ms; HandlerTime: {} ms.",
  3. _message.getMsgId(), _message.getAttribute(Attributes.PARENT_MSG_ID), _message.getResourceName(),
  4. _message.getPartitionName(), end, taskResult.isSuccess(), totalDuration - handlerDuration,
  5. handlerDuration);

代码示例来源:origin: org.apache.helix/helix-core

  1. if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {
  2. removeMessageFromZk(accessor, _message);
  3. reportMessageStat(_manager, _message, taskResult);
  4. logger.info(
  5. "Message: {} (parent: {}) handling task for {}:{} completed at: {}, results: {}. FrameworkTime: {} ms; HandlerTime: {} ms.",
  6. _message.getMsgId(), _message.getAttribute(Attributes.PARENT_MSG_ID), _message.getResourceName(),
  7. _message.getPartitionName(), end, taskResult.isSuccess(), totalDuration - handlerDuration,
  8. handlerDuration);

代码示例来源:origin: org.apache.helix/helix-core

  1. keyBuilder.currentState(instanceName, sessionId, resource,
  2. bucketizer.getBucketName(partitionKey));
  3. if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {

代码示例来源:origin: apache/helix

  1. keyBuilder.currentState(instanceName, sessionId, resource,
  2. bucketizer.getBucketName(partitionKey));
  3. if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {

相关文章