Java Code Examples for backtype.storm.LocalDRPC#shutdown()
The following examples show how to use
backtype.storm.LocalDRPC#shutdown() .
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: ManualDRPC.java From jstorm with Apache License 2.0 | 6 votes |
public static void testDrpc() { TopologyBuilder builder = new TopologyBuilder(); LocalDRPC drpc = new LocalDRPC(); DRPCSpout spout = new DRPCSpout("exclamation", drpc); builder.setSpout("drpc", spout); builder.setBolt("exclaim", new ExclamationBolt(), 3).shuffleGrouping("drpc"); builder.setBolt("return", new ReturnResults(), 3).shuffleGrouping("exclaim"); LocalCluster cluster = new LocalCluster(); Config conf = new Config(); cluster.submitTopology("exclaim", conf, builder.createTopology()); JStormUtils.sleepMs(30 * 1000); try { System.out.println(drpc.execute("exclamation", "aaa")); System.out.println(drpc.execute("exclamation", "bbb")); } catch (Exception e) { Assert.fail("Failed to test drpc"); } drpc.shutdown(); cluster.shutdown(); }
Example 2
Source File: WordCountTopology.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { final Config configuration = new Config(); configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_CQL_HOSTS, "localhost"); final LocalCluster cluster = new LocalCluster(); LocalDRPC client = new LocalDRPC(); LOG.info("Submitting topology."); cluster.submitTopology("cqlexample", configuration, buildWordCountAndSourceTopology(client)); LOG.info("Topology submitted."); Thread.sleep(10000); LOG.info("DRPC Query: Word Count [cat, dog, the, man]: {}", client.execute("words", "cat dog the man")); cluster.shutdown(); client.shutdown(); }
Example 3
Source File: ReachTopology.java From jstorm with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { LinearDRPCTopologyBuilder builder = construct(); Config conf = new Config(); conf.setNumWorkers(6); if (args.length != 0) { try { Map yamlConf = LoadConf.LoadYaml(args[0]); if (yamlConf != null) { conf.putAll(yamlConf); } } catch (Exception e) { System.out.println("Input " + args[0] + " isn't one yaml "); } StormSubmitter.submitTopology(TOPOLOGY_NAME, conf, builder.createRemoteTopology()); } else { conf.setMaxTaskParallelism(3); LocalDRPC drpc = new LocalDRPC(); LocalCluster cluster = new LocalCluster(); cluster.submitTopology(TOPOLOGY_NAME, conf, builder.createLocalTopology(drpc)); JStormUtils.sleepMs(10000); String[] urlsToTry = new String[] { "foo.com/blog/1", "engineering.twitter.com/blog/5", "notaurl.com" }; for (String url : urlsToTry) { System.out.println("Reach of " + url + ": " + drpc.execute(TOPOLOGY_NAME, url)); } cluster.shutdown(); drpc.shutdown(); } }
Example 4
Source File: E8_DRPCTopology.java From StormCV with Apache License 2.0 | 4 votes |
public static void main(String[] args){ // first some global (topology configuration) StormCVConfig conf = new StormCVConfig(); conf.put(StormCVConfig.STORMCV_OPENCV_LIB, "mac64_opencv_java248.dylib"); conf.setNumWorkers(5); // number of workers in the topology conf.put(StormCVConfig.STORMCV_FRAME_ENCODING, Frame.JPG_IMAGE); // indicates frames will be encoded as JPG throughout the topology (JPG is the default when not explicitly set) conf.put(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, true); // True if Storm should timeout messages or not. conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS , 10); // The maximum amount of time given to the topology to fully process a message emitted by a spout (default = 30) conf.put(StormCVConfig.STORMCV_SPOUT_FAULTTOLERANT, false); // indicates if the spout must be fault tolerant; i.e. spouts do NOT! replay tuples on fail conf.put(StormCVConfig.STORMCV_CACHES_TIMEOUT_SEC, 30); // TTL (seconds) for all elements in all caches throughout the topology (avoids memory overload) conf.put(Config.NIMBUS_TASK_LAUNCH_SECS, 30); String userDir = System.getProperty("user.dir").replaceAll("\\\\", "/"); List<String> prototypes = new ArrayList<String>(); prototypes.add( "file://"+ userDir +"/resources/data" ); // create a linear DRPC builder called 'match' LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("match"); //add a FeatureMatchRequestOp that receives drpc requests builder.addBolt(new RequestBolt(new FeatureMatchRequestOp()), 1); // add two bolts that perform sift extraction (as used in other examples!) builder.addBolt(new SingleInputBolt( new FeatureExtractionOp("sift", FeatureDetector.SIFT, DescriptorExtractor.SIFT).outputFrame(false) ), 1).shuffleGrouping(); // add bolt that matches queries it gets with the prototypes it has loaded upon the prepare. // The prototypes are divided over the available tasks which means that each query has to be send to all tasks (use allGrouping) // the matcher only reports a match if at least 1 strong match has been found (can be set to 0) builder.addBolt(new SingleInputBolt(new PartialMatcher(prototypes, 0, 0.5f)), 2).allGrouping(); // add a bolt that aggregates all the results it gets from the two matchers builder.addBolt(new BatchBolt(new FeatureMatchResultOp(true)), 1).fieldsGrouping(new Fields(CVParticleSerializer.REQUESTID)); // create local drpc server and cluster. Deploy the drpc topology on the cluster LocalDRPC drpc = new LocalDRPC(); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("drpc-demo", conf, builder.createLocalTopology(drpc)); // use all face images as queries (same images as loaded by the matcher!) File queryDir = new File(userDir +"/resources/data/"); for(String img : queryDir.list()){ if(!img.endsWith(".jpg")) continue; // to avoid reading non-image files // execute the drpc with the image as argument. Note that the execute blocks String matchesJson = drpc.execute("match", "file://"+userDir +"/resources/data/"+img); System.out.println(img+" : " + matchesJson); } cluster.shutdown(); drpc.shutdown(); }
Example 5
Source File: TridentReach.java From flink-perf with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { LocalDRPC drpc = new LocalDRPC(); Config conf = new Config(); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("reach", conf, buildTopology(drpc)); Thread.sleep(2000); System.out.println("REACH: " + drpc.execute("reach", "aaa")); System.out.println("REACH: " + drpc.execute("reach", "foo.com/blog/1")); System.out.println("REACH: " + drpc.execute("reach", "engineering.twitter.com/blog/5")); cluster.shutdown(); drpc.shutdown(); }