use of com.ctrip.xpipe.redis.core.meta.XpipeMetaManager in project x-pipe by ctripcorp.
the class ConfigCheck method fromXpipe.
private CheckCluster fromXpipe(XpipeMeta xpipeMeta, String checkCluster) {
XpipeMetaManager xpm = new DefaultXpipeMetaManager(xpipeMeta);
CheckCluster result = new CheckCluster(checkCluster);
for (String dc : dcs) {
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 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.redis.core.meta.XpipeMetaManager 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());
}
use of com.ctrip.xpipe.redis.core.meta.XpipeMetaManager in project x-pipe by ctripcorp.
the class DefaultMetaCache method getSentinelMonitorName.
@Override
public String getSentinelMonitorName(String clusterId, String shardId) {
XpipeMetaManager xpipeMetaManager = meta.getValue();
Set<String> dcs = xpipeMetaManager.getDcs();
for (String dc : dcs) {
ShardMeta shardMeta = xpipeMetaManager.getShardMeta(dc, clusterId, shardId);
if (shardMeta != null) {
return shardMeta.getSentinelMonitorName();
}
}
return null;
}
use of com.ctrip.xpipe.redis.core.meta.XpipeMetaManager in project x-pipe by ctripcorp.
the class DefaultMetaCache method inBackupDc.
@Override
public boolean inBackupDc(HostPort hostPort) {
XpipeMetaManager xpipeMetaManager = meta.getValue();
XpipeMetaManager.MetaDesc metaDesc = xpipeMetaManager.findMetaDesc(hostPort);
if (metaDesc == null) {
throw new IllegalStateException("unfound shard for instance:" + hostPort);
}
String instanceInDc = metaDesc.getDcId();
String activeDc = metaDesc.getActiveDc();
return !activeDc.equalsIgnoreCase(instanceInDc);
}
Aggregations