当前位置: 首页>>代码示例>>Java>>正文


Java ILocalCluster类代码示例

本文整理汇总了Java中backtype.storm.ILocalCluster的典型用法代码示例。如果您正苦于以下问题:Java ILocalCluster类的具体用法?Java ILocalCluster怎么用?Java ILocalCluster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ILocalCluster类属于backtype.storm包,在下文中一共展示了ILocalCluster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSubmitLocal

import backtype.storm.ILocalCluster; //导入依赖的package包/类
@Test
public void testSubmitLocal(
    @Injectable String topologyName,
    @Injectable Config stormConfig,
    @Injectable TopologyBuilder builder,
    @Injectable ILocalCluster cluster,
    @Injectable StormTopology stormTopology
) throws Exception {
  topology.topologyName = topologyName;
  topology.stormConfig = stormConfig;
  topology.builder = builder;

  new Expectations() {{
    builder.createTopology();
    result = stormTopology;
    cluster.submitTopology(topologyName, stormConfig, stormTopology);
  }};

  topology.submitLocal(cluster);
}
 
开发者ID:boozallen,项目名称:cognition,代码行数:21,代码来源:ConfigurableIngestTopologyTest.java

示例2: verifyProperValuesAreEmittedByEachBolt

import backtype.storm.ILocalCluster; //导入依赖的package包/类
@Test
public void verifyProperValuesAreEmittedByEachBolt() {
  MkClusterParam clusterParam = new MkClusterParam();
  clusterParam.setSupervisors(1);

  withSimulatedTimeLocalCluster(clusterParam, new TestJob() {
    @Override
    public void run(ILocalCluster cluster) {
      MockedSources mockedSources = new MockedSources();
      mockedSources.addMockData(CHECKINS_ID, new Values(1382904793783L, "287 Hudson St New York NY 10013"));

      Config config = new Config();
      config.setDebug(true);

      CompleteTopologyParam topologyParam = new CompleteTopologyParam();
      topologyParam.setMockedSources(mockedSources);
      topologyParam.setStormConf(config);

      LatLng latLng = new LatLng("40.725612", "-74.00791599999999");

      ArrayList<LatLng> latLngList = new ArrayList<LatLng>();
      latLngList.add(latLng);

      Map result = completeTopology(cluster, StormTopologyBuilder.build(), topologyParam);
      assertTrue(multiseteq(new Values(new Values(1382904793783L, "287 Hudson St New York NY 10013")), readTuples(result, CHECKINS_ID)));
      assertTrue(multiseteq(new Values(new Values(1382904793783L, latLng)), readTuples(result, GEOCODE_LOOKUP_ID)));
      assertTrue(multiseteq(new Values(new Values(92193652L, latLngList)), readTuples(result, HEATMAP_BUILDER_ID)));
      assertTrue(multiseteq(new Values(), readTuples(result, PERSISTOR_ID)));
    }
  });
}
 
开发者ID:Storm-Applied,项目名称:C3-Heatmap,代码行数:32,代码来源:TopologyTest.java

示例3: verifySpoutTuplesAreFullyAcked

import backtype.storm.ILocalCluster; //导入依赖的package包/类
@Test
public void verifySpoutTuplesAreFullyAcked() {
  withTrackedCluster(new TestJob() {
    @Override
    public void run(ILocalCluster cluster) throws Exception {
      AckTracker ackTracker = new AckTracker();

      FeederSpout feederSpout = new FeederSpout(new Fields("time", "address"));
      feederSpout.setAckFailDelegate(ackTracker);

      TrackedTopology trackedTopology = mkTrackedTopology(cluster, StormTopologyBuilder.buildWithSpout(FEEDER_SPOUT_ID, feederSpout));
      cluster.submitTopology("test-acking", new Config(), trackedTopology.getTopology());

      feederSpout.feed(new Values(1382904793783L, "287 Hudson St New York NY 10013"));
      feederSpout.feed(new Values(1382904793783L, "287 Hudson St New York NY 10013"));
      feederSpout.feed(new Values(1382904793783L, "287 Hudson St New York NY 10013"));
      feederSpout.feed(new Values(1382904793783L, "287 Hudson St New York NY 10013"));
      trackedWait(trackedTopology, 4);

      assertEquals(4, ackTracker.getNumAcks());
      ackTracker.resetNumAcks();

      feederSpout.feed(new Values(1382904793783L, "287 Hudson St New York NY 10013"));
      trackedWait(trackedTopology, 1);
      assertEquals(1, ackTracker.getNumAcks());
      ackTracker.resetNumAcks();
    }
  });
}
 
