use of com.ctrip.xpipe.utils.VisibleForTesting 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.utils.VisibleForTesting in project x-pipe by ctripcorp.
the class DefaultMigrationCluster method updateStorageClusterStatus.
@VisibleForTesting
protected void updateStorageClusterStatus() throws Exception {
MigrationStatus migrationStatus = this.currentState.getStatus();
ClusterStatus clusterStatus = migrationStatus.getClusterStatus();
logger.info("[updateStat][updatedb]{}, {}", clusterName(), clusterStatus);
RetryTemplate<String> retryTemplate = new RetryNTimesOnCondition<>(new RetryCondition.AbstractRetryCondition<String>() {
@Override
public boolean isSatisfied(String s) {
return ClusterStatus.isSameClusterStatus(s, clusterStatus);
}
@Override
public boolean isExceptionExpected(Throwable th) {
if (th instanceof TimeoutException)
return true;
return false;
}
}, 3);
retryTemplate.execute(new AbstractCommand<String>() {
@Override
protected void doExecute() throws Exception {
try {
getClusterService().updateStatusById(clusterId(), clusterStatus);
ClusterTbl newCluster = getClusterService().find(clusterName());
future().setSuccess(newCluster.getStatus());
} catch (Exception e) {
future().setFailure(e.getCause());
}
}
@Override
protected void doReset() {
}
@Override
public String getName() {
return "update cluster status";
}
});
ClusterTbl newCluster = getClusterService().find(clusterName());
logger.info("[updateStat][getdb]{}, {}", clusterName(), newCluster != null ? newCluster.getStatus() : null);
}
Aggregations