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


Java IMetricsContext类代码示例

本文整理汇总了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));
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:23,代码来源:MemcachedState.java

示例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));
}
 
开发者ID:mengzhiyi,项目名称:storm-hbase-1.0.x,代码行数:26,代码来源:HBaseMapState.java

示例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);
}
 
开发者ID:BinitaBharati,项目名称:storm-trident-example,代码行数:17,代码来源:RedisStoreStateFactory.java

示例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);
}
 
开发者ID:BinitaBharati,项目名称:storm-trident-example,代码行数:21,代码来源:RedisStoreStateFactory.java

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

示例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;
}
 
开发者ID:acromusashi,项目名称:acromusashi-stream-ml,代码行数:23,代码来源:InfinispanKmeansStateFactory.java

示例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;
}
 
开发者ID:acromusashi,项目名称:acromusashi-stream-ml,代码行数:28,代码来源:InfinispanLofStateFactory.java

示例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;
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:10,代码来源:TridentKafkaStateFactory.java

示例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));
}
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:33,代码来源:CassandraCqlMapStateFactory.java

示例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);
  }
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:9,代码来源:CassandraCqlMapState.java

示例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);
}
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:12,代码来源:CassandraCqlIncrementalStateFactory.java

示例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);
}
 
开发者ID:hpcc-systems,项目名称:storm-cassandra-cql,代码行数:13,代码来源:CassandraCqlStateFactory.java

示例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;
}
 
开发者ID:adform,项目名称:trident-aerospike,代码行数:15,代码来源:AerospikeSingleBinMapState.java

示例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;
}
 
开发者ID:adform,项目名称:trident-aerospike,代码行数:15,代码来源:AerospikeSplitKeyMultiBinMapState.java

示例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;
}
 
开发者ID:adform,项目名称:trident-aerospike,代码行数:15,代码来源:AerospikeSplitKeySingleBinMapState.java


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