use of com.ctrip.xpipe.observer.NodeAdded in project x-pipe by ctripcorp.
the class AbstractCurrentMetaObserver method update.
@SuppressWarnings("rawtypes")
@Override
public void update(Object args, Observable observable) {
if (args instanceof NodeAdded) {
ClusterMeta clusterMeta = (ClusterMeta) ((NodeAdded) args).getNode();
logger.info("[update][add][{}]{}", getClass().getSimpleName(), clusterMeta.getId());
handleClusterAdd(clusterMeta);
return;
}
if (args instanceof NodeDeleted) {
ClusterMeta clusterMeta = (ClusterMeta) ((NodeDeleted) args).getNode();
logger.info("[update][delete][{}]{}", getClass().getSimpleName(), clusterMeta.getId());
handleClusterDeleted(clusterMeta);
return;
}
if (args instanceof ClusterMetaComparator) {
ClusterMetaComparator clusterMetaComparator = (ClusterMetaComparator) args;
logger.info("[update][modify][{}]{}", getClass().getSimpleName(), clusterMetaComparator);
handleClusterModified(clusterMetaComparator);
return;
}
throw new IllegalArgumentException("unknown argument:" + args);
}
use of com.ctrip.xpipe.observer.NodeAdded 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;
}
Aggregations