Search in sources :

Example 1 with DefaultReplicationStoreManager

use of com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStoreManager in project x-pipe by ctripcorp.

the class AbstractRedisKeeperTest method createReplicationStoreManager.

protected ReplicationStoreManager createReplicationStoreManager(String clusterId, String shardId, String keeperRunid, KeeperConfig keeperConfig, File storeDir) {
    DefaultReplicationStoreManager replicationStoreManager = new DefaultReplicationStoreManager(keeperConfig, clusterId, shardId, keeperRunid, storeDir, createkeeperMonitor());
    replicationStoreManager.addObserver(new Observer() {

        @Override
        public void update(Object args, Observable observable) {
            if (args instanceof NodeAdded) {
                @SuppressWarnings("unchecked") ReplicationStore replicationStore = ((NodeAdded<ReplicationStore>) args).getNode();
                try {
                    replicationStore.getMetaStore().becomeActive();
                } catch (IOException e) {
                    logger.error("[update]" + replicationStore, e);
                }
            }
        }
    });
    return replicationStoreManager;
}
Also used : Observer(com.ctrip.xpipe.api.observer.Observer) DefaultReplicationStoreManager(com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStoreManager) NodeAdded(com.ctrip.xpipe.observer.NodeAdded) IOException(java.io.IOException) DefaultReplicationStore(com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore) Observable(com.ctrip.xpipe.api.observer.Observable)

Aggregations

Observable (com.ctrip.xpipe.api.observer.Observable)1 Observer (com.ctrip.xpipe.api.observer.Observer)1 NodeAdded (com.ctrip.xpipe.observer.NodeAdded)1 DefaultReplicationStore (com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore)1 DefaultReplicationStoreManager (com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStoreManager)1 IOException (java.io.IOException)1