Search in sources :

Example 26 with ExecutionContext

use of com.hazelcast.jet.impl.execution.ExecutionContext in project hazelcast-jet by hazelcast.

the class Networking method handleStreamPacket.

private void handleStreamPacket(Packet packet) throws IOException {
    BufferObjectDataInput in = createObjectDataInput(nodeEngine, packet.toByteArray());
    long executionId = in.readLong();
    int vertexId = in.readInt();
    int ordinal = in.readInt();
    ExecutionContext executionContext = jobExecutionService.getExecutionContext(executionId);
    executionContext.handlePacket(vertexId, ordinal, packet.getConn().getEndPoint(), in);
}
Also used : ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) BufferObjectDataInput(com.hazelcast.nio.BufferObjectDataInput)

Example 27 with ExecutionContext

use of com.hazelcast.jet.impl.execution.ExecutionContext in project hazelcast-jet by hazelcast.

the class CancelExecutionOperation method run.

@Override
public void run() throws Exception {
    JetService service = getService();
    JobExecutionService executionService = service.getJobExecutionService();
    Address callerAddress = getCallerAddress();
    ExecutionContext ctx = executionService.assertExecutionContext(callerAddress, jobId(), executionId, this);
    ctx.cancelExecution();
}
Also used : JetService(com.hazelcast.jet.impl.JetService) JobExecutionService(com.hazelcast.jet.impl.JobExecutionService) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) Address(com.hazelcast.nio.Address)

Example 28 with ExecutionContext

use of com.hazelcast.jet.impl.execution.ExecutionContext in project hazelcast-jet by hazelcast.

the class SnapshotOperation method doRun.

@Override
protected void doRun() throws Exception {
    JetService service = getService();
    ExecutionContext ctx = service.getJobExecutionService().assertExecutionContext(getCallerAddress(), jobId(), executionId, this);
    ctx.beginSnapshot(snapshotId).thenAccept(r -> {
        logFine(getLogger(), "Snapshot %s for job %s finished successfully on member", snapshotId, idToString(jobId()));
        doSendResponse(null);
    }).exceptionally(e -> {
        getLogger().warning(String.format("Snapshot %d for job %s finished with error on member", snapshotId, idToString(jobId())), e);
        doSendResponse(new JetException("Exception during snapshot: " + e, e));
        return null;
    });
}
Also used : JetException(com.hazelcast.jet.JetException) Util.idToString(com.hazelcast.jet.impl.util.Util.idToString) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) JetService(com.hazelcast.jet.impl.JetService) LoggingUtil.logFine(com.hazelcast.jet.impl.util.LoggingUtil.logFine) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) IOException(java.io.IOException) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) JetInitDataSerializerHook(com.hazelcast.jet.impl.execution.init.JetInitDataSerializerHook) JetService(com.hazelcast.jet.impl.JetService) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) JetException(com.hazelcast.jet.JetException)

Example 29 with ExecutionContext

use of com.hazelcast.jet.impl.execution.ExecutionContext 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

ExecutionContext (com.hazelcast.jet.impl.execution.ExecutionContext)29 Address (com.hazelcast.cluster.Address)7 Address (com.hazelcast.nio.Address)7 Map (java.util.Map)7 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)6 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)5 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)5 TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)5 ExecutionNotFoundException (com.hazelcast.jet.impl.exception.ExecutionNotFoundException)5 ExecutionPlan (com.hazelcast.jet.impl.execution.init.ExecutionPlan)5 HashMap (java.util.HashMap)5 CancellationException (java.util.concurrent.CancellationException)5 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)4 JetInitDataSerializerHook (com.hazelcast.jet.impl.execution.init.JetInitDataSerializerHook)4 RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)4 IOException (java.io.IOException)4 ConcurrentMap (java.util.concurrent.ConcurrentMap)4 MembershipManager (com.hazelcast.internal.cluster.impl.MembershipManager)3 TriggerMemberListPublishOp (com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp)3