use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class PrimaryDcKeeperMasterChooserAlgorithmTest method testLongConnection.
@Test
public void testLongConnection() throws Exception {
SlaveRole role = new SlaveRole(SERVER_ROLE.MASTER, "localhost", randomPort(), MASTER_STATE.REDIS_REPL_CONNECT, 0L);
RedisMeta chosen = redises.get(0);
Server server = startServer(chosen.getPort(), ByteBufUtils.readToString(role.format()));
Assert.assertEquals(0, server.getConnected());
for (int i = 0; i < 10; i++) {
primaryAlgorithm.choose();
Assert.assertEquals(1, server.getConnected());
}
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class DefaultSlaveOfJobTest method testSlavesFail.
@Test
public void testSlavesFail() throws Exception {
List<RedisMeta> slaves = new LinkedList<>();
List<Integer> ports = new LinkedList<>(randomPorts(2));
slaves.add(new RedisMeta().setIp("localhost").setPort(ports.get(0)));
slaves.add(new RedisMeta().setIp("localhost").setPort(ports.get(1)));
startServer(ports.get(0), "-Server0 FAIL\r\n");
startServer(ports.get(1), "-Server1 JUST FAIL\r\n");
try {
Command<Void> command = new DefaultSlaveOfJob(slaves, "localhost", randomPort(), getXpipeNettyClientKeyedObjectPool(), scheduled, executors);
command.execute().get(1, TimeUnit.SECONDS);
Assert.fail();
} catch (Exception e) {
logger.info("{}", e.getMessage());
}
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class SlaveofJobTest method getRedisSlaves.
private List<RedisMeta> getRedisSlaves(String[] redises) {
List<RedisMeta> slaves = new LinkedList<>();
for (String redis : redises) {
Pair<String, Integer> addr = IpUtils.parseSingleAsPair(redis);
RedisMeta redisMeta = new RedisMeta();
redisMeta.setIp(addr.getKey());
redisMeta.setPort(addr.getValue());
slaves.add(redisMeta);
}
return slaves;
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class DefaultRedisMasterCollectorTest method before.
@Before
public void before() {
MockitoAnnotations.initMocks(this);
collector.postConstructDefaultRedisMasterCollector();
plan = new RedisMasterSamplePlan("jq", "cluster1", "shard1");
RedisMeta redisMeta = new RedisMeta().setIp("127.0.0.1").setPort(6379).setMaster(XPipeConsoleConstant.DEFAULT_ADDRESS);
plan.addRedis("jq", redisMeta, new InstanceRedisMasterResult());
RedisMeta redisMeta2 = new RedisMeta().setIp("127.0.0.1").setPort(6380).setMaster(XPipeConsoleConstant.DEFAULT_ADDRESS);
plan.addRedis("jq", redisMeta2, new InstanceRedisMasterResult());
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class KeeperSingleDc method testReFullSync.
@Test
public void testReFullSync() throws ExecuteException, IOException {
RedisKeeperServer redisKeeperServer = getRedisKeeperServerActive(dc);
DefaultReplicationStore replicationStore = (DefaultReplicationStore) redisKeeperServer.getReplicationStore();
DcMeta dcMeta = getDcMeta();
RedisMeta slave1 = createSlave(activeKeeper.getIp(), activeKeeper.getPort());
int lastRdbUpdateCount = replicationStore.getRdbUpdateCount();
logger.info(remarkableMessage("[testReFullSync][sendRandomMessage]"));
sendRandomMessage(redisMaster, 1, replicationStoreCommandFileSize);
for (int i = 0; i < 3; i++) {
logger.info(remarkableMessage("[testReFullSync]{}"), i);
startRedis(slave1);
sleep(3000);
int currentRdbUpdateCount = replicationStore.getRdbUpdateCount();
logger.info("[testReFullSync]{},{}", lastRdbUpdateCount, currentRdbUpdateCount);
Assert.assertEquals(lastRdbUpdateCount + 1, currentRdbUpdateCount);
lastRdbUpdateCount = currentRdbUpdateCount;
sendMesssageToMasterAndTest(100, getRedisMaster(), Lists.newArrayList(slave1));
}
}
Aggregations