Search in sources :

Example 1 with Config

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

the class RedissonTest method testElasticacheConnectionFail.

@Test(expected = RedisConnectionException.class)
public void testElasticacheConnectionFail() throws InterruptedException {
    Config config = new Config();
    config.useElasticacheServers().addNodeAddress("127.99.0.1:1111");
    Redisson.create(config);
    Thread.sleep(1500);
}
Also used : Config(org.redisson.config.Config) Test(org.junit.Test)

Example 2 with Config

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

the class RedissonTest method testMasterSlaveConfigJSON.

@Test
public void testMasterSlaveConfigJSON() throws IOException {
    Config c2 = new Config();
    c2.useMasterSlaveServers().setMasterAddress("123.1.1.1:1231").addSlaveAddress("82.12.47.12:1028");
    String t = c2.toJSON();
    Config c = Config.fromJSON(t);
    assertThat(c.toJSON()).isEqualTo(t);
}
Also used : Config(org.redisson.config.Config) Test(org.junit.Test)

Example 3 with Config

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

the class RedissonSessionManager method start.

@Override
public void start() throws LifecycleException {
    Config config = null;
    try {
        config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
    } catch (IOException e) {
        // trying next format
        try {
            config = Config.fromYAML(new File(configPath), getClass().getClassLoader());
        } catch (IOException e1) {
            log.error("Can't parse json config " + configPath, e);
            throw new LifecycleException("Can't parse yaml config " + configPath, e1);
        }
    }
    try {
        redisson = Redisson.create(config);
    } catch (Exception e) {
        throw new LifecycleException(e);
    }
    lifecycle.fireLifecycleEvent(START_EVENT, null);
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) Config(org.redisson.config.Config) IOException(java.io.IOException) File(java.io.File) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException)

Example 4 with Config

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

the class JCachingProvider method loadConfig.

private Config loadConfig(URI uri) {
    Config config = null;
    try {
        URL jsonUrl = null;
        if (DEFAULT_URI_PATH.equals(uri.getPath())) {
            jsonUrl = JCachingProvider.class.getResource("/redisson-jcache.json");
        } else {
            jsonUrl = uri.toURL();
        }
        if (jsonUrl == null) {
            throw new IOException();
        }
        config = Config.fromJSON(jsonUrl);
    } catch (IOException e) {
        try {
            URL yamlUrl = null;
            if (DEFAULT_URI_PATH.equals(uri.getPath())) {
                yamlUrl = JCachingProvider.class.getResource("/redisson-jcache.yaml");
            } else {
                yamlUrl = uri.toURL();
            }
            if (yamlUrl != null) {
                config = Config.fromYAML(yamlUrl);
            }
        } catch (IOException e2) {
        // skip
        }
    }
    return config;
}
Also used : Config(org.redisson.config.Config) IOException(java.io.IOException) URL(java.net.URL)

Example 5 with Config

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

the class RedissonLocalCachedMapSerializationCodecTest method createConfig.

public static Config createConfig() {
    Config config = RedissonLocalCachedMapTest.createConfig();
    config.setCodec(new SerializationCodec());
    return config;
}
Also used : Config(org.redisson.config.Config) SerializationCodec(org.redisson.codec.SerializationCodec)

Aggregations

Config (org.redisson.config.Config)182 Test (org.junit.jupiter.api.Test)109 RedissonClient (org.redisson.api.RedissonClient)69 RedisProcess (org.redisson.RedisRunner.RedisProcess)52 RandomLoadBalancer (org.redisson.connection.balancer.RandomLoadBalancer)33 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)30 ClusterProcesses (org.redisson.ClusterRunner.ClusterProcesses)23 IOException (java.io.IOException)22 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)17 RedisRunner (org.redisson.RedisRunner)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 MethodSource (org.junit.jupiter.params.provider.MethodSource)15 BaseTest (org.redisson.BaseTest)15 RandomString (net.bytebuddy.utility.RandomString)14 URL (java.net.URL)12 RedisClientConfig (org.redisson.client.RedisClientConfig)12 Test (org.junit.Test)11 RLock (org.redisson.api.RLock)10 RedissonNodeConfig (org.redisson.config.RedissonNodeConfig)10 CountDownLatch (java.util.concurrent.CountDownLatch)9