use of com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcCheckMessage in project x-pipe by ctripcorp.
the class ClusterServersApiTest method testChangePrimaryDcCheck.
@Test
public void testChangePrimaryDcCheck() throws Exception {
createMetaServers(metaServerCount);
sleep(waitForMetaServerOkTime);
logger.info(remarkableMessage("[testChangePrimaryDcCheck][begin send primary dc check message]"));
for (TestMetaServer server : getServers()) {
logger.info("[testChangePrimaryDcCheck]{}", server.getAddress());
MetaServerConsoleService consoleService = new DefaultMetaServerConsoleService(server.getAddress());
PrimaryDcCheckMessage message = consoleService.changePrimaryDcCheck(getClusterId(), getShardId(), "newPrimaryDc");
logger.info("[testChangePrimaryDcCheck]{}, {}", server.getAddress(), message);
}
}
use of com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcCheckMessage in project x-pipe by ctripcorp.
the class DefaultMetaServer method changePrimaryDcCheck.
@Override
public PrimaryDcCheckMessage changePrimaryDcCheck(String clusterId, String shardId, String newPrimaryDc, ForwardInfo forwardInfo) {
logger.info("[changePrimaryDcCheck]{}, {}, {}, {}", clusterId, shardId, newPrimaryDc, forwardInfo);
String currentPrimaryDc = dcMetaCache.getPrimaryDc(clusterId, shardId);
String currentDc = dcMetaCache.getCurrentDc();
if (newPrimaryDc.equalsIgnoreCase(currentPrimaryDc)) {
return new PrimaryDcCheckMessage(PRIMARY_DC_CHECK_RESULT.PRIMARY_DC_ALREADY_IS_NEW, String.format("%s already primary dc", newPrimaryDc));
}
if (currentDc.equalsIgnoreCase(newPrimaryDc)) {
List<RedisMeta> redises = dcMetaCache.getShardRedises(clusterId, shardId);
SimpleErrorMessage result = new AtLeastOneChecker(redises, keyedObjectPool, scheduled).check();
if (result.getErrorType() == SIMPLE_RETURN_CODE.SUCCESS) {
return new PrimaryDcCheckMessage(PRIMARY_DC_CHECK_RESULT.SUCCESS);
}
return new PrimaryDcCheckMessage(PRIMARY_DC_CHECK_RESULT.FAIL, "all redises dead:" + result.getErrorMessage());
}
return new PrimaryDcCheckMessage(PRIMARY_DC_CHECK_RESULT.SUCCESS, String.format("current dc :%s is not new primary: %s ", currentDc, newPrimaryDc));
}
use of com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcCheckMessage in project x-pipe by ctripcorp.
the class PrimaryDcCheckMessageTest method testEncodeDecode.
@Test
public void testEncodeDecode() {
PrimaryDcCheckMessage message = new PrimaryDcCheckMessage(PRIMARY_DC_CHECK_RESULT.SUCCESS, "hello");
String encode = Codec.DEFAULT.encode(message);
logger.info("{}", encode);
PrimaryDcCheckMessage decode = Codec.DEFAULT.decode(encode, PrimaryDcCheckMessage.class);
logger.info("{}", decode);
}
Aggregations