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