mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
Merge branch '4.1.1-worker-enabled' into v4.1.1
This commit is contained in:
commit
42fa628a61
@ -1,5 +1,6 @@
|
|||||||
package tech.powerjob.samples.config;
|
package tech.powerjob.samples.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import tech.powerjob.common.utils.CommonUtils;
|
import tech.powerjob.common.utils.CommonUtils;
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
@ -9,6 +10,7 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import tech.powerjob.official.processors.impl.sql.SpringDatasourceSqlProcessor;
|
import tech.powerjob.official.processors.impl.sql.SpringDatasourceSqlProcessor;
|
||||||
|
import tech.powerjob.worker.PowerJobWorker;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
@ -17,6 +19,7 @@ import javax.sql.DataSource;
|
|||||||
* @since 2021/3/10
|
* @since 2021/3/10
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ConditionalOnBean(PowerJobWorker.class)
|
||||||
public class SqlProcessorConfiguration {
|
public class SqlProcessorConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
server.port=8081
|
server.port=8081
|
||||||
spring.jpa.open-in-view=false
|
spring.jpa.open-in-view=false
|
||||||
########### PowerJob-worker properties. ###########
|
########### PowerJob-worker properties. ###########
|
||||||
|
# Whether to enable PowerJob Worker, default is true
|
||||||
|
powerjob.worker.enabled=true
|
||||||
# Akka port, default is 27777
|
# Akka port, default is 27777
|
||||||
powerjob.worker.akka-port=27777
|
powerjob.worker.akka-port=27777
|
||||||
# Application name, used for grouping applications. Recommend to set the same value as project name.
|
# Application name, used for grouping applications. Recommend to set the same value as project name.
|
||||||
|
@ -33,6 +33,13 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<version>${springboot.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
@ -1,29 +1,27 @@
|
|||||||
package tech.powerjob.worker.autoconfigure;
|
package tech.powerjob.worker.autoconfigure;
|
||||||
|
|
||||||
import tech.powerjob.common.utils.CommonUtils;
|
|
||||||
import tech.powerjob.common.utils.NetUtils;
|
|
||||||
import tech.powerjob.worker.PowerJobWorker;
|
|
||||||
import tech.powerjob.worker.common.PowerJobWorkerConfig;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
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.Conditional;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import tech.powerjob.common.utils.CommonUtils;
|
||||||
|
import tech.powerjob.common.utils.NetUtils;
|
||||||
|
import tech.powerjob.worker.PowerJobWorker;
|
||||||
|
import tech.powerjob.worker.common.PowerJobWorkerConfig;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto configuration class for PowerJob-worker.
|
* Autoconfiguration class for PowerJob-worker.
|
||||||
*
|
*
|
||||||
* @author songyinyin
|
* @author songyinyin
|
||||||
* @since 2020/7/26 16:37
|
* @since 2020/7/26 16:37
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableConfigurationProperties(PowerJobProperties.class)
|
@EnableConfigurationProperties(PowerJobProperties.class)
|
||||||
@Conditional(PowerJobAutoConfiguration.PowerJobWorkerCondition.class)
|
@ConditionalOnProperty(prefix = "powerjob.worker", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class PowerJobAutoConfiguration {
|
public class PowerJobAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -36,7 +34,8 @@ public class PowerJobAutoConfiguration {
|
|||||||
* Address of PowerJob-server node(s). Do not mistake for ActorSystem port. Do not add
|
* Address of PowerJob-server node(s). Do not mistake for ActorSystem port. Do not add
|
||||||
* any prefix, i.e. http://.
|
* any prefix, i.e. http://.
|
||||||
*/
|
*/
|
||||||
CommonUtils.requireNonNull(worker.getServerAddress(), "serverAddress can't be empty!");
|
CommonUtils.requireNonNull(worker.getServerAddress(), "serverAddress can't be empty! " +
|
||||||
|
"if you don't want to enable powerjob, please config program arguments: powerjob.worker.enabled=false");
|
||||||
List<String> serverAddress = Arrays.asList(worker.getServerAddress().split(","));
|
List<String> serverAddress = Arrays.asList(worker.getServerAddress().split(","));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -85,21 +84,4 @@ public class PowerJobAutoConfiguration {
|
|||||||
return ohMyWorker;
|
return ohMyWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class PowerJobWorkerCondition extends AnyNestedCondition {
|
|
||||||
|
|
||||||
public PowerJobWorkerCondition() {
|
|
||||||
super(ConfigurationPhase.PARSE_CONFIGURATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@ConditionalOnProperty(prefix = "powerjob", name = "server-address")
|
|
||||||
static class PowerJobProperty {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConditionalOnProperty(prefix = "powerjob.worker", name = "server-address")
|
|
||||||
static class PowerJobWorkerProperty {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,12 @@ public class PowerJobProperties {
|
|||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public static class Worker {
|
public static class Worker {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to enable PowerJob Worker
|
||||||
|
*/
|
||||||
|
private boolean enabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of application, String type. Total length of this property should be no more than 255
|
* Name of application, String type. Total length of this property should be no more than 255
|
||||||
* characters. This is one of the required properties when registering a new application. This
|
* characters. This is one of the required properties when registering a new application. This
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
{
|
|
||||||
"groups": [
|
|
||||||
{
|
|
||||||
"name": "powerjob",
|
|
||||||
"type": "tech.powerjob.worker.autoconfigure.PowerJobProperties",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker",
|
|
||||||
"type": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties",
|
|
||||||
"sourceMethod": "getWorker()"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"properties": [
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.akka-port",
|
|
||||||
"type": "java.lang.Integer",
|
|
||||||
"description": "Akka port of PowerJob-worker",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.app-name",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"description": "Name of application. Register in PowerJob-console to prevent error.",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.enable-test-mode",
|
|
||||||
"type": "java.lang.Boolean",
|
|
||||||
"description": "Whether to enable test mode. In test mode, worker will not connect to server.",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker",
|
|
||||||
"defaultValue": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.max-result-length",
|
|
||||||
"type": "java.lang.Integer",
|
|
||||||
"description": "Max length for {@link ProcessResult}#msg, result longer than this property will be truncated.",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker",
|
|
||||||
"defaultValue": 8096
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.server-address",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"description": "PowerJob-server node(s) address. Ip:port or domain, multiple addresses should be separated with comma",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.store-strategy",
|
|
||||||
"type": "tech.powerjob.worker.common.constants.StoreStrategy",
|
|
||||||
"description": "Local store strategy, disk or memory",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.max-appended-wf-context-length",
|
|
||||||
"type": "java.lang.Integer",
|
|
||||||
"description": "Max length of appended workflow context. Appended workflow context that is longer than the value will be ignore.",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "powerjob.worker.tag",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"description": "Worker Tag",
|
|
||||||
"sourceType": "tech.powerjob.worker.autoconfigure.PowerJobProperties$Worker"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"hints": []
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user