use of com.hazelcast.jet.config.EdgeConfig in project hazelcast-jet by hazelcast.
the class ExecutionPlanBuilder method createExecutionPlans.
public static Map<MemberInfo, ExecutionPlan> createExecutionPlans(NodeEngine nodeEngine, MembersView membersView, DAG dag, JobConfig jobConfig, long lastSnapshotId) {
final JetInstance instance = getJetInstance(nodeEngine);
final int defaultParallelism = instance.getConfig().getInstanceConfig().getCooperativeThreadCount();
final Collection<MemberInfo> members = new HashSet<>(membersView.size());
final Address[] partitionOwners = new Address[nodeEngine.getPartitionService().getPartitionCount()];
initPartitionOwnersAndMembers(nodeEngine, membersView, members, partitionOwners);
final List<Address> addresses = members.stream().map(MemberInfo::getAddress).collect(toList());
final int clusterSize = members.size();
final boolean isJobDistributed = clusterSize > 1;
final EdgeConfig defaultEdgeConfig = instance.getConfig().getDefaultEdgeConfig();
final Map<MemberInfo, ExecutionPlan> plans = members.stream().collect(toMap(m -> m, m -> new ExecutionPlan(partitionOwners, jobConfig, lastSnapshotId)));
final Map<String, Integer> vertexIdMap = assignVertexIds(dag);
for (Entry<String, Integer> entry : vertexIdMap.entrySet()) {
final Vertex vertex = dag.getVertex(entry.getKey());
final ProcessorMetaSupplier metaSupplier = vertex.getMetaSupplier();
final int vertexId = entry.getValue();
final int localParallelism = determineParallelism(vertex, metaSupplier.preferredLocalParallelism(), defaultParallelism);
final int totalParallelism = localParallelism * clusterSize;
final List<EdgeDef> inbound = toEdgeDefs(dag.getInboundEdges(vertex.getName()), defaultEdgeConfig, e -> vertexIdMap.get(e.getSourceName()), isJobDistributed);
final List<EdgeDef> outbound = toEdgeDefs(dag.getOutboundEdges(vertex.getName()), defaultEdgeConfig, e -> vertexIdMap.get(e.getDestName()), isJobDistributed);
final ILogger logger = nodeEngine.getLogger(String.format("%s.%s#ProcessorMetaSupplier", metaSupplier.getClass().getName(), vertex.getName()));
metaSupplier.init(new MetaSupplierCtx(instance, logger, vertex.getName(), localParallelism, totalParallelism));
Function<Address, ProcessorSupplier> procSupplierFn = metaSupplier.get(addresses);
int procIdxOffset = 0;
for (Entry<MemberInfo, ExecutionPlan> e : plans.entrySet()) {
final ProcessorSupplier processorSupplier = procSupplierFn.apply(e.getKey().getAddress());
checkSerializable(processorSupplier, "ProcessorSupplier in vertex '" + vertex.getName() + '\'');
final VertexDef vertexDef = new VertexDef(vertexId, vertex.getName(), processorSupplier, procIdxOffset, localParallelism, totalParallelism);
vertexDef.addInboundEdges(inbound);
vertexDef.addOutboundEdges(outbound);
e.getValue().addVertex(vertexDef);
procIdxOffset += localParallelism;
}
}
return plans;
}
use of com.hazelcast.jet.config.EdgeConfig in project hazelcast-jet by hazelcast.
the class XmlConfigTest method when_edgeDefaultsSpecified_usesSpecified.
@Test
public void when_edgeDefaultsSpecified_usesSpecified() {
// Given
Properties properties = new Properties();
properties.put(XmlJetConfigLocator.HAZELCAST_JET_CONFIG_PROPERTY, "classpath:" + TEST_XML_1);
// When
JetConfig jetConfig = XmlJetConfigBuilder.getConfig(properties);
// Then
EdgeConfig edgeConfig = jetConfig.getDefaultEdgeConfig();
assertEquals("queueSize", 999, edgeConfig.getQueueSize());
assertEquals("packetSizeLimit", 997, edgeConfig.getPacketSizeLimit());
assertEquals("receiveWindowMultiplier", 996, edgeConfig.getReceiveWindowMultiplier());
}
Aggregations