You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ki...@apache.org on 2020/07/10 07:58:43 UTC
[shardingsphere] branch master updated: fixes heartbeat timeout
(#6317)
This is an automated email from the ASF dual-hosted git repository.
kimmking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 6f5e7c3 fixes heartbeat timeout (#6317)
6f5e7c3 is described below
commit 6f5e7c357247263cbd3247fa64be83fa27151fce
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Fri Jul 10 15:58:26 2020 +0800
fixes heartbeat timeout (#6317)
---
.../cluster/heartbeat/detect/HeartbeatHandler.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/detect/HeartbeatHandler.java b/shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/detect/HeartbeatHandler.java
index 3970a0b..3648c1c 100644
--- a/shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/detect/HeartbeatHandler.java
+++ b/shardingsphere-control-panel/shardingsphere-cluster/shardingsphere-cluster-heartbeat/src/main/java/org/apache/shardingsphere/cluster/heartbeat/detect/HeartbeatHandler.java
@@ -36,9 +36,7 @@ import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
@@ -48,8 +46,6 @@ import java.util.stream.Collectors;
@Slf4j
public final class HeartbeatHandler {
- private static final int FUTURE_GET_TIME_OUT_MILLISECONDS = 5000;
-
private HeartbeatConfiguration configuration;
private Collection<String> disabledDataSources = Collections.emptyList();
@@ -104,9 +100,10 @@ public final class HeartbeatHandler {
private HeartbeatResponse buildHeartbeatResponse(final List<Future<Map<String, HeartbeatResult>>> futureTasks) {
Map<String, Collection<HeartbeatResult>> heartbeatResultMap = futureTasks.stream().map(e -> {
try {
- return e.get(FUTURE_GET_TIME_OUT_MILLISECONDS, TimeUnit.MILLISECONDS);
- } catch (InterruptedException | ExecutionException | TimeoutException ex) {
+ return e.get();
+ } catch (InterruptedException | ExecutionException ex) {
log.error("Heartbeat report error", ex);
+ e.cancel(true);
return new HashMap<String, HeartbeatResult>();
}
}).flatMap(map -> map.entrySet().stream()).collect(Collectors.groupingBy(Map.Entry::getKey, HashMap::new, Collectors.mapping(Map.Entry::getValue, Collectors.toCollection(ArrayList::new))));