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


Java TransactionalValue类代码示例

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


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

示例1: makeState

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

示例2: multiPut

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public void multiPut(List<List<Object>> keys, List<TransactionalValue<T>> vals) {
    for (int i = 0; i < keys.size(); i++) {
        TridentTuple keyTuple = (TridentTuple) keys.get(i);
        TransactionalValue transactionalValue = (TransactionalValue) vals.get(i);
        Long txid = transactionalValue.getTxid();
        T key = (T) keyTuple.get(0);
        S3TransactionalOutput output = outputFor(key);
        List tuples = (List) transactionalValue.getVal();
        try {
            output.write(key, tuples, txid);
        } catch (IOException e) {
            LOG.error("Error while writing tuples for key {}", e, key);
        }
    }

}
 
开发者ID:wurstmeister,项目名称:storm-s3,代码行数:18,代码来源:S3MapState.java

示例3: multiGet

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public List<T> multiGet(List<List<Object>> keys) {
    List<CachedBatchReadsMap.RetVal<TransactionalValue>> vals = _backing.multiGet(keys);
    List<T> ret = new ArrayList<T>(vals.size());
    for(CachedBatchReadsMap.RetVal<TransactionalValue> retval: vals) {
        TransactionalValue v = retval.val;
        if(v!=null) {
            ret.add((T) v.getVal());
        } else {
            ret.add(null);
        }
    }
    return ret;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:15,代码来源:TransactionalMap.java

示例4: multiUpdate

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public List<T> multiUpdate(List<List<Object>> keys, List<ValueUpdater> updaters) {
    List<CachedBatchReadsMap.RetVal<TransactionalValue>> curr = _backing.multiGet(keys);
    List<TransactionalValue> newVals = new ArrayList<TransactionalValue>(curr.size());
    List<List<Object>> newKeys = new ArrayList();
    List<T> ret = new ArrayList<T>();
    for(int i=0; i<curr.size(); i++) {
        CachedBatchReadsMap.RetVal<TransactionalValue> retval = curr.get(i);
        TransactionalValue<T> val = retval.val;
        ValueUpdater<T> updater = updaters.get(i);
        TransactionalValue<T> newVal;
        boolean changed = false;
        if(val==null) {
            newVal = new TransactionalValue<T>(_currTx, updater.update(null));
            changed = true;
        } else {
            if(_currTx!=null && _currTx.equals(val.getTxid()) && !retval.cached) {
                newVal = val;
            } else {
                newVal = new TransactionalValue<T>(_currTx, updater.update(val.getVal()));
                changed = true;
            }
        }
        ret.add(newVal.getVal());
        if(changed) {
            newVals.add(newVal);
            newKeys.add(keys.get(i));
        }
    }
    if(!newKeys.isEmpty()) {
        _backing.multiPut(newKeys, newVals);
    }
    return ret;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:35,代码来源:TransactionalMap.java

示例5: multiPut

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public void multiPut(List<List<Object>> keys, List<T> vals) {
    List<TransactionalValue> newVals = new ArrayList<TransactionalValue>(vals.size());
    for(T val: vals) {
        newVals.add(new TransactionalValue<T>(_currTx, val));
    }
    _backing.multiPut(keys, newVals);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:9,代码来源:TransactionalMap.java

示例6: multiGet

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public List<TransactionalValue<Long>> multiGet(
		List<List<Object>> keys) {
	// TODO Auto-generated method stub
	List<TransactionalValue<Long>> retList = new ArrayList<>();
	for(List<Object> eachKeyList : keys)
	{
		String word = (String)eachKeyList.get(0);
		CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: word = %s", word);

		/**
		 * The below line is commented intentionally. Why ? To illustrate batch replay use case.
		 * I want the entire original phrase to be passed into multiPut, and not only the parts
		 * that failed to be stored into Redis due to FailedException.
		 */
		//List<String> redisVal = redisOperations.lrange(word); 
		
		List<String> redisVal = new ArrayList<>();
		CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: redisVal = %s", redisVal);

		if(redisVal != null && redisVal.size() > 0)
		{
			Long txId = Long.parseLong(redisVal.get(0));
			Long wordCount = Long.parseLong(redisVal.get(1));
			
			CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: txId = %d and count = %d for word = %s", txId, wordCount, word);
			TransactionalValue<Long> tv = new TransactionalValue<Long>(txId, wordCount);
			retList.add(tv);

		}
		else
		{
			retList.add(null);
		}
	}
	return retList;
}
 
开发者ID:BinitaBharati,项目名称:storm-trident-example,代码行数:38,代码来源:RedisStoreIBackingMap.java

示例7: multiGet

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public List<TransactionalValue<Long>> multiGet(
		List<List<Object>> keys) {
	// TODO Auto-generated method stub
	List<TransactionalValue<Long>> retList = new ArrayList<>();
	for(List<Object> eachKeyList : keys)
	{
		String word = (String)eachKeyList.get(0);
		CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: word = %s", word);

		List<String> redisVal = lrange(word);
		CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: redisVal = %s", redisVal);

		if(redisVal != null && redisVal.size() > 0)
		{
			Long txId = Long.parseLong(redisVal.get(0));
			Long wordCount = Long.parseLong(redisVal.get(1));
			
			CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: txId = %d and count = %d for word = %s", txId, wordCount, word);
			TransactionalValue<Long> tv = new TransactionalValue<Long>(txId, wordCount);
			retList.add(tv);

		}
		else
		{
			retList.add(null);
		}
	}
	return retList;
}
 
开发者ID:BinitaBharati,项目名称:storm-trident-example,代码行数:31,代码来源:RedisStoreIBackingMap.java

示例8: multiGet

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public List<TransactionalValue<Long>> multiGet(
		List<List<Object>> keys) {
	// TODO Auto-generated method stub
	List<TransactionalValue<Long>> retList = new ArrayList<>();
	for(List<Object> eachKeyList : keys)
	{
		String word = (String)eachKeyList.get(0);
		CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: word = %s", word);

		List<String> redisVal = redisOperations.lrange(word); 
		
		CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: redisVal = %s", redisVal);

		if(redisVal != null && redisVal.size() > 0)
		{
			Long txId = Long.parseLong(redisVal.get(0));
			Long wordCount = Long.parseLong(redisVal.get(1));
			
			CommonUtil.logMessage(logger, Thread.currentThread().getName(), "multiGet: txId = %d and count = %d for word = %s", txId, wordCount, word);
			TransactionalValue<Long> tv = new TransactionalValue<Long>(txId, wordCount);
			retList.add(tv);

		}
		else
		{
			retList.add(null);
		}
	}
	return retList;
}
 
开发者ID:BinitaBharati,项目名称:storm-trident-example,代码行数:32,代码来源:RedisStoreIBackingMap.java

示例9: toSimpleType

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public Value toSimpleType(TransactionalValue value) {
    Value[] result = new Value[2];
    result[0] = Value.get(value.getVal());
    result[1] = Value.get(value.getTxid());
    return Value.get(result);
}
 
开发者ID:adform,项目名称:trident-aerospike,代码行数:8,代码来源:SerializationUtils.java

示例10: toComplexType

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public TransactionalValue toComplexType(Object object) {
    if (object != null) {
        List<Object> values = (List<Object>) object;
        return new TransactionalValue((long) values.get(1), values.get(0));
    }
    return null;
}
 
开发者ID:adform,项目名称:trident-aerospike,代码行数:10,代码来源:SerializationUtils.java

示例11: multiGet

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
/**
 * Give me the latest transactional values that you have for the keys given
 *
 * @param keys
 * @return
 */
public List<TransactionalValue<T>> multiGet(List<List<Object>> keys) {
    List<TransactionalValue<T>> result = new ArrayList(keys.size());
    for (int i = 0; i < keys.size(); i++) {
        TridentTuple keyTuple = (TridentTuple) keys.get(i);
        T key = (T) keyTuple.get(0);
        S3TransactionalOutput output = outputFor(key);
        result.add(new TransactionalValue(output.getTransactionId(), null));
    }

    return result;
}
 
开发者ID:wurstmeister,项目名称:storm-s3,代码行数:18,代码来源:S3MapState.java

示例12: makeState

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public State makeState(Map conf, IMetricsContext iMetricsContext, int i, int i2) {
    Options options = new Options(conf);
    ESIndexMapState<TransactionalValue<T>> mapState = new ESIndexMapState<>(clientFactory.makeClient(conf), serializer, new BulkResponseHandler.LoggerResponseHandler(), options.reportError());
    MapState<T> ms  = TransactionalMap.build(new CachedMap(mapState, options.getCachedMapSize()));
    Values snapshotKey = new Values(options.getGlobalKey());
    return new SnapshottableMap<>(ms, snapshotKey);
}
 
开发者ID:fhussonnois,项目名称:storm-trident-elasticsearch,代码行数:9,代码来源:ESIndexMapState.java

示例13: shouldSerializeTransactionValue

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Test
public void shouldSerializeTransactionValue( ) throws IOException {
    TransactionalValueSerializer<FooDocument> serializer = new TransactionalValueSerializer<>(FooDocument.class);
    byte[] value = serializer.serialize(new TransactionalValue<>(1L, new FooDocument("foo")));

    TransactionalValue<FooDocument> actual = serializer.deserialize(value);
    Assert.assertNotNull(actual);
    Assert.assertEquals(1L, (long)actual.getTxid());
    Assert.assertEquals("foo", actual.getVal().value);
}
 
开发者ID:fhussonnois,项目名称:storm-trident-elasticsearch,代码行数:11,代码来源:ValueSerializerTest.java

示例14: multiPut

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
@Override
public void multiPut(List<List<Object>> keys, List<TransactionalValue<T>> vals) {
    for (int i = 0; i < keys.size(); i++) {
        String key = getKey(keys.get(i));
        T value = vals.get(i).getVal();
        addKeyValue(key, value);
    }
}
 
开发者ID:eshioji,项目名称:trident-tutorial,代码行数:9,代码来源:HazelCastState.java

示例15: multiGet

import storm.trident.state.TransactionalValue; //导入依赖的package包/类
public List<TransactionalValue<T>> multiGet(List<List<Object>> keys) {
    List<TransactionalValue<T>> result = new ArrayList<TransactionalValue<T>>(keys.size());
    for (int i = 0; i < keys.size(); i++) {
        String key = getKey(keys.get(i));
        result.add(new TransactionalValue<T>(0L, (T)(handler.getState().get(key))));
    }
    return result;
}
 
开发者ID:eshioji,项目名称:trident-tutorial,代码行数:9,代码来源:HazelCastState.java


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