當前位置: 首頁>>代碼示例>>Java>>正文


Java JetInstance類代碼示例

本文整理匯總了Java中com.hazelcast.jet.JetInstance的典型用法代碼示例。如果您正苦於以下問題:Java JetInstance類的具體用法?Java JetInstance怎麽用?Java JetInstance使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JetInstance類屬於com.hazelcast.jet包,在下文中一共展示了JetInstance類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("Usage: hdfs-to-map <name> <input path> <parallelism>");
        return;
    }

    String name = args[0];
    String inputPath = args[1];
    int parallelism = Integer.parseInt(args[2]);

    JetInstance client = Jet.newJetClient();
    IStreamMap<Long, String> map = client.getMap(name);
    map.clear();

    try {
        long begin = System.currentTimeMillis();
        fillMap(client, name, inputPath, parallelism);
        long elapsed = System.currentTimeMillis() - begin;
        System.out.println("Time=" + elapsed);
    } finally {
        client.shutdown();
    }
}
 
開發者ID:hazelcast,項目名稱:big-data-benchmark,代碼行數:24,代碼來源:HdfsToMap.java

示例2: fillMap

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
private static void fillMap(JetInstance client, String name, String inputPath, int parallelism) throws Exception {
    DAG dag = new DAG();
    JobConf conf = new JobConf();
    conf.setInputFormat(TextInputFormat.class);
    TextInputFormat.addInputPath(conf, new Path(inputPath));


    Vertex reader = dag.newVertex("reader", readHdfsP(conf, Util::entry));
    Vertex mapper = dag.newVertex("mapper",
            mapP((Map.Entry<LongWritable, Text> e) -> entry(e.getKey().get(), e.getValue().toString())));
    Vertex writer = dag.newVertex("writer", writeMapP(name));

    reader.localParallelism(parallelism);
    mapper.localParallelism(parallelism);
    writer.localParallelism(parallelism);

    dag.edge(between(reader, mapper));
    dag.edge(between(mapper, writer));


    JobConfig jobConfig = new JobConfig();
    jobConfig.addClass(HdfsToMap.class);

    client.newJob(dag, jobConfig).join();
}
 
開發者ID:hazelcast,項目名稱:big-data-benchmark,代碼行數:26,代碼來源:HdfsToMap.java

