Merge branch 'master' of github.com:mrniko/redisson

pull/802/merge
Nikita 8 years ago
commit cc476d5565

@ -65,6 +65,7 @@ Articles
[Introducing Redisson Live Objects (Object Hash Mapping)](https://dzone.com/articles/introducing-redisson-live-object-object-hash-mappi)
[Java Remote Method Invocation with Redisson](https://dzone.com/articles/java-remote-method-invocation-with-redisson)
[Java Multimaps With Redis](https://dzone.com/articles/multimaps-with-redis)
[Distributed lock with Redis](https://evuvatech.com/2016/02/05/distributed-lock-with-redis/)
Quick start
===============================

@ -345,22 +345,22 @@ public class Redisson implements RedissonClient {
}
@Override
public RRemoteService getRemoteSerivce() {
public RRemoteService getRemoteService() {
return new RedissonRemoteService(this, commandExecutor);
}
@Override
public RRemoteService getRemoteSerivce(String name) {
public RRemoteService getRemoteService(String name) {
return new RedissonRemoteService(this, name, commandExecutor);
}
@Override
public RRemoteService getRemoteSerivce(Codec codec) {
public RRemoteService getRemoteService(Codec codec) {
return new RedissonRemoteService(codec, this, commandExecutor);
}
@Override
public RRemoteService getRemoteSerivce(String name, Codec codec) {
public RRemoteService getRemoteService(String name, Codec codec) {
return new RedissonRemoteService(codec, this, name, commandExecutor);
}

@ -252,7 +252,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
service.setSchedulerChannelName(schedulerChannelName);
service.setSchedulerQueueName(schedulerQueueName);
redisson.getRemoteSerivce(name, codec).register(RemoteExecutorService.class, service, workers, executor);
redisson.getRemoteService(name, codec).register(RemoteExecutorService.class, service, workers, executor);
}
@Override

@ -678,7 +678,7 @@ public interface RedissonClient {
*
* @return RemoteService object
*/
RRemoteService getRemoteSerivce();
RRemoteService getRemoteService();
/**
* Returns object for remote operations prefixed with the default name (redisson_remote_service)
@ -687,7 +687,7 @@ public interface RedissonClient {
* @param codec - codec for response and request
* @return RemoteService object
*/
RRemoteService getRemoteSerivce(Codec codec);
RRemoteService getRemoteService(Codec codec);
/**
* Returns object for remote operations prefixed with the specified name
@ -695,7 +695,7 @@ public interface RedissonClient {
* @param name - the name used as the Redis key prefix for the services
* @return RemoteService object
*/
RRemoteService getRemoteSerivce(String name);
RRemoteService getRemoteService(String name);
/**
* Returns object for remote operations prefixed with the specified name
@ -705,7 +705,7 @@ public interface RedissonClient {
* @param codec - codec for response and request
* @return RemoteService object
*/
RRemoteService getRemoteSerivce(String name, Codec codec);
RRemoteService getRemoteService(String name, Codec codec);
/**
* Return batch object which executes group of

@ -24,8 +24,6 @@ import org.redisson.codec.SerializationCodec;
import org.redisson.remote.RemoteServiceAckTimeoutException;
import org.redisson.remote.RemoteServiceTimeoutException;
import io.netty.util.concurrent.Future;
public class RedissonRemoteServiceTest extends BaseTest {
public static class Pojo {
@ -193,10 +191,10 @@ public class RedissonRemoteServiceTest extends BaseTest {
AtomicInteger iterations = new AtomicInteger();
ExecutorService executor = Executors.newSingleThreadExecutor();
r1.getKeys().flushall();
r1.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl(iterations), 1, executor);
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl(iterations), 1, executor);
RedissonClient r2 = createInstance();
RemoteInterfaceAsync ri = r2.getRemoteSerivce().get(RemoteInterfaceAsync.class);
RemoteInterfaceAsync ri = r2.getRemoteService().get(RemoteInterfaceAsync.class);
RFuture<Void> f = ri.cancelMethod();
Thread.sleep(500);
@ -214,21 +212,21 @@ public class RedissonRemoteServiceTest extends BaseTest {
@Test(expected = IllegalArgumentException.class)
public void testWrongMethodAsync() throws InterruptedException {
redisson.getRemoteSerivce().get(RemoteInterfaceWrongMethodAsync.class);
redisson.getRemoteService().get(RemoteInterfaceWrongMethodAsync.class);
}
@Test(expected = IllegalArgumentException.class)
public void testWrongParamsAsync() throws InterruptedException {
redisson.getRemoteSerivce().get(RemoteInterfaceWrongParamsAsync.class);
redisson.getRemoteService().get(RemoteInterfaceWrongParamsAsync.class);
}
@Test
public void testAsync() throws InterruptedException {
RedissonClient r1 = createInstance();
r1.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RedissonClient r2 = createInstance();
RemoteInterfaceAsync ri = r2.getRemoteSerivce().get(RemoteInterfaceAsync.class);
RemoteInterfaceAsync ri = r2.getRemoteService().get(RemoteInterfaceAsync.class);
RFuture<Void> f = ri.voidMethod("someName", 100L);
f.sync();
@ -244,10 +242,10 @@ public class RedissonRemoteServiceTest extends BaseTest {
public void testExecutorAsync() throws InterruptedException {
RedissonClient r1 = createInstance();
ExecutorService executor = Executors.newSingleThreadExecutor();
r1.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl(), 1, executor);
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl(), 1, executor);
RedissonClient r2 = createInstance();
RemoteInterfaceAsync ri = r2.getRemoteSerivce().get(RemoteInterfaceAsync.class);
RemoteInterfaceAsync ri = r2.getRemoteService().get(RemoteInterfaceAsync.class);
RFuture<Void> f = ri.voidMethod("someName", 100L);
f.sync();
@ -284,7 +282,7 @@ public class RedissonRemoteServiceTest extends BaseTest {
// - check if concurrency is greater than what was allowed, and if yes set the concurrencyOfOneIsExceeded flag
// - wait 2s
// - decr the concurrency
server.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl() {
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl() {
@Override
public void timeoutMethod() throws InterruptedException {
try {
@ -312,7 +310,7 @@ public class RedissonRemoteServiceTest extends BaseTest {
@Override
public void run() {
try {
RemoteInterface ri = client.getRemoteSerivce().get(RemoteInterface.class, clientAmount * 3, TimeUnit.SECONDS, clientAmount * 3, TimeUnit.SECONDS);
RemoteInterface ri = client.getRemoteService().get(RemoteInterface.class, clientAmount * 3, TimeUnit.SECONDS, clientAmount * 3, TimeUnit.SECONDS);
readyLatch.await();
ri.timeoutMethod();
} catch (InterruptedException e) {
@ -348,10 +346,10 @@ public class RedissonRemoteServiceTest extends BaseTest {
@Test(expected = RemoteServiceTimeoutException.class)
public void testTimeout() throws InterruptedException {
RedissonClient r1 = createInstance();
r1.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RedissonClient r2 = createInstance();
RemoteInterface ri = r2.getRemoteSerivce().get(RemoteInterface.class, 1, TimeUnit.SECONDS);
RemoteInterface ri = r2.getRemoteService().get(RemoteInterface.class, 1, TimeUnit.SECONDS);
try {
ri.timeoutMethod();
@ -364,10 +362,10 @@ public class RedissonRemoteServiceTest extends BaseTest {
@Test
public void testInvocations() {
RedissonClient r1 = createInstance();
r1.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RedissonClient r2 = createInstance();
RemoteInterface ri = r2.getRemoteSerivce().get(RemoteInterface.class);
RemoteInterface ri = r2.getRemoteService().get(RemoteInterface.class);
ri.voidMethod("someName", 100L);
assertThat(ri.resultMethod(100L)).isEqualTo(200);
@ -396,11 +394,11 @@ public class RedissonRemoteServiceTest extends BaseTest {
RedissonClient server = createInstance();
RedissonClient client = createInstance();
server.getRemoteSerivce("MyServiceNamespace").register(RemoteInterface.class, new RemoteImpl());
server.getRemoteService("MyServiceNamespace").register(RemoteInterface.class, new RemoteImpl());
RemoteInterface serviceRemoteInterface = client.getRemoteSerivce("MyServiceNamespace").get(RemoteInterface.class);
RemoteInterface otherServiceRemoteInterface = client.getRemoteSerivce("MyOtherServiceNamespace").get(RemoteInterface.class);
RemoteInterface defaultServiceRemoteInterface = client.getRemoteSerivce().get(RemoteInterface.class);
RemoteInterface serviceRemoteInterface = client.getRemoteService("MyServiceNamespace").get(RemoteInterface.class);
RemoteInterface otherServiceRemoteInterface = client.getRemoteService("MyOtherServiceNamespace").get(RemoteInterface.class);
RemoteInterface defaultServiceRemoteInterface = client.getRemoteService().get(RemoteInterface.class);
assertThat(serviceRemoteInterface.resultMethod(21L)).isEqualTo(42L);
@ -426,7 +424,7 @@ public class RedissonRemoteServiceTest extends BaseTest {
public void testProxyToStringEqualsAndHashCode() {
RedissonClient client = createInstance();
try {
RemoteInterface service = client.getRemoteSerivce().get(RemoteInterface.class);
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class);
try {
System.out.println(service.toString());
@ -456,9 +454,9 @@ public class RedissonRemoteServiceTest extends BaseTest {
RedissonClient server = Redisson.create(createConfig().setCodec(new FstCodec()));
RedissonClient client = Redisson.create(createConfig().setCodec(new FstCodec()));
try {
server.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RemoteInterface service = client.getRemoteSerivce().get(RemoteInterface.class);
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class);
assertThat(service.resultMethod(21L)).as("Should be compatible with FstCodec").isEqualTo(42L);
@ -486,9 +484,9 @@ public class RedissonRemoteServiceTest extends BaseTest {
RedissonClient server = Redisson.create(createConfig().setCodec(new SerializationCodec()));
RedissonClient client = Redisson.create(createConfig().setCodec(new SerializationCodec()));
try {
server.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RemoteInterface service = client.getRemoteSerivce().get(RemoteInterface.class);
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class);
try {
assertThat(service.resultMethod(21L)).isEqualTo(42L);
@ -522,11 +520,11 @@ public class RedissonRemoteServiceTest extends BaseTest {
RedissonClient server = createInstance();
RedissonClient client = createInstance();
try {
server.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
// no ack but an execution timeout of 1 second
RemoteInvocationOptions options = RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.SECONDS);
RemoteInterface service = client.getRemoteSerivce().get(RemoteInterface.class, options);
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class, options);
service.voidMethod("noAck", 100L);
assertThat(service.resultMethod(21L)).isEqualTo(42);
@ -563,11 +561,11 @@ public class RedissonRemoteServiceTest extends BaseTest {
RedissonClient server = createInstance();
RedissonClient client = createInstance();
try {
server.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
// no ack but an execution timeout of 1 second
RemoteInvocationOptions options = RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.SECONDS);
RemoteInterfaceAsync service = client.getRemoteSerivce().get(RemoteInterfaceAsync.class, options);
RemoteInterfaceAsync service = client.getRemoteService().get(RemoteInterfaceAsync.class, options);
service.voidMethod("noAck", 100L).get();
assertThat(service.resultMethod(21L).get()).isEqualTo(42);
@ -604,11 +602,11 @@ public class RedissonRemoteServiceTest extends BaseTest {
RedissonClient server = createInstance();
RedissonClient client = createInstance();
try {
server.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
// fire and forget with an ack timeout of 1 sec
RemoteInvocationOptions options = RemoteInvocationOptions.defaults().expectAckWithin(1, TimeUnit.SECONDS).noResult();
RemoteInterface service = client.getRemoteSerivce().get(RemoteInterface.class, options);
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class, options);
service.voidMethod("noResult", 100L);
@ -653,12 +651,12 @@ public class RedissonRemoteServiceTest extends BaseTest {
RedissonClient server = createInstance();
RedissonClient client = createInstance();
try {
server.getRemoteSerivce().register(RemoteInterface.class, new RemoteImpl());
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
// no ack fire and forget
RemoteInvocationOptions options = RemoteInvocationOptions.defaults().noAck().noResult();
RemoteInterface service = client.getRemoteSerivce().get(RemoteInterface.class, options);
RemoteInterface invalidService = client.getRemoteSerivce("Invalid").get(RemoteInterface.class, options);
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class, options);
RemoteInterface invalidService = client.getRemoteService("Invalid").get(RemoteInterface.class, options);
service.voidMethod("noAck/noResult", 100L);

Loading…
Cancel
Save