use of org.redisson.config.Config in project redisson by redisson.
the class BaseTest method createConfig.
public static Config createConfig() {
// String redisAddress = System.getProperty("redisAddress");
// if (redisAddress == null) {
// redisAddress = "127.0.0.1:6379";
// }
Config config = new Config();
// config.setCodec(new MsgPackJacksonCodec());
// config.useSentinelServers().setMasterName("mymaster").addSentinelAddress("127.0.0.1:26379", "127.0.0.1:26389");
// config.useClusterServers().addNodeAddress("127.0.0.1:7004", "127.0.0.1:7001", "127.0.0.1:7000");
config.useSingleServer().setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
// .addSlaveAddress("127.0.0.1:6389");
return config;
}
use of org.redisson.config.Config in project redisson by redisson.
the class CommandHandlersTest method testDecoder.
@Test(expected = RedisException.class)
public void testDecoder() {
redisson.getBucket("1234").set("1234");
Config config = createConfig();
config.setCodec(new ErrorsCodec());
RedissonClient redisson = Redisson.create(config);
redisson.getBucket("1234").get();
}
use of org.redisson.config.Config in project redisson by redisson.
the class BaseConcurrentTest method testMultiInstanceConcurrency.
protected void testMultiInstanceConcurrency(int iterations, final RedissonRunnable runnable) throws InterruptedException {
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
NioEventLoopGroup group = new NioEventLoopGroup();
final Map<Integer, RedissonClient> instances = new HashMap<Integer, RedissonClient>();
for (int i = 0; i < iterations; i++) {
Config config = createConfig();
config.setEventLoopGroup(group);
RedissonClient instance = Redisson.create(config);
instances.put(i, instance);
}
long watch = System.currentTimeMillis();
for (int i = 0; i < iterations; i++) {
final int n = i;
executor.execute(new Runnable() {
@Override
public void run() {
RedissonClient redisson = instances.get(n);
runnable.run(redisson);
}
});
}
executor.shutdown();
Assert.assertTrue(executor.awaitTermination(RedissonRuntimeEnvironment.isTravis ? 10 : 3, TimeUnit.MINUTES));
System.out.println("multi: " + (System.currentTimeMillis() - watch));
executor = Executors.newCachedThreadPool();
for (final RedissonClient redisson : instances.values()) {
executor.execute(new Runnable() {
@Override
public void run() {
redisson.shutdown();
}
});
}
group.shutdownGracefully();
executor.shutdown();
Assert.assertTrue(executor.awaitTermination(5, TimeUnit.MINUTES));
}
use of org.redisson.config.Config in project redisson by redisson.
the class Redisson method create.
/**
* Create sync/async Redisson instance with default config
*
* @return Redisson instance
*/
public static RedissonClient create() {
Config config = new Config();
config.useSingleServer().setAddress("127.0.0.1:6379");
// config.useClusterServers().addNodeAddress("127.0.0.1:7000");
return create(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);
}
Aggregations