|
@@ -1,11 +1,16 @@
|
|
package com.its.op.service;
|
|
package com.its.op.service;
|
|
|
|
|
|
import com.its.op.dto.ThreadMonitoringDto;
|
|
import com.its.op.dto.ThreadMonitoringDto;
|
|
|
|
+import com.its.op.dto.WebsocketMonitoringDto;
|
|
|
|
+import com.its.op.websocket.ItsWebSocketSession;
|
|
|
|
+import com.its.op.websocket.ItsWebSocketSessionManager;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.socket.WebSocketSession;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -14,6 +19,7 @@ import java.util.stream.Collectors;
|
|
public class ResourceMonitoringService {
|
|
public class ResourceMonitoringService {
|
|
|
|
|
|
private final Map<String, Set<Thread>> threadMap = new HashMap<String, Set<Thread>>();
|
|
private final Map<String, Set<Thread>> threadMap = new HashMap<String, Set<Thread>>();
|
|
|
|
+ private final ItsWebSocketSessionManager itsWebSocketSessionManager;
|
|
|
|
|
|
private Set<Thread> getActiveThreadSet() {
|
|
private Set<Thread> getActiveThreadSet() {
|
|
//ThreadUtils.getAllThreads()
|
|
//ThreadUtils.getAllThreads()
|
|
@@ -107,4 +113,19 @@ public class ResourceMonitoringService {
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public List<WebsocketMonitoringDto> getWebsocketList() {
|
|
|
|
+ List<WebsocketMonitoringDto> result = new ArrayList<>();
|
|
|
|
+ ConcurrentHashMap<WebSocketSession, ItsWebSocketSession> socketMap = this.itsWebSocketSessionManager.getMap();
|
|
|
|
+ socketMap.forEach((key, session) -> {
|
|
|
|
+ WebsocketMonitoringDto dto = WebsocketMonitoringDto.builder().build();
|
|
|
|
+ dto.setConnectTm(session.getConnectTm());
|
|
|
|
+ dto.setGroupId(session.getGroupId());
|
|
|
|
+ dto.setRemoteAddress(session.getSession().getRemoteAddress().toString());
|
|
|
|
+ dto.setUri(session.getSession().getUri().toString());
|
|
|
|
+ dto.setSessionId(session.getSession().getId());
|
|
|
|
+ result.add(dto);
|
|
|
|
+ });
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|