本文整理汇总了Java中backtype.storm.task.IMetricsContext类的典型用法代码示例。如果您正苦于以下问题:Java IMetricsContext类的具体用法?Java IMetricsContext怎么用?Java IMetricsContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMetricsContext类属于backtype.storm.task包,在下文中一共展示了IMetricsContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext context, int partitionIndex, int numPartitions) {
MemcachedState s;
try {
s = new MemcachedState(makeMemcachedClient(_opts, _servers), _opts, _ser);
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
// s.registerMetrics(conf, context);
CachedMap c = new CachedMap(s, _opts.localCacheSize);
MapState ms;
if(_type == StateType.NON_TRANSACTIONAL) {
ms = NonTransactionalMap.build(c);
} else if(_type==StateType.OPAQUE) {
ms = OpaqueMap.build(c);
} else if(_type==StateType.TRANSACTIONAL){
ms = TransactionalMap.build(c);
} else {
throw new RuntimeException("Unknown state type: " + _type);
}
return new SnapshottableMap(ms, new Values(_opts.globalKey));
}
示例2: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
LOG.info("Preparing HBase State for partition {} of {}.", partitionIndex + 1, numPartitions);
IBackingMap state = new HBaseMapState(options, conf, partitionIndex);
if(options.cacheSize > 0) {
state = new CachedMap(state, options.cacheSize);
}
MapState mapState;
switch (stateType) {
case NON_TRANSACTIONAL:
mapState = NonTransactionalMap.build(state);
break;
case OPAQUE:
mapState = OpaqueMap.build(state);
break;
case TRANSACTIONAL:
mapState = TransactionalMap.build(state);
break;
default:
throw new IllegalArgumentException("Unknown state type: " + stateType);
}
return new SnapshottableMap(mapState, new Values(options.globalKey));
}
示例3: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// TODO Auto-generated method stub
String curThreadName = Thread.currentThread().getName();
CommonUtil.logMessage(logger, curThreadName, "makeState: entered partitionIndex = %d, numPartitions = %d ",
partitionIndex, numPartitions);
String redisServerIP = (String)conf.get("redisServerIP");
String redisServerPort = (String)conf.get("redisServerPort");
CommonUtil.logMessage(logger, curThreadName, "makeState: redisServerIP = %s, redisServerPort = %s ",
redisServerIP, redisServerPort);
return new RedisStoreState(redisServerIP, redisServerPort);
}
示例4: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// TODO Auto-generated method stub
String curThreadName = Thread.currentThread().getName();
CommonUtil.logMessage(logger, curThreadName, "makeState: entered partitionIndex = %d, numPartitions = %d ",
partitionIndex, numPartitions);
String redisServerIP = (String)conf.get("redisServerIP");
String redisServerPort = (String)conf.get("redisServerPort");
CommonUtil.logMessage(logger, curThreadName, "makeState: redisServerIP = %s, redisServerPort = %s ",
redisServerIP, redisServerPort);
IBackingMap<TransactionalValue<Long>> backMap = new RedisStoreIBackingMap(redisServerIP, redisServerPort);
IBackingMap<TransactionalValue> test = generic(generic(backMap, Long.class));
return new RedisStoreState(test);
}
示例5: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
/**
* Create a new state from a given configuration
* @param configuration A set of properties
* @param metrics Storm metrics
* @param partitionIndex Partition index
* @param numPartitions Number of partitions
* @return A new state
*/
public State makeState(Map configuration, IMetricsContext metrics, int partitionIndex, int numPartitions) {
if (clientFactory == null) {
clientFactory = new MongoDBClient(configuration);
}
MongoDBMapState state = new MongoDBMapState(clientFactory, mapper, options, configuration);
state.registerMetrics(configuration, metrics);
CachedMap cachedMap = new CachedMap(state, options.localCacheSize);
MapState mapState;
if (stateType == StateType.NON_TRANSACTIONAL) {
mapState = NonTransactionalMap.build(cachedMap);
} else if (stateType == StateType.OPAQUE) {
mapState = OpaqueMap.build(cachedMap);
} else if (stateType == StateType.TRANSACTIONAL) {
mapState = TransactionalMap.build(cachedMap);
} else {
throw new RuntimeException("Unknown state type: " + stateType);
}
return new SnapshottableMap(mapState, new Values(options.globalKey));
}
示例6: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions)
{
InfinispanKmeansState resultState = new InfinispanKmeansState(partitionIndex,
numPartitions, this.servers, this.cacheName);
if (this.mergeInterval > 0)
{
resultState.setMergeInterval(this.mergeInterval);
}
if (this.lifespan > 0)
{
resultState.setLifespan(this.lifespan);
}
resultState.initialize();
return resultState;
}
示例7: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions)
{
InfinispanLofState resultState = new InfinispanLofState(this.targetUri, this.tableName,
partitionIndex, numPartitions);
if (this.mergeInterval > 0)
{
resultState.setMergeInterval(this.mergeInterval);
}
if (this.lifespan > 0)
{
resultState.setLifespan(this.lifespan);
}
if (this.mergeConfig != null)
{
resultState.setMergeConfig(this.mergeConfig);
}
resultState.initialize();
return resultState;
}
示例8: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
LOG.info("makeState(partitonIndex={}, numpartitions={}", partitionIndex, numPartitions);
TridentKafkaState state = new TridentKafkaState()
.withKafkaTopicSelector(this.topicSelector)
.withTridentTupleToKafkaMapper(this.mapper);
state.prepare(conf);
return state;
}
示例9: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
public State makeState(Map configuration, IMetricsContext metrics, int partitionIndex, int numPartitions) {
if (clientFactory == null) {
clientFactory = new MapConfiguredCqlClientFactory(configuration);
}
Session session;
if(options.keyspace != null) {
session = clientFactory.getSession(options.keyspace);
} else {
session = clientFactory.getSession();
}
CassandraCqlMapState state = new CassandraCqlMapState(session, mapper, options, configuration);
state.registerMetrics(configuration, metrics, options.mapStateMetricName);
CachedMap cachedMap = new CachedMap(state, options.localCacheSize);
MapState mapState;
if (stateType == StateType.NON_TRANSACTIONAL) {
mapState = NonTransactionalMap.build(cachedMap);
} else if (stateType == StateType.OPAQUE) {
mapState = OpaqueMap.build(cachedMap);
} else if (stateType == StateType.TRANSACTIONAL) {
mapState = TransactionalMap.build(cachedMap);
} else {
throw new RuntimeException("Unknown state type: " + stateType);
}
return new SnapshottableMap(mapState, new Values(options.globalKey));
}
示例10: registerMetrics
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public void registerMetrics(Map conf, IMetricsContext context, String mapStateMetricName) {
int bucketSize = (Integer) (conf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS));
String metricBaseName = "cassandra/" + mapStateMetricName;
_mreads = context.registerMetric(metricBaseName + "/readCount", new CountMetric(), bucketSize);
_mwrites = context.registerMetric(metricBaseName + "/writeCount", new CountMetric(), bucketSize);
_mexceptions = context.registerMetric(metricBaseName + "/exceptionCount", new CountMetric(), bucketSize);
}
示例11: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public State makeState(Map configuration, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// NOTE: Lazy instantiation because Cluster is not serializable.
if (clientFactory == null) {
clientFactory = new MapConfiguredCqlClientFactory(configuration);
}
LOG.debug("Creating State for partition [{}] of [{}]", new Object[]{partitionIndex, numPartitions});
return new CassandraCqlIncrementalState<K, V>(clientFactory, aggregator, mapper, partitionIndex);
}
示例12: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public State makeState(Map configuration, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// worth synchronizing here?
if (clientFactory == null) {
clientFactory = new MapConfiguredCqlClientFactory(configuration);
}
final String maxBatchSizeString = (String) configuration.get(CassandraCqlStateFactory.TRIDENT_CASSANDRA_MAX_BATCH_SIZE);
final int maxBatchSize = (maxBatchSizeString == null) ? DEFAULT_MAX_BATCH_SIZE : Integer.parseInt((String) maxBatchSizeString);
LOG.debug("Creating State for partition [{}] of [{}]", new Object[]{partitionIndex, numPartitions});
return new CassandraCqlState(clientFactory, maxBatchSize, batchConsistencyLevel);
}
示例13: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
AerospikeSingleBinMapState aerospikeState = new AerospikeSingleBinMapState(binName, options, keyExtractor);
CachedMap cachedMap = new CachedMap(aerospikeState, 1000);
MapState mapState = null;
if (stateType == StateType.NON_TRANSACTIONAL) {
mapState = NonTransactionalMap.build(cachedMap);
} else if (stateType == StateType.OPAQUE) {
mapState = OpaqueMap.build(cachedMap);
} else if (stateType == StateType.TRANSACTIONAL) {
mapState = TransactionalMap.build(cachedMap);
}
return mapState;
}
示例14: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
AerospikeSplitKeyMultiBinMapState aerospikeState = new AerospikeSplitKeyMultiBinMapState(options, keyAndBinExtractor);
CachedMap cachedMap = new CachedMap(aerospikeState, 1000);
MapState mapState = null;
if (stateType == StateType.NON_TRANSACTIONAL) {
mapState = NonTransactionalMap.build(cachedMap);
} else if (stateType == StateType.OPAQUE) {
mapState = OpaqueMap.build(cachedMap);
} else if (stateType == StateType.TRANSACTIONAL) {
mapState = TransactionalMap.build(cachedMap);
}
return mapState;
}
示例15: makeState
import backtype.storm.task.IMetricsContext; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
AerospikeSplitKeySingleBinMapState aerospikeState = new AerospikeSplitKeySingleBinMapState(binName, options, keyAndBinFactory);
CachedMap cachedMap = new CachedMap(aerospikeState, 1000);
MapState mapState = null;
if (stateType == StateType.NON_TRANSACTIONAL) {
mapState = NonTransactionalMap.build(cachedMap);
} else if (stateType == StateType.OPAQUE) {
mapState = OpaqueMap.build(cachedMap);
} else if (stateType == StateType.TRANSACTIONAL) {
mapState = TransactionalMap.build(cachedMap);
}
return mapState;
}