use of org.redisson.api.RedissonClient in project redisson by redisson.
the class RedissonTest method testShutdown.
@Test
public void testShutdown() {
Config config = new Config();
config.useSingleServer().setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
RedissonClient r = Redisson.create(config);
Assert.assertFalse(r.isShuttingDown());
Assert.assertFalse(r.isShutdown());
r.shutdown();
Assert.assertTrue(r.isShuttingDown());
Assert.assertTrue(r.isShutdown());
}
use of org.redisson.api.RedissonClient in project redisson by redisson.
the class RedissonTest method testSingleConfigYAML.
@Test
public void testSingleConfigYAML() throws IOException {
RedissonClient r = BaseTest.createInstance();
String t = r.getConfig().toYAML();
Config c = Config.fromYAML(t);
assertThat(c.toYAML()).isEqualTo(t);
}
use of org.redisson.api.RedissonClient in project redisson by redisson.
the class RedissonTest method testMemoryCommand.
@Test(expected = RedisOutOfMemoryException.class)
public void testMemoryCommand() 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").fastPut("" + i, "" + i);
}
} finally {
r.shutdown();
p.stop();
}
}
use of org.redisson.api.RedissonClient 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();
}
}
use of org.redisson.api.RedissonClient 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();
}
Aggregations