Skip to content

Commit

Permalink
Feature2.4.10 (#280)
Browse files Browse the repository at this point in the history
* enable configurable TimeZone for JSON parser in Nio and Http config

* updated log4j2.xml

* updated log4j2.xml

* wip

* wip

* afterProcess only get triggered when beforeProcess success

* release2.4.9

* fixed: rename config file will pause/resume service

* added CLI: -psv <envId>

* wip: config namespace

* wip

* refactoring

* refactoring file upload handler

* HttpClient: remotet Http response status will not be set to the response status of ServiceContext

* refactoring

* support ISO9601 offset with no colon

* PingHandler returns status reason; NioServer only log status on change

* refactoring

* PingHandler returns 502 Bad Gateway when service paused; 503 Service Unavailable when health check failed

* refactoring: HealthInspector can set log level and status of pause/healthcheck

* java doc plugin to 17

* service pause by multiple reasons via password, and can only be resumed by all those reasons via correct password

* service pause by multiple reasons via password, and can only be resumed by all those reasons via correct password

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* release2.4.10
  • Loading branch information
SummerBootFramework authored Aug 7, 2024
1 parent 870c9af commit 0072382
Show file tree
Hide file tree
Showing 31 changed files with 725 additions and 410 deletions.
20 changes: 10 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.summerboot</groupId>
<artifactId>jexpress</artifactId>
<version>2.4.9</version>
<version>2.4.10</version>
<packaging>jar</packaging>
<name>Summer Boot jExpress</name>
<description>Summer Boot jExpress focuses on solving non-functional and operational maintainability requirements,
Expand Down Expand Up @@ -92,7 +92,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<source>11</source>
<source>17</source>
<!-- <aggregate>true</aggregate>-->
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
Expand Down Expand Up @@ -190,7 +190,7 @@
<maven.resources.version>3.3.1</maven.resources.version>
<maven-surefire.version>3.2.5</maven-surefire.version>
<!-- Commons -->
<commons-lang3.version>3.14.0</commons-lang3.version>
<commons-lang3.version>3.15.0</commons-lang3.version>
<commons-cli.version>1.8.0</commons-cli.version>
<commons-io.version>2.16.1</commons-io.version>
<!-- <commons-text.version>1.11.0</commons-text.version>-->
Expand All @@ -206,12 +206,12 @@
<jwt.version>0.11.5</jwt.version>

<!-- NIO Netty -->
<netty.version>4.1.111.Final</netty.version>
<netty.version>4.1.112.Final</netty.version>
<netty-tcnative.version>2.0.65.Final</netty-tcnative.version>
<!-- gRPC and protobuf -->
<grpc.version>1.65.0</grpc.version>
<grpc.version>1.65.1</grpc.version>
<guava.version>33.2.1-jre</guava.version>
<protobuf.version>4.27.2</protobuf.version>
<protobuf.version>4.27.3</protobuf.version>
<!-- Web JAX-RS -->
<swagger.core.version>2.2.22</swagger.core.version>
<!--<elastic-apm.version>1.36.0</elastic-apm.version>-->
Expand All @@ -228,7 +228,7 @@
<jackson.version>2.17.2</jackson.version>
<!-- Bean Validation -->
<hibernate-validator.version>8.0.1.Final</hibernate-validator.version>
<jakarta.el.version>6.0.0</jakarta.el.version>
<jakarta.el.version>6.0.1</jakarta.el.version>

<!-- IOC Injection -->
<guice.version>7.0.0</guice.version>
Expand All @@ -238,7 +238,7 @@
<hikari-cp.version>5.1.0</hikari-cp.version>

<!-- Cache -->
<jedis.version>5.1.3</jedis.version>
<jedis.version>5.1.4</jedis.version>

<quartz.version>2.5.0-rc1</quartz.version>
<mqtt.version>1.2.5</mqtt.version>
Expand All @@ -253,8 +253,8 @@
<openhtml.version>1.0.10</openhtml.version>
<batik-transcoder.version>1.17</batik-transcoder.version>
<!-- PDF - iText -->
<itext7-core.version>8.0.4</itext7-core.version>
<itext7-html2pdf.version>5.0.4</itext7-html2pdf.version>
<itext7-core.version>8.0.5</itext7-core.version>
<itext7-html2pdf.version>5.0.5</itext7-html2pdf.version>

<!-- Testing -->
<testng.version>7.10.2</testng.version>
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/org/summerboot/jexpress/boot/BackOffice.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ public Map<Integer, Integer> getBootErrorCodeMapping() {
private String portInUseAlertMessage = ALERT_MSG_PORT_IN_USE;

@Config(key = "backoffice.executor.core", defaultValue = "3",
desc = "MaxSize 0 = current computer/VM's available processors + 1")
desc = "0 = current computer/VM's available processors + 1")
private int tpeCore = 3;

@Config(key = "backoffice.executor.max", defaultValue = "" + Integer.MAX_VALUE,
desc = "MaxSize 0 = current computer/VM's available processors + 1")
private int tpeMax = Integer.MAX_VALUE;
@Config(key = "backoffice.executor.max", defaultValue = "3",
desc = "0 = current computer/VM's available processors + 1")
private int tpeMax = 3;

@Config(key = "backoffice.executor.queue", defaultValue = "0")
private int tpeQueue = 0;
@Config(key = "backoffice.executor.queue", defaultValue = "" + Integer.MAX_VALUE)
private int tpeQueue = Integer.MAX_VALUE;

@Config(key = "backoffice.executor.keepAliveTimeSec", defaultValue = "60")
private int tpeKeepAliveSeconds = 60;
Expand Down Expand Up @@ -231,6 +231,12 @@ public Map<Integer, Integer> getBootErrorCodeMapping() {
@Config(key = "naming.file.gRPCConfig", defaultValue = "cfg_grpc.properties")
private String gRPCConfigFileName = "cfg_grpc.properties";

@Config(key = "HealthMonitor.PauseLockCode.viaFile", defaultValue = "PauseLockCode.file")
private String pauseLockCodeViaFile = "PauseLockCode.file";

@Config(key = "HealthMonitor.PauseLockCode.viaWeb", defaultValue = "PauseLockCode.web")
private String pauseLockCodeViaWeb = "PauseLockCode.web";

@ConfigHeader(title = "4.2 Default Log4j2.xml Variables Naming")
@Config(key = "naming.log4j2.xml.var.logId", defaultValue = "logId")
private String log4j2LogId = "logId";
Expand Down Expand Up @@ -290,6 +296,9 @@ public Map<Integer, Integer> getBootErrorCodeMapping() {
@Config(key = "naming.cli.decrypt", defaultValue = "decrypt")
private String cliName_decrypt = "decrypt";

@Config(key = "naming.cli.psv", defaultValue = "psv")
private String cliName_psv = "psv";

@Config(key = "naming.memo.delimiter", defaultValue = ": ")
private String memoDelimiter = ": ";

Expand Down Expand Up @@ -361,6 +370,14 @@ public String getgRPCConfigFileName() {
return gRPCConfigFileName;
}

public String getPauseLockCodeViaFile() {
return pauseLockCodeViaFile;
}

public String getPauseLockCodeViaWeb() {
return pauseLockCodeViaWeb;
}

public String getLog4J2LogId() {
return log4j2LogId;
}
Expand Down Expand Up @@ -437,6 +454,10 @@ public String getCliName_decrypt() {
return cliName_decrypt;
}

public String getCliName_psv() {
return cliName_psv;
}

public String getMemoDelimiter() {
return memoDelimiter;
}
Expand Down
201 changes: 111 additions & 90 deletions src/main/java/org/summerboot/jexpress/boot/BootConstant.java
Original file line number Diff line number Diff line change
@@ -1,95 +1,116 @@
/*
* Copyright 2005-2022 Du Law Office - The Summer Boot Framework Project
*
* The Summer Boot Project licenses this file to you under the Apache License, version 2.0 (the
* "License"); you may not use this file except in compliance with the License and you have no
* policy prohibiting employee contributions back to this file (unless the contributor to this
* file is your current or retired employee). You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.summerboot.jexpress.boot;
<?xml version="1.0" encoding="UTF-8"?>
<!-- version 2.4.10 -->
<Configuration status="WARN" monitorInterval="30">
<Properties>
<Property name="logPattern" value="[${sys:logId}] %d{ISO8601} %p %c{}.%M() [%t] %m %ex%n"/>
<!-- usage: %replace{pattern}{regex}{substitution} -->
<Property name="logPattern2" value="[${sys:logId}] %d{ISO8601} %p %c{}.%M() [%t] %replace{%enc{%m}{CRLF}}{\\r|\\n|%0D|%0A|%0d|%0a}{|} %uEx%n"/>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<!-- <PatternLayout pattern="%d{ISO8601}{Canada/Eastern} %p %c{}.%M() [%t] %enc{%m}{CRLF} %ex%n"/>-->
<PatternLayout pattern="${sys:logPattern}"/>
</Console>
import java.util.Random;
<!--
1. Requires JVM arg: -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
2. Required total disk spece: around 200MB
3. Archive logs: by DAY and split them by MINUTE
4. Default log level is tuned for development
-->
<RollingRandomAccessFile
name="StatusLogFile"
fileName="${sys:logPath}/${sys:appName}_status_${sys:serverName}.log"
filePattern="${sys:logPath}/$${date:yyyy-MM-dd}/${sys:appName}_status_${sys:serverName}_%d{yyyy-MM-dd HH:mm}.%i.log.gz"
immediateFlush="false"
ignoreExceptions="false">
<PatternLayout pattern="${sys:logPattern}"/>
<Policies>
<SizeBasedTriggeringPolicy size="2MB"/>
</Policies>
<DefaultRolloverStrategy max="50"/>
</RollingRandomAccessFile>
<RollingRandomAccessFile
name="RequestLogFile"
fileName="${sys:logPath}/${sys:appName}_requests_${sys:serverName}.log"
filePattern="${sys:logPath}/$${date:yyyy-MM-dd}/${sys:appName}_requests_${sys:serverName}_%d{yyyy-MM-dd HH:mm}.%i.log.gz"
immediateFlush="false"
ignoreExceptions="false">
<PatternLayout pattern="${sys:logPattern}"/>
<Policies>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<DefaultRolloverStrategy max="500"/>
</RollingRandomAccessFile>
<RollingRandomAccessFile
name="ScheduledLogFile"
fileName="${sys:logPath}/${sys:appName}_schedule_${sys:serverName}.log"
filePattern="${sys:logPath}/$${date:yyyy-MM-dd}/${sys:appName}_schedule_${sys:serverName}_%d{yyyy-MM-dd HH:mm}.%i.log.gz"
immediateFlush="false"
ignoreExceptions="false">
<PatternLayout pattern="${sys:logPattern}"/>
<Policies>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<DefaultRolloverStrategy max="500"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="warn" includeLocation="true">
<AppenderRef ref="StatusLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Root>
<Logger level="info" name="com.hazelcast" includeLocation="true"/>
<Logger level="warn" name="io.netty" includeLocation="true"/>
<!-- Note: "java.lang.UnsupportedOperationException: sun.misc.Unsafe unavailable" can be seen, also can be ignored, when -Dio.netty.noUnsafe=true and io.netty.util.internal.CleanerJava9 log level is below INFO (either TRACE or DEBUG) -->
<Logger level="info" name="io.netty.util.internal.CleanerJava9" includeLocation="true"/>
<Logger level="debug" name="org.summerboot.jexpress.boot" includeLocation="true"/>
<Logger level="warn" org.summerboot.jexpress.boot.instrumentation.Timeout includeLocation="true"/>
<Logger level="info" name="org.summerboot.jexpress.integration.httpclient.HttpClientConfig" includeLocation="true"/>
<Logger level="info" name="org.summerboot.jexpress.nio.server.NioServerHttpInitializer" includeLocation="true"/>
<Logger level="debug" name="org.summerboot.jexpress.nio.server.NioServer" includeLocation="true"/>
<Logger level="debug" name="org.summerboot.jexpress.nio.grpc.GRPCServer" includeLocation="true"/>

/**
* @author Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
*/
public interface BootConstant {

String APP_ID = String.format("%06d", new Random().nextInt(999999));
<Logger level="warn" name="io.netty.handler" includeLocation="false" additivity="false">
<AppenderRef ref="RequestLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Logger>

//version
String VERSION = "SummerBoot.jExpress 2.4.9";
String JEXPRESS_PACKAGE_NAME = "org.summerboot.jexpress";
<Logger level="info" name="org.summerboot.jexpress.nio.server.BootHttpRequestHandler" includeLocation="false"
additivity="false">
<AppenderRef ref="RequestLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Logger>
<Logger level="info" name="org.summerboot.jexpress.integration.quartz.BootJobListener" includeLocation="false"
additivity="false">
<AppenderRef ref="ScheduledLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Logger>
<Logger level="warn" name="org.summerboot.jexpress.integration.ldap" includeLocation="true" additivity="false">
<AppenderRef ref="RequestLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Logger>
<Logger level="debug" name="org.hibernate.SQL" includeLocation="true" additivity="false">
<AppenderRef ref="RequestLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Logger>
<Logger level="debug" name="org.hibernate.type" includeLocation="true" additivity="false">
<AppenderRef ref="RequestLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Logger>

String DEFAULT_ADMIN_MM = "changeit";

/*
* Runtime info
*/
int CPU_CORE = Runtime.getRuntime().availableProcessors();
String PID = java.lang.management.ManagementFactory.getRuntimeMXBean().getName();
String BR = System.lineSeparator();

//logging metadata
String LOG4J2_KEY = "log4j.configurationFile";
String LOG4J2_JDKADAPTER_KEY = "java.util.logging.manager";
String LOG4J2_JDKADAPTER_VALUE = "org.apache.logging.log4j.jul.LogManager";

/**
* 3. jExpress Default Settings
*/
boolean CFG_ERROR_CODE_AS_INT = BackOffice.agent.isErrorCodeAsInt();
int CFG_CHANGE_MONITOR_INTERVAL_SEC = BackOffice.agent.getCfgChangeMonitorIntervalSec();
int PACKAGE_LEVEL = BackOffice.agent.getReflectionPackageLevel();
long WEB_RESOURCE_TTL_MS = BackOffice.agent.getWebResourceCacheTtlSec() * 1000;
String DIR_STANDALONE = BackOffice.agent.getDomainFolderPrefix();
String DIR_CONFIGURATION = BackOffice.agent.getConfigFolderName();
String DIR_PLUGIN = BackOffice.agent.getPluginFolderName();
String DIR_LOG = BackOffice.agent.getLogFolderName();

String FILE_CFG_AUTH = BackOffice.agent.getAuthConfigFileName();
String FILE_CFG_SMTP = BackOffice.agent.getSmtpConfigFileName();
String FILE_CFG_NIO = BackOffice.agent.getNioConfigFileName();
String FILE_CFG_GRPC = BackOffice.agent.getgRPCConfigFileName();

/*
* 4. jExpress Default CLI Name
*/
String CLI_USAGE = BackOffice.agent.getCliName_usage();
String CLI_VERSION = BackOffice.agent.getCliName_version();
String CLI_CONFIG_DOMAIN = BackOffice.agent.getCliName_domain();
String CLI_CONFIG_DIR = BackOffice.agent.getCliName_cfgdir();
String CLI_CONFIG_MONITOR_INTERVAL = BackOffice.agent.getCliName_monitorInterval();
String CLI_I8N = BackOffice.agent.getCliName_i18n();
String CLI_USE_IMPL = BackOffice.agent.getCliName_use();//To specify which implementation will be used via @Component.checkImplTagUsed
String CLI_CONFIG_DEMO = BackOffice.agent.getCliName_cfgdemo();
String CLI_LIST_UNIQUE = BackOffice.agent.getCliName_list();
String CLI_ADMIN_PWD_FILE = BackOffice.agent.getCliName_authfile();
String CLI_ADMIN_PWD = BackOffice.agent.getCliName_auth();
String CLI_JWT = BackOffice.agent.getCliName_jwt();
String CLI_ENCRYPT = BackOffice.agent.getCliName_encrypt();
String CLI_DECRYPT = BackOffice.agent.getCliName_decrypt();
String MEMO_DELIMITER = BackOffice.agent.getMemoDelimiter();

/*
* 5. Log4j2.xml variables
*
* Pass by System.setProperty() instead of making them public static, any better idea?
* ‘java.lang.System.getProperty()’ API underlyingly uses ‘java.util.Hashtable.get()’ API.
* Please be advised that ‘java.util.Hashtable.get()’ is a synchronized API.
* It means only one thread can invoke the ‘java.util.Hashtable.get()’ method at any given time.
*/
String SYS_PROP_LOGID = BackOffice.agent.getLog4J2LogId();// "logid" // used by log4j2.xml ${sys:logid}
String SYS_PROP_LOGFILEPATH = BackOffice.agent.getLog4j2LogFilePath();//"logPath"; // used by log4j2.xml ${sys:loggingPath}
String SYS_PROP_LOGFILENAME = BackOffice.agent.getLog4j2LogFileName();//"appName"; // used by log4j2.xml ${sys:appappName} as log file name
String SYS_PROP_SERVER_NAME = BackOffice.agent.getLog4j2ServerName();//"serverName"; // used by log4j2.xml ${hostName}
String SYS_PROP_APP_PACKAGE_NAME = BackOffice.agent.getLog4j2AppPackageName();//"appPackageName"; // used by both log4j2.xml ${sys:appPackage} and JPAHibernateConfig to scan @Entity

}
<Logger level="debug" name="${sys:appPackageName}" includeLocation="true" additivity="false">
<AppenderRef ref="RequestLogFile"/>
<!-- -->
<AppenderRef ref="Console"/>
</Logger>
</Loggers>
</Configuration>
Loading

0 comments on commit 0072382

Please sign in to comment.