mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
[opt] optimize worker-starter
This commit is contained in:
parent
a1dc3f990c
commit
8d8b8d504a
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>powerjob-worker-starter</artifactId>
|
<artifactId>powerjob-worker-starter</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.2.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<powerjob.worker.version>3.2.0</powerjob.worker.version>
|
<powerjob.worker.version>3.2.1</powerjob.worker.version>
|
||||||
<springboot.version>2.2.6.RELEASE</springboot.version>
|
<springboot.version>2.2.6.RELEASE</springboot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
package com.github.kfcfans.powerjob.worker.autoconfigure;
|
package com.github.kfcfans.powerjob.worker.autoconfigure;
|
||||||
|
|
||||||
|
import com.github.kfcfans.powerjob.common.utils.CommonUtils;
|
||||||
import com.github.kfcfans.powerjob.worker.OhMyWorker;
|
import com.github.kfcfans.powerjob.worker.OhMyWorker;
|
||||||
import com.github.kfcfans.powerjob.worker.common.OhMyConfig;
|
import com.github.kfcfans.powerjob.worker.common.OhMyConfig;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PowerJob 自动装配
|
* PowerJob 自动装配
|
||||||
*
|
*
|
||||||
* @author songyinyin
|
* @author songyinyin
|
||||||
* @date 2020/7/26 16:37
|
* @since 2020/7/26 16:37
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableConfigurationProperties(PowerJobProperties.class)
|
@EnableConfigurationProperties(PowerJobProperties.class)
|
||||||
@ -27,19 +26,18 @@ public class PowerJobAutoConfiguration {
|
|||||||
public OhMyWorker initPowerJob(PowerJobProperties properties) {
|
public OhMyWorker initPowerJob(PowerJobProperties properties) {
|
||||||
|
|
||||||
// 服务器HTTP地址(端口号为 server.port,而不是 ActorSystem port),请勿添加任何前缀(http://)
|
// 服务器HTTP地址(端口号为 server.port,而不是 ActorSystem port),请勿添加任何前缀(http://)
|
||||||
List<String> serverAddress = StringUtils.hasText(properties.getServerAddress())
|
CommonUtils.requireNonNull(properties.getServerAddress(), "serverAddress can't be empty!");
|
||||||
? Arrays.asList(properties.getServerAddress().split(","))
|
List<String> serverAddress = Arrays.asList(properties.getServerAddress().split(","));
|
||||||
: Collections.singletonList("127.0.0.1:7700");
|
|
||||||
|
|
||||||
// 1. 创建配置文件
|
// 1. 创建配置文件
|
||||||
OhMyConfig config = new OhMyConfig();
|
OhMyConfig config = new OhMyConfig();
|
||||||
// 可以不显示设置,默认值 27777
|
// 可以不显式设置,默认值 27777
|
||||||
config.setPort(properties.getAkkaPort());
|
config.setPort(properties.getAkkaPort());
|
||||||
// appName,需要提前在控制台注册,否则启动报错
|
// appName,需要提前在控制台注册,否则启动报错
|
||||||
config.setAppName(properties.getAppName());
|
config.setAppName(properties.getAppName());
|
||||||
config.setServerAddress(serverAddress);
|
config.setServerAddress(serverAddress);
|
||||||
// 如果没有大型 Map/MapReduce 的需求,建议使用内存来加速计算
|
// 如果没有大型 Map/MapReduce 的需求,建议使用内存来加速计算
|
||||||
// 有大型 Map/MapReduce 需求,可能产生大量子任务(Task)的场景,请使用 DISK,否则妥妥的 OutOfMemeory
|
// 有大型 Map/MapReduce 需求,可能产生大量子任务(Task)的场景,请使用 DISK,否则妥妥的 OutOfMemory
|
||||||
config.setStoreStrategy(properties.getStoreStrategy());
|
config.setStoreStrategy(properties.getStoreStrategy());
|
||||||
// 启动测试模式,true情况下,不再尝试连接 server 并验证appName
|
// 启动测试模式,true情况下,不再尝试连接 server 并验证appName
|
||||||
config.setEnableTestMode(properties.isEnableTestMode());
|
config.setEnableTestMode(properties.isEnableTestMode());
|
||||||
|
@ -10,7 +10,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||||||
* PowerJob 配置项
|
* PowerJob 配置项
|
||||||
*
|
*
|
||||||
* @author songyinyin
|
* @author songyinyin
|
||||||
* @date 2020/7/26 16:37
|
* @since 2020/7/26 16:37
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ConfigurationProperties(prefix = "powerjob")
|
@ConfigurationProperties(prefix = "powerjob")
|
||||||
@ -26,7 +26,7 @@ public class PowerJobProperties {
|
|||||||
/**
|
/**
|
||||||
* 调度服务器地址,ip:port 或 域名,多个用英文逗号分隔
|
* 调度服务器地址,ip:port 或 域名,多个用英文逗号分隔
|
||||||
*/
|
*/
|
||||||
private String serverAddress = "127.0.0.1:7700";
|
private String serverAddress;
|
||||||
/**
|
/**
|
||||||
* 本地持久化方式,默认使用磁盘
|
* 本地持久化方式,默认使用磁盘
|
||||||
*/
|
*/
|
||||||
|
@ -29,9 +29,8 @@
|
|||||||
{
|
{
|
||||||
"name": "powerjob.server-address",
|
"name": "powerjob.server-address",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
"description": "调度服务器地址,ip:port 或 域名,多个用英文逗号分隔",
|
"description": "调度服务器地址,ip:port 或 域名,多值用英文逗号分隔",
|
||||||
"sourceType": "com.github.kfcfans.powerjob.worker.autoconfigure.PowerJobProperties",
|
"sourceType": "com.github.kfcfans.powerjob.worker.autoconfigure.PowerJobProperties"
|
||||||
"defaultValue": "127.0.0.1:7700"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "powerjob.store-strategy",
|
"name": "powerjob.store-strategy",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user