Support
Quality
Security
License
Reuse
kandi has reviewed jstorm and discovered the below as its top functions. This is intended to give you an instant insight into jstorm implemented functionality, and help decide if they suit your requirements.
Enterprise Stream Process Engine
No Code Snippets are available at this moment for jstorm.
QUESTION
JedisSentinelPool is thread safe?
Asked 2017-Feb-08 at 07:46I know that jredis is not thread-safe, the Internet should be said that the use of JedisSentinelPool, it is thread-safe, but I use, the discovery is not the case, I do not know whether the use of a problem.
private static Logger logger = LoggerFactory.getLogger(Redis.class);
private JedisSentinelPool pool;
private static Redis instance = null;
public static Redis getInstance(){
if (instance == null) {
throw new RuntimeException("Do not initialize!!!");
}
return instance;
}
public static void buildInstance(Map conf) {
if (instance == null) {
synchronized (Redis.class) {
instance = new Redis();
instance.init(conf);
}
}
}
private Redis() {}
private void init(Map conf){
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxIdle(Integer.valueOf(String.valueOf(conf.get("redis.max_idle"))));
config.setTestOnBorrow(Boolean.valueOf(String.valueOf(conf.get("redis.isTest"))));
config.setMaxTotal(Integer.valueOf(String.valueOf(conf.get("redis.maxTotal"))));
String node = String.valueOf(conf.get("redis.node"));
int timeOut = Integer.valueOf(String.valueOf(conf.get("redis.timeout")));
String[] addressArr = String.valueOf(conf.get("redis.server")).split(",");
Set<String> sentinels = new HashSet<String>();
for (String str : addressArr) {
sentinels.add(str);
}
pool = new JedisSentinelPool(node, sentinels, config, timeOut);
}
private Jedis getRedisTemplate() {
Jedis resource = pool.getResource();
return resource;
}
/** public */void setValue(byte[] key, byte[] value) {
Jedis jedis = null;
try {
jedis = getRedisTemplate();
jedis.set(key, value);
closeJedis(jedis);
} catch (Exception e) {
e.printStackTrace();
closeBreakJedis(jedis);
}
}
java.lang.ClassCastException: java.lang.Long cannot be cast to [B
at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:216)
at redis.clients.jedis.Connection.getBulkReply(Connection.java:205)
at redis.clients.jedis.Jedis.hget(Jedis.java:622)
at com.mapbar.flash.common.cache.Redis.getHashValue(Redis.java:300)
at com.mapbar.flash.common.cache.TerminalCache.getCityCodeArray(TerminalCache.java:35)
at com.mapbar.flash.core.bolt.ElectronicFenceBolt.doExecute(ElectronicFenceBolt.java:106)
at com.mapbar.flash.core.bolt.ElectronicFenceBolt.doExecute(ElectronicFenceBolt.java:1)
at com.mapbar.flash.core.bolt.BaseBolt.execute(BaseBolt.java:79)
at backtype.storm.topology.BasicBoltExecutor.execute(BasicBoltExecutor.java:49)
at com.alibaba.jstorm.task.execute.BoltExecutors.processTupleEvent(BoltExecutors.java:183)
at com.alibaba.jstorm.task.execute.BoltExecutors.onEvent(BoltExecutors.java:161)
at backtype.storm.utils.DisruptorQueueImpl.consumeBatchToCursor(DisruptorQueueImpl.java:191)
at backtype.storm.utils.DisruptorQueueImpl.consumeBatchWhenAvailable(DisruptorQueueImpl.java:159)
at com.alibaba.jstorm.task.execute.BoltExecutors.run(BoltExecutors.java:137)
at com.alibaba.jstorm.callback.AsyncLoopRunnable.run(AsyncLoopRunnable.java:95)
at java.lang.Thread.run(Thread.java:745)
ANSWER
Answered 2017-Feb-08 at 07:46is my code problem,in a method i return the jredis before query.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Save this library and start creating your kit