/** * A naive implementation of edge identity calculation. * @return */ public static String calculateEdgeIdentity(ServiceNode sourceNode, ServiceNode targetNode, SpecExecutor specExecutorInstance){ return sourceNode.getNodeName() + "-" + specExecutorInstance.getUri() + "-" + targetNode.getNodeName(); }
/** * A naive implementation of generating a jobSpec's URI within a multi-hop logical Flow. */ @Override public URI jobSpecURIGenerator(Object... objects) { FlowSpec flowSpec = (FlowSpec) objects[0]; ServiceNode sourceNode = (ServiceNode) objects[1]; ServiceNode targetNode = (ServiceNode) objects[2]; try { return new URI(JobSpec.Builder.DEFAULT_JOB_CATALOG_SCHEME, flowSpec.getUri().getAuthority(), StringUtils.appendIfMissing(StringUtils.prependIfMissing(flowSpec.getUri().getPath(), "/"),"/") + sourceNode.getNodeName() + "-" + targetNode.getNodeName(), null); } catch (URISyntaxException e) { log.error( "URI construction failed when jobSpec from " + sourceNode.getNodeName() + " to " + targetNode.getNodeName()); throw new RuntimeException(); } } }
private List<JobExecutionPlan> getJobExecutionPlans(String source, String destination, JobSpec jobSpec) throws ExecutionException, InterruptedException { List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>(); for (TopologySpec topologySpec : topologySpecMap.values()) { Map<ServiceNode, ServiceNode> capabilities = topologySpec.getSpecExecutor().getCapabilities().get(); for (Map.Entry<ServiceNode, ServiceNode> capability : capabilities.entrySet()) { log.info(String.format("Evaluating current JobSpec: %s against TopologySpec: %s with " + "capability of source: %s and destination: %s ", jobSpec.getUri(), topologySpec.getUri(), capability.getKey(), capability.getValue())); if (source.equals(capability.getKey().getNodeName()) && destination .equals(capability.getValue().getNodeName())) { JobExecutionPlan jobExecutionPlan = new JobExecutionPlan(jobSpec, topologySpec.getSpecExecutor()); log.info(String .format("Current JobSpec: %s is executable on TopologySpec: %s. Added TopologySpec as candidate.", jobSpec.getUri(), topologySpec.getUri())); log.info("Since we found a candidate executor, we will not try to compute more. " + "(Intended limitation for IdentityFlowToJobSpecCompiler)"); jobExecutionPlans.add(jobExecutionPlan); return jobExecutionPlans; } } } return jobExecutionPlans; }
if (node.getNode().getNodeName().equals(targetNode.getNodeName())) {
private void weightGraphGenerateHelper(TopologySpec topologySpec) { try { Map<ServiceNode, ServiceNode> capabilities = topologySpec.getSpecExecutor().getCapabilities().get(); for (Map.Entry<ServiceNode, ServiceNode> capability : capabilities.entrySet()) { BaseServiceNodeImpl sourceNode = new BaseServiceNodeImpl(capability.getKey().getNodeName()); BaseServiceNodeImpl targetNode = new BaseServiceNodeImpl(capability.getValue().getNodeName()); if (!weightedGraph.containsVertex(sourceNode)) { weightedGraph.addVertex(sourceNode); } if (!weightedGraph.containsVertex(targetNode)) { weightedGraph.addVertex(targetNode); } FlowEdge flowEdge = new LoadBasedFlowEdgeImpl(sourceNode, targetNode, defaultFlowEdgeProps, topologySpec.getSpecExecutor()); // In Multi-Graph if flowEdge existed, just skip it. if (!weightedGraph.containsEdge(flowEdge)) { weightedGraph.addEdge(sourceNode, targetNode, flowEdge); } } } catch (InterruptedException | ExecutionException e) { Instrumented.markMeter(this.flowCompilationFailedMeter); throw new RuntimeException("Cannot determine topology capabilities", e); } }
.withValue(ConfigurationKeys.JOB_NAME_KEY, ConfigValueFactory.fromAnyRef( flowSpec.getConfig().getValue(ConfigurationKeys.FLOW_NAME_KEY).unwrapped().toString() + "-" + sourceNode.getNodeName() + "-" + targetNode.getNodeName())));
/** * A naive implementation of edge identity calculation. * @return */ public static String calculateEdgeIdentity(ServiceNode sourceNode, ServiceNode targetNode, SpecExecutor specExecutorInstance){ return sourceNode.getNodeName() + "-" + specExecutorInstance.getUri() + "-" + targetNode.getNodeName(); }
/** * A naive implementation of generating a jobSpec's URI within a multi-hop logical Flow. */ @Override public URI jobSpecURIGenerator(Object... objects) { FlowSpec flowSpec = (FlowSpec) objects[0]; ServiceNode sourceNode = (ServiceNode) objects[1]; ServiceNode targetNode = (ServiceNode) objects[2]; try { return new URI(JobSpec.Builder.DEFAULT_JOB_CATALOG_SCHEME, flowSpec.getUri().getAuthority(), StringUtils.appendIfMissing(StringUtils.prependIfMissing(flowSpec.getUri().getPath(), "/"),"/") + sourceNode.getNodeName() + "-" + targetNode.getNodeName(), null); } catch (URISyntaxException e) { log.error( "URI construction failed when jobSpec from " + sourceNode.getNodeName() + " to " + targetNode.getNodeName()); throw new RuntimeException(); } } }
private List<JobExecutionPlan> getJobExecutionPlans(String source, String destination, JobSpec jobSpec) throws ExecutionException, InterruptedException { List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>(); for (TopologySpec topologySpec : topologySpecMap.values()) { Map<ServiceNode, ServiceNode> capabilities = topologySpec.getSpecExecutor().getCapabilities().get(); for (Map.Entry<ServiceNode, ServiceNode> capability : capabilities.entrySet()) { log.info(String.format("Evaluating current JobSpec: %s against TopologySpec: %s with " + "capability of source: %s and destination: %s ", jobSpec.getUri(), topologySpec.getUri(), capability.getKey(), capability.getValue())); if (source.equals(capability.getKey().getNodeName()) && destination .equals(capability.getValue().getNodeName())) { JobExecutionPlan jobExecutionPlan = new JobExecutionPlan(jobSpec, topologySpec.getSpecExecutor()); log.info(String .format("Current JobSpec: %s is executable on TopologySpec: %s. Added TopologySpec as candidate.", jobSpec.getUri(), topologySpec.getUri())); log.info("Since we found a candidate executor, we will not try to compute more. " + "(Intended limitation for IdentityFlowToJobSpecCompiler)"); jobExecutionPlans.add(jobExecutionPlan); return jobExecutionPlans; } } } return jobExecutionPlans; }
if (node.getNode().getNodeName().equals(targetNode.getNodeName())) {
private void weightGraphGenerateHelper(TopologySpec topologySpec) { try { Map<ServiceNode, ServiceNode> capabilities = topologySpec.getSpecExecutor().getCapabilities().get(); for (Map.Entry<ServiceNode, ServiceNode> capability : capabilities.entrySet()) { BaseServiceNodeImpl sourceNode = new BaseServiceNodeImpl(capability.getKey().getNodeName()); BaseServiceNodeImpl targetNode = new BaseServiceNodeImpl(capability.getValue().getNodeName()); if (!weightedGraph.containsVertex(sourceNode)) { weightedGraph.addVertex(sourceNode); } if (!weightedGraph.containsVertex(targetNode)) { weightedGraph.addVertex(targetNode); } FlowEdge flowEdge = new LoadBasedFlowEdgeImpl(sourceNode, targetNode, defaultFlowEdgeProps, topologySpec.getSpecExecutor()); // In Multi-Graph if flowEdge existed, just skip it. if (!weightedGraph.containsEdge(flowEdge)) { weightedGraph.addEdge(sourceNode, targetNode, flowEdge); } } } catch (InterruptedException | ExecutionException e) { Instrumented.markMeter(this.flowCompilationFailedMeter); throw new RuntimeException("Cannot determine topology capabilities", e); } }
.withValue(ConfigurationKeys.JOB_NAME_KEY, ConfigValueFactory.fromAnyRef( flowSpec.getConfig().getValue(ConfigurationKeys.FLOW_NAME_KEY).unwrapped().toString() + "-" + sourceNode.getNodeName() + "-" + targetNode.getNodeName())));