|
|
@ -7,10 +7,28 @@ import java.util.List;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import org.redisson.core.MessageListener;
|
|
|
|
import org.redisson.core.RMap;
|
|
|
|
import org.redisson.core.RMap;
|
|
|
|
|
|
|
|
import org.redisson.core.RTopic;
|
|
|
|
|
|
|
|
|
|
|
|
public class TimeoutTest extends BaseTest {
|
|
|
|
public class TimeoutTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
|
|
|
|
public void testPubSub() throws InterruptedException, ExecutionException {
|
|
|
|
|
|
|
|
RTopic<String> topic = redisson.getTopic("simple");
|
|
|
|
|
|
|
|
topic.addListener(new MessageListener<String>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onMessage(String channel, String msg) {
|
|
|
|
|
|
|
|
System.out.println("msg: " + msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
|
|
|
topic.publish("test" + i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
// @Test
|
|
|
|
public void testReplaceTimeout() throws InterruptedException, ExecutionException {
|
|
|
|
public void testReplaceTimeout() throws InterruptedException, ExecutionException {
|
|
|
|
RMap<Integer, Integer> map = redisson.getMap("simple");
|
|
|
|
RMap<Integer, Integer> map = redisson.getMap("simple");
|
|
|
@ -26,7 +44,7 @@ public class TimeoutTest extends BaseTest {
|
|
|
|
System.out.println(r);
|
|
|
|
System.out.println(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
// @Test
|
|
|
|
public void testPutAsyncTimeout() throws InterruptedException, ExecutionException {
|
|
|
|
public void testPutAsyncTimeout() throws InterruptedException, ExecutionException {
|
|
|
|
RMap<Integer, Integer> map = redisson.getMap("simple");
|
|
|
|
RMap<Integer, Integer> map = redisson.getMap("simple");
|
|
|
@ -37,11 +55,11 @@ public class TimeoutTest extends BaseTest {
|
|
|
|
futures.add(future);
|
|
|
|
futures.add(future);
|
|
|
|
System.out.println(i);
|
|
|
|
System.out.println(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (Future<Integer> future : futures) {
|
|
|
|
for (Future<Integer> future : futures) {
|
|
|
|
future.get();
|
|
|
|
future.get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
Integer r = map.get(i);
|
|
|
|
Integer r = map.get(i);
|
|
|
|
System.out.println(r);
|
|
|
|
System.out.println(r);
|
|
|
@ -55,19 +73,19 @@ public class TimeoutTest extends BaseTest {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
map.put(i, i*1000);
|
|
|
|
map.put(i, i*1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
Future<Integer> future = map.getAsync(i);
|
|
|
|
Future<Integer> future = map.getAsync(i);
|
|
|
|
Thread.sleep(1000);
|
|
|
|
Thread.sleep(1000);
|
|
|
|
System.out.println(i);
|
|
|
|
System.out.println(i);
|
|
|
|
futures.add(future);
|
|
|
|
futures.add(future);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (Future<Integer> future : futures) {
|
|
|
|
for (Future<Integer> future : futures) {
|
|
|
|
Integer res = future.get();
|
|
|
|
Integer res = future.get();
|
|
|
|
System.out.println(res);
|
|
|
|
System.out.println(res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|