| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package com.evps.comm.server.config;
- import com.its.common.network.tcp.server.NettyServerConfig;
- import com.its.common.utils.TimeUtils;
- import lombok.Getter;
- import lombok.Setter;
- import lombok.ToString;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.boot.context.properties.ConfigurationProperties;
- import org.springframework.stereotype.Component;
- import javax.annotation.PostConstruct;
- @Slf4j
- @Getter
- @Setter
- @ToString
- @Component
- @ConfigurationProperties(prefix = "application")
- public class ApplicationConfig extends NettyServerConfig {
- private boolean loggingThread = false;
- private String processId = "evps-comm-server";
- private double cpuLimits = 75;
- private boolean packetDebug = true;
- private int autoEndMinutes = 20;
- private int lastCommTimeoutSeconds = 60;
- private int maxConnection = 0;
- private int packetWorkers = 0;
- private int loggingWorkers = 0;
- private int dbmsWorkers = 0;
- private int queueSize = 0;
- private String bootingTime;
- private boolean startSchedule;
- @PostConstruct
- private void init() {
- this.startSchedule = false;
- this.bootingTime = TimeUtils.now();
- configure();
- if (this.packetWorkers == 0) {
- this.packetWorkers = Runtime.getRuntime().availableProcessors() / 2;
- if (this.packetWorkers == 0) this.packetWorkers = 1;
- }
- if (this.loggingWorkers == 0) {
- this.loggingWorkers = Runtime.getRuntime().availableProcessors() / 4;
- if (this.loggingWorkers == 0) this.loggingWorkers = 1;
- }
- if (this.dbmsWorkers == 0) {
- this.dbmsWorkers = Runtime.getRuntime().availableProcessors() / 4;
- if (this.dbmsWorkers == 0) this.dbmsWorkers = 1;
- }
- if (this.readerIdleTimeSeconds < 10) {
- this.readerIdleTimeSeconds = 12;
- }
- if (this.autoEndMinutes != 0) {
- if (this.autoEndMinutes < 10){
- this.autoEndMinutes = 10;
- }
- if (this.autoEndMinutes > 60){
- this.autoEndMinutes = 60;
- }
- }
- if (this.lastCommTimeoutSeconds < 20){
- this.lastCommTimeoutSeconds = 20;
- }
- if (this.lastCommTimeoutSeconds > 180){
- this.lastCommTimeoutSeconds = 180;
- }
- this.acceptThreads = 1;
- log.info("[{}] -------------------------", this.getClass().getSimpleName());
- log.info("[{}] maxConnection: {}", this.getClass().getSimpleName(), this.maxConnection);
- log.info("[{}] loggingThread: {}", this.getClass().getSimpleName(), this.loggingThread);
- log.info("[{}] packetWorkers: {}", this.getClass().getSimpleName(), this.packetWorkers);
- log.info("[{}] loggingWorkers: {}", this.getClass().getSimpleName(), this.loggingWorkers);
- log.info("[{}] readerIdleTimeSeconds: {}", this.getClass().getSimpleName(), this.readerIdleTimeSeconds);
- log.info("{}", super.toString());
- }
- public int getQueueSize() {
- int qSize;
- if (this.queueSize == 0)
- qSize = 1000;
- else
- qSize = this.queueSize;
- return qSize;
- }
- }
|