Search in sources :

Example 46 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class DecoratorTest method listDecorator.

@Test
public void listDecorator() throws Exception {
    JetInstance instance = Mockito.mock(JetInstance.class);
    assertDecorator(IList.class, IListJet.class, l -> new IListDecorator<>(l, instance));
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) Test(org.junit.Test)

Example 47 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class AsyncMapWriterTest method setup.

@Before
public void setup() {
    JetConfig jetConfig = new JetConfig();
    Config config = jetConfig.getHazelcastConfig();
    // use two partitions per member
    config.setProperty(GroupProperty.PARTITION_COUNT.getName(), String.valueOf(NODE_COUNT * 2));
    config.setProperty(GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS.getName(), "3000");
    config.getMapConfig("default").setBackupCount(1).setAsyncBackupCount(0);
    config.getMapConfig(ALWAYS_FAILING_MAP).getMapStoreConfig().setEnabled(true).setImplementation(new AlwaysFailingMapStore());
    config.getMapConfig(RETRYABLE_MAP).getMapStoreConfig().setEnabled(true).setImplementation(new RetryableMapStore());
    JetInstance[] instances = createJetMembers(jetConfig, NODE_COUNT);
    instance1 = instances[0];
    instance2 = instances[1];
    nodeEngine = getNodeEngineImpl(instance1.getHazelcastInstance());
    writer = new AsyncMapWriter(nodeEngine);
    map = instance1.getMap("testMap");
    writer.setMapName(map.getName());
}
Also used : Config(com.hazelcast.config.Config) JetConfig(com.hazelcast.jet.config.JetConfig) JetInstance(com.hazelcast.jet.JetInstance) JetConfig(com.hazelcast.jet.config.JetConfig) Before(org.junit.Before)

Example 48 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class ExceptionUtilTest method test_serializationOnNode.

@Test
public void test_serializationOnNode() {
    // create one member and one client
    JetInstance client = createJetMember();
    RuntimeException exc = new RuntimeException("myException");
    try {
        DAG dag = new DAG();
        dag.newVertex("source", () -> new MockP().setCompleteError(exc)).localParallelism(1);
        client.newJob(dag).join();
    } catch (Exception caught) {
        assertThat(caught.toString(), containsString(exc.toString()));
        TestUtil.assertExceptionInCauses(exc, caught);
    }
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) MockP(com.hazelcast.jet.core.TestProcessors.MockP) DAG(com.hazelcast.jet.core.DAG) JetException(com.hazelcast.jet.JetException) ExecutionException(java.util.concurrent.ExecutionException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 49 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class HazelcastRemoteConnectorTest method setUp.

@BeforeClass
public static void setUp() {
    JetConfig jetConfig = new JetConfig();
    Config hazelcastConfig = jetConfig.getHazelcastConfig();
    hazelcastConfig.addCacheConfig(new CacheSimpleConfig().setName("*"));
    jet = factory.newMember(jetConfig);
    JetInstance jet2 = factory.newMember(jetConfig);
    Config config = new Config();
    config.addCacheConfig(new CacheSimpleConfig().setName("*"));
    config.addEventJournalConfig(new EventJournalConfig().setCacheName("default").setMapName("default"));
    config.getGroupConfig().setName(randomName());
    hz = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance hz2 = Hazelcast.newHazelcastInstance(config);
    clientConfig = new ClientConfig();
    clientConfig.getGroupConfig().setName(config.getGroupConfig().getName());
    Address address = hz.getCluster().getLocalMember().getAddress();
    clientConfig.getNetworkConfig().addAddress(address.getHost() + ':' + address.getPort());
    // workaround for `cache is not created` exception, create cache locally on all nodes
    hz2.getCacheManager().getCache(SOURCE_NAME);
    hz2.getCacheManager().getCache(SINK_NAME);
    jet2.getCacheManager().getCache(SOURCE_NAME);
    jet2.getCacheManager().getCache(SINK_NAME);
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) EventJournalConfig(com.hazelcast.config.EventJournalConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) JetConfig(com.hazelcast.jet.config.JetConfig) JetInstance(com.hazelcast.jet.JetInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) JetConfig(com.hazelcast.jet.config.JetConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) BeforeClass(org.junit.BeforeClass)

Example 50 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class StreamEventJournalP_WmCoalescingTest method setUp.

@Before
public void setUp() {
    JetConfig config = new JetConfig();
    EventJournalConfig journalConfig = new EventJournalConfig().setMapName("*").setCapacity(JOURNAL_CAPACITY).setEnabled(true);
    config.getHazelcastConfig().setProperty(PARTITION_COUNT.getName(), "2");
    config.getHazelcastConfig().addEventJournalConfig(journalConfig);
    JetInstance instance = this.createJetMember(config);
    assert map == null;
    map = (MapProxyImpl<Integer, Integer>) instance.getHazelcastInstance().<Integer, Integer>getMap("test");
    partitionKeys = new int[2];
    for (int i = 1; IntStream.of(partitionKeys).anyMatch(val -> val == 0); i++) {
        int partitionId = instance.getHazelcastInstance().getPartitionService().getPartition(i).getPartitionId();
        partitionKeys[partitionId] = i;
    }
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) JetConfig(com.hazelcast.jet.config.JetConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) Before(org.junit.Before)

Aggregations

JetInstance (com.hazelcast.jet.JetInstance)84 Test (org.junit.Test)45 Job (com.hazelcast.jet.Job)32 JetConfig (com.hazelcast.jet.config.JetConfig)22 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)14 Pipeline (com.hazelcast.jet.pipeline.Pipeline)14 JobConfig (com.hazelcast.jet.config.JobConfig)13 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)12 DAG (com.hazelcast.jet.core.DAG)10 ExpectedException (org.junit.rules.ExpectedException)10 Jet (com.hazelcast.jet.Jet)9 Assert.assertEquals (org.junit.Assert.assertEquals)9 JetService (com.hazelcast.jet.impl.JetService)8 Map (java.util.Map)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 JobRepository (com.hazelcast.jet.impl.JobRepository)7 Sources (com.hazelcast.jet.pipeline.Sources)7 CancellationException (java.util.concurrent.CancellationException)7 Assert.assertNotNull (org.junit.Assert.assertNotNull)7 Before (org.junit.Before)7