Search in sources :

Example 1 with JobRecord

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

the class SplitBrainTest method when_newMemberJoinsToCluster_then_jobQuorumSizeIsUpdated.

@Test
public void when_newMemberJoinsToCluster_then_jobQuorumSizeIsUpdated() {
    int clusterSize = 3;
    JetConfig jetConfig = new JetConfig();
    JetInstance[] instances = new JetInstance[clusterSize];
    for (int i = 0; i < clusterSize; i++) {
        instances[i] = createJetMember(jetConfig);
    }
    StuckProcessor.executionStarted = new CountDownLatch(clusterSize * PARALLELISM);
    MockPS processorSupplier = new MockPS(StuckProcessor::new, clusterSize);
    DAG dag = new DAG().vertex(new Vertex("test", processorSupplier));
    Job job = instances[0].newJob(dag, new JobConfig().setSplitBrainProtection(true));
    assertOpenEventually(StuckProcessor.executionStarted);
    createJetMember(jetConfig);
    assertTrueEventually(() -> {
        JobRepository jobRepository = getJetService(instances[0]).getJobRepository();
        JobRecord jobRecord = jobRepository.getJobRecord(job.getId());
        assertEquals(3, jobRecord.getQuorumSize());
    });
    StuckProcessor.proceedLatch.countDown();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) JetInstance(com.hazelcast.jet.JetInstance) CountDownLatch(java.util.concurrent.CountDownLatch) JobRepository(com.hazelcast.jet.impl.JobRepository) JetConfig(com.hazelcast.jet.config.JetConfig) JobConfig(com.hazelcast.jet.config.JobConfig) JobRecord(com.hazelcast.jet.impl.JobRecord) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 2 with JobRecord

use of com.hazelcast.jet.impl.JobRecord in project hazelcast by hazelcast.

the class TopologyChangeTest method when_nodeIsNotJobParticipant_then_initFails.

@Test
public void when_nodeIsNotJobParticipant_then_initFails() throws Throwable {
    final long jobId = 1;
    final long executionId = 1;
    HazelcastInstance master = instances[0];
    int memberListVersion = Accessors.getClusterService(master).getMemberListVersion();
    Set<MemberInfo> memberInfos = new HashSet<>();
    for (int i = 1; i < instances.length; i++) {
        memberInfos.add(new MemberInfo(getNode(instances[i]).getLocalMember()));
    }
    Version version = instances[0].getCluster().getLocalMember().getVersion().asVersion();
    JobRecord jobRecord = new JobRecord(version, jobId, null, "", new JobConfig(), Collections.emptySet(), null);
    instances[0].getMap(JOB_RECORDS_MAP_NAME).put(jobId, jobRecord);
    InitExecutionOperation op = new InitExecutionOperation(jobId, executionId, memberListVersion, version, memberInfos, null, false);
    Future<Object> future = Accessors.getOperationService(master).createInvocationBuilder(JetServiceBackend.SERVICE_NAME, op, Accessors.getAddress(master)).invoke();
    try {
        future.get();
        fail();
    } catch (ExecutionException e) {
        assertInstanceOf(IllegalArgumentException.class, e.getCause());
        assertTrue("Expected: contains 'is not in participants'\nActual: '" + e.getMessage() + "'", e.getMessage().contains("is not in participants"));
    }
}
Also used : JobConfig(com.hazelcast.jet.config.JobConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Version(com.hazelcast.version.Version) JobRecord(com.hazelcast.jet.impl.JobRecord) InitExecutionOperation(com.hazelcast.jet.impl.operation.InitExecutionOperation) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

JobConfig (com.hazelcast.jet.config.JobConfig)2 JobRecord (com.hazelcast.jet.impl.JobRecord)2 Test (org.junit.Test)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)1 JetInstance (com.hazelcast.jet.JetInstance)1 Job (com.hazelcast.jet.Job)1 JetConfig (com.hazelcast.jet.config.JetConfig)1 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)1 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)1 JobRepository (com.hazelcast.jet.impl.JobRepository)1 InitExecutionOperation (com.hazelcast.jet.impl.operation.InitExecutionOperation)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Version (com.hazelcast.version.Version)1 HashSet (java.util.HashSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutionException (java.util.concurrent.ExecutionException)1