use of com.ctrip.xpipe.redis.core.meta.comparator.DcMetaComparator in project x-pipe by ctripcorp.
the class DefaultDcMetaCache method clusterDeleted.
@Override
public void clusterDeleted(String clusterId) {
EventMonitor.DEFAULT.logEvent(META_CHANGE_TYPE, String.format("del:%s", clusterId));
ClusterMeta clusterMeta = dcMetaManager.get().removeCluster(clusterId);
logger.info("[clusterDeleted]{}", clusterMeta);
DcMetaComparator dcMetaComparator = DcMetaComparator.buildClusterRemoved(clusterMeta);
notifyObservers(dcMetaComparator);
}
use of com.ctrip.xpipe.redis.core.meta.comparator.DcMetaComparator in project x-pipe by ctripcorp.
the class DefaultDcMetaCache method clusterModified.
@Override
public void clusterModified(ClusterMeta clusterMeta) {
EventMonitor.DEFAULT.logEvent(META_CHANGE_TYPE, String.format("mod:%s", clusterMeta.getId()));
ClusterMeta current = dcMetaManager.get().getClusterMeta(clusterMeta.getId());
dcMetaManager.get().update(clusterMeta);
logger.info("[clusterModified]{}, {}", current, clusterMeta);
DcMetaComparator dcMetaComparator = DcMetaComparator.buildClusterChanged(current, clusterMeta);
notifyObservers(dcMetaComparator);
}
use of com.ctrip.xpipe.redis.core.meta.comparator.DcMetaComparator in project x-pipe by ctripcorp.
the class DefaultDcMetaCache method changeDcMeta.
@VisibleForTesting
protected void changeDcMeta(DcMeta current, DcMeta future) {
DcMetaComparator dcMetaComparator = new DcMetaComparator(current, future);
dcMetaComparator.compare();
if (dcMetaComparator.totalChangedCount() > META_MODIFY_PROTECT_COUNT) {
logger.error("[run][modify count size too big]{}, {}, {}", META_MODIFY_PROTECT_COUNT, dcMetaComparator.totalChangedCount(), dcMetaComparator);
EventMonitor.DEFAULT.logAlertEvent("remove too many:" + dcMetaComparator.totalChangedCount());
return;
}
logger.info("[run][change dc meta]");
dcMetaManager.set(DefaultDcMetaManager.buildFromDcMeta(future));
if (dcMetaComparator.totalChangedCount() > 0) {
logger.info("[run][change]{}", dcMetaComparator);
EventMonitor.DEFAULT.logEvent(META_CHANGE_TYPE, String.format("[add:%s, del:%s, mod:%s]", StringUtil.join(",", (clusterMeta) -> clusterMeta.getId(), dcMetaComparator.getAdded()), StringUtil.join(",", (clusterMeta) -> clusterMeta.getId(), dcMetaComparator.getRemoved()), StringUtil.join(",", (comparator) -> comparator.idDesc(), dcMetaComparator.getMofified())));
notifyObservers(dcMetaComparator);
}
}
use of com.ctrip.xpipe.redis.core.meta.comparator.DcMetaComparator in project x-pipe by ctripcorp.
the class DefaultCurrentMetaManager method dcMetaChange.
private void dcMetaChange(DcMetaComparator comparator) {
for (ClusterMeta clusterMeta : comparator.getAdded()) {
if (currentClusterServer.hasKey(clusterMeta.getId())) {
addCluster(clusterMeta.getId());
} else {
logger.info("[dcMetaChange][add][not interested]{}", clusterMeta.getId());
}
}
for (ClusterMeta clusterMeta : comparator.getRemoved()) {
if (currentClusterServer.hasKey(clusterMeta.getId())) {
destroyCluster(clusterMeta);
} else {
logger.info("[dcMetaChange][destroy][not interested]{}", clusterMeta.getId());
}
}
for (@SuppressWarnings("rawtypes") MetaComparator changedComparator : comparator.getMofified()) {
ClusterMetaComparator clusterMetaComparator = (ClusterMetaComparator) changedComparator;
String clusterId = clusterMetaComparator.getCurrent().getId();
if (currentClusterServer.hasKey(clusterId)) {
handleClusterChanged(clusterMetaComparator);
} else {
logger.info("[dcMetaChange][change][not interested]{}", clusterId);
}
}
}
Aggregations