mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: nodeCrashed event with lists of session and recording ids
parent
f89f1abffd
commit
3e9f8b5669
|
@ -1,6 +1,5 @@
|
||||||
package io.openvidu.server.cdr;
|
package io.openvidu.server.cdr;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
|
@ -11,15 +10,16 @@ import io.openvidu.server.kurento.kms.Kms;
|
||||||
public class CDREventNodeCrashed extends CDREvent {
|
public class CDREventNodeCrashed extends CDREvent {
|
||||||
|
|
||||||
private Kms kms;
|
private Kms kms;
|
||||||
private List<String> sessionIds = new ArrayList<>();
|
private List<String> sessionIds;
|
||||||
private List<String> recordingIds = new ArrayList<>();
|
private List<String> recordingIds;
|
||||||
private String environmentId;
|
private String environmentId;
|
||||||
|
|
||||||
public CDREventNodeCrashed(CDREventName eventName, Long timeStamp, Kms kms, String environmentId) {
|
public CDREventNodeCrashed(CDREventName eventName, Long timeStamp, Kms kms, String environmentId,
|
||||||
|
List<String> sessionIds, List<String> recordingIds) {
|
||||||
super(eventName, null, null, timeStamp);
|
super(eventName, null, null, timeStamp);
|
||||||
this.kms = kms;
|
this.kms = kms;
|
||||||
kms.getKurentoSessions().forEach(session -> sessionIds.add(session.getSessionId()));
|
this.sessionIds = sessionIds;
|
||||||
kms.getActiveRecordings().forEach(entry -> recordingIds.add(entry.getKey()));
|
this.recordingIds = recordingIds;
|
||||||
this.environmentId = environmentId;
|
this.environmentId = environmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package io.openvidu.server.cdr;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -193,6 +194,13 @@ public class CallDetailRecord {
|
||||||
this.log(new CDREventSignal(sessionId, uniqueSessionId, from, to, type, data));
|
this.log(new CDREventSignal(sessionId, uniqueSessionId, from, to, type, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void recordNodeCrashed(Kms kms, String environmentId, long timeOfKurentoDisconnection,
|
||||||
|
List<String> sessionIds, List<String> recordingIds) {
|
||||||
|
CDREvent e = new CDREventNodeCrashed(CDREventName.nodeCrashed, timeOfKurentoDisconnection, kms, environmentId,
|
||||||
|
sessionIds, recordingIds);
|
||||||
|
this.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
protected void log(CDREvent event) {
|
protected void log(CDREvent event) {
|
||||||
this.loggers.forEach(logger -> {
|
this.loggers.forEach(logger -> {
|
||||||
|
|
||||||
|
@ -224,9 +232,4 @@ public class CallDetailRecord {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordNodeCrashed(Kms kms, String environmentId, long timeOfKurentoDisconnection) {
|
|
||||||
CDREvent e = new CDREventNodeCrashed(CDREventName.nodeCrashed, timeOfKurentoDisconnection, kms, environmentId);
|
|
||||||
this.log(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package io.openvidu.server.core;
|
package io.openvidu.server.core;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -635,7 +636,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) {
|
public void onMediaNodeCrashed(Kms kms, long timeOfKurentoDisconnection, List<String> sessionIds,
|
||||||
|
List<String> recordingIds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMasterNodeCrashed() {
|
public void onMasterNodeCrashed() {
|
||||||
|
|
|
@ -215,7 +215,13 @@ public abstract class KmsManager {
|
||||||
kms.getKurentoClientReconnectTimer().cancelTimer();
|
kms.getKurentoClientReconnectTimer().cancelTimer();
|
||||||
|
|
||||||
final long timeOfKurentoDisconnection = kms.getTimeOfKurentoClientDisconnection();
|
final long timeOfKurentoDisconnection = kms.getTimeOfKurentoClientDisconnection();
|
||||||
sessionEventsHandler.onMediaNodeCrashed(kms, timeOfKurentoDisconnection);
|
final List<String> affectedSessionIds = kms.getKurentoSessions().stream()
|
||||||
|
.map(session -> session.getSessionId()).collect(Collectors.toUnmodifiableList());
|
||||||
|
final List<String> affectedRecordingIds = kms.getActiveRecordings().stream()
|
||||||
|
.map(entry -> entry.getKey()).collect(Collectors.toUnmodifiableList());
|
||||||
|
|
||||||
|
sessionEventsHandler.onMediaNodeCrashed(kms, timeOfKurentoDisconnection, affectedSessionIds,
|
||||||
|
affectedRecordingIds);
|
||||||
|
|
||||||
// Close all sessions and recordings with reason "nodeCrashed"
|
// 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(),
|
||||||
|
|
Loading…
Reference in New Issue