优化client
This commit is contained in:
@@ -130,14 +130,14 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
||||
checkApplicationHealth();
|
||||
checkHttpAddressHealth();
|
||||
loadSncpAddressHealth();
|
||||
localEntrys.values().stream().filter(e -> !e.canceled).forEach(entry -> {
|
||||
checkLocalHealth(entry);
|
||||
});
|
||||
remoteEntrys.values().stream().filter(entry -> "SNCP".equalsIgnoreCase(entry.protocol)).forEach(entry -> {
|
||||
updateSncpAddress(entry);
|
||||
});
|
||||
localEntrys.values().stream()
|
||||
.filter(e -> !e.canceled)
|
||||
.forEach(this::checkLocalHealth);
|
||||
remoteEntrys.values().stream()
|
||||
.filter(entry -> "SNCP".equalsIgnoreCase(entry.protocol))
|
||||
.forEach(this::updateSncpAddress);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "scheduleAtFixedRate check error", e instanceof CompletionException ? ((CompletionException) e).getCause() : e);
|
||||
logger.log(Level.SEVERE, "scheduleAtFixedRate check error", e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class AsyncNioCompletionHandler<A> implements CompletionHandler<Integer, A>, Run
|
||||
@Override
|
||||
public void completed(Integer result, A attach) {
|
||||
ScheduledFuture future = this.timeoutFuture;
|
||||
if (future != null) {
|
||||
if (future != null && !future.isDone()) {
|
||||
this.timeoutFuture = null;
|
||||
future.cancel(true);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class AsyncNioCompletionHandler<A> implements CompletionHandler<Integer, A>, Run
|
||||
@Override
|
||||
public void failed(Throwable exc, A attach) {
|
||||
ScheduledFuture future = this.timeoutFuture;
|
||||
if (future != null) {
|
||||
if (future != null && !future.isDone()) {
|
||||
this.timeoutFuture = null;
|
||||
future.cancel(true);
|
||||
}
|
||||
|
||||
@@ -137,8 +137,10 @@ public abstract class Client<C extends ClientConnection<R, P>, R extends ClientR
|
||||
try {
|
||||
R req = pingRequestSupplier.get();
|
||||
if (req == null) { //可能运行中进行重新赋值
|
||||
timeoutFuture.cancel(true);
|
||||
timeoutFuture = null;
|
||||
if (timeoutFuture != null && !timeoutFuture.isDone()) {
|
||||
timeoutFuture.cancel(true);
|
||||
timeoutFuture = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
Reference in New Issue
Block a user