use of redis.clients.jedis.JedisPool in project storm by apache.
the class TestRedisDataSourcesProvider method testRedisSink.
@SuppressWarnings("unchecked")
@Test
public void testRedisSink() {
ISqlTridentDataSource ds = DataSourcesRegistry.constructTridentDataSource(URI.create("redis://:foobared@localhost:6380/2"), null, null, TBL_PROPERTIES, FIELDS);
Assert.assertNotNull(ds);
ISqlTridentDataSource.SqlTridentConsumer consumer = ds.getConsumer();
Assert.assertEquals(RedisState.Factory.class, consumer.getStateFactory().getClass());
Assert.assertEquals(RedisStateUpdater.class, consumer.getStateUpdater().getClass());
RedisState state = (RedisState) consumer.getStateFactory().makeState(Collections.emptyMap(), null, 0, 1);
StateUpdater stateUpdater = consumer.getStateUpdater();
JedisPool mockJedisPool = mock(JedisPool.class);
Jedis mockJedis = mock(Jedis.class);
Pipeline mockPipeline = mock(Pipeline.class);
Whitebox.setInternalState(state, "jedisPool", mockJedisPool);
when(mockJedisPool.getResource()).thenReturn(mockJedis);
when(mockJedis.pipelined()).thenReturn(mockPipeline);
List<TridentTuple> tupleList = mockTupleList();
stateUpdater.updateState(state, tupleList, null);
for (TridentTuple t : tupleList) {
// PK goes to the key
String id = String.valueOf(t.getValueByField("ID"));
String serializedValue = new String(SERIALIZER.write(t.getValues(), null).array());
verify(mockPipeline).hset(eq(ADDITIONAL_KEY), eq(id), eq(serializedValue));
}
verify(mockPipeline).sync();
verify(mockJedis).close();
}
use of redis.clients.jedis.JedisPool in project bigbluebutton by bigbluebutton.
the class JedisConnection method dbConnect.
public static Jedis dbConnect() {
String serverIP = "127.0.0.1";
//String serverIP = getLocalIP();
//serverIP = serverIP.substring(7);
JedisPool redisPool = new JedisPool(serverIP, 6379);
try {
return redisPool.getResource();
} catch (Exception e) {
//log.error("Error in PollApplication.dbConnect():");
///log.error(e.toString());
}
//log.error("Returning NULL from dbConnect()");
return null;
}
use of redis.clients.jedis.JedisPool in project jstorm by alibaba.
the class RedisSinkBolt method prepare.
@Override
public void prepare(Map conf, TopologyContext context, OutputCollector collector) {
this.collector = collector;
GenericObjectPoolConfig pconf = new GenericObjectPoolConfig();
pconf.setMaxWaitMillis(2000);
pconf.setMaxTotal(1000);
pconf.setTestOnBorrow(false);
pconf.setTestOnReturn(false);
pconf.setTestWhileIdle(true);
pconf.setMinEvictableIdleTimeMillis(120000);
pconf.setTimeBetweenEvictionRunsMillis(60000);
pconf.setNumTestsPerEvictionRun(-1);
pool = new JedisPool(pconf, redisHost, redisPort, timeout);
}
use of redis.clients.jedis.JedisPool in project twitter-2-weibo by rjyo.
the class CommandServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
log.info("Web started.");
JedisPool pool = getPool(getServletContext());
DBHelper helper = DBHelperFactory.createHelper(pool);
// clear the queue
helper.clearQueue();
Scheduler scheduler = new Scheduler();
QueueTask task = new QueueTask();
task.setHelper(DBHelperFactory.createHelper(pool));
scheduler.schedule("*/2 * * * *", task);
scheduler.start();
log.info("Cron scheduler started.");
log.info("Worker started.");
// 1 Threads to handle the sync job
new Thread(new SyncWorkerRunnable(DBHelperFactory.createHelper(pool))).start();
}
use of redis.clients.jedis.JedisPool in project twitter-2-weibo by rjyo.
the class WorkerServlet method init.
@Override
public void init(final ServletConfig config) throws ServletException {
super.init(config);
log.info("Worker started.");
JedisPool pool = getPool(getServletContext());
// 3 Threads to handle the sync job
new Thread(new SyncWorkerRunnable(DBHelperFactory.createHelper(pool))).start();
}
Aggregations