mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: KmsManager @PostConstruct abstract
parent
9b248756ef
commit
00484937bd
|
@ -17,9 +17,13 @@
|
||||||
|
|
||||||
package io.openvidu.server.kurento.kms;
|
package io.openvidu.server.kurento.kms;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.kurento.client.KurentoClient;
|
import org.kurento.client.KurentoClient;
|
||||||
import org.kurento.commons.exception.KurentoException;
|
import org.kurento.commons.exception.KurentoException;
|
||||||
|
|
||||||
|
@ -46,4 +50,21 @@ public class FixedOneKmsManager extends KmsManager {
|
||||||
return Arrays.asList(kms);
|
return Arrays.asList(kms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostConstruct
|
||||||
|
protected void postConstructInitKurentoClients() {
|
||||||
|
try {
|
||||||
|
List<KmsProperties> kmsProps = new ArrayList<>();
|
||||||
|
for (String kmsUri : this.openviduConfig.getKmsUris()) {
|
||||||
|
String kmsId = "kms-" + RandomStringUtils.randomAlphanumeric(6).toUpperCase();
|
||||||
|
kmsProps.add(new KmsProperties(kmsId, kmsUri));
|
||||||
|
}
|
||||||
|
this.initializeKurentoClients(kmsProps, true, false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Some KMS wasn't reachable
|
||||||
|
log.error("Shutting down OpenVidu Server");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.util.stream.Collectors;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
|
||||||
import org.kurento.client.KurentoConnectionListener;
|
import org.kurento.client.KurentoConnectionListener;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -91,8 +90,6 @@ public abstract class KmsManager {
|
||||||
|
|
||||||
final protected Map<String, Kms> kmss = new ConcurrentHashMap<>();
|
final protected Map<String, Kms> kmss = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
protected Map<String, String> forceKmsUrisToHaveKmsIds;
|
|
||||||
|
|
||||||
public synchronized void addKms(Kms kms) {
|
public synchronized void addKms(Kms kms) {
|
||||||
this.kmss.put(kms.getId(), kms);
|
this.kmss.put(kms.getId(), kms);
|
||||||
}
|
}
|
||||||
|
@ -203,29 +200,7 @@ public abstract class KmsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
protected List<Kms> postConstruct() {
|
protected abstract void postConstructInitKurentoClients();
|
||||||
try {
|
|
||||||
List<KmsProperties> kmsProps = new ArrayList<>();
|
|
||||||
if (forceKmsUrisToHaveKmsIds != null) {
|
|
||||||
for (String kmsUri : this.openviduConfig.getKmsUris()) {
|
|
||||||
String kmsId = forceKmsUrisToHaveKmsIds.get(kmsUri);
|
|
||||||
kmsProps.add(new KmsProperties(kmsId, kmsUri));
|
|
||||||
}
|
|
||||||
return this.initializeKurentoClients(kmsProps, true, true);
|
|
||||||
} else {
|
|
||||||
for (String kmsUri : this.openviduConfig.getKmsUris()) {
|
|
||||||
String kmsId = "kms-" + RandomStringUtils.randomAlphanumeric(6).toUpperCase();
|
|
||||||
kmsProps.add(new KmsProperties(kmsId, kmsUri));
|
|
||||||
}
|
|
||||||
return this.initializeKurentoClients(kmsProps, true, false);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Some KMS wasn't reachable
|
|
||||||
log.error("Shutting down OpenVidu Server");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
Loading…
Reference in New Issue