use of com.ctrip.xpipe.redis.console.job.retry.RetryNTimesOnCondition 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