feat: add support xxl-job 2.3.x (#295)
This commit is contained in:
parent
42ea174ed9
commit
84ccd88e31
|
|
@ -83,7 +83,8 @@ jobs:
|
|||
- spring-scheduled-scenario
|
||||
- elasticjob-2.x-scenario
|
||||
- quartz-scheduler-2.x-scenario
|
||||
- xxl-job-2.x-scenario
|
||||
- xxl-job-2.2.0-scenario
|
||||
- xxl-job-2.3.x-scenario
|
||||
- thrift-scenario
|
||||
- dbcp-2.x-scenario
|
||||
- jsonrpc4j-1.x-scenario
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ Release Notes.
|
|||
* Upgrade netty-codec-http2 to 4.1.79.Final.
|
||||
* Fix race condition causing agent to not reconnect after network error
|
||||
* Force the injected high-priority classes in order to avoid NoClassDefFoundError.
|
||||
* Plugin to support xxl-job 2.3.x.
|
||||
|
||||
#### Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -18,9 +18,17 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.xxljob;
|
||||
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.AbstractTag;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String XXL_IJOB_HANDLER = "com.xxl.job.core.handler.IJobHandler";
|
||||
|
|
@ -29,4 +37,17 @@ public class Constants {
|
|||
public static final String XXL_METHOD_JOB_HANDLER = "com.xxl.job.core.handler.impl.MethodJobHandler";
|
||||
|
||||
public static final AbstractTag JOB_PARAM = Tags.ofKey("jobParam");
|
||||
/**
|
||||
* 2.3.x after
|
||||
*/
|
||||
public static final ElementMatcher.Junction<MethodDescription> ARGS_MATCHER_23 = ElementMatchers.takesNoArguments();
|
||||
/**
|
||||
* 2.0 ~ 2.2.0
|
||||
*/
|
||||
public static final ElementMatcher.Junction<MethodDescription> ARGS_MATCHER_20_TO_22 = takesArguments(1).and(takesArgument(0, String.class));
|
||||
|
||||
public static final ElementMatcher.Junction<MethodDescription> EXECUTE_METHOD_MATCHER = named("execute")
|
||||
.and(isPublic())
|
||||
.and(ARGS_MATCHER_23.or(ARGS_MATCHER_20_TO_22));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import java.lang.reflect.Method;
|
|||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.JOB_PARAM;
|
||||
|
||||
/**
|
||||
* Intercept method of {@link com.xxl.job.core.handler.impl.MethodJobHandler#execute(String)}.
|
||||
* Intercept method of {@link com.xxl.job.core.handler.impl.MethodJobHandler} execute() or execute(String) .
|
||||
* record the xxl-job method job local span.
|
||||
*/
|
||||
public class MethodJobHandlerMethodInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
|
@ -39,13 +39,20 @@ public class MethodJobHandlerMethodInterceptor implements InstanceMethodsAroundI
|
|||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
|
||||
String methodName = (String) objInst.getSkyWalkingDynamicField();
|
||||
String jobParam = (String) allArguments[0];
|
||||
String operationName = ComponentsDefine.XXL_JOB.getName() + "/MethodJob/" + methodName;
|
||||
|
||||
AbstractSpan span = ContextManager.createLocalSpan(operationName);
|
||||
span.setComponent(ComponentsDefine.XXL_JOB);
|
||||
Tags.LOGIC_ENDPOINT.set(span, Tags.VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT);
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
if (allArguments.length == 1) {
|
||||
// support 2.0 ~ 2.2
|
||||
String jobParam = (String) allArguments[0];
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
} else if (allArguments.length == 0) {
|
||||
// support 2.3
|
||||
String jobParam = com.xxl.job.core.context.XxlJobHelper.getJobParam();
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import java.lang.reflect.Method;
|
|||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.JOB_PARAM;
|
||||
|
||||
/**
|
||||
* Intercept method of {@link com.xxl.job.core.handler.impl.ScriptJobHandler#execute(String)}.
|
||||
* Intercept method of {@link com.xxl.job.core.handler.impl.ScriptJobHandler} execute() or execute(String) .
|
||||
* record the xxl-job script job local span.
|
||||
*/
|
||||
public class ScriptJobHandlerMethodInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
|
@ -39,13 +39,20 @@ public class ScriptJobHandlerMethodInterceptor implements InstanceMethodsAroundI
|
|||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
|
||||
String jobTypeAndId = (String) objInst.getSkyWalkingDynamicField();
|
||||
String jobParam = (String) allArguments[0];
|
||||
String operationName = ComponentsDefine.XXL_JOB.getName() + "/ScriptJob/" + jobTypeAndId;
|
||||
|
||||
AbstractSpan span = ContextManager.createLocalSpan(operationName);
|
||||
span.setComponent(ComponentsDefine.XXL_JOB);
|
||||
Tags.LOGIC_ENDPOINT.set(span, Tags.VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT);
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
if (allArguments.length == 1) {
|
||||
// support 2.0 ~ 2.2
|
||||
String jobParam = (String) allArguments[0];
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
} else if (allArguments.length == 0) {
|
||||
// support 2.3
|
||||
String jobParam = com.xxl.job.core.context.XxlJobHelper.getJobParam();
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,20 +31,27 @@ import java.lang.reflect.Method;
|
|||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.JOB_PARAM;
|
||||
|
||||
/**
|
||||
* Intercept execute(String) method on implement class of {@link com.xxl.job.core.handler.IJobHandler}.
|
||||
* Intercept execute(String) method or execute() on implement class of {@link com.xxl.job.core.handler.IJobHandler}.
|
||||
* record the xxl-job simple job local span.
|
||||
*/
|
||||
public class SimpleJobHandlerMethodInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
|
||||
String jobParam = (String) allArguments[0];
|
||||
String operationName = ComponentsDefine.XXL_JOB.getName() + "/SimpleJob/" + method.getDeclaringClass().getName();
|
||||
|
||||
AbstractSpan span = ContextManager.createLocalSpan(operationName);
|
||||
span.setComponent(ComponentsDefine.XXL_JOB);
|
||||
Tags.LOGIC_ENDPOINT.set(span, Tags.VAL_LOCAL_SPAN_AS_LOGIC_ENDPOINT);
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
if (allArguments.length == 1) {
|
||||
// support 2.0 ~ 2.2
|
||||
String jobParam = (String) allArguments[0];
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
} else if (allArguments.length == 0) {
|
||||
// support 2.3
|
||||
String jobParam = com.xxl.job.core.context.XxlJobHelper.getJobParam();
|
||||
span.tag(JOB_PARAM, jobParam);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,15 +27,14 @@ import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.EXECUTE_METHOD_MATCHER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_METHOD_JOB_HANDLER;
|
||||
|
||||
/**
|
||||
* Enhance {@link com.xxl.job.core.handler.impl.MethodJobHandler} instance and intercept {@link com.xxl.job.core.handler.impl.MethodJobHandler#execute(String)} method,
|
||||
* Enhance {@link com.xxl.job.core.handler.impl.MethodJobHandler} instance and intercept execute() or execute(String) method,
|
||||
* this method is a entrance of execute method job.
|
||||
*
|
||||
* @see org.apache.skywalking.apm.plugin.xxljob.MethodJobHandlerConstructorInterceptor
|
||||
|
|
@ -78,10 +77,7 @@ public class MethodJobHandlerInstrumentation extends ClassInstanceMethodsEnhance
|
|||
new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getMethodsMatcher() {
|
||||
return named("execute")
|
||||
.and(isPublic())
|
||||
.and(takesArguments(1))
|
||||
.and(takesArgument(0, String.class));
|
||||
return EXECUTE_METHOD_MATCHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,15 +25,13 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsIn
|
|||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.EXECUTE_METHOD_MATCHER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_SCRIPT_JOB_HANDLER;
|
||||
|
||||
/**
|
||||
* Enhance {@link com.xxl.job.core.handler.impl.ScriptJobHandler} instance and intercept {@link com.xxl.job.core.handler.impl.ScriptJobHandler#execute(String)} method,
|
||||
* Enhance {@link com.xxl.job.core.handler.impl.ScriptJobHandler} instance and intercept execute() or execute(String) method,
|
||||
* this method is a entrance of execute script job.
|
||||
*
|
||||
* @see org.apache.skywalking.apm.plugin.xxljob.ScriptJobHandlerConstructorInterceptor
|
||||
|
|
@ -72,10 +70,7 @@ public class ScriptJobHandlerInstrumentation extends ClassInstanceMethodsEnhance
|
|||
new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getMethodsMatcher() {
|
||||
return named("execute")
|
||||
.and(isPublic())
|
||||
.and(takesArguments(1))
|
||||
.and(takesArgument(0, String.class));
|
||||
return EXECUTE_METHOD_MATCHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,17 +29,14 @@ import org.apache.skywalking.apm.agent.core.plugin.match.IndirectMatch;
|
|||
import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.match.logical.LogicalMatchOperation;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_IJOB_HANDLER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_SCRIPT_JOB_HANDLER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.EXECUTE_METHOD_MATCHER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_GLUE_JOB_HANDLER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_IJOB_HANDLER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_METHOD_JOB_HANDLER;
|
||||
import static org.apache.skywalking.apm.plugin.xxljob.Constants.XXL_SCRIPT_JOB_HANDLER;
|
||||
|
||||
/**
|
||||
* Enhance the implement class of {@link com.xxl.job.core.handler.IJobHandler} and intercept execute(String) method,
|
||||
* Enhance the implement class of {@link com.xxl.job.core.handler.IJobHandler} and intercept execute() or execute(String) method,
|
||||
* this method is a entrance of execute job.
|
||||
*
|
||||
* @see org.apache.skywalking.apm.plugin.xxljob.SimpleJobHandlerMethodInterceptor
|
||||
|
|
@ -71,10 +68,7 @@ public class SimpleJobHandlerInstrumentation extends ClassInstanceMethodsEnhance
|
|||
new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getMethodsMatcher() {
|
||||
return named("execute")
|
||||
.and(isPublic())
|
||||
.and(takesArguments(1))
|
||||
.and(takesArgument(0, String.class));
|
||||
return EXECUTE_METHOD_MATCHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@
|
|||
|
||||
home="$(cd "$(dirname $0)"; pwd)"
|
||||
|
||||
java -jar ${agent_opts} ${home}/../libs/xxl-job-2.x-scenario.jar &
|
||||
java -jar ${agent_opts} ${home}/../libs/xxl-job-2.2.0-scenario.jar &
|
||||
|
|
@ -14,12 +14,12 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
segmentItems:
|
||||
- serviceName: xxl-job-2.x-scenario
|
||||
- serviceName: xxl-job-2.2.0-scenario
|
||||
segmentSize: ge 7
|
||||
segments:
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: GET:/xxl-job-2.x-scenario/case/simpleJob
|
||||
- operationName: GET:/xxl-job-2.2.0-scenario/case/simpleJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Http
|
||||
|
|
@ -31,14 +31,14 @@ segmentItems:
|
|||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.x-scenario/case/simpleJob'}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.2.0-scenario/case/simpleJob'}
|
||||
- {key: http.method, value: GET}
|
||||
- {key: http.status_code, value: '200'}
|
||||
refs:
|
||||
- {parentEndpoint: xxl-job/SimpleJob/test.apache.skywalking.apm.testcase.xxljob.job.BeanJob, networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /xxl-job-2.x-scenario/case/simpleJob
|
||||
- operationName: /xxl-job-2.2.0-scenario/case/simpleJob
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Http
|
||||
|
|
@ -51,7 +51,7 @@ segmentItems:
|
|||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: http.method, value: GET}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.x-scenario/case/simpleJob'}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.2.0-scenario/case/simpleJob'}
|
||||
- {key: http.status_code, value: '200'}
|
||||
- operationName: xxl-job/SimpleJob/test.apache.skywalking.apm.testcase.xxljob.job.BeanJob
|
||||
parentSpanId: -1
|
||||
|
|
@ -69,7 +69,7 @@ segmentItems:
|
|||
- {key: jobParam, value: 'k=1'}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: GET:/xxl-job-2.x-scenario/case/methodJob
|
||||
- operationName: GET:/xxl-job-2.2.0-scenario/case/methodJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Http
|
||||
|
|
@ -81,14 +81,14 @@ segmentItems:
|
|||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.x-scenario/case/methodJob'}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.2.0-scenario/case/methodJob'}
|
||||
- {key: http.method, value: GET}
|
||||
- {key: http.status_code, value: '200'}
|
||||
refs:
|
||||
- {parentEndpoint: xxl-job/MethodJob/org.apache.skywalking.apm.testcase.xxljob.job.MethodJob.work, networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /xxl-job-2.x-scenario/case/methodJob
|
||||
- operationName: /xxl-job-2.2.0-scenario/case/methodJob
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Http
|
||||
|
|
@ -101,7 +101,7 @@ segmentItems:
|
|||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: http.method, value: GET}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.x-scenario/case/methodJob'}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.2.0-scenario/case/methodJob'}
|
||||
- {key: http.status_code, value: '200'}
|
||||
- operationName: xxl-job/MethodJob/org.apache.skywalking.apm.testcase.xxljob.job.MethodJob.work
|
||||
parentSpanId: -1
|
||||
|
|
@ -119,7 +119,7 @@ segmentItems:
|
|||
- {key: jobParam, value: 'k=2'}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: GET:/xxl-job-2.x-scenario/case/glueJob
|
||||
- operationName: GET:/xxl-job-2.2.0-scenario/case/glueJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Http
|
||||
|
|
@ -131,14 +131,14 @@ segmentItems:
|
|||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.x-scenario/case/glueJob'}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.2.0-scenario/case/glueJob'}
|
||||
- {key: http.method, value: GET}
|
||||
- {key: http.status_code, value: '200'}
|
||||
refs:
|
||||
- {parentEndpoint: xxl-job/SimpleJob/com.xxl.job.service.handler.GlueJob, networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /xxl-job-2.x-scenario/case/glueJob
|
||||
- operationName: /xxl-job-2.2.0-scenario/case/glueJob
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Http
|
||||
|
|
@ -151,7 +151,7 @@ segmentItems:
|
|||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: http.method, value: GET}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.x-scenario/case/glueJob'}
|
||||
- {key: url, value: 'http://localhost:8080/xxl-job-2.2.0-scenario/case/glueJob'}
|
||||
- {key: http.status_code, value: '200'}
|
||||
- operationName: xxl-job/SimpleJob/com.xxl.job.service.handler.GlueJob
|
||||
parentSpanId: -1
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
# limitations under the License.
|
||||
|
||||
type: jvm
|
||||
entryService: http://localhost:8080/xxl-job-2.x-scenario/case/call
|
||||
healthCheck: http://localhost:8080/xxl-job-2.x-scenario/case/healthCheck
|
||||
entryService: http://localhost:8080/xxl-job-2.2.0-scenario/case/call
|
||||
healthCheck: http://localhost:8080/xxl-job-2.2.0-scenario/case/healthCheck
|
||||
startScript: ./bin/startup.sh
|
||||
environment:
|
||||
- MYSQL_ADDRESS=mysql-server:3306
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<groupId>org.apache.skywalking.apm.testcase</groupId>
|
||||
<artifactId>xxl-job-2.x-scenario</artifactId>
|
||||
<artifactId>xxl-job-2.2.0-scenario</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
|
@ -30,13 +30,12 @@
|
|||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
<!-- Cannot be auto testing xxl-job (2.0.0 ~ 2.1.2) because the xxl-job server incompatible -->
|
||||
<test.framework.version>2.2.0</test.framework.version>
|
||||
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
|
||||
<lombok.version>1.18.20</lombok.version>
|
||||
</properties>
|
||||
|
||||
<name>skywalking-xxl-job-2.x-scenario</name>
|
||||
<name>skywalking-xxl-job-2.2.0-scenario</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
|
@ -98,7 +97,7 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>xxl-job-2.x-scenario</finalName>
|
||||
<finalName>xxl-job-2.2.0-scenario</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/xxl-job-2.x-scenario.jar</source>
|
||||
<source>${project.build.directory}/xxl-job-2.2.0-scenario.jar</source>
|
||||
<outputDirectory>./libs</outputDirectory>
|
||||
<fileMode>0775</fileMode>
|
||||
</file>
|
||||
|
|
@ -37,7 +37,7 @@ public class MethodJob {
|
|||
|
||||
log.info("MethodJobHandler execute. param: {}", param);
|
||||
|
||||
Request request = new Request.Builder().url("http://localhost:8080/xxl-job-2.x-scenario/case/methodJob").build();
|
||||
Request request = new Request.Builder().url("http://localhost:8080/xxl-job-2.2.0-scenario/case/methodJob").build();
|
||||
Response response = Utils.OK_CLIENT.newCall(request).execute();
|
||||
response.body().close();
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public class BeanJob extends IJobHandler {
|
|||
|
||||
log.info("BeanJobHandler execute. param: {}", param);
|
||||
|
||||
Request request = new Request.Builder().url("http://localhost:8080/xxl-job-2.x-scenario/case/simpleJob").build();
|
||||
Request request = new Request.Builder().url("http://localhost:8080/xxl-job-2.2.0-scenario/case/simpleJob").build();
|
||||
Response response = Utils.OK_CLIENT.newCall(request).execute();
|
||||
response.body().close();
|
||||
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /xxl-job-2.x-scenario
|
||||
context-path: /xxl-job-2.2.0-scenario
|
||||
logging:
|
||||
config: classpath:log4j2.xml
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ CREATE TABLE if NOT EXISTS `xxl_job_lock` (
|
|||
INSERT INTO `xxl_job_group`(`id`, `app_name`, `title`, `address_type`, `address_list`) VALUES (1, 'xxl-job-executor-demo', 'my-executor', 0, NULL);
|
||||
INSERT INTO `xxl_job`.`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/1 * * * * ?', 'demo-bean-job', '2020-09-09 23:32:46', '2020-09-11 22:01:15', 'XXL', '', 'FIRST', 'BeanJobHandler', 'k=1', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'init', '2018-11-03 22:21:31', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job`.`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 (2, 1, '0/1 * * * * ?', 'demo-method-job', '2020-09-09 23:32:46', '2020-09-11 22:01:12', 'XXL', '', 'FIRST', 'MethodJobHandler', 'k=2', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'init', '2020-09-09 23:32:46', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job`.`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 (3, 1, '0/1 * * * * ?', 'demo-glue-java-job', '2020-09-09 23:51:06', '2020-09-11 22:17:25', 'XXL', '', 'FIRST', '', 'k=3', 'SERIAL_EXECUTION', 0, 0, 'GLUE_GROOVY', 'package com.xxl.job.service.handler;\n\nimport com.xxl.job.core.log.XxlJobLogger;\nimport com.xxl.job.core.biz.model.ReturnT;\nimport com.xxl.job.core.handler.IJobHandler;\nimport okhttp3.OkHttpClient;\nimport okhttp3.Request;\nimport okhttp3.Response;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\npublic class GlueJob extends IJobHandler {\n\n private static final Logger log = LoggerFactory.getLogger(GlueJob.class);\n\n private static final OkHttpClient client = new OkHttpClient.Builder().build();\n\n @Override\n public ReturnT<String> execute(String param) throws Exception {\n\n log.info(\"GlueJob execute. param: {}\", param);\n\n Request request = new Request.Builder().url(\"http://localhost:8080/xxl-job-2.x-scenario/case/glueJob\").build();\n Response response = client.newCall(request).execute();\n response.body().close();\n\n return ReturnT.SUCCESS;\n }\n}\n', 'init', '2020-09-11 22:17:25', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job`.`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 (3, 1, '0/1 * * * * ?', 'demo-glue-java-job', '2020-09-09 23:51:06', '2020-09-11 22:17:25', 'XXL', '', 'FIRST', '', 'k=3', 'SERIAL_EXECUTION', 0, 0, 'GLUE_GROOVY', 'package com.xxl.job.service.handler;\n\nimport com.xxl.job.core.log.XxlJobLogger;\nimport com.xxl.job.core.biz.model.ReturnT;\nimport com.xxl.job.core.handler.IJobHandler;\nimport okhttp3.OkHttpClient;\nimport okhttp3.Request;\nimport okhttp3.Response;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\npublic class GlueJob extends IJobHandler {\n\n private static final Logger log = LoggerFactory.getLogger(GlueJob.class);\n\n private static final OkHttpClient client = new OkHttpClient.Builder().build();\n\n @Override\n public ReturnT<String> execute(String param) throws Exception {\n\n log.info(\"GlueJob execute. param: {}\", param);\n\n Request request = new Request.Builder().url(\"http://localhost:8080/xxl-job-2.2.0-scenario/case/glueJob\").build();\n Response response = client.newCall(request).execute();\n response.body().close();\n\n return ReturnT.SUCCESS;\n }\n}\n', 'init', '2020-09-11 22:17:25', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job`.`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 (4, 1, '0/1 * * * * ?', 'demo-glue-shell-job', '2020-09-09 23:53:32', '2020-09-11 22:01:04', 'XXL', '', 'FIRST', '', 'k=4', 'SERIAL_EXECUTION', 0, 0, 'GLUE_SHELL', '#!/bin/bash\necho \"xxl-job: hello shell\"\n\necho \"Good bye!\"\nexit 0\n', 'init', '2020-09-09 23:54:57', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job_user`(`id`, `username`, `password`, `role`, `permission`) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, NULL);
|
||||
INSERT INTO `xxl_job_lock` ( `lock_name`) VALUES ( 'schedule_lock');
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
|
||||
#
|
||||
# http://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.
|
||||
|
||||
home="$(cd "$(dirname $0)"; pwd)"
|
||||
|
||||
java -jar ${agent_opts} ${home}/../libs/xxl-job-2.3.x-scenario.jar &
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
|
||||
#
|
||||
# http://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.
|
||||
segmentItems:
|
||||
- serviceName: xxl-job-2.3.x-scenario
|
||||
segmentSize: ge 7
|
||||
segments:
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: GET:/xxl-job-2.3.x-scenario/case/simpleJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 1
|
||||
isError: false
|
||||
spanType: Entry
|
||||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: url, value: 'http://localhost:18080/xxl-job-2.3.x-scenario/case/simpleJob'}
|
||||
- {key: http.method, value: GET}
|
||||
- {key: http.status_code, value: '200'}
|
||||
refs:
|
||||
- {parentEndpoint: xxl-job/SimpleJob/test.apache.skywalking.apm.testcase.xxljob.job.BeanJob, networkAddress: 'localhost:18080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /xxl-job-2.3.x-scenario/case/simpleJob
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Http
|
||||
startTime: not null
|
||||
endTime: not null
|
||||
componentId: 12
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: localhost:18080
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: http.method, value: GET}
|
||||
- {key: url, value: 'http://localhost:18080/xxl-job-2.3.x-scenario/case/simpleJob'}
|
||||
- {key: http.status_code, value: '200'}
|
||||
- operationName: xxl-job/SimpleJob/test.apache.skywalking.apm.testcase.xxljob.job.BeanJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Unknown
|
||||
startTime: not null
|
||||
endTime: not null
|
||||
componentId: 98
|
||||
isError: false
|
||||
spanType: Local
|
||||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: x-le, value: '{"logic-span":true}'}
|
||||
- {key: jobParam, value: 'k=1'}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: GET:/xxl-job-2.3.x-scenario/case/methodJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 1
|
||||
isError: false
|
||||
spanType: Entry
|
||||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: url, value: 'http://localhost:18080/xxl-job-2.3.x-scenario/case/methodJob'}
|
||||
- {key: http.method, value: GET}
|
||||
- {key: http.status_code, value: '200'}
|
||||
refs:
|
||||
- {parentEndpoint: xxl-job/MethodJob/org.apache.skywalking.apm.testcase.xxljob.job.MethodJob.work, networkAddress: 'localhost:18080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /xxl-job-2.3.x-scenario/case/methodJob
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Http
|
||||
startTime: not null
|
||||
endTime: not null
|
||||
componentId: 12
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: localhost:18080
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: http.method, value: GET}
|
||||
- {key: url, value: 'http://localhost:18080/xxl-job-2.3.x-scenario/case/methodJob'}
|
||||
- {key: http.status_code, value: '200'}
|
||||
- operationName: xxl-job/MethodJob/org.apache.skywalking.apm.testcase.xxljob.job.MethodJob.work
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Unknown
|
||||
startTime: not null
|
||||
endTime: not null
|
||||
componentId: 98
|
||||
isError: false
|
||||
spanType: Local
|
||||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: x-le, value: '{"logic-span":true}'}
|
||||
- {key: jobParam, value: 'k=2'}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: GET:/xxl-job-2.3.x-scenario/case/glueJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 1
|
||||
isError: false
|
||||
spanType: Entry
|
||||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: url, value: 'http://localhost:18080/xxl-job-2.3.x-scenario/case/glueJob'}
|
||||
- {key: http.method, value: GET}
|
||||
- {key: http.status_code, value: '200'}
|
||||
refs:
|
||||
- {parentEndpoint: xxl-job/SimpleJob/com.xxl.job.service.handler.GlueJob, networkAddress: 'localhost:18080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /xxl-job-2.3.x-scenario/case/glueJob
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Http
|
||||
startTime: not null
|
||||
endTime: not null
|
||||
componentId: 12
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: localhost:18080
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: http.method, value: GET}
|
||||
- {key: url, value: 'http://localhost:18080/xxl-job-2.3.x-scenario/case/glueJob'}
|
||||
- {key: http.status_code, value: '200'}
|
||||
- operationName: xxl-job/SimpleJob/com.xxl.job.service.handler.GlueJob
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Unknown
|
||||
startTime: not null
|
||||
endTime: not null
|
||||
componentId: 98
|
||||
isError: false
|
||||
spanType: Local
|
||||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: x-le, value: '{"logic-span":true}'}
|
||||
- {key: jobParam, value: 'k=3'}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: xxl-job/ScriptJob/GLUE_SHELL/id/4
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Unknown
|
||||
startTime: not null
|
||||
endTime: not null
|
||||
componentId: 98
|
||||
isError: false
|
||||
spanType: Local
|
||||
peer: ''
|
||||
skipAnalysis: false
|
||||
tags:
|
||||
- {key: x-le, value: '{"logic-span":true}'}
|
||||
- {key: jobParam, value: 'k=4'}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
|
||||
#
|
||||
# http://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.
|
||||
|
||||
type: jvm
|
||||
entryService: http://localhost:18080/xxl-job-2.3.x-scenario/case/call
|
||||
healthCheck: http://localhost:18080/xxl-job-2.3.x-scenario/case/healthCheck
|
||||
startScript: ./bin/startup.sh
|
||||
environment:
|
||||
- MYSQL_ADDRESS=mysql-server:3306
|
||||
- MYSQL_ROOT_PASSWORD=123456
|
||||
- XXL_JOB_SERVER=http://xxl-job-server:8080/xxl-job-admin
|
||||
depends_on:
|
||||
- mysql-server
|
||||
- xxl-job-server
|
||||
dependencies:
|
||||
mysql-server:
|
||||
image: mysql:8.0
|
||||
hostname: mysql-server
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=123456
|
||||
|
||||
xxl-job-server:
|
||||
image: xuxueli/xxl-job-admin:2.3.0
|
||||
hostname: xxl-job-server
|
||||
environment:
|
||||
- PARAMS=--spring.datasource.url=jdbc:mysql://mysql-server:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai --spring.datasource.username=root --spring.datasource.password=123456 --xxl.job.accessToken=default_token
|
||||
depends_on:
|
||||
- mysql-server
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ contributor license agreements. See the NOTICE file distributed with
|
||||
~ this work for additional information regarding copyright ownership.
|
||||
~ The ASF 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. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://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.
|
||||
~
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<groupId>org.apache.skywalking.apm.testcase</groupId>
|
||||
<artifactId>xxl-job-2.3.x-scenario</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
<!-- testing xxl-job (2.3.0 ~ 2.3.1) -->
|
||||
<test.framework.version>2.3.0</test.framework.version>
|
||||
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
|
||||
<lombok.version>1.18.20</lombok.version>
|
||||
</properties>
|
||||
|
||||
<name>skywalking-xxl-job-2.3.x-scenario</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<version>1.10.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>xxl-job-2.3.x-scenario</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>assemble</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
<outputDirectory>./target/</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ contributor license agreements. See the NOTICE file distributed with
|
||||
~ this work for additional information regarding copyright ownership.
|
||||
~ The ASF 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. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://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.
|
||||
~
|
||||
-->
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>./bin</directory>
|
||||
<fileMode>0775</fileMode>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/xxl-job-2.3.x-scenario.jar</source>
|
||||
<outputDirectory>./libs</outputDirectory>
|
||||
<fileMode>0775</fileMode>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.apache.skywalking.apm.testcase.xxljob;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.apache.skywalking.apm.testcase.xxljob;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static final OkHttpClient OK_CLIENT = new OkHttpClient.Builder().build();
|
||||
|
||||
public static final ObjectMapper JSON = new ObjectMapper();
|
||||
|
||||
public static final MediaType FORM_DATA = MediaType.parse("application/x-www-form-urlencoded; charset=UTF-8");
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.apache.skywalking.apm.testcase.xxljob.controller;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.skywalking.apm.testcase.xxljob.service.XXLJobServerControlService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/case")
|
||||
@Log4j2
|
||||
public class CaseController {
|
||||
|
||||
private static final String SUCCESS = "Success";
|
||||
|
||||
@Autowired
|
||||
private XXLJobServerControlService xxlJobServerControlService;
|
||||
|
||||
@RequestMapping("/simpleJob")
|
||||
@ResponseBody
|
||||
public String simpleJob() {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/methodJob")
|
||||
@ResponseBody
|
||||
public String methodJob() {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/glueJob")
|
||||
@ResponseBody
|
||||
public String glueJob() {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/healthCheck")
|
||||
@ResponseBody
|
||||
public String healthCheck() throws Exception {
|
||||
|
||||
xxlJobServerControlService.checkCurrentExecutorRegistered();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/call")
|
||||
@ResponseBody
|
||||
public String call() {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.apache.skywalking.apm.testcase.xxljob.job;
|
||||
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.skywalking.apm.testcase.xxljob.Utils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MethodJob {
|
||||
|
||||
@XxlJob("MethodJobHandler")
|
||||
public void work() throws IOException {
|
||||
|
||||
log.info("MethodJobHandler execute. param: {}", XxlJobHelper.getJobParam());
|
||||
|
||||
Request request = new Request.Builder().url("http://localhost:18080/xxl-job-2.3.x-scenario/case/methodJob").build();
|
||||
Response response = Utils.OK_CLIENT.newCall(request).execute();
|
||||
response.body().close();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.apache.skywalking.apm.testcase.xxljob.job;
|
||||
|
||||
import com.xxl.job.core.executor.XxlJobExecutor;
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import test.apache.skywalking.apm.testcase.xxljob.job.BeanJob;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class XXLJobConfig {
|
||||
|
||||
@Value("${xxl.job.admin.addresses}")
|
||||
private String adminAddresses;
|
||||
|
||||
@Value("${xxl.job.executor.appname}")
|
||||
private String appName;
|
||||
|
||||
@Value("${xxl.job.executor.ip}")
|
||||
private String ip;
|
||||
|
||||
@Value("${xxl.job.executor.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${xxl.job.accessToken}")
|
||||
private String accessToken;
|
||||
|
||||
@Value("${xxl.job.executor.logpath}")
|
||||
private String logPath;
|
||||
|
||||
@Bean
|
||||
public XxlJobExecutor xxlJobExecutor() {
|
||||
log.info(">>>>>>>>>>> xxl-job config init.");
|
||||
|
||||
XxlJobSpringExecutor xxlJobExecutor = new XxlJobSpringExecutor();
|
||||
xxlJobExecutor.setAdminAddresses(adminAddresses);
|
||||
xxlJobExecutor.setAppname(appName);
|
||||
xxlJobExecutor.setIp(ip);
|
||||
xxlJobExecutor.setPort(port);
|
||||
xxlJobExecutor.setAccessToken(accessToken);
|
||||
xxlJobExecutor.setLogPath(logPath);
|
||||
|
||||
XxlJobExecutor.registJobHandler("BeanJobHandler", new BeanJob());
|
||||
|
||||
return xxlJobExecutor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.apache.skywalking.apm.testcase.xxljob.job;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.datasource.init.ScriptUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class XXLJobInitializer implements InitializingBean {
|
||||
|
||||
@Value("${xxl.mysql.address}")
|
||||
private String mysqlAddress;
|
||||
@Value("${xxl.mysql.root_password}")
|
||||
private String mysqlRootPassword;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
log.info("Initializer xxl-job");
|
||||
|
||||
initDatabase();
|
||||
log.info("Initializer xxl-job success");
|
||||
}
|
||||
|
||||
private void initDatabase() throws Exception {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
String url = String.format("jdbc:mysql://%s", mysqlAddress);
|
||||
try (Connection conn = DriverManager.getConnection(url, "root", mysqlRootPassword)) {
|
||||
ClassPathResource classPathResource = new ClassPathResource("tables_xxl_job.sql");
|
||||
ScriptUtils.executeSqlScript(conn, classPathResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.apache.skywalking.apm.testcase.xxljob.service;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.xxl.job.core.util.IpUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import org.apache.logging.log4j.core.util.IOUtils;
|
||||
import org.apache.skywalking.apm.testcase.xxljob.Utils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class XXLJobServerControlService {
|
||||
|
||||
@Value("${xxl.job.admin.addresses}")
|
||||
private String xxlJobAdminAddresses;
|
||||
@Value("${xxl.job.executor.appname}")
|
||||
private String appName;
|
||||
|
||||
@Value("${xxl.job.executor.port}")
|
||||
private int port;
|
||||
|
||||
private volatile AtomicInteger atomicInteger = new AtomicInteger(0);
|
||||
private String cookie;
|
||||
|
||||
private void login() throws Exception {
|
||||
Request request = new Request.Builder()
|
||||
.url(String.format("%s/login", xxlJobAdminAddresses))
|
||||
.method("POST", RequestBody.create(Utils.FORM_DATA, "userName=admin&password=123456"))
|
||||
.build();
|
||||
Response response = Utils.OK_CLIENT.newCall(request).execute();
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
JobResult result = Utils.JSON.readValue(response.body().byteStream(), JobResult.class);
|
||||
if (result.getCode() == 200) {
|
||||
this.cookie = response.headers().get("Set-Cookie");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("xxl-job login error!");
|
||||
}
|
||||
|
||||
public void checkCurrentExecutorRegistered() throws Exception {
|
||||
|
||||
login();
|
||||
if (atomicInteger.incrementAndGet() == 1) {
|
||||
Request request = new Request.Builder()
|
||||
.url(String.format("%s/jobgroup/update", xxlJobAdminAddresses))
|
||||
.method("POST", RequestBody.create(Utils.FORM_DATA,
|
||||
String.format("id=1&appname=%s&title=test&addressType=1&addressList=http://%s:%d/",
|
||||
appName, IpUtil.getIp(), port)))
|
||||
.header("Cookie", cookie)
|
||||
.build();
|
||||
Utils.OK_CLIENT.newCall(request).execute();
|
||||
}
|
||||
Thread.sleep(2 * 1000L);
|
||||
Request request = new Request.Builder()
|
||||
.url(String.format("%s/jobgroup/pageList", xxlJobAdminAddresses))
|
||||
.method("POST", RequestBody.create(Utils.FORM_DATA, String.format("appname=%s", appName)))
|
||||
.header("Cookie", cookie)
|
||||
.build();
|
||||
Response response = Utils.OK_CLIENT.newCall(request).execute();
|
||||
if (response.isSuccessful()) {
|
||||
String s = IOUtils.toString(response.body().charStream());
|
||||
log.info("job admin return value: {}", s);
|
||||
JobGroup jobGroup = Utils.JSON.readValue(s, JobGroup.class);
|
||||
JobGroupData[] jobGroupDatas = jobGroup.getData();
|
||||
if (jobGroupDatas != null && jobGroupDatas.length == 1) {
|
||||
JobGroupData jobGroupData = jobGroupDatas[0];
|
||||
if (!StringUtils.isEmpty(jobGroupData.getAddressList())
|
||||
&& jobGroupData.getRegistryList() != null
|
||||
&& jobGroupData.getRegistryList().length > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
throw new IllegalStateException("current executor unregistered");
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
private static class JobResult {
|
||||
@JsonProperty
|
||||
private int code;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
private static class JobGroup {
|
||||
@JsonProperty
|
||||
private JobGroupData[] data;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
private static class JobGroupData {
|
||||
@JsonProperty
|
||||
private int id;
|
||||
@JsonProperty
|
||||
private String appname;
|
||||
@JsonProperty
|
||||
private String addressList;
|
||||
@JsonProperty
|
||||
private String[] registryList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://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 test.apache.skywalking.apm.testcase.xxljob.job;
|
||||
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.skywalking.apm.testcase.xxljob.Utils;
|
||||
|
||||
@Slf4j
|
||||
public class BeanJob extends IJobHandler {
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
|
||||
log.info("BeanJobHandler execute. param: {}", XxlJobHelper.getJobParam());
|
||||
|
||||
Request request = new Request.Builder().url("http://localhost:18080/xxl-job-2.3.x-scenario/case/simpleJob").build();
|
||||
Response response = Utils.OK_CLIENT.newCall(request).execute();
|
||||
response.body().close();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
|
||||
#
|
||||
# http://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.
|
||||
server:
|
||||
port: 18080
|
||||
servlet:
|
||||
context-path: /xxl-job-2.3.x-scenario
|
||||
logging:
|
||||
config: classpath:log4j2.xml
|
||||
|
||||
xxl:
|
||||
mysql:
|
||||
address: ${MYSQL_ADDRESS}
|
||||
root_password: ${MYSQL_ROOT_PASSWORD}
|
||||
job:
|
||||
accessToken: default_token
|
||||
admin:
|
||||
addresses: ${XXL_JOB_SERVER}
|
||||
executor:
|
||||
ip:
|
||||
port: 29999
|
||||
logpath: /data/applogs/xxl-job/jobhandler
|
||||
appname: xxl-job-executor-sample
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ contributor license agreements. See the NOTICE file distributed with
|
||||
~ this work for additional information regarding copyright ownership.
|
||||
~ The ASF 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. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://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.
|
||||
~
|
||||
-->
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_ERR">
|
||||
<PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-5level] [%logger{36}] [%msg]%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="INFO">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
|
||||
--
|
||||
-- http://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.
|
||||
|
||||
|
||||
|
||||
CREATE database if NOT EXISTS `xxl_job` default character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||
use `xxl_job`;
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_info` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`job_group` int(11) NOT NULL COMMENT '执行器主键ID',
|
||||
`job_desc` varchar(255) NOT NULL,
|
||||
`add_time` datetime DEFAULT NULL,
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
`author` varchar(64) DEFAULT NULL COMMENT '作者',
|
||||
`alarm_email` varchar(255) DEFAULT NULL COMMENT '报警邮件',
|
||||
`schedule_type` varchar(50) NOT NULL DEFAULT 'NONE' COMMENT '调度类型',
|
||||
`schedule_conf` varchar(128) DEFAULT NULL COMMENT '调度配置,值含义取决于调度类型',
|
||||
`misfire_strategy` varchar(50) NOT NULL DEFAULT 'DO_NOTHING' COMMENT '调度过期策略',
|
||||
`executor_route_strategy` varchar(50) DEFAULT NULL COMMENT '执行器路由策略',
|
||||
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
|
||||
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
|
||||
`executor_block_strategy` varchar(50) DEFAULT NULL COMMENT '阻塞处理策略',
|
||||
`executor_timeout` int(11) NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒',
|
||||
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
|
||||
`glue_type` varchar(50) NOT NULL COMMENT 'GLUE类型',
|
||||
`glue_source` mediumtext COMMENT 'GLUE源代码',
|
||||
`glue_remark` varchar(128) DEFAULT NULL COMMENT 'GLUE备注',
|
||||
`glue_updatetime` datetime DEFAULT NULL COMMENT 'GLUE更新时间',
|
||||
`child_jobid` varchar(255) DEFAULT NULL COMMENT '子任务ID,多个逗号分隔',
|
||||
`trigger_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '调度状态:0-停止,1-运行',
|
||||
`trigger_last_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '上次调度时间',
|
||||
`trigger_next_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '下次调度时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`job_group` int(11) NOT NULL COMMENT '执行器主键ID',
|
||||
`job_id` int(11) NOT NULL COMMENT '任务,主键ID',
|
||||
`executor_address` varchar(255) DEFAULT NULL COMMENT '执行器地址,本次执行的地址',
|
||||
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
|
||||
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
|
||||
`executor_sharding_param` varchar(20) DEFAULT NULL COMMENT '执行器任务分片参数,格式如 1/2',
|
||||
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
|
||||
`trigger_time` datetime DEFAULT NULL COMMENT '调度-时间',
|
||||
`trigger_code` int(11) NOT NULL COMMENT '调度-结果',
|
||||
`trigger_msg` text COMMENT '调度-日志',
|
||||
`handle_time` datetime DEFAULT NULL COMMENT '执行-时间',
|
||||
`handle_code` int(11) NOT NULL COMMENT '执行-状态',
|
||||
`handle_msg` text COMMENT '执行-日志',
|
||||
`alarm_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '告警状态:0-默认、1-无需告警、2-告警成功、3-告警失败',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `I_trigger_time` (`trigger_time`),
|
||||
KEY `I_handle_code` (`handle_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_log_report` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`trigger_day` datetime DEFAULT NULL COMMENT '调度-时间',
|
||||
`running_count` int(11) NOT NULL DEFAULT '0' COMMENT '运行中-日志数量',
|
||||
`suc_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量',
|
||||
`fail_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `i_trigger_day` (`trigger_day`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_logglue` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`job_id` int(11) NOT NULL COMMENT '任务,主键ID',
|
||||
`glue_type` varchar(50) DEFAULT NULL COMMENT 'GLUE类型',
|
||||
`glue_source` mediumtext COMMENT 'GLUE源代码',
|
||||
`glue_remark` varchar(128) NOT NULL COMMENT 'GLUE备注',
|
||||
`add_time` datetime DEFAULT NULL,
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_registry` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`registry_group` varchar(50) NOT NULL,
|
||||
`registry_key` varchar(255) NOT NULL,
|
||||
`registry_value` varchar(255) NOT NULL,
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `i_g_k_v` (`registry_group`,`registry_key`,`registry_value`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_group` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`app_name` varchar(64) NOT NULL COMMENT '执行器AppName',
|
||||
`title` varchar(12) NOT NULL COMMENT '执行器名称',
|
||||
`address_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '执行器地址类型:0=自动注册、1=手动录入',
|
||||
`address_list` text COMMENT '执行器地址列表,多地址逗号分隔',
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(50) NOT NULL COMMENT '账号',
|
||||
`password` varchar(50) NOT NULL COMMENT '密码',
|
||||
`role` tinyint(4) NOT NULL COMMENT '角色:0-普通用户、1-管理员',
|
||||
`permission` varchar(255) DEFAULT NULL COMMENT '权限:执行器ID列表,多个逗号分割',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `i_username` (`username`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `xxl_job_lock` (
|
||||
`lock_name` varchar(50) NOT NULL COMMENT '锁名称',
|
||||
PRIMARY KEY (`lock_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT INTO `xxl_job_group`(`id`, `app_name`, `title`, `address_type`, `address_list`, `update_time`) VALUES (1, 'xxl-job-executor-sample', '示例执行器', 0, NULL, '2018-11-03 22:21:31' );
|
||||
INSERT INTO `xxl_job`.`xxl_job_info`(`id`, `job_group`, `schedule_conf`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`,`schedule_type`, `misfire_strategy`, `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/1 * * * * ?', 'demo-bean-job', '2020-09-09 23:32:46', '2020-09-11 22:01:15', 'XXL', '', 'CRON', 'FIRE_ONCE_NOW', 'FIRST', 'BeanJobHandler', 'k=1', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'init', '2018-11-03 22:21:31', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job`.`xxl_job_info`(`id`, `job_group`, `schedule_conf`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`,`schedule_type`, `misfire_strategy`, `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 (2, 1, '0/1 * * * * ?', 'demo-method-job', '2020-09-09 23:32:46', '2020-09-11 22:01:12', 'XXL', '', 'CRON', 'FIRE_ONCE_NOW', 'FIRST', 'MethodJobHandler', 'k=2', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'init', '2020-09-09 23:32:46', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job`.`xxl_job_info`(`id`, `job_group`, `schedule_conf`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`,`schedule_type`, `misfire_strategy`, `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 (3, 1, '0/1 * * * * ?', 'demo-glue-java-job', '2020-09-09 23:51:06', '2020-09-11 22:17:25', 'XXL', '', 'CRON', 'FIRE_ONCE_NOW', 'FIRST', '', 'k=3', 'SERIAL_EXECUTION', 0, 0, 'GLUE_GROOVY', 'package com.xxl.job.service.handler;\n\nimport com.xxl.job.core.context.XxlJobHelper;\nimport com.xxl.job.core.handler.IJobHandler; \nimport okhttp3.Request;\nimport okhttp3.Response;\nimport org.apache.skywalking.apm.testcase.xxljob.Utils;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\npublic class GlueJob extends IJobHandler {\n\n private static final Logger log = LoggerFactory.getLogger(GlueJob.class);\n\n @Override\n public void execute() throws Exception {\n\n log.info(\"BeanJobHandler execute. param: {}\", XxlJobHelper.getJobParam());\n\n Request request = new Request.Builder().url(\"http://localhost:18080/xxl-job-2.3.x-scenario/case/glueJob\").build();\n Response response = Utils.OK_CLIENT.newCall(request).execute();\n response.body().close();\n\n }\n}', 'init', '2020-09-11 22:17:25', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job`.`xxl_job_info`(`id`, `job_group`, `schedule_conf`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`,`schedule_type`, `misfire_strategy`, `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 (4, 1, '0/1 * * * * ?', 'demo-glue-shell-job', '2020-09-09 23:53:32', '2020-09-11 22:01:04', 'XXL', '', 'CRON', 'FIRE_ONCE_NOW','FIRST', '', 'k=4', 'SERIAL_EXECUTION', 0, 0, 'GLUE_SHELL', '#!/bin/bash\necho \"xxl-job: hello shell\"\n\necho \"Good bye!\"\nexit 0\n', 'init', '2020-09-09 23:54:57', '', 1, 0, 0);
|
||||
INSERT INTO `xxl_job_user`(`id`, `username`, `password`, `role`, `permission`) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, NULL);
|
||||
INSERT INTO `xxl_job_lock` ( `lock_name`) VALUES ( 'schedule_lock');
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
|
||||
#
|
||||
# http://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.
|
||||
|
||||
2.3.0
|
||||
Loading…
Reference in New Issue