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


Java State类代码示例

本文整理汇总了Java中storm.trident.state.State的典型用法代码示例。如果您正苦于以下问题:Java State类的具体用法?Java State怎么用?Java State使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


State类属于storm.trident.state包,在下文中一共展示了State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeState

import storm.trident.state.State; //导入依赖的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

示例2: makeState

import storm.trident.state.State; //导入依赖的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

示例3: makeState

import storm.trident.state.State; //导入依赖的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

示例4: makeState

import storm.trident.state.State; //导入依赖的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

示例5: makeState

import storm.trident.state.State; //导入依赖的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

示例6: makeState

import storm.trident.state.State; //导入依赖的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

示例7: batchRetrieve

import storm.trident.state.State; //导入依赖的package包/类
@Override
public List<Iterator<List<Object>>> batchRetrieve(State state, List<TridentTuple> args) {
    List<Iterator<List<Object>>> ret = new ArrayList(args.size());
    for(int i=0; i<args.size(); i++) {
        ret.add(((ITupleCollection)state).getTuples());
    }
    return ret;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:9,代码来源:TupleCollectionGet.java

示例8: prepare

import storm.trident.state.State; //导入依赖的package包/类
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:13,代码来源:StateQueryProcessor.java

示例9: prepare

import storm.trident.state.State; //导入依赖的package包/类
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:13,代码来源:PartitionPersistProcessor.java

示例10: makeState

import storm.trident.state.State; //导入依赖的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

示例11: makeState

import storm.trident.state.State; //导入依赖的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 storm.trident.state.State; //导入依赖的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: batchRetrieve

import storm.trident.state.State; //导入依赖的package包/类
@Override
public List<Iterator<List<Object>>> batchRetrieve(State state, List<TridentTuple> args) {
    List<Iterator<List<Object>>> ret = new ArrayList(args.size());
    for (int i = 0; i < args.size(); i++) {
        ret.add(((ITupleCollection) state).getTuples());
    }
    return ret;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:9,代码来源:TupleCollectionGet.java

示例14: prepare

import storm.trident.state.State; //导入依赖的package包/类
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:13,代码来源:StateQueryProcessor.java

示例15: prepare

import storm.trident.state.State; //导入依赖的package包/类
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:13,代码来源:PartitionPersistProcessor.java


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