use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class OneDcKeepers method killActive.
@Test
public void killActive() throws Exception {
RedisMeta redisMaster = getRedisMaster();
sendMessageToMasterAndTestSlaveRedis();
System.out.println("press any key to make back keeper active");
waitForAnyKey();
KeeperMeta backupKeeper = getKeepersBackup().get(0);
RedisKeeperServer redisKeeperServer = getRedisKeeperServer(backupKeeper);
Assert.assertEquals(PARTIAL_STATE.FULL, redisKeeperServer.getRedisMaster().partialState());
logger.info(remarkableMessage("make keeper active{}"), backupKeeper);
setKeeperState(backupKeeper, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort());
waitForAnyKeyToExit();
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class DefaultRedisKeeperServerTest method testKeeperServerInitState.
@Test
public void testKeeperServerInitState() throws Exception {
KeeperMeta keeperMeta = createKeeperMeta();
RedisKeeperServer redisKeeperServer = createRedisKeeperServer(keeperMeta);
redisKeeperServer.initialize();
Assert.assertEquals(KeeperState.UNKNOWN, redisKeeperServer.getRedisKeeperServerState().keeperState());
redisKeeperServer.setRedisKeeperServerState(new RedisKeeperServerStateActive(redisKeeperServer));
redisKeeperServer.getReplicationStore().getMetaStore().becomeActive();
redisKeeperServer.dispose();
redisKeeperServer = createRedisKeeperServer(keeperMeta);
redisKeeperServer.initialize();
Assert.assertEquals(KeeperState.PRE_ACTIVE, redisKeeperServer.getRedisKeeperServerState().keeperState());
redisKeeperServer.setRedisKeeperServerState(new RedisKeeperServerStateBackup(redisKeeperServer));
redisKeeperServer.getReplicationStore().getMetaStore().becomeBackup();
redisKeeperServer.dispose();
redisKeeperServer = createRedisKeeperServer(keeperMeta);
redisKeeperServer.initialize();
Assert.assertEquals(KeeperState.PRE_BACKUP, redisKeeperServer.getRedisKeeperServerState().keeperState());
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta 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());
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class KeeperContainerServiceTest method setUp.
@Before
public void setUp() throws Exception {
keeperContainerService = new KeeperContainerService();
ReflectionTestUtils.setField(keeperContainerService, "leaderElectorManager", leaderElectorManager);
ReflectionTestUtils.setField(keeperContainerService, "metaService", metaService);
ReflectionTestUtils.setField(keeperContainerService, "leaderElectorManager", leaderElectorManager);
ReflectionTestUtils.setField(keeperContainerService, "keeperContainerConfig", keeperContainerConfig);
ReflectionTestUtils.setField(keeperContainerService, "keeperConfig", keeperConfig);
ReflectionTestUtils.setField(keeperContainerService, "keepersMonitorManager", keepersMonitorManager);
someCluster = "someCluster";
someShard = "someShard";
somePort = 6789;
someKeeperMeta = new KeeperMeta();
someKeeperMeta.setPort(somePort);
someKeeperTransMeta = new KeeperTransMeta();
someKeeperTransMeta.setClusterId(someCluster);
someKeeperTransMeta.setShardId(someShard);
someKeeperTransMeta.setKeeperMeta(someKeeperMeta);
when(keeperContainerConfig.getReplicationStoreDir()).thenReturn(System.getProperty("user.dir"));
ReflectionTestUtils.setField(ComponentRegistryHolder.class, "componentRegistry", componentRegistry);
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class KeeperContainerServiceTest method testAddKeeperWithSamePortMultipleTimes.
@Test(expected = RedisKeeperRuntimeException.class)
public void testAddKeeperWithSamePortMultipleTimes() throws Exception {
String anotherShard = "anotherShard";
KeeperMeta anotherKeeperMeta = new KeeperMeta();
anotherKeeperMeta.setPort(somePort);
KeeperTransMeta anotherKeeperTransMeta = new KeeperTransMeta();
anotherKeeperTransMeta.setKeeperMeta(anotherKeeperMeta);
anotherKeeperTransMeta.setClusterId(someCluster);
anotherKeeperTransMeta.setShardId(anotherShard);
keeperContainerService.add(someKeeperTransMeta);
keeperContainerService.add(anotherKeeperTransMeta);
}
Aggregations