You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/08/27 01:47:13 UTC

[GitHub] [skywalking] hailin0 commented on a change in pull request #5395: Add logic-endpoint and testcase for elasticjob-2.x plugin

hailin0 commented on a change in pull request #5395:
URL: https://github.com/apache/skywalking/pull/5395#discussion_r477895146



##########
File path: test/plugin/scenarios/elasticjob-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/elasticjob/job/JobConfig.java
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.elasticjob.job;
+
+import com.dangdang.ddframe.job.api.simple.SimpleJob;
+import com.dangdang.ddframe.job.config.JobCoreConfiguration;
+import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
+import com.dangdang.ddframe.job.lite.api.JobScheduler;
+import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
+import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler;
+import com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter;
+import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
+import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class JobConfig {
+
+    private final String cron = "0/5 * * * * ?";
+    private final int shardingTotalCount = 1;
+    private final String shardingItemParameters = "0=test";
+    private final String jobParameters = "parameter";
+
+    @Bean
+    public SimpleJob simpleJob() {
+        return new DemoSimpleJob();
+    }
+
+    @Bean(initMethod = "init")
+    public ZookeeperRegistryCenter regCenter(@Value("${elasticjob.regCenter.serverList}") final String serverList,
+                                             @Value("${elasticjob.regCenter.namespace}") final String namespace) {
+        return new ZookeeperRegistryCenter(new ZookeeperConfiguration(serverList, namespace));
+    }
+
+    @Bean(initMethod = "init")
+    public JobScheduler simpleJobScheduler(final SimpleJob simpleJob, final CoordinatorRegistryCenter regCenter) {
+        return new SpringJobScheduler(simpleJob, regCenter,
+                getLiteJobConfiguration(simpleJob.getClass(),
+                cron, shardingTotalCount, shardingItemParameters, jobParameters));
+    }
+
+    private LiteJobConfiguration getLiteJobConfiguration(final Class<? extends SimpleJob> jobClass,
+                                                         final String cron,
+                                                         final int shardingTotalCount,
+                                                         final String shardingItemParameters,
+                                                         final String jobParameters) {
+        // 定义作业核心配置

Review comment:
       ok




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org