示例3: test_Jar_Distribution

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void test_Jar_Distribution() throws Throwable {
    createCluster();

    DAG dag = new DAG();
    dag.newVertex("create and print person", LoadPersonIsolated::new);


    JetInstance jetInstance = getJetInstance();
    JobConfig jobConfig = new JobConfig();
    jobConfig.addJar(this.getClass().getResource("/sample-pojo-1.0-person.jar"));
    jobConfig.addJar(this.getClass().getResource("/sample-pojo-1.0-deployment.jar"));
    jobConfig.addClass(AbstractDeploymentTest.class);

    executeAndPeel(jetInstance.newJob(dag, jobConfig));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:17,代碼來源:AbstractDeploymentTest.java

示例4: setUp

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Before
public void setUp() {
    JetConfig config = new JetConfig();

    EventJournalConfig journalConfig = new EventJournalConfig()
            .setMapName("*")
            .setCapacity(JOURNAL_CAPACITY)
            .setEnabled(true);

    config.getHazelcastConfig().setProperty(PARTITION_COUNT.getName(), String.valueOf(NUM_PARTITIONS));
    config.getHazelcastConfig().addEventJournalConfig(journalConfig);
    JetInstance instance = this.createJetMember(config);

    map = (MapProxyImpl<Integer, Integer>) instance.getHazelcastInstance().<Integer, Integer>getMap("test");
    List<Integer> allPartitions = IntStream.range(0, NUM_PARTITIONS).boxed().collect(toList());

    supplier = () -> new StreamEventJournalP<>(map, allPartitions, e -> true,
            EventJournalMapEvent::getNewValue, START_FROM_OLDEST, false,
            wmGenParams(Integer::intValue, withFixedLag(0), suppressAll(), -1));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:21,代碼來源:StreamEventJournalPTest.java

示例5: when_writeBufferedJobFailed_then_bufferDisposed

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void when_writeBufferedJobFailed_then_bufferDisposed() throws Exception {
    JetInstance instance = createJetMember();
    try {
        DAG dag = new DAG();
        Vertex source = dag.newVertex("source", StuckForeverSourceP::new);
        Vertex sink = dag.newVertex("sink", getLoggingBufferedWriter()).localParallelism(1);

        dag.edge(Edge.between(source, sink));

        Job job = instance.newJob(dag);
        // wait for the job to initialize
        Thread.sleep(5000);
        job.cancel();

        assertTrueEventually(() -> assertTrue("No \"dispose\", only: " + events, events.contains("dispose")), 60);
        System.out.println(events);
    } finally {
        instance.shutdown();
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:22,代碼來源:WriteBufferedPTest.java

示例6: test_serializationFromNodeToClient

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void test_serializationFromNodeToClient() {
    // create one member and one client
    createJetMember();
    JetInstance client = createJetClient();

    RuntimeException exc = new RuntimeException("myException");
    try {
        DAG dag = new DAG();
        dag.newVertex("source", () -> new ProcessorThatFailsInComplete(exc)).localParallelism(1);
        client.newJob(dag).join();
    } catch (Exception caught) {
        assertThat(caught.toString(), containsString(exc.toString()));
        TestUtil.assertExceptionInCauses(exc, caught);
    } finally {
        shutdownFactory();
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:19,代碼來源:ExceptionUtilTest.java

示例7: test_serializationOnNode

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void test_serializationOnNode() {
    JetTestInstanceFactory factory = new JetTestInstanceFactory();
    // create one member and one client
    JetInstance client = factory.newMember();

    RuntimeException exc = new RuntimeException("myException");
    try {
        DAG dag = new DAG();
        dag.newVertex("source", () -> new ProcessorThatFailsInComplete(exc)).localParallelism(1);
        client.newJob(dag).join();
    } catch (Exception caught) {
        assertThat(caught.toString(), containsString(exc.toString()));
        TestUtil.assertExceptionInCauses(exc, caught);
    } finally {
        factory.terminateAll();
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:19,代碼來源:ExceptionUtilTest.java

示例8: testJobSubmissionTimeWhenJobIsRunning

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
private void testJobSubmissionTimeWhenJobIsRunning(JetInstance instance) throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    JobConfig config = new JobConfig();
    String jobName = "job1";
    config.setName(jobName);

    // When
    Job job = instance1.newJob(dag, config);
    StuckProcessor.executionStarted.await();
    Job trackedJob = instance.getJob("job1");

    // Then
    assertNotNull(trackedJob);
    assertNotEquals(0, job.getSubmissionTime());
    assertNotEquals(0, trackedJob.getSubmissionTime());
    StuckProcessor.proceedLatch.countDown();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:19,代碼來源:JobTest.java

示例9: setup

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Before
public void setup() {
    factory = new JetTestInstanceFactory();

    JetConfig config = new JetConfig();
    config.getInstanceConfig().setCooperativeThreadCount(LOCAL_PARALLELISM);

    // force snapshots to fail by adding a failing map store configuration for snapshot data maps
    MapConfig mapConfig = new MapConfig(SnapshotRepository.SNAPSHOT_DATA_NAME_PREFIX + '*');
    MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new FailingMapStore());
    config.getHazelcastConfig().addMapConfig(mapConfig);

    JetInstance[] instances = factory.newMembers(config, 2);
    instance1 = instances[0];
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:18,代碼來源:SnapshotFailureTest.java

示例10: when_jobCancelledOnSingleNode_then_terminatedEventually

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void when_jobCancelledOnSingleNode_then_terminatedEventually() {
    // Given
    JetInstance instance = newInstance();

    DAG dag = new DAG();
    dag.newVertex("slow", StuckSource::new);

    Job job = instance.newJob(dag);
    assertExecutionStarted();

    // When
    job.cancel();

    // Then
    assertExecutionTerminated();
    expectedException.expect(CancellationException.class);
    job.join();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:20,代碼來源:CancellationTest.java

示例11: when_jobCancelledOnMultipleNodes_then_terminatedEventually

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void when_jobCancelledOnMultipleNodes_then_terminatedEventually() {
    // Given
    newInstance();
    JetInstance instance = newInstance();

    DAG dag = new DAG();
    dag.newVertex("slow", StuckSource::new);

    Job job = instance.newJob(dag);
    assertExecutionStarted();

    // When
    job.cancel();

    // Then
    assertExecutionTerminated();
    expectedException.expect(CancellationException.class);
    job.join();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:21,代碼來源:CancellationTest.java

示例12: when_jobCancelled_then_jobStatusIsSetEventually

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void when_jobCancelled_then_jobStatusIsSetEventually() {
    // Given
    JetInstance instance = newInstance();

    DAG dag = new DAG();
    dag.newVertex("slow", StuckSource::new);

    Job job = instance.newJob(dag);
    assertExecutionStarted();

    // When
    job.cancel();

    // Then
    assertTrueEventually(() -> assertEquals(JobStatus.COMPLETED, job.getStatus()), 3);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:18,代碼來源:CancellationTest.java

示例13: when_jobCancelledFromClient_then_terminatedEventually

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void when_jobCancelledFromClient_then_terminatedEventually() {
    // Given
    newInstance();
    newInstance();
    JetInstance client = factory.newClient();

    DAG dag = new DAG();
    dag.newVertex("slow", StuckSource::new);

    Job job = client.newJob(dag);
    assertExecutionStarted();

    // When
    job.cancel();

    // Then
    assertExecutionTerminated();
    expectedException.expect(CancellationException.class);
    job.join();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:22,代碼來源:CancellationTest.java

示例14: when_jobCancelledFromClient_then_jobStatusIsSetEventually

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void when_jobCancelledFromClient_then_jobStatusIsSetEventually() {
    // Given
    newInstance();
    newInstance();
    JetInstance client = factory.newClient();

    DAG dag = new DAG();
    dag.newVertex("slow", StuckSource::new);

    Job job = client.newJob(dag);
    assertExecutionStarted();

    // When
    job.cancel();

    // Then
    assertTrueEventually(() -> assertEquals(JobStatus.COMPLETED, job.getStatus()), 3);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:20,代碼來源:CancellationTest.java

示例15: when_jobCancelled_then_trackedJobsGetNotified

import com.hazelcast.jet.JetInstance; //導入依賴的package包/類
@Test
public void when_jobCancelled_then_trackedJobsGetNotified() {
    // Given
    JetInstance instance1 = newInstance();
    JetInstance instance2 = newInstance();

    DAG dag = new DAG();
    dag.newVertex("slow", StuckSource::new);

    Job job = instance1.newJob(dag);
    assertExecutionStarted();

    // When
    job.cancel();

    // Then
    assertExecutionTerminated();
    expectedException.expect(CancellationException.class);
    Job tracked = instance2.getJobs().iterator().next();
    tracked.join();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:22,代碼來源:CancellationTest.java


注:本文中的com.hazelcast.jet.JetInstance類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。