Search in sources :

Example 1 with ShardStatus

use of com.ctrip.xpipe.redis.core.meta.ShardStatus in project x-pipe by ctripcorp.

the class RedisKeeperServerStateBackupTest method beforeRedisKeeperServerStateTest.

@Before
public void beforeRedisKeeperServerStateTest() throws Exception {
    activeKeeperMeta = createKeeperMeta();
    activeKeeperMeta.setPort(redisKeeperServer.getCurrentKeeperMeta().getPort() + 1);
    ShardStatus shardStatus = createShardStatus(activeKeeperMeta, null, redisMasterMeta);
    backup = new RedisKeeperServerStateBackup(redisKeeperServer);
    backup.setShardStatus(shardStatus);
}
Also used : ShardStatus(com.ctrip.xpipe.redis.core.meta.ShardStatus) Before(org.junit.Before)

Example 2 with ShardStatus

use of com.ctrip.xpipe.redis.core.meta.ShardStatus in project x-pipe by ctripcorp.

the class RedisKeeperServerStateActiveTest method beforeRedisKeeperServerStateTest.

@Before
public void beforeRedisKeeperServerStateTest() throws Exception {
    ShardStatus shardStatus = createShardStatus(redisKeeperServer.getCurrentKeeperMeta(), null, redisMasterMeta);
    active = new RedisKeeperServerStateActive(redisKeeperServer);
    active.setShardStatus(shardStatus);
}
Also used : ShardStatus(com.ctrip.xpipe.redis.core.meta.ShardStatus) Before(org.junit.Before)

Example 3 with ShardStatus

use of com.ctrip.xpipe.redis.core.meta.ShardStatus in project x-pipe by ctripcorp.

the class RedisKeeperServerStateUnknownTest method testActive.

@Test
public void testActive() throws IOException {
    // active
    KeeperMeta keeperMeta = redisKeeperServer.getCurrentKeeperMeta();
    ShardStatus shardStatus = createShardStatus(keeperMeta, null, redisMasterMeta);
    unknown.setShardStatus(shardStatus);
    RedisKeeperServerState newState = redisKeeperServer.getRedisKeeperServerState();
    Assert.assertTrue(newState instanceof RedisKeeperServerStateActive);
    Assert.assertEquals(new InetSocketAddress(redisMasterMeta.getIp(), redisMasterMeta.getPort()), newState.getMaster().getSocketAddress());
}
Also used : RedisKeeperServerState(com.ctrip.xpipe.redis.keeper.RedisKeeperServerState) ShardStatus(com.ctrip.xpipe.redis.core.meta.ShardStatus) InetSocketAddress(java.net.InetSocketAddress) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta) Test(org.junit.Test)

Example 4 with ShardStatus

use of com.ctrip.xpipe.redis.core.meta.ShardStatus in project x-pipe by ctripcorp.

the class RedisKeeperServerStateUnknownTest method testBackup.

@Test
public void testBackup() throws IOException {
    // active
    KeeperMeta keeperMeta = SerializationUtils.clone(redisKeeperServer.getCurrentKeeperMeta());
    keeperMeta.setPort(keeperMeta.getPort() + 1);
    ShardStatus shardStatus = createShardStatus(keeperMeta, null, redisMasterMeta);
    unknown.setShardStatus(shardStatus);
    RedisKeeperServerState newState = redisKeeperServer.getRedisKeeperServerState();
    Assert.assertTrue(newState instanceof RedisKeeperServerStateBackup);
    Assert.assertEquals(new InetSocketAddress(keeperMeta.getIp(), keeperMeta.getPort()), newState.getMaster().getSocketAddress());
}
Also used : RedisKeeperServerState(com.ctrip.xpipe.redis.keeper.RedisKeeperServerState) ShardStatus(com.ctrip.xpipe.redis.core.meta.ShardStatus) InetSocketAddress(java.net.InetSocketAddress) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta) Test(org.junit.Test)

Example 5 with ShardStatus

use of com.ctrip.xpipe.redis.core.meta.ShardStatus in project x-pipe by ctripcorp.

the class RedisKeeperServerStateActiveTest method getMaster.

@Test
public void getMaster() throws IOException, SAXException {
    Assert.assertEquals(new InetSocketAddress(redisMasterMeta.getIp(), redisMasterMeta.getPort()), active.getMaster().getSocketAddress());
    KeeperMeta upstreamKeeper = createKeeperMeta();
    upstreamKeeper.setPort(redisMasterMeta.getPort() + 1);
    ShardStatus newStatus = createShardStatus(redisKeeperServer.getCurrentKeeperMeta(), upstreamKeeper, null);
    active.setShardStatus(newStatus);
    Assert.assertEquals(new InetSocketAddress(upstreamKeeper.getIp(), upstreamKeeper.getPort()), active.getMaster().getSocketAddress());
}
Also used : ShardStatus(com.ctrip.xpipe.redis.core.meta.ShardStatus) InetSocketAddress(java.net.InetSocketAddress) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta) Test(org.junit.Test)

Aggregations

ShardStatus (com.ctrip.xpipe.redis.core.meta.ShardStatus)5 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)3 InetSocketAddress (java.net.InetSocketAddress)3 Test (org.junit.Test)3 RedisKeeperServerState (com.ctrip.xpipe.redis.keeper.RedisKeeperServerState)2 Before (org.junit.Before)2