openvidu-server: fix nullpointers when removing crashed Media Node

pull/651/head
pabloFuente 2021-09-02 17:53:05 +02:00
parent 132653cde7
commit 3b3fcaa1f0
4 changed files with 15 additions and 12 deletions

View File

@ -649,8 +649,8 @@ public class SessionEventsHandler {
* This handler must be called before cleaning any sessions or recordings hosted * This handler must be called before cleaning any sessions or recordings hosted
* by the crashed Media Node * by the crashed Media Node
*/ */
public void onMediaNodeCrashed(Kms kms, long timeOfKurentoDisconnection, List<String> sessionIds, public void onMediaNodeCrashed(Kms kms, String environmentId, long timeOfKurentoDisconnection,
List<String> recordingIds) { List<String> sessionIds, List<String> recordingIds) {
} }
public void onMasterNodeCrashed(CDREventNodeCrashed event) { public void onMasterNodeCrashed(CDREventNodeCrashed event) {

View File

@ -87,7 +87,8 @@ public class FixedOneKmsManager extends KmsManager {
} }
@Override @Override
protected void removeMediaNodeUponCrash(String mediaNodeId) { protected String removeMediaNodeUponCrash(String mediaNodeId) {
return null;
} }
@Override @Override

View File

@ -222,7 +222,7 @@ public abstract class KmsManager {
// 1. Remove Media Node from cluster // 1. Remove Media Node from cluster
log.warn("Removing Media Node {} after crash", kms.getId()); log.warn("Removing Media Node {} after crash", kms.getId());
removeMediaNodeUponCrash(kms.getId()); String environmentId = removeMediaNodeUponCrash(kms.getId());
// 2. Close all sessions and recordings with reason "nodeCrashed" // 2. Close all sessions and recordings with reason "nodeCrashed"
log.warn("Closing {} sessions hosted by KMS with uri {}: {}", kms.getKurentoSessions().size(), log.warn("Closing {} sessions hosted by KMS with uri {}: {}", kms.getKurentoSessions().size(),
@ -237,8 +237,8 @@ public abstract class KmsManager {
} }
// 3. Send nodeCrashed webhook event // 3. Send nodeCrashed webhook event
sessionEventsHandler.onMediaNodeCrashed(kms, timeOfKurentoDisconnection, affectedSessionIds, sessionEventsHandler.onMediaNodeCrashed(kms, environmentId, timeOfKurentoDisconnection,
affectedRecordingIds); affectedSessionIds, affectedRecordingIds);
} else { } else {
@ -337,7 +337,7 @@ public abstract class KmsManager {
public abstract void decrementActiveRecordings(RecordingProperties recordingProperties, String recordingId, public abstract void decrementActiveRecordings(RecordingProperties recordingProperties, String recordingId,
Session session); Session session);
protected abstract void removeMediaNodeUponCrash(String mediaNodeId); protected abstract String removeMediaNodeUponCrash(String mediaNodeId);
@PostConstruct @PostConstruct
protected abstract void postConstructInitKurentoClients(); protected abstract void postConstructInitKurentoClients();

View File

@ -26,8 +26,6 @@ import java.util.concurrent.TimeUnit;
import javax.ws.rs.ProcessingException; import javax.ws.rs.ProcessingException;
import com.github.dockerjava.api.model.*;
import com.google.common.collect.ImmutableList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -41,11 +39,17 @@ import com.github.dockerjava.api.exception.ConflictException;
import com.github.dockerjava.api.exception.DockerClientException; import com.github.dockerjava.api.exception.DockerClientException;
import com.github.dockerjava.api.exception.InternalServerErrorException; import com.github.dockerjava.api.exception.InternalServerErrorException;
import com.github.dockerjava.api.exception.NotFoundException; import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.Bind;
import com.github.dockerjava.api.model.Container;
import com.github.dockerjava.api.model.DeviceRequest;
import com.github.dockerjava.api.model.HostConfig;
import com.github.dockerjava.api.model.Volume;
import com.github.dockerjava.core.DefaultDockerClientConfig; import com.github.dockerjava.core.DefaultDockerClientConfig;
import com.github.dockerjava.core.DockerClientBuilder; import com.github.dockerjava.core.DockerClientBuilder;
import com.github.dockerjava.core.DockerClientConfig; import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.core.command.ExecStartResultCallback; import com.github.dockerjava.core.command.ExecStartResultCallback;
import com.github.dockerjava.core.command.PullImageResultCallback; import com.github.dockerjava.core.command.PullImageResultCallback;
import com.google.common.collect.ImmutableList;
import io.openvidu.client.OpenViduException; import io.openvidu.client.OpenViduException;
import io.openvidu.client.OpenViduException.Code; import io.openvidu.client.OpenViduException.Code;
@ -134,9 +138,7 @@ public class LocalDockerManager implements DockerManager {
if (enableGPU) { if (enableGPU) {
DeviceRequest deviceRequest = new DeviceRequest() DeviceRequest deviceRequest = new DeviceRequest()
.withCapabilities(ImmutableList.of(ImmutableList.of("gpu"))) .withCapabilities(ImmutableList.of(ImmutableList.of("gpu"))).withCount(-1).withOptions(null);
.withCount(-1)
.withOptions(null);
hostConfig.withDeviceRequests(ImmutableList.of(deviceRequest)); hostConfig.withDeviceRequests(ImmutableList.of(deviceRequest));
} }