Fixed - FailedSlaveNodeDetector's parameters by can't be defined in yaml. #6082

pull/6083/head
Nikita Koksharov 6 months ago
parent 84ea15ca72
commit a505aac511

@ -27,14 +27,37 @@ import java.util.concurrent.ConcurrentSkipListSet;
*/
public class FailedCommandsDetector implements FailedNodeDetector {
private final long checkInterval;
private long checkInterval;
private long failedCommandsLimit;
private final NavigableSet<Long> failedCommands = new ConcurrentSkipListSet<>();
public FailedCommandsDetector() {
}
public FailedCommandsDetector(long checkInterval, int failedCommandsLimit) {
if (checkInterval == 0) {
throw new IllegalArgumentException("checkInterval value");
}
if (failedCommandsLimit == 0) {
throw new IllegalArgumentException("failedCommandsLimit value");
}
this.checkInterval = checkInterval;
this.failedCommandsLimit = failedCommandsLimit;
}
public void setCheckInterval(long checkInterval) {
if (checkInterval == 0) {
throw new IllegalArgumentException("checkInterval value");
}
this.checkInterval = checkInterval;
}
public void setFailedCommandsLimit(long failedCommandsLimit) {
if (failedCommandsLimit == 0) {
throw new IllegalArgumentException("failedCommandsLimit value");
}
this.failedCommandsLimit = failedCommandsLimit;
}
@ -65,6 +88,10 @@ public class FailedCommandsDetector implements FailedNodeDetector {
@Override
public boolean isNodeFailed() {
if (failedCommandsLimit == 0) {
throw new IllegalArgumentException("failedCommandsLimit isn't set");
}
long start = System.currentTimeMillis() - checkInterval;
failedCommands.headSet(start).clear();

@ -24,6 +24,9 @@ package org.redisson.client;
*/
public class FailedCommandsTimeoutDetector extends FailedCommandsDetector {
public FailedCommandsTimeoutDetector() {
}
public FailedCommandsTimeoutDetector(long checkInterval, int failedCommandsLimit) {
super(checkInterval, failedCommandsLimit);
}

@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class FailedConnectionDetector implements FailedNodeDetector {
private final long checkInterval;
private long checkInterval;
private final AtomicLong firstFailTime = new AtomicLong(0);
@ -34,6 +34,18 @@ public class FailedConnectionDetector implements FailedNodeDetector {
}
public FailedConnectionDetector(long checkInterval) {
if (checkInterval == 0) {
throw new IllegalArgumentException("checkInterval value");
}
this.checkInterval = checkInterval;
}
public void setCheckInterval(long checkInterval) {
if (checkInterval == 0) {
throw new IllegalArgumentException("checkInterval value");
}
this.checkInterval = checkInterval;
}

Loading…
Cancel
Save