diff --git a/db/4pigxx_job.sql b/db/4pigxx_job.sql index 412825e15..4fb89347c 100644 --- a/db/4pigxx_job.sql +++ b/db/4pigxx_job.sql @@ -282,7 +282,7 @@ CREATE TABLE `xxl_job_group` ( -- Records of xxl_job_group -- ---------------------------- BEGIN; -INSERT INTO `xxl_job_group` VALUES (1, 'xxl-job-executor-sample', '示例执行器', 1, 0, NULL); +INSERT INTO `xxl_job_group` VALUES (1, 'xxl-job-executor', '示例执行器', 1, 0, NULL); COMMIT; -- ---------------------------- @@ -319,7 +319,7 @@ CREATE TABLE `xxl_job_info` ( -- Records of xxl_job_info -- ---------------------------- BEGIN; -INSERT INTO `xxl_job_info` VALUES (1, 1, '0 0 0 * * ? *', '测试任务1', '2018-11-03 22:21:31', '2018-11-03 22:21:31', 'XXL', '', 'FIRST', 'demoJobHandler', '', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'GLUE代码初始化', '2018-11-03 22:21:31', '', 0, 0, 0); +INSERT INTO `xxl_job_info`(`id`, `job_group`, `job_cron`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`, `executor_route_strategy`, `executor_handler`, `executor_param`, `executor_block_strategy`, `executor_timeout`, `executor_fail_retry_count`, `glue_type`, `glue_source`, `glue_remark`, `glue_updatetime`, `child_jobid`, `trigger_status`, `trigger_last_time`, `trigger_next_time`) VALUES (1, 1, '0 0 0 * * ? *', '测试任务1', '2018-11-03 22:21:31', '2020-04-15 13:58:35', 'lengleng', '', 'ROUND', 'demoJobHandler', '', 'DISCARD_LATER', 0, 0, 'BEAN', '', 'GLUE代码初始化', '2018-11-03 22:21:31', '', 0, 0, 0); COMMIT; -- ---------------------------- @@ -375,16 +375,7 @@ CREATE TABLE `xxl_job_log_report` ( `fail_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量', PRIMARY KEY (`id`), UNIQUE KEY `i_trigger_day` (`trigger_day`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - --- ---------------------------- --- Records of xxl_job_log_report --- ---------------------------- -BEGIN; -INSERT INTO `xxl_job_log_report` VALUES (1, '2019-12-09 00:00:00', 0, 0, 0); -INSERT INTO `xxl_job_log_report` VALUES (2, '2019-12-08 00:00:00', 0, 0, 0); -INSERT INTO `xxl_job_log_report` VALUES (3, '2019-12-07 00:00:00', 0, 0, 0); -COMMIT; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- ---------------------------- -- Table structure for xxl_job_logglue diff --git a/db/6pigxx_config.sql b/db/6pigxx_config.sql index bccfae29e..4441ba0ef 100644 --- a/db/6pigxx_config.sql +++ b/db/6pigxx_config.sql @@ -35,7 +35,7 @@ BEGIN; INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', 'jasypt:\n encryptor:\n password: pigx\n \nspring:\n redis:\n host: pigx-redis\n servlet:\n multipart:\n max-file-size: 100MB\n max-request-size: 100MB\n cloud:\n sentinel:\n eager: true\n filter:\n url-patterns: /** \n transport:\n dashboard: pigx-sentinel:5020\n \nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n#开启灰度\ngray:\n rule:\n enabled: true\n\nmybatis-plus:\n tenant-enable: ture\n mapper-locations: classpath:/mapper/*Mapper.xml\n global-config:\n banner: false\n db-config:\n id-type: auto\n field-strategy: NOT_EMPTY\n type-handlers-package: com.pig4cloud.pigx.common.data.handler\n\nswagger:\n title: PigX Swagger API\n license: Powered By PigX\n licenseUrl: https://pig4cloud.com/\n terms-of-service-url: https://pig4cloud.com/\n contact:\n email: wangiegie@gmail.com\n url: https://pig4cloud.com/about.html\n authorization:\n name: pigX OAuth\n auth-regex: ^.*$\n authorization-scope-list:\n - scope: server\n description: server all\n token-url-list:\n - http://${GATEWAY_HOST:pigx-gateway}:${GATEWAY_PORT:9999}/auth/oauth/token\n\nsecurity:\n oauth2:\n client:\n ignore-urls:\n - /actuator/**\n - /v2/api-docs\n resource:\n loadBalanced: true\n token-info-uri: http://pigx-auth/oauth/check_token', '954b56ac77f2691529aad5c497591b28', '2019-04-18 02:10:20', '2020-02-24 13:58:21', NULL, '172.17.0.125', '', '', '通用配置文件', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (2, 'pigx-auth-dev.yml', 'DEFAULT_GROUP', '# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n freemarker:\n allow-request-override: false\n allow-session-override: false\n cache: true\n charset: UTF-8\n check-template-location: true\n content-type: text/html\n enabled: true\n expose-request-attributes: false\n expose-session-attributes: false\n expose-spring-macro-helpers: true\n prefer-file-system-access: true\n suffix: .ftl\n template-loader-path: classpath:/templates/', 'a6674e6747c1a0bb6c6d78e13706f8f0', '2019-04-18 02:11:32', '2019-08-27 18:24:04', NULL, '127.0.0.1', '', '', '认证中心配置文件', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (3, 'pigx-codegen-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n scope: server\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx_codegen}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n resources:\n static-locations: classpath:/static/,classpath:/views/\n\npigx:\n tenant:\n column: tenant_id\n tables:\n - gen_datasource_conf', 'b7d132a3ecdfac4252c994adbb65b23a', '2019-04-18 02:12:10', '2019-08-27 18:24:18', NULL, '127.0.0.1', '', '', '代码生成', 'null', 'null', 'yaml', 'null'); -INSERT INTO `config_info` VALUES (4, 'pigx-daemon-elastic-job-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n client-secret: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n scope: server\n## 定时任务\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n\nxxl:\n job:\n admin:\n addresses: http://${XXL-HOST:pigx-xxl}:${XXL-HOST:9080}/xxl-job-admin\n executor:\n port: 9988\n appName: test-xxl', '9ce58242d57b57f737dcb59a41ee6e55', '2019-04-18 02:12:57', '2019-10-04 11:22:56', NULL, '127.0.0.1', '', '', '定时任务-elastic-job配置', 'null', 'null', 'yaml', 'null'); +INSERT INTO `config_info` VALUES (4, 'pigx-daemon-elastic-job-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n client-secret: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n scope: server\n## 定时任务\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n\nxxl:\n job:\n admin:\n addresses: http://${XXL_HOST:pigx-xxl}:${XXL_HOST:9080}/xxl-job-admin', 'af2d24afd75cbd73c3bbc8297ca65bc9', '2019-04-18 02:12:57', '2020-04-15 21:56:37', NULL, '127.0.0.1', '', '', '定时任务-elastic-job配置', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (5, 'pigx-gateway-dev.yml', 'DEFAULT_GROUP', 'security:\n encode:\n key: \'pigxpigxpigxpigx\'\n\nignore:\n clients:\n - test\n swagger-providers:\n - pigx-auth\n - pigx-tx-manager\n\nribbon:\n rule:\n gray-enabled: true', '24403a5b205b1e9d320078e309584bbc', '2019-04-18 02:13:52', '2019-10-20 17:07:42', NULL, '127.0.0.1', '', '', '网关配置文件', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (6, 'pigx-monitor-dev.yml', 'DEFAULT_GROUP', 'spring:\n # 安全配置\n security:\n user:\n name: ENC(rZHA4LW5hHmhLAAzJoFNag==) # pigx\n password: ENC(bjeyh+Aeii3kHXkoo00ZUw==) # pigx\n boot:\n admin:\n ui:\n title: \'pigx 服务状态监控\'\n brand: \'pigx 服务状态监控\'\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n endpoint:\n health:\n show-details: ALWAYS #显示详细信息', '7925a0c734460526262319b6a189e39d', '2019-04-18 02:14:17', '2019-12-31 19:04:00', NULL, '172.17.0.157', '', '', '监控配置文件', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (7, 'pigx-upms-biz-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(ltJPpR50wT0oIY9kfOe1Iw==)\n client-secret: ENC(ltJPpR50wT0oIY9kfOe1Iw==)\n scope: server\n ignore-urls:\n - /druid/**\n - /actuator/**\n - /v2/api-docs\n\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n stat-view-servlet:\n enabled: true\n url-pattern: /druid/*\n #login-username: admin\n #login-password: admin\n filter:\n stat:\n enabled: true\n log-slow-sql: true\n slow-sql-millis: 10000\n merge-sql: false\n wall:\n config:\n multi-statement-allow: true\n\n# 文件系统 (提供测试环境,不要乱传)\nminio:\n url: http://minio.pig4cloud.com\n access-key: lengleng\n secret-key: lengleng\n\n# Logger Config\nlogging:\n level:\n com.pig4cloud.pigx.admin.mapper: debug\n\n# 租户表维护\npigx:\n tenant:\n column: tenant_id\n tables:\n - sys_user\n - sys_role\n - sys_menu\n - sys_dept\n - sys_log\n - sys_social_details\n - sys_dict\n - sys_dict_item\n - sys_public_param\n - sys_log\n - sys_file\n - sys_oauth_client_details', 'fab3a6b4cb292954d9841b22a41e3dab', '2019-04-18 02:32:44', '2019-11-01 12:22:38', NULL, '127.0.0.1', '', '', 'admin 服务配置', 'null', 'null', 'yaml', 'null'); diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/XxlJobAutoConfiguration.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/XxlJobAutoConfiguration.java index 443b22b73..8f6361b95 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/XxlJobAutoConfiguration.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/XxlJobAutoConfiguration.java @@ -20,6 +20,7 @@ package com.pig4cloud.pigx.common.job; import com.pig4cloud.pigx.common.job.properties.XxlJobProperties; import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -34,10 +35,12 @@ import org.springframework.context.annotation.Configuration; @ComponentScan("com.pig4cloud.pigx.common.job.properties") public class XxlJobAutoConfiguration { + @Bean public XxlJobSpringExecutor xxlJobSpringExecutor(XxlJobProperties xxlJobProperties) { XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdmin().getAddresses()); - xxlJobSpringExecutor.setAppName(xxlJobProperties.getExecutor().getAppName()); + xxlJobSpringExecutor.setAppname(xxlJobProperties.getExecutor().getAppname()); + xxlJobSpringExecutor.setAddress(xxlJobProperties.getExecutor().getAddress()); xxlJobSpringExecutor.setIp(xxlJobProperties.getExecutor().getIp()); xxlJobSpringExecutor.setPort(xxlJobProperties.getExecutor().getPort()); xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getExecutor().getAccessToken()); diff --git a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlExecutorProperties.java b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlExecutorProperties.java index 09f56cec7..405998b14 100644 --- a/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlExecutorProperties.java +++ b/pigx-common/pigx-common-job/src/main/java/com/pig4cloud/pigx/common/job/properties/XxlExecutorProperties.java @@ -28,7 +28,14 @@ public class XxlExecutorProperties { /** * 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册 */ - private String appName = "xxl-job-executor"; + private String appname = "xxl-job-executor"; + + /** + * 服务注册地址,优先使用该配置作为注册地址 + * 为空时使用内嵌服务 ”IP:PORT“ 作为注册地址 + * 从而更灵活的支持容器类型执行器动态IP和动态映射端口问题 + */ + private String address; /** * 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP diff --git a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/job/DemoJobHandler.java b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/job/DemoJob.java similarity index 84% rename from pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/job/DemoJobHandler.java rename to pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/job/DemoJob.java index 7f8c2b957..fc3ca49a6 100644 --- a/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/job/DemoJobHandler.java +++ b/pigx-visual/pigx-daemon-elastic-job/src/main/java/com/pig4cloud/pigx/daemon/elastic/job/DemoJob.java @@ -18,27 +18,25 @@ package com.pig4cloud.pigx.daemon.elastic.job; import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.IJobHandler; -import com.xxl.job.core.handler.annotation.JobHandler; +import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.util.ShardingUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import static com.xxl.job.core.biz.model.ReturnT.SUCCESS; + /** * @author lengleng * @date 2019-09-18 */ @Slf4j @Component -@JobHandler("demoJobHandler") -public class DemoJobHandler extends IJobHandler { +public class DemoJob { - @Override - public ReturnT execute(String s) { + @XxlJob("demoJobHandler") + public ReturnT demoJobHandler(String s) { ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo(); - - XxlJobLogger.log("This is a demo job." + shardingVO); return SUCCESS; } diff --git a/pigx-visual/pigx-daemon-elastic-job/src/main/resources/mapper/ExecutionLogMapper.xml b/pigx-visual/pigx-daemon-elastic-job/src/main/resources/mapper/ExecutionLogMapper.xml deleted file mode 100644 index 81088fdfb..000000000 --- a/pigx-visual/pigx-daemon-elastic-job/src/main/resources/mapper/ExecutionLogMapper.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/pigx-visual/pigx-daemon-elastic-job/src/main/resources/mapper/StatusTraceLogMapper.xml b/pigx-visual/pigx-daemon-elastic-job/src/main/resources/mapper/StatusTraceLogMapper.xml deleted file mode 100644 index 98fa36a18..000000000 --- a/pigx-visual/pigx-daemon-elastic-job/src/main/resources/mapper/StatusTraceLogMapper.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 66300f23d..1ecbd0fec 100644 --- a/pom.xml +++ b/pom.xml @@ -49,8 +49,8 @@ 4.1.0 2.1.1 2.11.2 - 6.0.11 - 2.1.1 + 6.0.13 + 2.2.0 2.3.6.RELEASE 5.22.0 172.17.0.111