Search in sources :

Example 6 with MembersView

use of com.hazelcast.internal.cluster.impl.MembersView in project hazelcast-jet by hazelcast.

the class ExecutionLifecycleTest method when_executionCancelledBeforeStart_then_jobFutureIsCancelledOnExecute.

@Test
public void when_executionCancelledBeforeStart_then_jobFutureIsCancelledOnExecute() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(instance.getHazelcastInstance());
    Address localAddress = nodeEngineImpl.getThisAddress();
    ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngineImpl.getClusterService();
    MembersView membersView = clusterService.getMembershipManager().getMembersView();
    int memberListVersion = membersView.getVersion();
    JetService jetService = getJetService(instance);
    final Map<MemberInfo, ExecutionPlan> executionPlans = ExecutionPlanBuilder.createExecutionPlans(nodeEngineImpl, membersView, dag, new JobConfig(), NO_SNAPSHOT);
    ExecutionPlan executionPlan = executionPlans.get(membersView.getMember(localAddress));
    long jobId = 0;
    long executionId = 1;
    Set<MemberInfo> participants = new HashSet<>(membersView.getMembers());
    jetService.getJobExecutionService().initExecution(jobId, executionId, localAddress, memberListVersion, participants, executionPlan);
    ExecutionContext executionContext = jetService.getJobExecutionService().getExecutionContext(executionId);
    executionContext.cancelExecution();
    // When
    CompletableFuture<Void> future = executionContext.beginExecution();
    // Then
    expectedException.expect(CancellationException.class);
    future.join();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) JetService(com.hazelcast.jet.impl.JetService) Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) MembersView(com.hazelcast.internal.cluster.impl.MembersView) JobConfig(com.hazelcast.jet.config.JobConfig) ExecutionPlan(com.hazelcast.jet.impl.execution.init.ExecutionPlan) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MemberInfo (com.hazelcast.internal.cluster.MemberInfo)6 MembersView (com.hazelcast.internal.cluster.impl.MembersView)6 HashSet (java.util.HashSet)5 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)4 JobConfig (com.hazelcast.jet.config.JobConfig)4 ExecutionPlan (com.hazelcast.jet.impl.execution.init.ExecutionPlan)4 DAG (com.hazelcast.jet.core.DAG)3 Edge (com.hazelcast.jet.core.Edge)3 TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)3 Vertex (com.hazelcast.jet.core.Vertex)3 ILogger (com.hazelcast.logging.ILogger)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 Collection (java.util.Collection)3 List (java.util.List)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 Address (com.hazelcast.cluster.Address)2 Edge.between (com.hazelcast.jet.core.Edge.between)2 JobStatus (com.hazelcast.jet.core.JobStatus)2 COMPLETED (com.hazelcast.jet.core.JobStatus.COMPLETED)2