本文整理汇总了Java中backtype.storm.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于backtype.storm包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add_system_components
import backtype.storm.Constants; //导入依赖的package包/类
public static StormTopology add_system_components(StormTopology topology) {
// generate inputs
Map<GlobalStreamId, Grouping> inputs = new HashMap<>();
// generate outputs
HashMap<String, StreamInfo> outputs = new HashMap<>();
//ArrayList<String> fields = new ArrayList<String>();
outputs.put(Constants.SYSTEM_TICK_STREAM_ID, Thrift.outputFields(JStormUtils.mk_list("rate_secs")));
outputs.put(Constants.METRICS_TICK_STREAM_ID, Thrift.outputFields(JStormUtils.mk_list("interval")));
outputs.put(Constants.CREDENTIALS_CHANGED_STREAM_ID, Thrift.outputFields(JStormUtils.mk_list("creds")));
// ComponentCommon common = new ComponentCommon(inputs, outputs);
IBolt ackerbolt = new SystemBolt();
Bolt bolt = Thrift.mkBolt(inputs, ackerbolt, outputs, 0);
topology.put_to_bolts(Constants.SYSTEM_COMPONENT_ID, bolt);
add_system_streams(topology);
return topology;
}
示例2: prepare
import backtype.storm.Constants; //导入依赖的package包/类
public void prepare(Map config, TopologyContext context, OutputCollector collector) {
TimeCacheMap.ExpiredCallback<Object, TrackingInfo> callback = null;
if (_delegate instanceof TimeoutCallback) {
callback = new TimeoutItems();
}
_tracked = new TimeCacheMap<Object, TrackingInfo>(context.maxTopologyMessageTimeout(), callback);
_collector = collector;
_delegate.prepare(config, context, new OutputCollector(new CoordinatedOutputCollector(collector)));
for (String component : Utils.get(context.getThisTargets(), Constants.COORDINATED_STREAM_ID, new HashMap<String, Grouping>()).keySet()) {
for (Integer task : context.getComponentTasks(component)) {
_countOutTasks.add(task);
}
}
if (!_sourceArgs.isEmpty()) {
_numSourceReports = 0;
for (Entry<String, SourceArgs> entry : _sourceArgs.entrySet()) {
if (entry.getValue().singleCount) {
_numSourceReports += 1;
} else {
_numSourceReports += context.getComponentTasks(entry.getKey()).size();
}
}
}
}
示例3: prepare
import backtype.storm.Constants; //导入依赖的package包/类
public void prepare(Map config, TopologyContext context, OutputCollector collector) {
TimeCacheMap.ExpiredCallback<Object, TrackingInfo> callback = null;
if (_delegate instanceof TimeoutCallback) {
callback = new TimeoutItems();
}
_tracked = new TimeCacheMap<>(context.maxTopologyMessageTimeout(), callback);
_collector = collector;
_delegate.prepare(config, context, new OutputCollector(new CoordinatedOutputCollector(collector)));
for (String component : Utils.get(context.getThisTargets(), Constants.COORDINATED_STREAM_ID, new HashMap<String, Grouping>()).keySet()) {
for (Integer task : context.getComponentTasks(component)) {
_countOutTasks.add(task);
}
}
if (!_sourceArgs.isEmpty()) {
_numSourceReports = 0;
for (Entry<String, SourceArgs> entry : _sourceArgs.entrySet()) {
if (entry.getValue().singleCount) {
_numSourceReports += 1;
} else {
_numSourceReports += context.getComponentTasks(entry.getKey()).size();
}
}
}
}
示例4: prepare
import backtype.storm.Constants; //导入依赖的package包/类
public void prepare(Map config, TopologyContext context,
OutputCollector collector) {
TimeCacheMap.ExpiredCallback<Object, TrackingInfo> callback = null;
if (_delegate instanceof TimeoutCallback) {
callback = new TimeoutItems();
}
_tracked = new TimeCacheMap<Object, TrackingInfo>(
context.maxTopologyMessageTimeout(), callback);
_collector = collector;
_delegate.prepare(config, context, new OutputCollector(
new CoordinatedOutputCollector(collector)));
for (String component : Utils.get(context.getThisTargets(),
Constants.COORDINATED_STREAM_ID,
new HashMap<String, Grouping>()).keySet()) {
for (Integer task : context.getComponentTasks(component)) {
_countOutTasks.add(task);
}
}
if (!_sourceArgs.isEmpty()) {
_numSourceReports = 0;
for (Entry<String, SourceArgs> entry : _sourceArgs.entrySet()) {
if (entry.getValue().singleCount) {
_numSourceReports += 1;
} else {
_numSourceReports += context.getComponentTasks(
entry.getKey()).size();
}
}
}
}
示例5: execute
import backtype.storm.Constants; //导入依赖的package包/类
public void execute(Tuple tuple) {
try {
if (tuple.getSourceComponent().equals(Constants.SYSTEM_COMPONENT_ID)
&& tuple.getSourceStreamId().equals(Constants.SYSTEM_TICK_STREAM_ID)) {
logger.info("flush commit hbase !");
table.flushCommits();
} else {
writeHbase(this.configure, tuple.getStringByField("rowkey"), hbaseColumnFamlity,
tuple.getStringByField("column"), tuple.getStringByField("columnvalue"));
}
} catch (IOException e) {
logger.error("Hbase save wrong !\n", e);
}
}
示例6: LogHandler
import backtype.storm.Constants; //导入依赖的package包/类
public LogHandler(Map conf) {
logDir = JStormUtils.getLogDir();
String logDirPath = PathUtils.getCanonicalPath(logDir);
if (logDirPath == null) {
accessDirs.add(logDir);
}else {
accessDirs.add(logDirPath);
}
stormHome = System.getProperty("jstorm.home");
if (stormHome != null) {
String stormHomePath = PathUtils.getCanonicalPath(stormHome);
if (stormHomePath == null) {
accessDirs.add(stormHome);
}else {
accessDirs.add(stormHomePath);
}
}
String confDir = System.getProperty(Constants.JSTORM_CONF_DIR);
if (StringUtils.isBlank(confDir) == false) {
String confDirPath = PathUtils.getCanonicalPath(confDir);
if (confDirPath != null) {
accessDirs.add(confDirPath);
}
}
this.conf = conf;
LOG.info("logview logDir=" + logDir); // +++
}
示例7: add_system_components
import backtype.storm.Constants; //导入依赖的package包/类
@SuppressWarnings("unused")
public static StormTopology add_system_components(StormTopology topology) {
// generate inputs
Map<GlobalStreamId, Grouping> inputs = new HashMap<GlobalStreamId, Grouping>();
// generate outputs
HashMap<String, StreamInfo> outputs = new HashMap<String, StreamInfo>();
ArrayList<String> fields = new ArrayList<String>();
outputs.put(Constants.SYSTEM_TICK_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("rate_secs")));
outputs.put(Constants.METRICS_TICK_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("interval")));
outputs.put(Constants.CREDENTIALS_CHANGED_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("creds")));
ComponentCommon common = new ComponentCommon(inputs, outputs);
IBolt ackerbolt = new SystemBolt();
Bolt bolt = Thrift.mkBolt(inputs, ackerbolt, outputs,
Integer.valueOf(0));
topology.put_to_bolts(Constants.SYSTEM_COMPONENT_ID, bolt);
add_system_streams(topology);
return topology;
}
示例8: prepare
import backtype.storm.Constants; //导入依赖的package包/类
@Override
public void prepare(Map config, TopologyContext context,
OutputCollector collector) {
TimeCacheMap.ExpiredCallback<Object, TrackingInfo> callback = null;
if (_delegate instanceof TimeoutCallback) {
callback = new TimeoutItems();
}
_tracked = new TimeCacheMap<Object, TrackingInfo>(
context.maxTopologyMessageTimeout(), callback);
_collector = collector;
_delegate.prepare(config, context, new OutputCollector(
new CoordinatedOutputCollector(collector)));
for (String component : Utils.get(context.getThisTargets(),
Constants.COORDINATED_STREAM_ID,
new HashMap<String, Grouping>()).keySet()) {
for (Integer task : context.getComponentTasks(component)) {
_countOutTasks.add(task);
}
}
if (!_sourceArgs.isEmpty()) {
_numSourceReports = 0;
for (Entry<String, SourceArgs> entry : _sourceArgs.entrySet()) {
if (entry.getValue().singleCount) {
_numSourceReports += 1;
} else {
_numSourceReports += context.getComponentTasks(
entry.getKey()).size();
}
}
}
}
示例9: getTupleType
import backtype.storm.Constants; //导入依赖的package包/类
private TupleType getTupleType(Tuple tuple) {
if (_idStreamSpec != null
&& tuple.getSourceGlobalStreamid().equals(_idStreamSpec._id)) {
return TupleType.ID;
} else if (!_sourceArgs.isEmpty()
&& tuple.getSourceStreamId().equals(
Constants.COORDINATED_STREAM_ID)) {
return TupleType.COORD;
} else {
return TupleType.REGULAR;
}
}
示例10: createHeartbeatBoltMessage
import backtype.storm.Constants; //导入依赖的package包/类
private BoltMsg createHeartbeatBoltMessage(String genId) {
BoltMsg msg = new BoltMsg();
msg.setId(genId);
msg.setTask(Constants.SYSTEM_TASK_ID);
msg.setStream(HEARTBEAT_STREAM_ID);
msg.setTuple(new ArrayList<Object>());
return msg;
}
示例11: LogHandler
import backtype.storm.Constants; //导入依赖的package包/类
public LogHandler(Map conf) {
logDir = JStormUtils.getLogDir();
String logDirPath = PathUtils.getCanonicalPath(logDir);
if (logDirPath == null) {
accessDirs.add(logDir);
} else {
accessDirs.add(logDirPath);
}
stormHome = System.getProperty("jstorm.home");
if (stormHome != null) {
String stormHomePath = PathUtils.getCanonicalPath(stormHome);
if (stormHomePath == null) {
accessDirs.add(stormHome);
} else {
accessDirs.add(stormHomePath);
}
}
String confDir = System.getProperty(Constants.JSTORM_CONF_DIR);
if (StringUtils.isBlank(confDir) == false) {
String confDirPath = PathUtils.getCanonicalPath(confDir);
if (confDirPath != null) {
accessDirs.add(confDirPath);
}
}
this.conf = conf;
LOG.info("logview logDir=" + logDir); // +++
}
示例12: add_system_components
import backtype.storm.Constants; //导入依赖的package包/类
public static StormTopology add_system_components(StormTopology topology) {
// generate inputs
Map<GlobalStreamId, Grouping> inputs = new HashMap<GlobalStreamId, Grouping>();
// generate outputs
HashMap<String, StreamInfo> outputs = new HashMap<String, StreamInfo>();
ArrayList<String> fields = new ArrayList<String>();
outputs.put(Constants.SYSTEM_TICK_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("rate_secs")));
outputs.put(Constants.METRICS_TICK_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("interval")));
outputs.put(Constants.CREDENTIALS_CHANGED_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("creds")));
ComponentCommon common = new ComponentCommon(inputs, outputs);
IBolt ackerbolt = new SystemBolt();
Bolt bolt = Thrift.mkBolt(inputs, ackerbolt, outputs,
Integer.valueOf(0));
topology.put_to_bolts(Constants.SYSTEM_COMPONENT_ID, bolt);
add_system_streams(topology);
return topology;
}
示例13: handleRedirect
import backtype.storm.Constants; //导入依赖的package包/类
private void handleRedirect(Tuple t, String sourceUrl, String newUrl,
Metadata sourceMetadata) {
// build an absolute URL
URL sURL;
try {
sURL = new URL(sourceUrl);
URL tmpURL = URLUtil.resolveURL(sURL, newUrl);
newUrl = tmpURL.toExternalForm();
} catch (MalformedURLException e) {
LOG.debug("MalformedURLException on {} or {}: {}", sourceUrl,
newUrl, e);
return;
}
// apply URL filters
if (this.urlFilters != null) {
newUrl = this.urlFilters.filter(sURL, sourceMetadata, newUrl);
}
// filtered
if (newUrl == null) {
return;
}
Metadata metadata = metadataTransfer.getMetaForOutlink(newUrl,
sourceUrl, sourceMetadata);
// TODO check that hasn't exceeded max number of redirections
emitQueue.add(new Object[] {
com.digitalpebble.storm.crawler.Constants.StatusStreamName, t,
new Values(newUrl, metadata, Status.DISCOVERED) });
}
示例14: declareOutputFields
import backtype.storm.Constants; //导入依赖的package包/类
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("url", "content", "metadata"));
declarer.declareStream(
com.digitalpebble.storm.crawler.Constants.StatusStreamName,
new Fields("url", "metadata", "status"));
}
示例15: handleRedirect
import backtype.storm.Constants; //导入依赖的package包/类
private void handleRedirect(Tuple t, String sourceUrl, String newUrl,
Metadata sourceMetadata) {
// build an absolute URL
URL sURL;
try {
sURL = new URL(sourceUrl);
URL tmpURL = URLUtil.resolveURL(sURL, newUrl);
newUrl = tmpURL.toExternalForm();
} catch (MalformedURLException e) {
LOG.debug("MalformedURLException on {} or {}: {}", sourceUrl,
newUrl, e);
return;
}
// apply URL filters
if (this.urlFilters != null) {
newUrl = this.urlFilters.filter(sURL, sourceMetadata, newUrl);
}
// filtered
if (newUrl == null) {
return;
}
Metadata metadata = metadataTransfer.getMetaForOutlink(newUrl,
sourceUrl, sourceMetadata);
// TODO check that hasn't exceeded max number of redirections
_collector.emit(
com.digitalpebble.storm.crawler.Constants.StatusStreamName, t,
new Values(newUrl, metadata, Status.DISCOVERED));
}