Java Code Examples for com.hazelcast.jet.Jet#newJetInstance()

The following examples show how to use com.hazelcast.jet.Jet#newJetInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JetBetMain.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
private void init() throws IOException, URISyntaxException {
    final JetConfig config = new JetConfig();
    jet = Jet.newJetInstance(config);
    pipeline = buildPipeline();

    // Initialize the domain object factories
    final HazelcastInstance client = jet.getHazelcastInstance();
    CentralFactory.setHorses(HazelcastHorseFactory.getInstance(client));
    CentralFactory.setRaces(new HazelcastFactory<>(client, Race.class));
    CentralFactory.setEvents(new HazelcastFactory<>(client, Event.class));
    CentralFactory.setUsers(new HazelcastFactory<>(client, User.class));
    CentralFactory.setBets(new HazelcastFactory<>(client, Bet.class));

    loadHistoricalRaces();
    createRandomUsers();
    createFutureEvent();
}
 
Example 2
Source File: WordCounter.java    From tutorials with MIT License 6 votes vote down vote up
public Long countWord(List<String> sentences, String word) {
    long count = 0;
    JetInstance jet = Jet.newJetInstance();
    try {
        List<String> textList = jet.getList(LIST_NAME);
        textList.addAll(sentences);
        Pipeline p = createPipeLine();
        jet.newJob(p)
            .join();
        Map<String, Long> counts = jet.getMap(MAP_NAME);
        count = counts.get(word);
    } finally {
        Jet.shutdownAll();
    }
    return count;
}
 
Example 3
Source File: InProcessClassification.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    System.setProperty("hazelcast.logging.type", "log4j");

    if (args.length != 1) {
        System.out.println("Usage: InProcessClassification <data path>");
        System.exit(1);
    }

    String dataPath = args[0];
    JetInstance instance = Jet.newJetInstance();
    JobConfig jobConfig = new JobConfig();
    jobConfig.attachDirectory(dataPath, "data");

    try {
        IMap<Long, String> reviewsMap = instance.getMap("reviewsMap");
        SampleReviews.populateReviewsMap(reviewsMap);
        instance.newJob(buildPipeline(reviewsMap), jobConfig).join();
    } finally {
        instance.shutdown();
    }
}
 
Example 4
Source File: ModelServerClassification.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    System.setProperty("hazelcast.logging.type", "log4j");

    if (args.length != 2) {
        System.out.println("Usage: ModelServerClassification <data path> <model server address>");
        System.exit(1);
    }
    String dataPath = args[0];
    String serverAddress = args[1];

    JobConfig jobConfig = new JobConfig();
    jobConfig.attachDirectory(dataPath, "data");

    JetInstance instance = Jet.newJetInstance();
    try {
        IMap<Long, String> reviewsMap = instance.getMap("reviewsMap");
        SampleReviews.populateReviewsMap(reviewsMap);

        Pipeline p = buildPipeline(serverAddress, reviewsMap);

        instance.newJob(p, jobConfig).join();
    } finally {
        instance.shutdown();
    }
}
 
Example 5
Source File: HazelcastJetServerConfiguration.java    From hazelcast-jet-contrib with Apache License 2.0 6 votes vote down vote up
@Bean
JetInstance jetInstance(HazelcastJetServerProperty serverProperty,
                        HazelcastJetIMDGProperty imdgProperty) throws IOException {
    Resource serverConfigLocation = serverProperty.resolveConfigLocation();
    Resource imdgConfigLocation = imdgProperty.resolveConfigLocation();

    JetConfig jetConfig = serverConfigLocation != null ? getJetConfig(serverConfigLocation)
            : ConfigProvider.locateAndGetJetConfig();
    if (imdgConfigLocation != null) {
        jetConfig.setHazelcastConfig(getIMDGConfig(imdgConfigLocation));
    }

    injectSpringManagedContext(jetConfig.getHazelcastConfig());

    return Jet.newJetInstance(jetConfig);
}
 
Example 6
Source File: RealTimeImageRecognition.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    validateWebcam();
    if (args.length != 1) {
        System.err.println("Missing command-line argument: <model path>");
        System.exit(1);
    }

    Path modelPath = Paths.get(args[0]).toAbsolutePath();
    if (!Files.isDirectory(modelPath)) {
        System.err.println("Model path does not exist (" + modelPath + ")");
        System.exit(1);
    }

    Pipeline pipeline = buildPipeline();

    JobConfig jobConfig = new JobConfig();
    jobConfig.attachDirectory(modelPath.toString(), "model");

    JetInstance jet = Jet.newJetInstance();
    try {
        jet.newJob(pipeline, jobConfig).join();
    } finally {
        Jet.shutdownAll();
    }
}
 
Example 7
Source File: TrafficPredictor.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    if (args.length != 2) {
        System.err.println("Missing command-line arguments: <input file> <output directory>");
        System.exit(1);
    }

    Path sourceFile = Paths.get(args[0]).toAbsolutePath();
    final String targetDirectory = args[1];
    if (!Files.isReadable(sourceFile)) {
        System.err.println("Source file does not exist or is not readable (" + sourceFile + ")");
        System.exit(1);
    }

    JetInstance instance = Jet.newJetInstance();
    Pipeline pipeline = buildPipeline(sourceFile, targetDirectory);
    try {
        instance.newJob(pipeline).join();
    } finally {
        Jet.shutdownAll();
    }
}
 
