openvidu-server: infinite OPENVIDU_PRO_CLUSTER_RECONNECTION_TIMEOUT with -1

pull/711/head
pabloFuente 2022-03-29 11:16:02 +02:00
parent 5b61d8d0e9
commit 9ac32da633
2 changed files with 25 additions and 16 deletions

View File

@ -39,6 +39,7 @@ import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.validator.routines.DomainValidator;
import org.apache.commons.validator.routines.InetAddressValidator;
@ -470,7 +471,11 @@ public class OpenviduConfig {
}
public int getReconnectionTimeout() {
return 2000000000;
return -1;
}
public int getAppliedReconnectionTimeout() {
return Integer.MAX_VALUE;
}
// Properties management methods
@ -927,25 +932,28 @@ public class OpenviduConfig {
}
}
protected Integer asOptionalNonNegativeInteger(String property, int min, int max) {
protected Integer asOptionalIntegerBetweenRanges(String property, Range<Integer>... ranges) {
try {
String value = getValue(property);
if (value == null || value.isEmpty()) {
return null;
}
Integer integerValue = Integer.parseInt(getValue(property));
if (integerValue < 0) {
addError(property, "Is not a non negative integer");
boolean belognsToRanges = false;
for (int i = 0; i < ranges.length; i++) {
if (ranges[i].contains(integerValue)) {
belognsToRanges = true;
break;
}
}
if (integerValue < min) {
addError(property, "Must be >= " + min);
if (!belognsToRanges) {
addError(property, "It does not belong to the accepted ranges");
return 0;
} else {
return integerValue;
}
if (integerValue >= max) {
addError(property, "Must be < " + max);
}
return integerValue;
} catch (NumberFormatException e) {
addError(property, "Is not a non negative integer");
addError(property, "Is not an integer");
return 0;
}
}

View File

@ -243,7 +243,8 @@ public abstract class KmsManager {
if (iteration.decrementAndGet() < 0) {
kms.getKurentoClientReconnectTimer().cancelTimer();
boolean mustRetryReconnection = accumulatedTimeout < openviduConfig.getReconnectionTimeout();
boolean mustRetryReconnection = accumulatedTimeout < openviduConfig
.getAppliedReconnectionTimeout();
boolean mustRemoveMediaNode = !mustRetryReconnection;
if (!kms.hasTriggeredNodeCrashedEvent()) {
@ -266,10 +267,10 @@ public abstract class KmsManager {
if (mustRetryReconnection) {
log.info(
"Retrying reconnection to Media Node {} with IP {}. {} seconds consumed of a maximum of {}",
kms.getId(), kms.getIp(), accumulatedTimeout,
openviduConfig.getReconnectionTimeout());
log.info("Retrying reconnection to Media Node {} with IP {}. {}", kms.getId(), kms.getIp(),
openviduConfig.getReconnectionTimeout() == -1 ? "Infinite retry"
: (accumulatedTimeout + " seconds consumed of a maximum of "
+ openviduConfig.getReconnectionTimeout()));
disconnectionHandler(kms, accumulatedTimeout);
} else {