use of com.ctrip.xpipe.redis.core.meta.XpipeMetaManager in project x-pipe by ctripcorp.
the class ClientConfigMonitor method fromXPipe.
private CheckCluster fromXPipe(XpipeMeta xpipeMeta, String checkCluster) {
XpipeMetaManager xpm = new DefaultXpipeMetaManager(xpipeMeta);
CheckCluster result = new CheckCluster(checkCluster);
for (String dc : xpipeMeta.getDcs().keySet()) {
ClusterMeta clusterMeta = xpm.getClusterMeta(dc, checkCluster);
if (clusterMeta == null) {
continue;
}
for (ShardMeta shardMeta : clusterMeta.getShards().values()) {
CheckShard orShard = result.getOrCreate(shardMeta.getId());
shardMeta.getRedises().forEach(redis -> {
orShard.addRedis(new CheckRedis(redis.getIp(), redis.getPort(), dc));
});
}
}
return result;
}
use of com.ctrip.xpipe.redis.core.meta.XpipeMetaManager in project x-pipe by ctripcorp.
the class DefaultMetaCache method findClusterShard.
@Override
public Pair<String, String> findClusterShard(HostPort hostPort) {
XpipeMetaManager xpipeMetaManager = meta.getValue();
XpipeMetaManager.MetaDesc metaDesc = xpipeMetaManager.findMetaDesc(hostPort);
if (metaDesc == null) {
return null;
}
return new Pair<>(metaDesc.getClusterId(), metaDesc.getShardId());
}
use of com.ctrip.xpipe.redis.core.meta.XpipeMetaManager in project x-pipe by ctripcorp.
the class DefaultMetaCache method getDc.
@Override
public String getDc(HostPort hostPort) {
XpipeMetaManager xpipeMetaManager = meta.getValue();
XpipeMetaManager.MetaDesc metaDesc = xpipeMetaManager.findMetaDesc(hostPort);
if (metaDesc == null) {
throw new IllegalStateException("unfound shard for instance:" + hostPort);
}
return metaDesc.getDcId();
}
use of com.ctrip.xpipe.redis.core.meta.XpipeMetaManager in project x-pipe by ctripcorp.
the class DefaultMetaCache method getActiveDcSentinels.
@Override
public Set<HostPort> getActiveDcSentinels(String clusterId, String shardId) {
XpipeMetaManager xpipeMetaManager = meta.getValue();
String activeDc = xpipeMetaManager.getActiveDc(clusterId, shardId);
SentinelMeta sentinel = xpipeMetaManager.getSentinel(activeDc, clusterId, shardId);
return new HashSet<>(IpUtils.parseAsHostPorts(sentinel.getAddress()));
}
Aggregations