@Override public HelixTaskResult handleMessage() throws InterruptedException { if (jobScheduler.isActive()) { // we want to make sure current node is in active state String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE); log.info("{} ControllerUserDefinedMessage received : {}, type {}", this.serviceName, msg, _message.getMsgSubType()); try { if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) { handleAdd(msg); } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) { handleDelete(msg); } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) { handleUpdate(msg); } } catch (IOException e) { log.error("Cannot process Helix message.", e); HelixTaskResult helixTaskResult = new HelixTaskResult(); helixTaskResult.setSuccess(false); return helixTaskResult; } } else { String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE); log.error("ControllerUserDefinedMessage received but ignored due to not in active mode: {}, type {}", msg, _message.getMsgSubType()); } HelixTaskResult helixTaskResult = new HelixTaskResult(); helixTaskResult.setSuccess(true); return helixTaskResult; }
public GroupMessageInfo onCompleteSubMessage(Message subMessage) { String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID); GroupMessageInfo info = _groupMsgMap.get(parentMid); if (info != null) { int val = info._countDown.decrementAndGet(); if (val <= 0) { return _groupMsgMap.remove(parentMid); } } return null; }
public GroupMessageInfo onCompleteSubMessage(Message subMessage) { String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID); GroupMessageInfo info = _groupMsgMap.get(parentMid); if (info != null) { int val = info._countDown.decrementAndGet(); if (val <= 0) { return _groupMsgMap.remove(parentMid); } } return null; }
void addCurStateUpdate(Message subMessage, PropertyKey key, CurrentState delta) { String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID); GroupMessageInfo info = _groupMsgMap.get(parentMid); if (info != null) { info._curStateUpdateList.add(new CurrentStateUpdate(key, delta)); } } }
void addCurStateUpdate(Message subMessage, PropertyKey key, CurrentState delta) { String parentMid = subMessage.getAttribute(Attributes.PARENT_MSG_ID); GroupMessageInfo info = _groupMsgMap.get(parentMid); if (info != null) { info._curStateUpdateList.add(new CurrentStateUpdate(key, delta)); } } }
private static String instantiateByMessage(String string, Message message) { Matcher matcher = pattern.matcher(string); String result = string; while (matcher.find()) { String var = matcher.group(); result = result.replace(var, message.getAttribute(Message.Attributes.valueOf(var.substring(1, var.length() - 1)))); } return result; }
String instanceName = message.getAttribute(Message.Attributes.TGT_NAME); String resourceName = message.getAttribute(Message.Attributes.RESOURCE_NAME);
String instanceName = message.getAttribute(Message.Attributes.TGT_NAME); String resourceName = message.getAttribute(Message.Attributes.RESOURCE_NAME);
@Override public HelixTaskResult handleMessage() throws InterruptedException { if (jobScheduler.isActive()) { String flowSpecUri = _message.getAttribute(Message.Attributes.INNER_MESSAGE); try { if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) { Spec spec = flowCatalog.getSpec(new URI(flowSpecUri)); this.jobScheduler.onAddSpec(spec); } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) { List<String> flowSpecUriParts = Splitter.on(":").omitEmptyStrings().trimResults().splitToList(flowSpecUri); this.jobScheduler.onDeleteSpec(new URI(flowSpecUriParts.get(0)), flowSpecUriParts.get(1)); } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) { Spec spec = flowCatalog.getSpec(new URI(flowSpecUri)); this.jobScheduler.onUpdateSpec(spec); } } catch (SpecNotFoundException | URISyntaxException e) { LOGGER.error("Cannot process Helix message for flowSpecUri: " + flowSpecUri, e); } } HelixTaskResult helixTaskResult = new HelixTaskResult(); helixTaskResult.setSuccess(true); return helixTaskResult; }
private void finalCleanup(HelixTaskResult taskResult) { try { if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) { removeMessageFromZk(_manager.getHelixDataAccessor(), _message); reportMessageStat(_manager, _message, taskResult); sendReply(getSrcClusterDataAccessor(_message), _message, taskResult); _executor.finishTask(this); } } catch (Exception e) { logger.error(String.format("Error to final clean up for message : %s", _message.getId())); } } }
@Override public HelixTaskResult handleMessage() throws InterruptedException { if (jobScheduler.isActive()) { // we want to make sure current node is in active state String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE); log.info("{} ControllerUserDefinedMessage received : {}, type {}", this.serviceName, msg, _message.getMsgSubType()); try { if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_ADD)) { handleAdd(msg); } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_REMOVE)) { handleDelete(msg); } else if (_message.getMsgSubType().equals(ServiceConfigKeys.HELIX_FLOWSPEC_UPDATE)) { handleUpdate(msg); } } catch (IOException e) { log.error("Cannot process Helix message.", e); HelixTaskResult helixTaskResult = new HelixTaskResult(); helixTaskResult.setSuccess(false); return helixTaskResult; } } else { String msg = _message.getAttribute(Message.Attributes.INNER_MESSAGE); log.error("ControllerUserDefinedMessage received but ignored due to not in active mode: {}, type {}", msg, _message.getMsgSubType()); } HelixTaskResult helixTaskResult = new HelixTaskResult(); helixTaskResult.setSuccess(true); return helixTaskResult; }
logger.info( "Message: {} (parent: {}) handling task for {}:{} completed at: {}, results: {}. FrameworkTime: {} ms; HandlerTime: {} ms.", _message.getMsgId(), _message.getAttribute(Attributes.PARENT_MSG_ID), _message.getResourceName(), _message.getPartitionName(), end, taskResult.isSuccess(), totalDuration - handlerDuration, handlerDuration);
if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) { removeMessageFromZk(accessor, _message); reportMessageStat(_manager, _message, taskResult); logger.info( "Message: {} (parent: {}) handling task for {}:{} completed at: {}, results: {}. FrameworkTime: {} ms; HandlerTime: {} ms.", _message.getMsgId(), _message.getAttribute(Attributes.PARENT_MSG_ID), _message.getResourceName(), _message.getPartitionName(), end, taskResult.isSuccess(), totalDuration - handlerDuration, handlerDuration);
keyBuilder.currentState(instanceName, sessionId, resource, bucketizer.getBucketName(partitionKey)); if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {
keyBuilder.currentState(instanceName, sessionId, resource, bucketizer.getBucketName(partitionKey)); if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {