Search in sources :

Example 21 with JetService

use of com.hazelcast.jet.impl.JetService in project hazelcast-jet by hazelcast.

the class JoinSubmittedJobOperation method doRun.

@Override
protected void doRun() {
    JetService service = getService();
    JobCoordinationService coordinationService = service.getJobCoordinationService();
    CompletableFuture<Void> executionFuture = coordinationService.joinSubmittedJob(jobId());
    executionFuture.whenComplete(withTryCatch(getLogger(), (r, t) -> doSendResponse(peel(t))));
}
Also used : JetService(com.hazelcast.jet.impl.JetService) ExceptionUtil.peel(com.hazelcast.jet.impl.util.ExceptionUtil.peel) ExceptionUtil.withTryCatch(com.hazelcast.jet.impl.util.ExceptionUtil.withTryCatch) JobCoordinationService(com.hazelcast.jet.impl.JobCoordinationService) CompletableFuture(java.util.concurrent.CompletableFuture) JetInitDataSerializerHook(com.hazelcast.jet.impl.execution.init.JetInitDataSerializerHook) JetService(com.hazelcast.jet.impl.JetService) JobCoordinationService(com.hazelcast.jet.impl.JobCoordinationService)

Example 22 with JetService

use of com.hazelcast.jet.impl.JetService 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 23 with JetService

use of com.hazelcast.jet.impl.JetService in project hazelcast-jet by hazelcast.

the class SubmitJobOperation method run.

@Override
public void run() {
    JetService service = getService();
    JobCoordinationService coordinationService = service.getJobCoordinationService();
    coordinationService.submitOrJoinJob(jobId(), dag, config);
}
Also used : JetService(com.hazelcast.jet.impl.JetService) JobCoordinationService(com.hazelcast.jet.impl.JobCoordinationService)

Example 24 with JetService

use of com.hazelcast.jet.impl.JetService in project hazelcast-jet by hazelcast.

the class AsyncMapWriterTest method when_memberLeaves_then_retryAutomatically.

@Test
@Ignore("This test is currently racy as an operation is only retried once.")
public void when_memberLeaves_then_retryAutomatically() throws Exception {
    // Given
    for (int i = 0; i < 100; i++) {
        writer.put(i, i);
    }
    CompletableFuture<Void> future = new CompletableFuture<>();
    JetService service = nodeEngine.getService(JetService.SERVICE_NAME);
    service.numConcurrentPutAllOps().set(MAX_PARALLEL_ASYNC_OPS - NODE_COUNT);
    // When
    boolean flushed = writer.tryFlushAsync(future);
    assertTrue("tryFlushAsync returned false", flushed);
    terminateInstance(instance2);
    // Then
    future.get();
    for (int i = 0; i < 100; i++) {
        assertEquals(i, map.get(i));
    }
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JetService(com.hazelcast.jet.impl.JetService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 25 with JetService

use of com.hazelcast.jet.impl.JetService in project hazelcast-jet by hazelcast.

the class AsyncMapWriterTest method when_opFinished_then_releaseCount.

@Test
public void when_opFinished_then_releaseCount() throws Exception {
    // Given
    writer.put("key1", "value1");
    CompletableFuture<Void> future = new CompletableFuture<>();
    JetService service = nodeEngine.getService(JetService.SERVICE_NAME);
    service.numConcurrentPutAllOps().set(MAX_PARALLEL_ASYNC_OPS - NODE_COUNT);
    // When
    boolean flushed = writer.tryFlushAsync(future);
    assertTrue("tryFlushAsync returned false", flushed);
    future.get();
    writer.put("key2", "value2");
    flushed = writer.tryFlushAsync(future);
    // Then
    assertTrue("tryFlushAsync returned false", flushed);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JetService(com.hazelcast.jet.impl.JetService) Test(org.junit.Test)

Aggregations

JetService (com.hazelcast.jet.impl.JetService)28 Test (org.junit.Test)9 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)6 JetInstance (com.hazelcast.jet.JetInstance)5 Job (com.hazelcast.jet.Job)5 JobConfig (com.hazelcast.jet.config.JobConfig)5 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)5 JobCoordinationService (com.hazelcast.jet.impl.JobCoordinationService)5 JetConfig (com.hazelcast.jet.config.JetConfig)4 STARTING (com.hazelcast.jet.core.JobStatus.STARTING)4 JobRepository (com.hazelcast.jet.impl.JobRepository)4 MasterContext (com.hazelcast.jet.impl.MasterContext)4 Address (com.hazelcast.nio.Address)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Future (java.util.concurrent.Future)4 Assert.assertEquals (org.junit.Assert.assertEquals)4 Assert.assertNotNull (org.junit.Assert.assertNotNull)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 Assert.fail (org.junit.Assert.fail)4