Search in sources :

Example 6 with XpipeMetaManager

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;
}
Also used : DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)

Example 7 with XpipeMetaManager

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());
}
Also used : XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager) Pair(com.ctrip.xpipe.tuple.Pair)

Example 8 with XpipeMetaManager

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();
}
Also used : XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)

Example 9 with XpipeMetaManager

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()));
}
Also used : XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)

Aggregations

XpipeMetaManager (com.ctrip.xpipe.redis.core.meta.XpipeMetaManager)9 DefaultXpipeMetaManager (com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)9 HostPort (com.ctrip.xpipe.endpoint.HostPort)2 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)1 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)1 Pair (com.ctrip.xpipe.tuple.Pair)1