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


Java OutputCollector類代碼示例

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


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

示例1: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
public final void prepare(final Map map,
		final TopologyContext topologyContext,
		final OutputCollector collector) {
	this.collector = collector;
	// Bolt will read the AFINN Sentiment file [which is in the classpath]
	// and stores the key, value pairs to a Map.
	try {
		BufferedReader br = new BufferedReader(new FileReader(path));
		String line;
		while ((line = br.readLine()) != null) {
			String[] tabSplit = line.split("\t");
			afinnSentimentMap.put(tabSplit[0],
					Integer.parseInt(tabSplit[1]));
		}
		br.close();

	} catch (final IOException ioException) {
		LOGGER.error(ioException.getMessage(), ioException);
		ioException.printStackTrace();
		System.exit(1);
	}

}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Apache-Storm,代碼行數:24,代碼來源:SentimentBolt.java

示例2: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void prepare(Map conf, TopologyContext context,
        OutputCollector collector) {
    super.prepare(conf, context, collector);
    _collector = collector;

    indexName = ConfUtils.getString(conf, IndexerBolt.ESIndexNameParamName,
            "fetcher");
    docType = ConfUtils.getString(conf, IndexerBolt.ESDocTypeParamName,
            "doc");
    create = ConfUtils.getBoolean(conf, IndexerBolt.ESCreateParamName,
            false);

    try {
        connection = ElasticSearchConnection
                .getConnection(conf, ESBoltType);
    } catch (Exception e1) {
        LOG.error("Can't connect to ElasticSearch", e1);
        throw new RuntimeException(e1);
    }

    this.eventCounter = context.registerMetric("ElasticSearchIndexer",
            new MultiCountMetric(), 10);
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:26,代碼來源:IndexerBolt.java

示例3: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
    LOG.info("Preparing bolt with configuration {}", this);
    //for backward compatibility.
    if (mapper == null) {
        LOG.info("Mapper not specified. Setting default mapper to {}", FieldNameBasedTupleToKafkaMapper.class.getSimpleName());
        this.mapper = new FieldNameBasedTupleToKafkaMapper<K,V>();
    }

    //for backward compatibility.
    if (topicSelector == null) {
        if (stormConf.containsKey(TOPIC)) {
            LOG.info("TopicSelector not specified. Using [{}] for topic [{}] specified in bolt configuration,",
                    DefaultTopicSelector.class.getSimpleName(), stormConf.get(TOPIC));
            this.topicSelector = new DefaultTopicSelector((String) stormConf.get(TOPIC));
        } else {
            throw new IllegalStateException("topic should be specified in bolt's configuration");
        }
    }

    producer = mkProducer(boltSpecifiedProperties);
    this.collector = collector;
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:24,代碼來源:KafkaBolt.java

示例4: invalidJsonForDiscoveryFilter

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Test
public void invalidJsonForDiscoveryFilter() throws CmdLineException, ConfigurationException {
    OFEventWFMTopology manager = new OFEventWFMTopology(makeLaunchEnvironment());
    TopologyConfig config = manager.getConfig();
    OFELinkBolt bolt = new OFELinkBolt(config);

    TopologyContext context = Mockito.mock(TopologyContext.class);

    Mockito.when(context.getComponentId(TASK_ID_BOLT))
            .thenReturn(COMPONENT_ID_SOURCE);
    Mockito.when(context.getComponentOutputFields(COMPONENT_ID_SOURCE, STREAM_ID_INPUT))
            .thenReturn(KafkaMessage.FORMAT);

    OutputCollectorMock outputDelegate = Mockito.spy(new OutputCollectorMock());
    OutputCollector output = new OutputCollector(outputDelegate);

    bolt.prepare(stormConfig(), context, output);
    bolt.initState(new InMemoryKeyValueState<>());

    Tuple tuple = new TupleImpl(context, new Values("{\"corrupted-json"), TASK_ID_BOLT, STREAM_ID_INPUT);
    bolt.doWork(tuple);

    Mockito.verify(outputDelegate).ack(tuple);
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:25,代碼來源:OFELinkBoltTest.java

示例5: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
    this.collector = collector;
    this.context = context;

    if (!initialized) {
        this.topologyId = (String) conf.get(StormConfigKey.TOPOLOGY_ID);
        this.datasource = (String) conf.get(StormConfigKey.DATASOURCE);
        this.zkConnect = (String) conf.get(StormConfigKey.ZKCONNECT);
        this.zkRoot = Utils.buildZKTopologyPath(topologyId);
        // 初始化配置文件
        try {
            PropertiesHolder.initialize(zkConnect, zkRoot);
            GlobalCache.initialize(datasource);
            handlerManager = new BoltHandlerManager(buildProvider());
            reloadBolt(null);
            logger.info(getClass().getName() + " Initialized!");
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new InitializationException(e);
        }
        initialized = true;
    }
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:25,代碼來源:DbusAppenderBolt.java

示例6: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
    this.collector = collector;
    this.context = context;

    if (!initialized) {
        this.topologyId = (String) conf.get(StormConfigKey.TOPOLOGY_ID);
        this.datasource = (String) conf.get(StormConfigKey.DATASOURCE);
        this.zkConnect = (String) conf.get(StormConfigKey.ZKCONNECT);
        this.zkRoot = Utils.buildZKTopologyPath(topologyId);
        // 初始化配置文件
        try {
            PropertiesHolder.initialize(zkConnect, zkRoot);
            GlobalCache.initialize(datasource);
            handlerManager = new BoltHandlerManager(buildProvider());

            reloadBolt(null);
            logger.info(getClass().getName() + " Initialized!");
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new InitializationException(e);
        }
        initialized = true;
    }
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:26,代碼來源:DispatcherBolt.java

示例7: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
    this.collector = collector;
    this.context = context;

    if (!initialized) {
        this.topologyId = (String) conf.get(Constants.StormConfigKey.TOPOLOGY_ID);
        this.datasource = (String) conf.get(Constants.StormConfigKey.DATASOURCE);
        this.zkconnect = (String) conf.get(Constants.StormConfigKey.ZKCONNECT);
        this.zkRoot = Utils.buildZKTopologyPath(topologyId);
        try {
            PropertiesHolder.initialize(zkconnect, zkRoot);
            producer = createProducer(context.getThisTaskId());
            topicProvider = new DataOutputTopicProvider();
            GlobalCache.initialize(datasource);
            handlerManager = new BoltHandlerManager(buildProvider());
            initialized = true;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new InitializationException(e);
        }
    }
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:23,代碼來源:DbusHeartBeatBolt.java

示例8: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
    this.collector = collector;
    this.topologyId = (String) conf.get(Constants.StormConfigKey.FULL_SPLITTER_TOPOLOGY_ID);
    this.isGlobal = this.topologyId.toLowerCase().indexOf(ZkTopoConfForFullPull.GLOBAL_FULLPULLER_TOPO_PREFIX) != -1 ? true : false;
    if (this.isGlobal) {
        this.zkMonitorRootNodePath = Constants.FULL_PULL_MONITOR_ROOT_GLOBAL;
    } else {
        this.zkMonitorRootNodePath = Constants.FULL_PULL_MONITOR_ROOT;
    }
    this.zkconnect = (String) conf.get(Constants.StormConfigKey.ZKCONNECT);
    this.zkTopoRoot = Constants.TOPOLOGY_ROOT + "/" + Constants.FULL_SPLITTING_PROPS_ROOT;
    if (!initialized) {
        // 初始化配置文件
        try {
            loadRunningConf(null);
        } catch (Exception e) {
            throw new InitializationException(e);
        }
        initialized = true;
    }
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:22,代碼來源:DataShardsSplittingBolt.java

示例9: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
    this.collector = collector;

    this.tupleToRabbitMqMessageConverter.prepare(stormConf, context);
    
    if (this.rabbitMqChannelProvider == null) {
        this.rabbitMqChannelProvider = RabbitMqChannelProvider.withStormConfig(stormConf);
    }
    
    try {
        this.rabbitMqChannelProvider.prepare();
    } catch (IOException | TimeoutException ex) {
        throw new RuntimeException("Unable to prepare RabbitMQ channel provider", ex);
    }
}
 
開發者ID:anderelate,項目名稱:storm-rabbitmq,代碼行數:17,代碼來源:RabbitMqBolt.java

示例10: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
    this.collector = collector;
    this.alarmEPLManager = new AlarmEPLManager(stormConf, new CountDownLatch(1));
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
 
開發者ID:JiuzhouSec,項目名稱:nightwatch,代碼行數:11,代碼來源:AlarmBolt.java

示例11: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, TopologyContext context, final OutputCollector collector) {
    eplManager = new EPLManager(stormConf, collector, new CountDownLatch(1));
    this.collector = collector;

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
 
開發者ID:JiuzhouSec,項目名稱:nightwatch,代碼行數:12,代碼來源:ExtractBolt.java

示例12: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map conf, TopologyContext context,
        OutputCollector collector) {
    super.prepare(conf, context, collector);
    _collector = collector;
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:8,代碼來源:DummyIndexer.java

示例13: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
@SuppressWarnings({ "rawtypes" })
public void prepare(Map stormConf, TopologyContext context,
        OutputCollector collect) {
    super.prepare(stormConf, context, collect);
    parseFilters = ParseFilters.fromConf(stormConf);
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:8,代碼來源:FeedDetectorBolt.java

示例14: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void prepare(Map stormConf, TopologyContext context,
        OutputCollector collector) {
    super.prepare(stormConf, context, collector);
    sniffWhenNoSMKey = ConfUtils.getBoolean(stormConf,
            "sitemap.sniffContent", false);
    filterHoursSinceModified = ConfUtils.getInt(stormConf,
            "sitemap.filter.hours.since.modified", -1);
    parseFilters = ParseFilters.fromConf(stormConf);
    maxOffsetGuess = ConfUtils.getInt(stormConf, "sitemap.offset.guess",
            300);
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:14,代碼來源:PatentSiteMapParserBolt.java

示例15: prepare

import org.apache.storm.task.OutputCollector; //導入依賴的package包/類
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void prepare(Map stormConf, TopologyContext context,
        OutputCollector collect) {
    super.prepare(stormConf, context, collect);
    sniffWhenNoMDKey = ConfUtils.getBoolean(stormConf, "feed.sniffContent",
            false);
    filterHoursSincePub = ConfUtils.getInt(stormConf,
            "feed.filter.hours.since.published", -1);
    parseFilters = ParseFilters.fromConf(stormConf);
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:12,代碼來源:FeedParserBolt.java


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