Search in sources :

Example 36 with Config

use of org.redisson.config.Config in project redisson by redisson.

the class RedissonTwoLockedThread method before.

@Before
public void before() throws IOException, InterruptedException {
    if (RedissonRuntimeEnvironment.isTravis) {
        RedisRunner.startDefaultRedisServerInstance();
        redisson = createInstance();
    }
    Config config = BaseTest.createConfig();
    config.setCodec(codec);
    redisson = Redisson.create(config);
}
Also used : Config(org.redisson.config.Config) Before(org.junit.Before)

Example 37 with Config

use of org.redisson.config.Config in project redisson by redisson.

the class RedissonExecutorServiceTest method before.

@Before
@Override
public void before() throws IOException, InterruptedException {
    super.before();
    if (RedissonRuntimeEnvironment.isTravis) {
        Config config = createConfig();
        RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
        nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("test", 1));
        node = RedissonNode.create(nodeConfig);
        node.start();
    }
}
Also used : Config(org.redisson.config.Config) BaseTest.createConfig(org.redisson.BaseTest.createConfig) RedissonNodeConfig(org.redisson.config.RedissonNodeConfig) RedissonNodeConfig(org.redisson.config.RedissonNodeConfig) Before(org.junit.Before)

Example 38 with Config

use of org.redisson.config.Config in project redisson by redisson.

the class RedissonTest method testMemoryScript.

@Test(expected = RedisOutOfMemoryException.class)
public void testMemoryScript() throws IOException, InterruptedException {
    RedisProcess p = redisTestSmallMemory();
    Config config = new Config();
    config.useSingleServer().setAddress(p.getRedisServerAddressAndPort()).setTimeout(100000);
    RedissonClient r = null;
    try {
        r = Redisson.create(config);
        r.getKeys().flushall();
        for (int i = 0; i < 10000; i++) {
            r.getMap("test").put("" + i, "" + i);
        }
    } finally {
        r.shutdown();
        p.stop();
    }
}
Also used : RedissonClient(org.redisson.api.RedissonClient) RedisProcess(org.redisson.RedisRunner.RedisProcess) Config(org.redisson.config.Config) Test(org.junit.Test)

Example 39 with Config

use of org.redisson.config.Config in project redisson by redisson.

the class RedissonTest method testSmallPool.

@Test
public void testSmallPool() throws InterruptedException {
    Config config = new Config();
    config.useSingleServer().setConnectionMinimumIdleSize(3).setConnectionPoolSize(3).setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
    RedissonClient localRedisson = Redisson.create(config);
    RMap<String, String> map = localRedisson.getMap("test");
    ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
    long start = System.currentTimeMillis();
    int iterations = 500_000;
    for (int i = 0; i < iterations; i++) {
        final int j = i;
        executor.execute(new Runnable() {

            @Override
            public void run() {
                map.put("" + j, "" + j);
            }
        });
    }
    executor.shutdown();
    Assert.assertTrue(executor.awaitTermination(10, TimeUnit.MINUTES));
    assertThat(map.size()).isEqualTo(iterations);
    localRedisson.shutdown();
}
Also used : RedissonClient(org.redisson.api.RedissonClient) Config(org.redisson.config.Config) ExecutorService(java.util.concurrent.ExecutorService) Test(org.junit.Test)

Example 40 with Config

use of org.redisson.config.Config in project redisson by redisson.

the class RedissonTest method testClusterConfig.

@Test
public void testClusterConfig() throws IOException {
    Config originalConfig = new Config();
    originalConfig.useClusterServers().addNodeAddress("123.123.1.23:1902", "9.3.1.0:1902");
    String t = originalConfig.toJSON();
    Config c = Config.fromJSON(t);
    System.out.println(t);
    assertThat(c.toJSON()).isEqualTo(t);
}
Also used : Config(org.redisson.config.Config) Test(org.junit.Test)

Aggregations

Config (org.redisson.config.Config)68 Test (org.junit.Test)51 RedissonClient (org.redisson.api.RedissonClient)44 RedisProcess (org.redisson.RedisRunner.RedisProcess)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 IOException (java.io.IOException)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 RedissonNodeConfig (org.redisson.config.RedissonNodeConfig)4 HashMap (java.util.HashMap)3 ExecutorService (java.util.concurrent.ExecutorService)3 Before (org.junit.Before)3 SerializationCodec (org.redisson.codec.SerializationCodec)3 File (java.io.File)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 LifecycleException (org.apache.catalina.LifecycleException)2 BeforeClass (org.junit.BeforeClass)2 BaseTest.createConfig (org.redisson.BaseTest.createConfig)2 RLock (org.redisson.api.RLock)2 JsonJacksonCodec (org.redisson.codec.JsonJacksonCodec)2