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 javax.annotation.PostConstruct;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.validator.routines.DomainValidator; import org.apache.commons.validator.routines.DomainValidator;
import org.apache.commons.validator.routines.InetAddressValidator; import org.apache.commons.validator.routines.InetAddressValidator;
@ -470,7 +471,11 @@ public class OpenviduConfig {
} }
public int getReconnectionTimeout() { public int getReconnectionTimeout() {
return 2000000000; return -1;
}
public int getAppliedReconnectionTimeout() {
return Integer.MAX_VALUE;
} }
// Properties management methods // 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 { try {
String value = getValue(property); String value = getValue(property);
if (value == null || value.isEmpty()) { if (value == null || value.isEmpty()) {
return null; return null;
} }
Integer integerValue = Integer.parseInt(getValue(property)); Integer integerValue = Integer.parseInt(getValue(property));
if (integerValue < 0) { boolean belognsToRanges = false;
addError(property, "Is not a non negative integer"); for (int i = 0; i < ranges.length; i++) {
if (ranges[i].contains(integerValue)) {
belognsToRanges = true;
break;
}
} }
if (integerValue < min) { if (!belognsToRanges) {
addError(property, "Must be >= " + min); 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) { } catch (NumberFormatException e) {
addError(property, "Is not a non negative integer"); addError(property, "Is not an integer");
return 0; return 0;
} }
} }

View File

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