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


Java Constants类代码示例

本文整理汇总了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;

}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:24,代码来源:Common.java

示例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();
            }
        }
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:25,代码来源:CoordinatedBolt.java

示例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();
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:25,代码来源:CoordinatedBolt.java

示例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();
			}
		}
	}
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:31,代码来源:CoordinatedBolt.java

示例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);
	}
}
 
开发者ID:zhai3516,项目名称:storm-demos,代码行数:15,代码来源:WriteHbaseBolt.java

示例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); // +++

		}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:35,代码来源:Httpserver.java

示例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;

}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:31,代码来源:Common.java

示例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();
			}
		}
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:32,代码来源:CoordinatedBolt.java

示例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;
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:13,代码来源:CoordinatedBolt.java

示例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;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:9,代码来源:ShellBolt.java

示例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); // +++

        }
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:34,代码来源:Httpserver.java

示例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;

}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:30,代码来源:Common.java

示例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) });
}
 
开发者ID:zaizi,项目名称:alfresco-apache-storm-demo,代码行数:35,代码来源:FetcherBolt.java

示例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"));
}
 
开发者ID:zaizi,项目名称:alfresco-apache-storm-demo,代码行数:8,代码来源:FetcherBolt.java

示例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));
}
 
开发者ID:zaizi,项目名称:alfresco-apache-storm-demo,代码行数:34,代码来源:SimpleFetcherBolt.java


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