Search in sources :

Example 1 with DcInfo

use of com.ctrip.xpipe.redis.core.meta.DcInfo in project x-pipe by ctripcorp.

the class AppTest method beforeAppTest.

@Before
public void beforeAppTest() {
    System.setProperty(AbstractProfile.PROFILE_KEY, AbstractProfile.PROFILE_NAME_PRODUCTION);
    System.setProperty(ArrangeTaskExecutor.ARRANGE_TASK_EXECUTOR_START, "true");
    Map<String, DcInfo> dcInfos = new HashMap<>();
    dcInfos.put("jq", new DcInfo("http://localhost:" + IdcUtil.JQ_METASERVER_PORT));
    dcInfos.put("oy", new DcInfo("http://localhost:" + IdcUtil.OY_METASERVER_PORT));
    System.setProperty(DefaultMetaServerConfig.KEY_DC_INFOS, JsonCodec.INSTANCE.encode(dcInfos));
}
Also used : DcInfo(com.ctrip.xpipe.redis.core.meta.DcInfo) HashMap(java.util.HashMap) Before(org.junit.Before)

Example 2 with DcInfo

use of com.ctrip.xpipe.redis.core.meta.DcInfo 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 3 with DcInfo

use of com.ctrip.xpipe.redis.core.meta.DcInfo 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)3 MetaServerMultiDcService (com.ctrip.xpipe.redis.core.metaserver.MetaServerMultiDcService)2 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1