开发者ID:Storm-Applied,项目名称:C3-Heatmap,代码行数:30,代码来源:TopologyTest.java

示例4: run

import backtype.storm.ILocalCluster; //导入依赖的package包/类
@Override
public void run(ILocalCluster cluster) throws Exception {
    Map<String, TopologyTestInfo> topologies = new HashMap<String, TopologyTestInfo>();
    // to testing topologies - must fail
    StormUtils.forTesting(cluster, topologies);
    clear();
    
    // try starting unknown
    
    PipelineOptions opt = new PipelineOptions();
    opt.setNumberOfWorkers(3);
    PipelineCommand cmd = new PipelineCommand("abba", PipelineCommand.Status.START, opt);
    cmd.execute();
    fakeCheckedPipeline("abba");
    waitForExecution(1, 0, 500); // pipeline status tracker <-> monitoring
    Assert.assertEquals(1, getFailedHandler().getFailedCount());
    clear();

    cmd = new PipelineCommand(null, PipelineCommand.Status.START, opt);
    cmd.execute();
    waitForExecution(0, 1);
    Assert.assertEquals(1, getFailedHandler().getFailedCount());
    clear();

    // TODO try connect / disconnect not started pipeline
    
    // try unknown command

    cmd = new PipelineCommand("abba", null);
    cmd.execute();
    waitForExecution(0, 1);
    Assert.assertTrue(getTracer().contains(cmd));
    Assert.assertEquals(1, getTracer().getLogEntryCount());
    Assert.assertEquals(1, getFailedHandler().getFailedCount());
    clear();
    
    cmd = new PipelineCommand("abba", PipelineCommand.Status.STOP);
    cmd.execute();
    waitForExecution(0, 1);
    Assert.assertTrue(getTracer().contains(cmd));
    Assert.assertEquals(1, getTracer().getLogEntryCount());
    Assert.assertEquals(1, getFailedHandler().getFailedCount());
    clear();

    cmd = new PipelineCommand(null, PipelineCommand.Status.STOP);
    cmd.execute();
    waitForExecution(0, 1);
    Assert.assertTrue(getTracer().contains(cmd));
    Assert.assertEquals(1, getTracer().getLogEntryCount());
    Assert.assertEquals(1, getFailedHandler().getFailedCount());
    clear();

    StormUtils.forTesting(null, null);
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:55,代码来源:StormTests.java

示例5: testBasicTopology

import backtype.storm.ILocalCluster; //导入依赖的package包/类
@Test
public void testBasicTopology() {
	PythonRepository.getInstance();
	MkClusterParam mkClusterParam = new MkClusterParam();
	Config daemonConf = new Config();
	daemonConf.put(Config.STORM_LOCAL_MODE_ZMQ, false);
	mkClusterParam.setDaemonConf(daemonConf);

	try {
		Testing.withSimulatedTimeLocalCluster(mkClusterParam,
				new TestJob() {

					@SuppressWarnings({ "rawtypes", "unchecked" })
					@Override
					public void run(ILocalCluster cluster) throws Exception {
						// TODO Auto-generated method stub
						TopologyBuilder builder = new TopologyBuilder(); 
						builder.setSpout("karma-json-spout", new BasicJSONTestSpout());
						Properties basicKarmaBoltProperties = new Properties();
						basicKarmaBoltProperties.setProperty("name", "Stormy");
						basicKarmaBoltProperties.setProperty("karma.input.type", "JSON");
						basicKarmaBoltProperties.setProperty("base.uri", "http://ex.com");
						String source = null; 
						try {
							source = new File(this.getClass().getClassLoader().getResource("people-model.ttl").toURI()).getAbsolutePath().toString();
							basicKarmaBoltProperties.setProperty("model.file", source);
						} catch (URISyntaxException e) {
							LOG.error("Unable to load model", e);
						}
						
						builder.setBolt("karma-generate-json", new KarmaBolt(basicKarmaBoltProperties, null)).shuffleGrouping("karma-json-spout");

						Set<String> sources = new HashSet<String>();
						sources.add(source);
						KarmaReducerBolt reducerBolt = new KarmaReducerBolt(sources);
						builder.setBolt("karma-reducer-json", reducerBolt).fieldsGrouping("karma-generate-json", new Fields("id"));
						
						String inputs = IOUtils.toString(getTestResource("input/people.json"));
						JSONArray array = new JSONArray(inputs);
						List<Values> values = new LinkedList<Values>();
						for(int i = 0; i < array.length(); i++)
						{
							JSONObject obj = array.getJSONObject(i);
							values.add(new Values("a.txt",obj.toString()));
						}
						
						 MockedSources mockedSources = new MockedSources();
		                 mockedSources.addMockData("karma-json-spout", values.toArray(new Values[values.size()]));
		                    
						Config config = new Config();
						config.setDebug(true);
						
						StormTopology topology = builder.createTopology(); 
						CompleteTopologyParam completeTopologyParam = new CompleteTopologyParam();
	                    completeTopologyParam.setMockedSources(mockedSources);
	                    completeTopologyParam.setStormConf(config);
	                    Map results = Testing.completeTopology(cluster, topology, completeTopologyParam);
						ArrayList<String> karmaJsonSpoutResults = ( ArrayList<String>)results.get("karma-json-spout");
	                    Assert.assertEquals(7, karmaJsonSpoutResults.size() );
						ArrayList<String> karmaJsonReducerResults = ( ArrayList<String>)results.get("karma-reducer-json");
	                    Assert.assertEquals(7, karmaJsonReducerResults.size() );
						ArrayList<String> karmaBoltResults = ( ArrayList<String>)results.get("karma-generate-json");
	                    Assert.assertEquals(7, karmaBoltResults.size() );
					}
				});

	} catch (Exception ex) {
		if ((ex instanceof IOException) == false) {
			throw ex;
		}
	}

}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:74,代码来源:TestBasicKarmaTopology.java

示例6: getLocalCluster

import backtype.storm.ILocalCluster; //导入依赖的package包/类
private static ILocalCluster getLocalCluster() {
	return localCluster;
}
 
开发者ID:IntersysConsulting,项目名称:ingestive,代码行数:4,代码来源:IngestionTopology.java

示例7: setLocalCluster

import backtype.storm.ILocalCluster; //导入依赖的package包/类
public static void setLocalCluster(ILocalCluster cluster) {
	localCluster = cluster;
}
 
开发者ID:IntersysConsulting,项目名称:ingestive,代码行数:4,代码来源:IngestionTopology.java

示例8: run

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
 * run the testing logic with the cluster.
 * 
 * @param cluster
 *            the cluster which created by
 *            <code>Testing.withSimulatedTimeLocalCluster</code> and
 *            <code>Testing.withTrackedCluster</code>.
 */
public void run(ILocalCluster cluster) throws Exception;
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:10,代码来源:TestJob.java

示例9: run

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
 * run the testing logic with the cluster.
 * 
 * @param cluster the cluster which created by <code>Testing.withSimulatedTimeLocalCluster</code> and <code>Testing.withTrackedCluster</code>.
 */
public void run(ILocalCluster cluster) throws Exception;
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:7,代码来源:TestJob.java

示例10: forTesting

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
 * Defines data for testing.
 * 
 * @param instance
 *            the local cluster instance (may be <b>null</b> to stop using
 *            the local cluster).
 * @param topologies
 *            the test topologies
 */
public static void forTesting(ILocalCluster instance, Map<String, TopologyTestInfo> topologies) {
    localCluster = instance;
    testTopologies = topologies;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:14,代码来源:StormUtils.java

示例11: getLocalCluster

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
 * Returns the local cluster in testing.
 * 
 * @return the local cluster, may be <b>null</b> but not if {@link #inTesting()} is <code>true</code>
 */
public static ILocalCluster getLocalCluster() {
    return localCluster;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:9,代码来源:StormUtils.java

示例12: LocalClusterAccess

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
 * Creates an instance.
 * 
 * @param cluster the cluster instance
 */
private LocalClusterAccess(ILocalCluster cluster) {
    this.cluster = cluster;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:9,代码来源:StormUtils.java

示例13: setLocalCluster

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
 * Sets the local cluster for testing. If a local cluster is set,
 * information requests are delegated to the local cluster.
 * 
 * @param cluster the cluster
 */
public static final void setLocalCluster(ILocalCluster cluster) {
    localCluster = cluster;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:10,代码来源:ThriftConnection.java

示例14: run

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
* run the testing logic with the cluster.
* 
* @param cluster the cluster which created by <code>Testing.withSimulatedTimeLocalCluster</code>
*        and <code>Testing.withTrackedCluster</code>.
*/
  public void run(ILocalCluster cluster) throws Exception;
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:8,代码来源:TestJob.java

示例15: run

import backtype.storm.ILocalCluster; //导入依赖的package包/类
/**
 * run the testing logic with the cluster.
 *
 * @param cluster the cluster which created by <code>Testing.withSimulatedTimeLocalCluster</code> and <code>Testing.withTrackedCluster</code>.
 */
void run(ILocalCluster cluster) throws Exception;
 
开发者ID:alibaba,项目名称:jstorm,代码行数:7,代码来源:TestJob.java


注:本文中的backtype.storm.ILocalCluster类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。