调整节点管理代码结构
parent
ad32da0dfd
commit
4a0e9945b4
|
@ -1,10 +1,16 @@
|
|||
package com.genersoft.iot.vmp.media.zlm;
|
||||
|
||||
import com.genersoft.iot.vmp.media.event.MediaServerChangeEvent;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.event.HookZlmServerStartEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 管理zlm流媒体节点的状态
|
||||
|
@ -13,6 +19,8 @@ public class ZLMMediaServerStatusManger {
|
|||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ZLMMediaServerStatusManger.class);
|
||||
|
||||
private Map<Object, MediaServerItem> offlineZlmMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final String type = "zlm";
|
||||
|
||||
@Async("taskExecutor")
|
||||
|
@ -24,6 +32,24 @@ public class ZLMMediaServerStatusManger {
|
|||
return;
|
||||
}
|
||||
logger.info("[ZLM 待上线节点变化] ID:" + event.getMediaServerItem().getId());
|
||||
offlineZlmMap.put(event.getMediaServerItem().getId(), event.getMediaServerItem());
|
||||
}
|
||||
|
||||
@Async("taskExecutor")
|
||||
@EventListener
|
||||
public void onApplicationEvent(HookZlmServerStartEvent event) {
|
||||
if (event.getMediaServerItem() == null
|
||||
|| !type.equals(event.getMediaServerItem().getType())
|
||||
|| event.getMediaServerItem().isStatus()) {
|
||||
return;
|
||||
}
|
||||
logger.info("[ZLM-HOOK事件-服务启动] ID:" + event.getMediaServerItem().getId());
|
||||
offlineZlmMap.remove(event.getMediaServerItem().getId());
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = ) //每天的0点执行
|
||||
public void execute(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.genersoft.iot.vmp.media.zlm.event;
|
||||
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* zlm server_start事件
|
||||
*/
|
||||
public class HookZlmServerStartEvent extends ApplicationEvent {
|
||||
|
||||
public HookZlmServerStartEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
private MediaServerItem mediaServerItem;
|
||||
|
||||
public MediaServerItem getMediaServerItem() {
|
||||
return mediaServerItem;
|
||||
}
|
||||
|
||||
public void setMediaServerItem(MediaServerItem mediaServerItem) {
|
||||
this.mediaServerItem = mediaServerItem;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue