Search in sources :

Example 61 with Pipeline

use of redis.clients.jedis.Pipeline in project jedis by xetorthio.

the class PipeliningTest method testCloseableWithMulti.

@Test
public void testCloseableWithMulti() throws IOException {
    // we need to test with fresh instance of Jedis
    Jedis jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
    jedis2.auth("foobared");
    Pipeline pipeline = jedis2.pipelined();
    Response<String> retFuture1 = pipeline.set("a", "1");
    Response<String> retFuture2 = pipeline.set("b", "2");
    pipeline.multi();
    pipeline.set("a", "a");
    pipeline.set("b", "b");
    pipeline.close();
    try {
        pipeline.exec();
        fail("close should discard transaction");
    } catch (JedisDataException e) {
        assertTrue(e.getMessage().contains("EXEC without MULTI"));
    // pass
    }
    // it shouldn't meet any exception
    retFuture1.get();
    retFuture2.get();
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisDataException(redis.clients.jedis.exceptions.JedisDataException) Pipeline(redis.clients.jedis.Pipeline) Test(org.junit.Test)

Example 62 with Pipeline

use of redis.clients.jedis.Pipeline in project jedis by xetorthio.

the class PipeliningTest method testResetStateWhenInPipeline.

@Test
public void testResetStateWhenInPipeline() {
    Pipeline pipeline = jedis.pipelined();
    pipeline.set("foo", "3");
    jedis.resetState();
    String result = jedis.get("foo");
    assertEquals(result, "3");
}
Also used : Pipeline(redis.clients.jedis.Pipeline) Test(org.junit.Test)

Example 63 with Pipeline

use of redis.clients.jedis.Pipeline in project jedis by xetorthio.

the class PipeliningTest method pipelineMultiShoudThrowJedisDataExceptionWhenAlreadyInMulti.

@Test(expected = JedisDataException.class)
public void pipelineMultiShoudThrowJedisDataExceptionWhenAlreadyInMulti() {
    Pipeline pipeline = jedis.pipelined();
    pipeline.multi();
    pipeline.set("foo", "3");
    pipeline.multi();
}
Also used : Pipeline(redis.clients.jedis.Pipeline) Test(org.junit.Test)

Example 64 with Pipeline

use of redis.clients.jedis.Pipeline in project jedis by xetorthio.

the class PipeliningTest method testSyncWithNoCommandQueued.

@Test
public void testSyncWithNoCommandQueued() {
    // we need to test with fresh instance of Jedis
    Jedis jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
    Pipeline pipeline = jedis2.pipelined();
    pipeline.sync();
    jedis2.close();
    jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
    pipeline = jedis2.pipelined();
    List<Object> resp = pipeline.syncAndReturnAll();
    assertTrue(resp.isEmpty());
    jedis2.close();
}
Also used : Jedis(redis.clients.jedis.Jedis) Pipeline(redis.clients.jedis.Pipeline) Test(org.junit.Test)

Example 65 with Pipeline

use of redis.clients.jedis.Pipeline in project jedis by xetorthio.

the class PipeliningTest method testEvalKeyAndArg.

@Test
public void testEvalKeyAndArg() {
    String key = "test";
    String arg = "3";
    String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";
    Pipeline p = jedis.pipelined();
    p.set(key, "0");
    Response<Object> result0 = p.eval(script, Arrays.asList(key), Arrays.asList(arg));
    p.incr(key);
    Response<Object> result1 = p.eval(script, Arrays.asList(key), Arrays.asList(arg));
    Response<String> result2 = p.get(key);
    p.sync();
    assertNull(result0.get());
    assertNull(result1.get());
    assertEquals("13", result2.get());
}
Also used : Pipeline(redis.clients.jedis.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (redis.clients.jedis.Pipeline)77 Test (org.junit.Test)72 Jedis (redis.clients.jedis.Jedis)12 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Map (java.util.Map)6 JedisDataException (redis.clients.jedis.exceptions.JedisDataException)6 HashMap (java.util.HashMap)5 Set (java.util.Set)3 Response (redis.clients.jedis.Response)3 LinkedHashMap (java.util.LinkedHashMap)2 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)1 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)1 RedisDataTypeDescription (org.apache.storm.redis.common.mapper.RedisDataTypeDescription)1 RedisClusterStateUpdater (org.apache.storm.redis.trident.state.RedisClusterStateUpdater)1 RedisState (org.apache.storm.redis.trident.state.RedisState)1 RedisStateUpdater (org.apache.storm.redis.trident.state.RedisStateUpdater)1 ISqlTridentDataSource (org.apache.storm.sql.runtime.ISqlTridentDataSource)1 StateUpdater (org.apache.storm.trident.state.StateUpdater)1 TridentTuple (org.apache.storm.trident.tuple.TridentTuple)1