Skip to content

Commit

Permalink
Merge branch '4.3.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
KFCFans committed Aug 13, 2023
2 parents 00228f3 + 15fa1ab commit 58e542c
Show file tree
Hide file tree
Showing 90 changed files with 2,202 additions and 498 deletions.
4 changes: 4 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Security notices relating to PowerJob

Please disclose any security issues or vulnerabilities found through [Tidelift's coordinated disclosure system](https://tidelift.com/security) or to the maintainers privately(tengjiqi@gmail.com).

2 changes: 1 addition & 1 deletion others/dev/publish_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if [ "$startup" = "y" ] || [ "$startup" = "Y" ]; then
echo "================== 准备启动 powerjob-server =================="
docker run -d \
--name powerjob-server \
-p 7700:7700 -p 10086:10086 -p 5001:5005 -p 10001:10000 \
-p 7700:7700 -p 10086:10086 -p 10010:10010 -p 5001:5005 -p 10001:10000 \
-e JVMOPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" \
-e PARAMS="--spring.profiles.active=pre" \
-e TZ="Asia/Shanghai" \
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>tech.powerjob</groupId>
<artifactId>powerjob</artifactId>
<version>4.3.3</version>
<version>4.3.4</version>
<packaging>pom</packaging>
<name>powerjob</name>
<url>http://www.powerjob.tech</url>
Expand Down
6 changes: 3 additions & 3 deletions powerjob-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
<parent>
<artifactId>powerjob</artifactId>
<groupId>tech.powerjob</groupId>
<version>4.3.3</version>
<version>4.3.4</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>powerjob-client</artifactId>
<version>4.3.3</version>
<version>4.3.4</version>
<packaging>jar</packaging>

<properties>
<junit.version>5.9.1</junit.version>
<fastjson.version>1.2.83</fastjson.version>
<powerjob.common.version>4.3.3</powerjob.common.version>
<powerjob.common.version>4.3.4</powerjob.common.version>

<mvn.shade.plugin.version>3.2.4</mvn.shade.plugin.version>
</properties>
Expand Down
4 changes: 2 additions & 2 deletions powerjob-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<artifactId>powerjob</artifactId>
<groupId>tech.powerjob</groupId>
<version>4.3.3</version>
<version>4.3.4</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>powerjob-common</artifactId>
<version>4.3.3</version>
<version>4.3.4</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/**
* 通过 JVM 启动参数传入的配置信息
*
*
* @author tjq
* @since 2020/8/8
*/
Expand All @@ -16,7 +15,15 @@ public class PowerJobDKey {
*/
public static final String PREFERRED_NETWORK_INTERFACE = "powerjob.network.interface.preferred";

/**
* 绑定地址,一般填写本机网卡地址
*/
public static final String BIND_LOCAL_ADDRESS = "powerjob.network.local.address";
/**
* 外部地址,可选,默认与绑定地址相同。当存在 NAT 等场景时可通过单独传递外部地址来实现通讯
*/
public static final String NT_EXTERNAL_ADDRESS = "powerjob.network.external.address";
public static final String NT_EXTERNAL_PORT = "powerjob.network.external.port";

/**
* Java regular expressions for network interfaces that will be ignored.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package tech.powerjob.common.exception;

/**
* ImpossibleException
*
* @author tjq
* @since 2023/7/12
*/
public class ImpossibleException extends RuntimeException {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import tech.powerjob.common.exception.ImpossibleException;
import tech.powerjob.common.exception.PowerJobException;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* JSON工具类
Expand All @@ -27,6 +30,8 @@ public class JsonUtils {
.configure(JsonParser.Feature.IGNORE_UNDEFINED, true)
.build();

private static final TypeReference<Map<String, Object>> MAP_TYPE_REFERENCE = new TypeReference<Map<String, Object>> () {};

private JsonUtils(){

}
Expand Down Expand Up @@ -67,6 +72,18 @@ public static <T> T parseObject(String json, Class<T> clz) throws JsonProcessing
return JSON_MAPPER.readValue(json, clz);
}

public static Map<String, Object> parseMap(String json) {
if (StringUtils.isEmpty(json)) {
return new HashMap<>();
}
try {
return JSON_MAPPER.readValue(json, MAP_TYPE_REFERENCE);
} catch (Exception e) {
ExceptionUtils.rethrow(e);
}
throw new ImpossibleException();
}

public static <T> T parseObject(byte[] b, Class<T> clz) throws IOException {
return JSON_MAPPER.readValue(b, clz);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ public static int getRandomPort() {
return ThreadLocalRandom.current().nextInt(RND_PORT_START, RND_PORT_END);
}

/**
* 检测某个 IP 端口是否可用
* @param ip IP
* @param port 端口
* @return 是否可用
*/
public static boolean checkIpPortAvailable(String ip, int port) {
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress(ip, port), 1000);
return true;
} catch (Exception e) {
return false;
}
}

/**
* 获取本机 IP 地址
*
Expand Down Expand Up @@ -155,6 +170,9 @@ public static NetworkInterface findNetworkInterface() {
log.warn("[Net] findNetworkInterface failed", e);
}

// sort by interface index, the smaller is preferred.
validNetworkInterfaces.sort(Comparator.comparingInt(NetworkInterface::getIndex));

// Try to find the preferred one
for (NetworkInterface networkInterface : validNetworkInterfaces) {
if (isPreferredNetworkInterface(networkInterface)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package tech.powerjob.common.utils;

import org.apache.commons.lang3.StringUtils;

/**
* PropertyUtils
*
* @author tjq
* @since 2023/7/15
*/
public class PropertyUtils {

public static String readProperty(String key, String defaultValue) {
// 从启动参数读取
String property = System.getProperty(key);
if (StringUtils.isNotEmpty(property)) {
return property;
}

// 从 ENV 读取
property= System.getenv(key);
if (StringUtils.isNotEmpty(property)) {
return property;
}
// 部分操作系统不兼容 a.b.c 的环境变量,转换为 a_b_c 再取一次,即 PowerJob 支持 2 种类型的环境变量 key
property = System.getenv(key.replaceAll("\\.", "_"));
if (StringUtils.isNotEmpty(property)) {
return property;
}
return defaultValue;
}
}
6 changes: 3 additions & 3 deletions powerjob-official-processors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<artifactId>powerjob</artifactId>
<groupId>tech.powerjob</groupId>
<version>4.3.3</version>
<version>4.3.4</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>powerjob-official-processors</artifactId>
<version>4.3.3</version>
<version>4.3.4</version>
<packaging>jar</packaging>

<properties>
Expand All @@ -20,7 +20,7 @@
<!-- 不会被打包的部分,scope 只能是 test 或 provide -->
<junit.version>5.9.1</junit.version>
<logback.version>1.2.9</logback.version>
<powerjob.worker.version>4.3.3</powerjob.worker.version>
<powerjob.worker.version>4.3.4</powerjob.worker.version>
<spring.jdbc.version>5.2.9.RELEASE</spring.jdbc.version>
<h2.db.version>2.1.214</h2.db.version>
<mysql.version>8.0.28</mysql.version>
Expand Down

0 comments on commit 58e542c

Please sign in to comment.