|
|
@@ -9,6 +9,7 @@ import com.utic.ptis.server.dto.LinkDto;
|
|
|
import com.utic.ptis.server.dto.LinkTrafFusionInfo;
|
|
|
import com.utic.ptis.server.dto.LogicalLinkDto;
|
|
|
import com.utic.ptis.server.repository.ApplicationRepository;
|
|
|
+import com.utic.ptis.server.utils.LogUtils;
|
|
|
import lombok.Getter;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -31,22 +32,21 @@ public class LinkRepositoryService implements AbstractProcessService {
|
|
|
private final LinkTrafParamService linkTrafParamService;
|
|
|
|
|
|
private final ConcurrentHashMap<String, LinkDto> linkMap = new ConcurrentHashMap<>();
|
|
|
-
|
|
|
- private String[] link1Arr = null;
|
|
|
- private String[] link2Arr = null;
|
|
|
- private String[] link3Arr = null;
|
|
|
- private String[] link4Arr = null;
|
|
|
-
|
|
|
- private final ConcurrentHashMap<String, LinkDto> level1Map = new ConcurrentHashMap<>();
|
|
|
- private final ConcurrentHashMap<String, LinkDto> level2Map = new ConcurrentHashMap<>();
|
|
|
- private final ConcurrentHashMap<String, LinkDto> level3Map = new ConcurrentHashMap<>();
|
|
|
- private final ConcurrentHashMap<String, LinkDto> level4Map = new ConcurrentHashMap<>();
|
|
|
-
|
|
|
private final LinkTrafFusionInfo fusionInfo = new LinkTrafFusionInfo();
|
|
|
+ private volatile String[] linkArr = null;
|
|
|
+ private volatile String[] link1Arr = null;
|
|
|
+ private int link1Count = 0;
|
|
|
+ private int link2Count = 0;
|
|
|
+ private int link3Count = 0;
|
|
|
+ private int link4Count = 0;
|
|
|
+ private String prcsTime;
|
|
|
|
|
|
public LinkDto getLink(String linkId) {
|
|
|
return this.linkMap.get(linkId);
|
|
|
}
|
|
|
+ public void setPrcsTime(String prcsTime) {
|
|
|
+ this.prcsTime = prcsTime;
|
|
|
+ }
|
|
|
|
|
|
private boolean initializeLinkCount() {
|
|
|
boolean result = true;
|
|
|
@@ -56,32 +56,24 @@ public class LinkRepositoryService implements AbstractProcessService {
|
|
|
log.info("[INIT...] findLinkCount: LV1({}), LV2({}), LV3({}), LV4({}). {}",
|
|
|
linkCount.getLevel1(), linkCount.getLevel2(), linkCount.getLevel3(), linkCount.getLevel4(), Elapsed.elapsedStr(elapsed.nanoSeconds()));
|
|
|
|
|
|
- if (linkCount.getLevel1() > 0) {
|
|
|
- this.link1Arr = new String[linkCount.getLevel1()];
|
|
|
- }
|
|
|
- else {
|
|
|
- log.error("[INIT...] linkCount.getLevel1() is zero.");
|
|
|
- result = false;
|
|
|
- }
|
|
|
- if (linkCount.getLevel2() > 0) {
|
|
|
- this.link2Arr = new String[linkCount.getLevel2()];
|
|
|
+ this.link1Count = linkCount.getLevel1();
|
|
|
+ this.link2Count = linkCount.getLevel2();
|
|
|
+ this.link3Count = linkCount.getLevel3();
|
|
|
+ this.link4Count = linkCount.getLevel4();
|
|
|
+
|
|
|
+ int totalLinkCount = this.link1Count + this.link2Count + this.link3Count + this.link4Count;
|
|
|
+ if (this.link1Count > 0) {
|
|
|
+ this.link1Arr = new String[this.link1Count];
|
|
|
}
|
|
|
else {
|
|
|
- log.error("[INIT...] linkCount.getLevel2() is zero.");
|
|
|
+ log.error("[INIT...] totalLinkCount is zero.");
|
|
|
result = false;
|
|
|
}
|
|
|
- if (linkCount.getLevel3() > 0) {
|
|
|
- this.link3Arr = new String[linkCount.getLevel3()];
|
|
|
- result = false;
|
|
|
+ if (totalLinkCount > 0) {
|
|
|
+ this.linkArr = new String[totalLinkCount];
|
|
|
}
|
|
|
else {
|
|
|
- log.error("[INIT...] linkCount.getLevel3() is zero.");
|
|
|
- }
|
|
|
- if (linkCount.getLevel4() > 0) {
|
|
|
- this.link4Arr = new String[linkCount.getLevel4()];
|
|
|
- }
|
|
|
- else {
|
|
|
- log.error("[INIT...] linkCount.getLevel4() is zero.");
|
|
|
+ log.error("[INIT...] totalLinkCount is zero.");
|
|
|
result = false;
|
|
|
}
|
|
|
log.info("[INIT...] findLinkCount. {}", Elapsed.elapsedStr(elapsed.nanoSeconds()));
|
|
|
@@ -93,62 +85,31 @@ public class LinkRepositoryService implements AbstractProcessService {
|
|
|
log.info("[INIT...] findLinkAll.");
|
|
|
Elapsed elapsed = new Elapsed();
|
|
|
List<LinkDto> links = this.linkMapper.findLinkAll();
|
|
|
- log.info("[INIT...] findLinkAll: {} EA. {}", links.size(), Elapsed.elapsedStr(elapsed.nanoSeconds()));
|
|
|
+ log.info("[INIT...] findLinkAll: (SEL) {}", LogUtils.elapsedLog("LINK", links.size(), elapsed.milliSeconds()));
|
|
|
+
|
|
|
Elapsed tmpElapsed = new Elapsed();
|
|
|
int link1, link2, link3, link4;
|
|
|
+ int linkCnt = 0;
|
|
|
link1 = link2 = link3 = link4 = 0;
|
|
|
for (LinkDto link : links) {
|
|
|
link.init();
|
|
|
|
|
|
- boolean loading = true;
|
|
|
if (link.getLinkLevel() == 1) {
|
|
|
- if (link1 < this.link1Arr.length) {
|
|
|
- this.link1Arr[link1++] = link.getLinkId();
|
|
|
- this.level1Map.put(link.getLinkId(), link);
|
|
|
- }
|
|
|
- else {
|
|
|
- log.error("[INIT...] link1Arr is full. {} / {}", link1, this.link1Arr.length);
|
|
|
- loading = false;
|
|
|
- }
|
|
|
+ this.link1Arr[link1++] = link.getLinkId();
|
|
|
} else if (link.getLinkLevel() == 2) {
|
|
|
- if (link2 < this.link2Arr.length) {
|
|
|
- this.link2Arr[link2++] = link.getLinkId();
|
|
|
- this.level2Map.put(link.getLinkId(), link);
|
|
|
- }
|
|
|
- else {
|
|
|
- log.error("[INIT...] link2Arr is full. {} / {}", link2, this.link2Arr.length);
|
|
|
- loading = false;
|
|
|
- }
|
|
|
+ link2++;
|
|
|
} else if (link.getLinkLevel() == 3) {
|
|
|
- if (link3 < this.link3Arr.length) {
|
|
|
- this.link3Arr[link3++] = link.getLinkId();
|
|
|
- this.level3Map.put(link.getLinkId(), link);
|
|
|
- }
|
|
|
- else {
|
|
|
- log.error("[INIT...] link3Arr is full. {} / {}", link3, this.link3Arr.length);
|
|
|
- loading = false;
|
|
|
- }
|
|
|
+ link3++;
|
|
|
} else if (link.getLinkLevel() == 4) {
|
|
|
- if (link4 < this.link4Arr.length) {
|
|
|
- this.link4Arr[link4++] = link.getLinkId();
|
|
|
- this.level4Map.put(link.getLinkId(), link);
|
|
|
- }
|
|
|
- else {
|
|
|
- log.error("[INIT...] link4Arr is full. {} / {}", link4, this.link4Arr.length);
|
|
|
- loading = false;
|
|
|
- }
|
|
|
- }
|
|
|
- if (loading) {
|
|
|
- // 배열에 정상적으로 저장되었을 경우에만 맵에 저장한다.
|
|
|
- this.linkMap.put(link.getLinkId(), link);
|
|
|
- }
|
|
|
- else {
|
|
|
- result = loading;
|
|
|
+ link4++;
|
|
|
}
|
|
|
+ this.linkArr[linkCnt++] = link.getLinkId();
|
|
|
+ this.linkMap.put(link.getLinkId(), link);
|
|
|
}
|
|
|
- log.info("[INIT...] findLinkAll: Arr, LV1({}), LV2({}), LV3({}), LV4({}).", link1, link2, link3, link4);
|
|
|
- log.info("[INIT...] findLinkAll: Map, LV1({}), LV2({}), LV3({}), LV4({}). {} EA. {}",
|
|
|
- level1Map.size(), level2Map.size(), level3Map.size(), level4Map.size(), linkMap.size(), Elapsed.elapsedStr(tmpElapsed.nanoSeconds()));
|
|
|
+ log.info("[INIT...] findLinkAll: (MEM) {}, LV1({}), LV2({}), LV3({}), LV4({}).",
|
|
|
+ LogUtils.elapsedLog("MemoryAllocate", linkCnt, tmpElapsed.milliSeconds()),
|
|
|
+ link1, link2, link3, link4);
|
|
|
+
|
|
|
log.info("[INIT...] findLinkAll. {}", Elapsed.elapsedStr(elapsed.nanoSeconds()));
|
|
|
return result;
|
|
|
}
|