Code clean up
This commit is contained in:
parent
513fc8bd3e
commit
989a2d24f8
@ -778,7 +778,6 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void restoreSessions() {
|
private void restoreSessions() {
|
||||||
sessions.clear();
|
|
||||||
log.debug("[{}] Restoring sessions from cache", deviceId);
|
log.debug("[{}] Restoring sessions from cache", deviceId);
|
||||||
DeviceSessionsCacheEntry sessionsDump = null;
|
DeviceSessionsCacheEntry sessionsDump = null;
|
||||||
try {
|
try {
|
||||||
@ -818,13 +817,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
|
|||||||
ensureSessionsCapacity();
|
ensureSessionsCapacity();
|
||||||
|
|
||||||
log.debug("[{}] Dumping sessions: {}, rpc subscriptions: {}, attribute subscriptions: {} to cache", deviceId, sessions.size(), rpcSubscriptions.size(), attributeSubscriptions.size());
|
log.debug("[{}] Dumping sessions: {}, rpc subscriptions: {}, attribute subscriptions: {} to cache", deviceId, sessions.size(), rpcSubscriptions.size(), attributeSubscriptions.size());
|
||||||
List<SessionSubscriptionInfoProto> sessionsList;
|
List<SessionSubscriptionInfoProto> sessionsList = new ArrayList<>(sessions.size());
|
||||||
if (sessions.size() < systemContext.getMaxConcurrentSessionsPerDevice()) {
|
|
||||||
sessionsList = new ArrayList<>(sessions.size());
|
|
||||||
} else {
|
|
||||||
log.warn("[{}] Sessions size {} list more than maxConcurrentSessionsPerDevice {}. Dumping only latest", deviceId, sessions.size(), systemContext.getMaxConcurrentSessionsPerDevice());
|
|
||||||
sessionsList = new ArrayList<>((int) systemContext.getMaxConcurrentSessionsPerDevice());
|
|
||||||
}
|
|
||||||
sessions.forEach((uuid, sessionMD) -> {
|
sessions.forEach((uuid, sessionMD) -> {
|
||||||
if (sessionMD.getSessionInfo().getType() == SessionType.SYNC) {
|
if (sessionMD.getSessionInfo().getType() == SessionType.SYNC) {
|
||||||
return;
|
return;
|
||||||
@ -838,14 +831,10 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
|
|||||||
.setSessionIdMSB(uuid.getMostSignificantBits())
|
.setSessionIdMSB(uuid.getMostSignificantBits())
|
||||||
.setSessionIdLSB(uuid.getLeastSignificantBits())
|
.setSessionIdLSB(uuid.getLeastSignificantBits())
|
||||||
.setNodeId(sessionInfo.getNodeId()).build();
|
.setNodeId(sessionInfo.getNodeId()).build();
|
||||||
if (sessionsList.size() <= systemContext.getMaxConcurrentSessionsPerDevice()) {
|
sessionsList.add(SessionSubscriptionInfoProto.newBuilder()
|
||||||
sessionsList.add(SessionSubscriptionInfoProto.newBuilder()
|
.setSessionInfo(sessionInfoProto)
|
||||||
.setSessionInfo(sessionInfoProto)
|
.setSubscriptionInfo(subscriptionInfoProto).build());
|
||||||
.setSubscriptionInfo(subscriptionInfoProto).build());
|
log.debug("[{}] Dumping session: {}", deviceId, sessionMD);
|
||||||
log.debug("[{}] Dumping session: {}", deviceId, sessionMD);
|
|
||||||
} else {
|
|
||||||
log.warn("[{}] Session was not dumped: {}", deviceId, sessionMD);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
systemContext.getDeviceSessionCacheService()
|
systemContext.getDeviceSessionCacheService()
|
||||||
.put(deviceId, DeviceSessionsCacheEntry.newBuilder()
|
.put(deviceId, DeviceSessionsCacheEntry.newBuilder()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user