Search in sources :

Example 16 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testBatchBigRequest.

@ParameterizedTest
@MethodSource("data")
public void testBatchBigRequest(BatchOptions batchOptions) {
    Config config = BaseTest.createConfig();
    config.useSingleServer().setTimeout(15000);
    RedissonRxClient redisson = Redisson.create(config).rxJava();
    RBatchRx batch = redisson.createBatch(batchOptions);
    for (int i = 0; i < 210; i++) {
        batch.getMap("test").fastPut("1", "2");
        batch.getMap("test").fastPut("2", "3");
        batch.getMap("test").put("2", "5");
        batch.getAtomicLong("counter").incrementAndGet();
        batch.getAtomicLong("counter").incrementAndGet();
    }
    BatchResult<?> res = sync(batch.execute());
    Assertions.assertEquals(210 * 5, res.getResponses().size());
    redisson.shutdown();
}
Also used : Config(org.redisson.config.Config) RBatchRx(org.redisson.api.RBatchRx) RedissonRxClient(org.redisson.api.RedissonRxClient) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 17 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testTwice.

@ParameterizedTest
@MethodSource("data")
public void testTwice(BatchOptions batchOptions) {
    Assertions.assertThrows(IllegalStateException.class, () -> {
        RBatchRx batch = redisson.createBatch(batchOptions);
        batch.getMap("test").put("1", "2");
        sync(batch.execute());
        sync(batch.execute());
    });
}
Also used : RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 18 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testSkipResult.

@ParameterizedTest
@MethodSource("data")
public void testSkipResult(BatchOptions batchOptions) {
    Assumptions.assumeTrue(RedisRunner.getDefaultRedisServerInstance().getRedisVersion().compareTo("3.2.0") > 0);
    batchOptions.skipResult();
    RBatchRx batch = redisson.createBatch(batchOptions);
    batch.getBucket("A1").set("001");
    batch.getBucket("A2").set("001");
    batch.getBucket("A3").set("001");
    batch.getKeys().delete("A1");
    batch.getKeys().delete("A2");
    sync(batch.execute());
    assertThat(sync(redisson.getBucket("A1").isExists())).isFalse();
    assertThat(sync(redisson.getBucket("A3").isExists())).isTrue();
}
Also used : RBatchRx(org.redisson.api.RBatchRx) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 19 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testBatchRedirect.

// @Test
public void testBatchRedirect(BatchOptions batchOptions) {
    RBatchRx batch = redisson.createBatch(batchOptions);
    for (int i = 0; i < 5; i++) {
        batch.getMap("" + i).fastPut("" + i, i);
    }
    sync(batch.execute());
    batch = redisson.createBatch(batchOptions);
    for (int i = 0; i < 1; i++) {
        batch.getMap("" + i).size();
        batch.getMap("" + i).containsValue("" + i);
        batch.getMap("" + i).containsValue(i);
    }
    BatchResult<?> t = sync(batch.execute());
    System.out.println(t);
}
Also used : RBatchRx(org.redisson.api.RBatchRx)

Example 20 with RBatchRx

use of org.redisson.api.RBatchRx in project redisson by redisson.

the class RedissonBatchRxTest method testPerformance.

@ParameterizedTest
@MethodSource("data")
public void testPerformance(BatchOptions batchOptions) {
    Assertions.assertTimeout(Duration.ofSeconds(20), () -> {
        RMapRx<String, String> map = redisson.getMap("map");
        Map<String, String> m = new HashMap<String, String>();
        for (int j = 0; j < 1000; j++) {
            m.put("" + j, "" + j);
        }
        sync(map.putAll(m));
        for (int i = 0; i < 10000; i++) {
            RBatchRx batch = redisson.createBatch(batchOptions);
            RMapRx<String, String> m1 = batch.getMap("map");
            Single<Map<String, String>> f = m1.getAll(m.keySet());
            sync(batch.execute());
            assertThat(sync(f)).hasSize(1000);
        }
    });
}
Also used : HashMap(java.util.HashMap) RBatchRx(org.redisson.api.RBatchRx) HashMap(java.util.HashMap) Map(java.util.Map) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

RBatchRx (org.redisson.api.RBatchRx)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 MethodSource (org.junit.jupiter.params.provider.MethodSource)18 RedissonRxClient (org.redisson.api.RedissonRxClient)5 Config (org.redisson.config.Config)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 HashMap (java.util.HashMap)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 ClusterRunner (org.redisson.ClusterRunner)2 ClusterProcesses (org.redisson.ClusterRunner.ClusterProcesses)2 RedisRunner (org.redisson.RedisRunner)2 Completable (io.reactivex.rxjava3.core.Completable)1 Single (io.reactivex.rxjava3.core.Single)1 IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Test (org.junit.jupiter.api.Test)1 BaseTest (org.redisson.BaseTest)1