@Override public StandardDataFlow createDataFlowFromController() throws IOException { final byte[] snippetBytes = controller.getSnippetManager().export(); final byte[] authorizerFingerprint = getAuthorizerFingerprint(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); dao.save(controller, baos); final byte[] flowBytes = baos.toByteArray(); baos.reset(); final FlowManager flowManager = controller.getFlowManager(); final Set<String> missingComponents = new HashSet<>(); flowManager.getRootGroup().findAllProcessors().stream().filter(AbstractComponentNode::isExtensionMissing).forEach(p -> missingComponents.add(p.getIdentifier())); flowManager.getAllControllerServices().stream().filter(ComponentNode::isExtensionMissing).forEach(cs -> missingComponents.add(cs.getIdentifier())); controller.getAllReportingTasks().stream().filter(ComponentNode::isExtensionMissing).forEach(r -> missingComponents.add(r.getIdentifier())); return new StandardDataFlow(flowBytes, snippetBytes, authorizerFingerprint, missingComponents); }
public StandardDataFlow(final DataFlow toCopy) { this.flow = copy(toCopy.getFlow()); this.snippetBytes = copy(toCopy.getSnippets()); this.authorizerFingerprint = copy(toCopy.getAuthorizerFingerprint()); this.missingComponentIds = Collections.unmodifiableSet(toCopy.getMissingComponents() == null ? new HashSet<>() : new HashSet<>(toCopy.getMissingComponents())); }
@Override public StandardDataFlow createDataFlow() throws IOException { // Load the flow from disk if the file exists. if (dao.isFlowPresent()) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); dao.load(baos); final byte[] bytes = baos.toByteArray(); final byte[] snippetBytes = controller.getSnippetManager().export(); final byte[] authorizerFingerprint = getAuthorizerFingerprint(); final StandardDataFlow fromDisk = new StandardDataFlow(bytes, snippetBytes, authorizerFingerprint, new HashSet<>()); return fromDisk; } // Flow from disk does not exist, so serialize the Flow Controller and use that. // This is done because on startup, if there is no flow, the Flow Controller // will automatically create a Root Process Group, and we need to ensure that // we replicate that Process Group to all nodes in the cluster, so that they all // end up with the same ID for the root Process Group. return createDataFlowFromController(); }
public StandardDataFlow(final DataFlow toCopy) { this.flow = copy(toCopy.getFlow()); this.snippetBytes = copy(toCopy.getSnippets()); this.authorizerFingerprint = copy(toCopy.getAuthorizerFingerprint()); this.missingComponentIds = Collections.unmodifiableSet(toCopy.getMissingComponents() == null ? new HashSet<>() : new HashSet<>(toCopy.getMissingComponents())); }
@Override public DataFlow unmarshal(final AdaptedDataFlow aDf) { final StandardDataFlow dataFlow = new StandardDataFlow(aDf.getFlow(), aDf.getSnippets(), aDf.getAuthorizerFingerprint(), aDf.getMissingComponents()); return dataFlow; }
request.setDataFlow(new StandardDataFlow(flowService.createDataFlowFromController()));
actualProposedFlow = new StandardDataFlow(flowBytes, null, authorizerFingerprint, missingComponents);
root.findAllProcessors().stream().filter(AbstractComponentNode::isExtensionMissing).forEach(p -> missingComponents.add(p.getIdentifier())); final DataFlow existingDataFlow = new StandardDataFlow(existingFlow, existingSnippets, existingAuthFingerprint, missingComponents);
@Override public DataFlow unmarshal(final AdaptedDataFlow aDf) { final StandardDataFlow dataFlow = new StandardDataFlow(aDf.getFlow(), aDf.getSnippets(), aDf.getAuthorizerFingerprint(), aDf.getMissingComponents()); return dataFlow; }