Search in sources :

Example 1 with KeeperHeartBeatManager

use of com.ctrip.xpipe.redis.meta.server.keeper.KeeperHeartBeatManager in project x-pipe by ctripcorp.

the class DefaultDynamicStateManager method remove.

@Override
public void remove(String clusterId) {
    logger.info("[remote]{}", clusterId);
    clusterMetas.remove(clusterId);
    for (KeeperKey keeperKey : keepers.keySet()) {
        if (keeperKey.getClusterId().equals(clusterId)) {
            logger.info("[remove]{}", keeperKey);
            KeeperHeartBeatManager keeperHeartBeatManager = keepers.remove(keeperKey);
            keeperHeartBeatManager.close();
        }
    }
}
Also used : KeeperHeartBeatManager(com.ctrip.xpipe.redis.meta.server.keeper.KeeperHeartBeatManager)

Example 2 with KeeperHeartBeatManager

use of com.ctrip.xpipe.redis.meta.server.keeper.KeeperHeartBeatManager in project x-pipe by ctripcorp.

the class DefaultDynamicStateManager method add.

@Override
public void add(ClusterMeta clusterMeta) {
    clusterMetas.put(clusterMeta.getId(), clusterMeta);
    for (ShardMeta shardMeta : clusterMeta.getShards().values()) {
        for (KeeperMeta keeperMeta : shardMeta.getKeepers()) {
            final KeeperKey keeperKey = createKeeperKey(clusterMeta.getId(), shardMeta.getId(), keeperMeta);
            @SuppressWarnings("unused") KeeperHeartBeatManager keeperHeartBeatManager = MapUtils.getOrCreate(keepers, keeperKey, new ObjectFactory<KeeperHeartBeatManager>() {

                @Override
                public KeeperHeartBeatManager create() {
                    KeeperHeartBeatManager keeperHeartBeatManager = new DefaultKeeperHeartBeatManager(keeperKey, scheduled);
                    keeperHeartBeatManager.addObserver(DefaultDynamicStateManager.this);
                    return keeperHeartBeatManager;
                }
            });
        }
    }
}
Also used : ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) KeeperHeartBeatManager(com.ctrip.xpipe.redis.meta.server.keeper.KeeperHeartBeatManager) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta)

Example 3 with KeeperHeartBeatManager

use of com.ctrip.xpipe.redis.meta.server.keeper.KeeperHeartBeatManager in project x-pipe by ctripcorp.

the class DefaultDynamicStateManager method ping.

@Override
public void ping(KeeperInstanceMeta keeperInstanceMeta) {
    final KeeperKey keeperKey = createKeeperKey(keeperInstanceMeta);
    logger.debug("[ping]{}", keeperKey);
    KeeperHeartBeatManager keeperHeartBeatManager = keepers.get(keeperKey);
    if (keeperHeartBeatManager == null) {
        logger.error("[ping][error, not this cluster]{}", keeperKey);
        return;
    }
    keeperHeartBeatManager.ping(keeperInstanceMeta);
}
Also used : KeeperHeartBeatManager(com.ctrip.xpipe.redis.meta.server.keeper.KeeperHeartBeatManager)

Aggregations

KeeperHeartBeatManager (com.ctrip.xpipe.redis.meta.server.keeper.KeeperHeartBeatManager)3 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)1 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)1