com.hazelcast.jet.Jet Java Examples
The following examples show how to use
com.hazelcast.jet.Jet.
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 |
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: TradeAnalysis.java From hazelcast-jet-training with Apache License 2.0 | 6 votes |
public static void main(String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { JobConfig jobConfig = new JobConfig() .setAutoScaling(true) .setName("TradeAnalysis") .setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE); jet.newJob(p, jobConfig).join(); } finally { Jet.shutdownAll(); } }
Example #3
Source File: Lab4.java From hazelcast-jet-training with Apache License 2.0 | 6 votes |
public static void main(String[] args) { JetInstance jet = Jet.bootstrappedInstance(); // symbol -> company name // random symbols from https://www.nasdaq.com IMap<String, String> lookupTable = jet.getMap(LOOKUP_TABLE); lookupTable.put("AAPL", "Apple Inc. - Common Stock"); lookupTable.put("GOOGL", "Alphabet Inc."); lookupTable.put("MSFT", "Microsoft Corporation"); Pipeline p = buildPipeline(lookupTable); try { jet.newJob(p).join(); } finally { jet.shutdown(); } }
Example #4
Source File: InProcessClassification.java From hazelcast-jet-demos with Apache License 2.0 | 6 votes |
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 #5
Source File: ModelServerClassification.java From hazelcast-jet-demos with Apache License 2.0 | 6 votes |
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 #6
Source File: Solution4.java From hazelcast-jet-training with Apache License 2.0 | 6 votes |
public static void main (String[] args) { JetInstance jet = Jet.bootstrappedInstance(); // symbol -> company name IMap<String, String> lookupTable = jet.getMap(LOOKUP_TABLE); lookupTable.put("AAPL", "Apple Inc. - Common Stock"); lookupTable.put("GOOGL", "Alphabet Inc."); lookupTable.put("MSFT", "Microsoft Corporation"); Pipeline p = buildPipeline(lookupTable); try { jet.newJob(p).join(); } finally { jet.shutdown(); } }
Example #7
Source File: TestJetMain.java From hazelcast-jet-demos with Apache License 2.0 | 6 votes |
@Test public void testBuildDAG() { User u = makeUser(); Bet b = makeBet(); u.addBet(b); assertNotNull(b); try { IMap<String, ?> ism = jet.getMap(WORST_ID); System.out.println(ism); System.out.println("Size: " + ism.size()); for (String s : ism.keySet()) { System.out.println(s + " : " + ism.get(s)); } } finally { Jet.shutdownAll(); } }
Example #8
Source File: RealTimeImageRecognition.java From hazelcast-jet-demos with Apache License 2.0 | 6 votes |
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 #9
Source File: TrafficPredictor.java From hazelcast-jet-demos with Apache License 2.0 | 6 votes |
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 #10
Source File: FlightTelemetry.java From hazelcast-jet-demos with Apache License 2.0 | 6 votes |
public static void main(String[] args) { if (FlightDataSource.API_AUTHENTICATION_KEY.equals("YOUR_API_KEY_HERE")) { System.err.println("API_AUTHENTICATION_KEY not set in FlightDataSource.java"); System.exit(1); } JetInstance jet = getJetInstance(); Pipeline pipeline = buildPipeline(); addListener(jet.getMap(TAKE_OFF_MAP), a -> System.out.println("New aircraft taking off: " + a)); addListener(jet.getMap(LANDING_MAP), a -> System.out.println("New aircraft landing " + a)); try { Job job = jet.newJob(pipeline, new JobConfig().setName("FlightTelemetry").setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE)); job.join(); } finally { Jet.shutdownAll(); } }
Example #11
Source File: HazelcastJetServerConfiguration.java From hazelcast-jet-contrib with Apache License 2.0 | 6 votes |
@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 #12
Source File: WordCounter.java From tutorials with MIT License | 6 votes |
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 #13
Source File: Lab1.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main (String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { jet.newJob(p).join(); } finally { jet.shutdown(); } }
Example #14
Source File: Lab3.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main (String[] args) { JetInstance jet = Jet.bootstrappedInstance(); // Subscribe for map events jet.getMap(LATEST_TRADES_PER_SYMBOL).addEntryListener(new TradeListener(), true); Pipeline p = buildPipeline(); try { jet.newJob(p).join(); } finally { jet.shutdown(); } }
Example #15
Source File: Solution6.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main(String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { Job job = jet.newJob(p); job.join(); } finally { jet.shutdown(); } }
Example #16
Source File: BreastCancerClassification.java From hazelcast-jet-demos with Apache License 2.0 | 5 votes |
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 #17
Source File: Solution5.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main(String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { Job job = jet.newJob(p); job.join(); } finally { jet.shutdown(); } }
Example #18
Source File: Solution2.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main(String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { jet.newJob(p).join(); } finally { jet.shutdown(); } }
Example #19
Source File: Solution3.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main (String[] args) { JetInstance jet = Jet.bootstrappedInstance(); jet.getMap(LATEST_TRADES_PER_SYMBOL).addEntryListener(new TradeListener(), true); Pipeline p = buildPipeline(); try { jet.newJob(p).join(); } finally { jet.shutdown(); } }
Example #20
Source File: Lab2.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main (String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { jet.newJob(p).join(); } finally { jet.shutdown(); } }
Example #21
Source File: JetRunner.java From beam with Apache License 2.0 | 5 votes |
private void startClusterIfNeeded(JetPipelineOptions options) { Integer noOfLocalMembers = options.getJetLocalMode(); if (noOfLocalMembers > 0) { Collection<JetInstance> jetInstances = new ArrayList<>(); for (int i = 0; i < noOfLocalMembers; i++) { jetInstances.add(Jet.newJetInstance()); } LOG.info("Started " + jetInstances.size() + " Jet cluster members"); } }
Example #22
Source File: JetRunner.java From beam with Apache License 2.0 | 5 votes |
private void stopClusterIfNeeded(JetPipelineOptions options) { Integer noOfLocalMembers = options.getJetLocalMode(); if (noOfLocalMembers > 0) { Jet.shutdownAll(); LOG.info("Stopped all Jet cluster members"); } }
Example #23
Source File: Lab5.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main (String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { Job job = jet.newJob(p); job.join(); } finally { jet.shutdown(); } }
Example #24
Source File: Lab6.java From hazelcast-jet-training with Apache License 2.0 | 5 votes |
public static void main(String[] args) { Pipeline p = buildPipeline(); JetInstance jet = Jet.bootstrappedInstance(); try { Job job = jet.newJob(p); job.join(); } finally { jet.shutdown(); } }
Example #25
Source File: HazelcastJetClientConfiguration.java From hazelcast-jet-contrib with Apache License 2.0 | 5 votes |
@Bean JetInstance jetInstance(HazelcastJetClientProperty properties) throws IOException { Resource configLocation = properties.resolveConfigLocation(); if (configLocation == null) { return Jet.newJetClient(); } return Jet.newJetClient(getClientConfig(configLocation)); }
Example #26
Source File: CryptocurrencySentimentAnalysis.java From hazelcast-jet-demos with Apache License 2.0 | 5 votes |
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 #27
Source File: TestJetMain.java From hazelcast-jet-demos with Apache License 2.0 | 5 votes |
@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 #28
Source File: AnalysisJet.java From hazelcast-jet-demos with Apache License 2.0 | 5 votes |
/** * 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 #29
Source File: MarkovChainGenerator.java From hazelcast-jet-demos with Apache License 2.0 | 5 votes |
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 #30
Source File: FlightTelemetry.java From hazelcast-jet-demos with Apache License 2.0 | 5 votes |
private static JetInstance getJetInstance() { String bootstrap = System.getProperty("bootstrap"); if (bootstrap != null && bootstrap.equals("true")) { return JetBootstrap.getInstance(); } return Jet.newJetInstance(); }