Search in sources :

Example 1 with MetaServerMultiDcService

use of com.ctrip.xpipe.redis.core.metaserver.MetaServerMultiDcService in project x-pipe by ctripcorp.

the class MultiDcNotifier method keeperActiveElected.

@Override
public void keeperActiveElected(String clusterId, String shardId, KeeperMeta activeKeeper) {
    if (!dcMetaCache.isCurrentDcPrimary(clusterId, shardId)) {
        logger.info("[keeperActiveElected][current dc backup, do nothing]{}, {}", clusterId, shardId, activeKeeper);
        return;
    }
    if (activeKeeper == null) {
        return;
    }
    Map<String, DcInfo> dcInfos = metaServerConfig.getDcInofs();
    Set<String> backupDcs = dcMetaCache.getBakupDcs(clusterId, shardId);
    logger.info("[keeperActiveElected][current dc primary, notify backup dc]{}, {}, {}, {}", clusterId, shardId, backupDcs, activeKeeper);
    for (String backupDcName : backupDcs) {
        DcInfo dcInfo = dcInfos.get(backupDcName);
        if (dcInfo == null) {
            logger.error("[keeperActiveElected][backup dc, but can not find dcinfo]{}, {}", backupDcName, dcInfos);
            continue;
        }
        MetaServerMultiDcService metaServerMultiDcService = metaServerMultiDcServiceManager.getOrCreate(dcInfo.getMetaServerAddress());
        executors.execute(new BackupDcNotifyTask(metaServerMultiDcService, clusterId, shardId, activeKeeper));
    }
}
Also used : MetaServerMultiDcService(com.ctrip.xpipe.redis.core.metaserver.MetaServerMultiDcService) DcInfo(com.ctrip.xpipe.redis.core.meta.DcInfo)

Example 2 with MetaServerMultiDcService

use of com.ctrip.xpipe.redis.core.metaserver.MetaServerMultiDcService in project x-pipe by ctripcorp.

the class DefaultMultiDcService method getActiveKeeper.

@Override
public KeeperMeta getActiveKeeper(String dcName, String clusterId, String shardId) {
    dcName = dcName.toLowerCase();
    DcInfo dcInfo = metaServerConfig.getDcInofs().get(dcName);
    if (dcInfo == null) {
        logger.error("[doChooseKeeperMaster][dc info null]{}", dcName);
        return null;
    }
    MetaServerMultiDcService metaServerMultiDcService = metaServerMultiDcServiceManager.getOrCreate(dcInfo.getMetaServerAddress());
    KeeperMeta keeperMeta = metaServerMultiDcService.getActiveKeeper(clusterId, shardId);
    return keeperMeta;
}
Also used : MetaServerMultiDcService(com.ctrip.xpipe.redis.core.metaserver.MetaServerMultiDcService) DcInfo(com.ctrip.xpipe.redis.core.meta.DcInfo) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta)

Aggregations

DcInfo (com.ctrip.xpipe.redis.core.meta.DcInfo)2 MetaServerMultiDcService (com.ctrip.xpipe.redis.core.metaserver.MetaServerMultiDcService)2 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)1