Example 8
Source File: MarkovChainGenerator.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    JetInstance jet = Jet.newJetInstance();
    Pipeline p = buildPipeline();

    System.out.println("Generating model...");
    try {
        jet.newJob(p).join();
        printTransitionsAndMarkovChain(jet);
    } finally {
        Jet.shutdownAll();
    }
}
 
Example 9
Source File: FlightTelemetry.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
private static JetInstance getJetInstance() {
    String bootstrap = System.getProperty("bootstrap");
    if (bootstrap != null && bootstrap.equals("true")) {
        return JetBootstrap.getInstance();
    }
    return Jet.newJetInstance();
}
 
Example 10
Source File: AnalysisJet.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
/**
 * Populate a map with data from disc
 */
public void setup() {
    jet = Jet.newJetInstance();

    final IMap<String, Event> name2Event = jet.getMap(EVENTS_BY_NAME);

    try (BufferedReader r = new BufferedReader(new InputStreamReader(AnalysisJet.class.getResourceAsStream(HISTORICAL), UTF_8))) {
        r.lines().map(l -> JSONSerializable.parse(l, Event::parseBag))
         .forEach(e -> name2Event.put(e.getName(), e));
    } catch (IOException iox) {
        iox.printStackTrace();
    }
}
 
Example 11
Source File: TestJetMain.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    jet = Jet.newJetInstance();
    client = jet.getHazelcastInstance();

    CentralFactory.setHorses(HazelcastHorseFactory.getInstance(client));
    CentralFactory.setRaces(new HazelcastFactory<>(client, Race.class));
    CentralFactory.setEvents(new HazelcastFactory<>(client, Event.class));
    CentralFactory.setUsers(new HazelcastFactory<>(client, User.class));
    CentralFactory.setBets(new HazelcastFactory<>(client, Bet.class));
}
 
Example 12
Source File: CryptocurrencySentimentAnalysis.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    System.out.println("DISCLAIMER: This is not investment advice");

    Pipeline pipeline = buildPipeline();
    // Start Jet
    JetInstance jet = Jet.newJetInstance();
    try {
        new CryptoSentimentGui(jet.getMap(MAP_NAME_JET_RESULTS));
        jet.newJob(pipeline).join();
    } finally {
        Jet.shutdownAll();
    }
}
 
Example 13
Source File: HazelcastJetAutoConfigurationClientTests.java    From hazelcast-jet-contrib with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() {
    JetConfig jetConfig = new JetConfig();
    jetConfig.configureHazelcast(hzConfig -> hzConfig
            .setClusterName("boot-starter")
            .getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false)
    );
    jetServer = Jet.newJetInstance(jetConfig);
}
 
Example 14
Source File: BreastCancerClassification.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (args.length != 2) {
        System.err.println("Missing command-line arguments: <model-file-path> <validation-input-data>");
        System.exit(1);
    }

    Path modelFile = Paths.get(args[0]).toAbsolutePath();
    Path inputFile = Paths.get(args[1]).toAbsolutePath();
    validateFileReadable(modelFile);
    validateFileReadable(inputFile);

    System.setProperty("hazelcast.logging.type", "log4j");

    JetInstance jet = Jet.newJetInstance();

    JobConfig jobConfig = new JobConfig();
    jobConfig.setName("h2o Breast Cancer Classification");
    jobConfig.attachFile(modelFile.toString(), "model");

    Job job = jet.newJob(buildPipeline(inputFile), jobConfig);

    try {
        job.join();
    } finally {
        jet.shutdown();
    }
}
 
Example 15
Source File: ApplicationConfig.java    From hazelcast-jet-demos with Apache License 2.0 4 votes vote down vote up
@Bean
public JetInstance jetInstance(Config config) {
    JetConfig jetConfig = new JetConfig().setHazelcastConfig(config);
    return Jet.newJetInstance(jetConfig);
}
 
Example 16
Source File: ApplicationConfig.java    From hazelcast-jet-demos with Apache License 2.0 4 votes vote down vote up
@Bean
public JetInstance jetInstance(Config config) {
    JetConfig jetConfig = new JetConfig().setHazelcastConfig(config);
    return Jet.newJetInstance(jetConfig);
}
 
Example 17
Source File: ApplicationConfig.java    From hazelcast-jet-demos with Apache License 2.0 4 votes vote down vote up
@Bean
public JetInstance jetInstance(Config config) {
    JetConfig jetConfig = new JetConfig().setHazelcastConfig(config);
    return Jet.newJetInstance(jetConfig);
}
 
Example 18
Source File: HazelcastJetServerConfiguration.java    From hazelcast-jet-contrib with Apache License 2.0 4 votes vote down vote up
@Bean
JetInstance jetInstance(JetConfig jetConfig) {
    return Jet.newJetInstance(jetConfig);
}