Fixed - RObject.migrate method.

pull/1423/head
Nikita 7 years ago
parent dece260e2b
commit 601ba4d16f

@ -94,13 +94,13 @@ public abstract class RedissonObject implements RObject {
}
@Override
public void migrate(String host, int port, int database) {
get(migrateAsync(host, port, database));
public void migrate(String host, int port, int database, long timeout) {
get(migrateAsync(host, port, database, timeout));
}
@Override
public RFuture<Void> migrateAsync(String host, int port, int database) {
return commandExecutor.writeAsync(getName(), RedisCommands.MIGRATE, host, port, getName(), database);
public RFuture<Void> migrateAsync(String host, int port, int database, long timeout) {
return commandExecutor.writeAsync(getName(), RedisCommands.MIGRATE, host, port, getName(), database, timeout);
}
@Override

@ -38,8 +38,9 @@ public interface RObject extends RObjectAsync {
* @param host - destination host
* @param port - destination port
* @param database - destination database
* @param timeout - maximum idle time in any moment of the communication with the destination instance in milliseconds
*/
void migrate(String host, int port, int database);
void migrate(String host, int port, int database, long timeout);
/**
* Move object to another database

@ -37,9 +37,10 @@ public interface RObjectAsync {
* @param host - destination host
* @param port - destination port
* @param database - destination database
* @param timeout - maximum idle time in any moment of the communication with the destination instance in milliseconds
* @return void
*/
RFuture<Void> migrateAsync(String host, int port, int database);
RFuture<Void> migrateAsync(String host, int port, int database, long timeout);
/**
* Move object to another database in async mode

@ -2,13 +2,18 @@ package org.redisson;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
import org.redisson.RedisRunner.FailedToStartRedisException;
import org.redisson.RedisRunner.RedisProcess;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
public class RedissonBucketTest extends BaseTest {
@ -113,6 +118,31 @@ public class RedissonBucketTest extends BaseTest {
Assert.assertFalse(newBucket.renamenx("test2"));
}
@Test
public void testMigrate() throws FailedToStartRedisException, IOException, InterruptedException {
RedisProcess runner = new RedisRunner()
.appendonly(true)
.randomDir()
.randomPort()
.run();
RBucket<String> bucket = redisson.getBucket("test");
bucket.set("someValue");
bucket.migrate(runner.getRedisServerBindAddress(), runner.getRedisServerPort(), 0, 5000);
Config config = new Config();
config.useSingleServer().setAddress(runner.getRedisServerAddressAndPort());
RedissonClient r = Redisson.create(config);
RBucket<String> bucket2 = r.getBucket("test");
assertThat(bucket2.get()).isEqualTo("someValue");
assertThat(bucket.isExists()).isFalse();
runner.stop();
}
@Test
public void testRename() {
RBucket<String> bucket = redisson.getBucket("test");

Loading…
Cancel
Save