use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class XPipeStabilityTest method statbilityTest.
@Test
public void statbilityTest() throws Exception {
String mode = System.getProperty("mode", "all");
Cat.logEvent("statbilityTest", "begin");
HostPort master = new HostPort(IpUtils.parseSingle(masterAddress));
List<HostPort> slaves = new LinkedList<>();
IpUtils.parse(slaveAddress).forEach(address -> slaves.add(new HostPort(address)));
if (mode.equalsIgnoreCase("all")) {
testMode = new AllKeyMode(master, slaves, producerThreadNum, producerIntervalMicro, msgSize, maxKeys);
} else {
testMode = new PubSubMode(master, slaves, producerThreadNum, producerIntervalMicro, msgSize, maxKeys);
}
logger.info("{}", testMode);
testMode.test();
TimeUnit.DAYS.sleep(runDays);
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultSentinelManager method getMasterOfMonitor.
@Override
public HostPort getMasterOfMonitor(Sentinel sentinel, String sentinelMonitorName) {
SimpleObjectPool<NettyClient> clientPool = keyedClientPool.getKeyPool(new InetSocketAddress(sentinel.getIp(), sentinel.getPort()));
AbstractSentinelCommand.SentinelMaster sentinelMaster = new AbstractSentinelCommand.SentinelMaster(clientPool, scheduled, sentinelMonitorName);
sentinelMaster.logResponse(false);
HostPort result = null;
try {
result = sentinelMaster.execute().get();
logger.info("[getMasterOfMonitor]getMasterOfMonitor {} from {} : {}", sentinelMonitorName, sentinel, result);
} catch (Exception e) {
logger.error("[getMasterOfMonitor] {} from {} : {}", sentinelMonitorName, sentinel, e.getMessage());
}
return result;
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultMetaCache method findMasterInSameShard.
@Override
public HostPort findMasterInSameShard(HostPort hostPort) {
XpipeMetaManager xpipeMetaManager = meta.getValue();
XpipeMetaManager.MetaDesc metaDesc = xpipeMetaManager.findMetaDesc(hostPort);
if (metaDesc == null) {
throw new IllegalStateException("unfound shard for instance:" + hostPort);
}
String clusterName = metaDesc.getClusterId();
String shardName = metaDesc.getShardId();
Pair<String, RedisMeta> redisMaster = xpipeMetaManager.getRedisMaster(clusterName, shardName);
// could be null if no master in a shard
if (redisMaster == null) {
return null;
}
RedisMeta redisMeta = redisMaster.getValue();
return new HostPort(redisMeta.getIp(), redisMeta.getPort());
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultMetaCache method allKeepers.
@Override
public Set<HostPort> allKeepers() {
Set<HostPort> result = new HashSet<>();
XpipeMeta xpipeMeta = getXpipeMeta();
xpipeMeta.getDcs().forEach((dcName, dcMeta) -> {
dcMeta.getClusters().forEach((clusterName, clusterMeta) -> {
clusterMeta.getShards().forEach((shardName, shardMeta) -> {
shardMeta.getKeepers().forEach(keeperMeta -> {
result.add(new HostPort(keeperMeta.getIp(), keeperMeta.getPort()));
});
});
});
});
return result;
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultMetaCache method findMaster.
@Override
public HostPort findMaster(String clusterId, String shardId) throws MasterNotFoundException {
XpipeMetaManager xpipeMetaManager = meta.getValue();
Pair<String, RedisMeta> redisMaster = xpipeMetaManager.getRedisMaster(clusterId, shardId);
if (redisMaster == null) {
throw new MasterNotFoundException(clusterId, shardId);
}
return new HostPort(redisMaster.getValue().getIp(), redisMaster.getValue().getPort());
}
Aggregations