You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/06/28 11:36:33 UTC
[shardingsphere-elasticjob-lite] branch master updated: Update json
to yaml (#857)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-lite.git
The following commit(s) were added to refs/heads/master by this push:
new c876b4c Update json to yaml (#857)
c876b4c is described below
commit c876b4cd43cb046ad4476ca84f6b4db871471ae5
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jun 28 19:36:26 2020 +0800
Update json to yaml (#857)
---
.../elasticjob/lite/fixture/APIJsonConstants.java | 72 ----------------------
...teJsonConstants.java => LiteYamlConstants.java} | 16 ++---
.../internal/config/ConfigurationServiceTest.java | 14 ++---
.../config/RescheduleListenerManagerTest.java | 10 +--
.../failover/FailoverListenerManagerTest.java | 8 +--
.../MonitorExecutionListenerManagerTest.java | 8 +--
.../sharding/ShardingListenerManagerTest.java | 8 +--
.../internal/statistics/JobStatisticsAPIImpl.java | 6 +-
...nConstants.java => LifecycleYamlConstants.java} | 14 ++---
.../internal/settings/JobSettingsAPIImplTest.java | 8 +--
.../statistics/JobStatisticsAPIImplTest.java | 16 ++---
11 files changed, 54 insertions(+), 126 deletions(-)
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/APIJsonConstants.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/APIJsonConstants.java
deleted file mode 100644
index ad1dbb6..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/APIJsonConstants.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.shardingsphere.elasticjob.lite.fixture;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class APIJsonConstants {
-
- private static final String SIMPLE_JOB_JSON = "{\"jobName\":\"test_job\",\"jobType\":\"SIMPLE\","
- + "\"cron\":\"0/1 * * * * ?\",\"shardingTotalCount\":3,\"shardingItemParameters\":\"0\\u003dA,1\\u003dB,2\\u003dC\",\"jobParameter\":\"param\",\"failover\":true,\"misfire\":false,"
- + "\"jobErrorHandlerType\":\"%s\","
- + "\"description\":\"desc\"}";
-
- private static final String DATAFLOW_JOB_JSON = "{\"jobName\":\"test_job\",\"jobType\":\"DATAFLOW\","
- + "\"cron\":\"0/1 * * * * ?\",\"shardingTotalCount\":3,\"shardingItemParameters\":\"\",\"jobParameter\":\"\",\"failover\":false,\"misfire\":true,"
- + "\"jobErrorHandlerType\":\"%s\","
- + "\"description\":\"\",\"streamingProcess\":true}";
-
- private static final String SCRIPT_JOB_JSON = "{\"jobName\":\"test_job\",\"jobType\":\"SCRIPT\","
- + "\"cron\":\"0/1 * * * * ?\","
- + "\"shardingTotalCount\":3,\"shardingItemParameters\":\"\",\"jobParameter\":\"\",\"failover\":false,\"misfire\":true,"
- + "\"jobErrorHandlerType\":\"%s\","
- + "\"description\":\"\","
- + "\"scriptCommandLine\":\"test.sh\"}";
-
- /**
- * Get configuration of simple job in json format.
- *
- * @param jobErrorHandlerType job error handler type
- * @return configuration of simple job in json format
- */
- public static String getSimpleJobJson(final String jobErrorHandlerType) {
- return String.format(SIMPLE_JOB_JSON, jobErrorHandlerType);
- }
-
- /**
- * Get configuration of dataflow job in json format.
- *
- * @param jobErrorHandlerType job error handler type
- * @return configuration of dataflow job in json format
- */
- public static String getDataflowJobJson(final String jobErrorHandlerType) {
- return String.format(DATAFLOW_JOB_JSON, jobErrorHandlerType);
- }
-
- /**
- * Get configuration of script job in json format.
- *
- * @param jobErrorHandlerType job error handler type
- * @return configuration of script job in json format
- */
- public static String getScriptJobJson(final String jobErrorHandlerType) {
- return String.format(SCRIPT_JOB_JSON, jobErrorHandlerType);
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/LiteJsonConstants.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/LiteYamlConstants.java
similarity index 86%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/LiteJsonConstants.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/LiteYamlConstants.java
index 311b2bd..64a5b68 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/LiteJsonConstants.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/LiteYamlConstants.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class LiteJsonConstants {
+public final class LiteYamlConstants {
private static final String JOB_YAML = "jobName: test_job\n"
+ "jobType: SIMPLE\n"
@@ -45,7 +45,7 @@ public final class LiteJsonConstants {
private static final int DEFAULT_MAX_TIME_DIFF_SECONDS = 1000;
/**
- * Get the config of simple job in json format.
+ * Get the config of simple job in YAML format.
*
* @return the string of job config
*/
@@ -54,32 +54,32 @@ public final class LiteJsonConstants {
}
/**
- * Get the config of simple job in json format.
+ * Get the config of simple job in YAML format.
*
* @param maxTimeDiffSeconds max different time in seconds
* @return the string of job config
*/
- public static String getJobJson(final int maxTimeDiffSeconds) {
+ public static String getJobYaml(final int maxTimeDiffSeconds) {
return String.format(JOB_YAML, DEFAULT_FAILOVER, DEFAULT_MONITOR_EXECUTION, maxTimeDiffSeconds);
}
/**
- * Get the config of simple job in json format.
+ * Get the config of simple job in YAML format.
*
* @param failover Whether to enable failover
* @return the string of job config
*/
- public static String getJobJsonWithFailover(final boolean failover) {
+ public static String getJobYamlWithFailover(final boolean failover) {
return String.format(JOB_YAML, failover, DEFAULT_MONITOR_EXECUTION, DEFAULT_MAX_TIME_DIFF_SECONDS);
}
/**
- * Get the config of simple job in json format.
+ * Get the config of simple job in YAML format.
*
* @param monitorExecution Whether to enable monitor execution
* @return the string of job config
*/
- public static String getJobJsonWithMonitorExecution(final boolean monitorExecution) {
+ public static String getJobYamlWithMonitorExecution(final boolean monitorExecution) {
return String.format(JOB_YAML, DEFAULT_FAILOVER, monitorExecution, DEFAULT_MAX_TIME_DIFF_SECONDS);
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java
index a7527c3..443de8c 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.elasticjob.lite.internal.config;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
-import org.apache.shardingsphere.elasticjob.lite.fixture.LiteJsonConstants;
+import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
import org.apache.shardingsphere.elasticjob.lite.fixture.TestSimpleJob;
import org.apache.shardingsphere.elasticjob.lite.fixture.util.JobConfigurationUtil;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
@@ -53,7 +53,7 @@ public final class ConfigurationServiceTest {
@Test
public void assertLoadDirectly() {
- when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobYaml());
+ when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml());
JobConfiguration actual = configService.load(false);
assertThat(actual.getJobName(), is("test_job"));
assertThat(actual.getCron(), is("0/1 * * * * ?"));
@@ -62,7 +62,7 @@ public final class ConfigurationServiceTest {
@Test
public void assertLoadFromCache() {
- when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobYaml());
+ when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml());
JobConfiguration actual = configService.load(true);
assertThat(actual.getJobName(), is("test_job"));
assertThat(actual.getCron(), is("0/1 * * * * ?"));
@@ -72,7 +72,7 @@ public final class ConfigurationServiceTest {
@Test
public void assertLoadFromCacheButNull() {
when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(null);
- when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobYaml());
+ when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml());
JobConfiguration actual = configService.load(true);
assertThat(actual.getJobName(), is("test_job"));
assertThat(actual.getCron(), is("0/1 * * * * ?"));
@@ -108,13 +108,13 @@ public final class ConfigurationServiceTest {
@Test
public void assertIsMaxTimeDiffSecondsTolerableWithDefaultValue() throws JobExecutionEnvironmentException {
- when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobJson(-1));
+ when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml(-1));
configService.checkMaxTimeDiffSecondsTolerable();
}
@Test
public void assertIsMaxTimeDiffSecondsTolerable() throws JobExecutionEnvironmentException {
- when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobYaml());
+ when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml());
when(jobNodeStorage.getRegistryCenterTime()).thenReturn(System.currentTimeMillis());
configService.checkMaxTimeDiffSecondsTolerable();
verify(jobNodeStorage).getRegistryCenterTime();
@@ -122,7 +122,7 @@ public final class ConfigurationServiceTest {
@Test(expected = JobExecutionEnvironmentException.class)
public void assertIsNotMaxTimeDiffSecondsTolerable() throws JobExecutionEnvironmentException {
- when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobYaml());
+ when(jobNodeStorage.getJobNodeData(ConfigurationNode.ROOT)).thenReturn(LiteYamlConstants.getJobYaml());
when(jobNodeStorage.getRegistryCenterTime()).thenReturn(0L);
try {
configService.checkMaxTimeDiffSecondsTolerable();
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java
index 313d721..bd22268 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/RescheduleListenerManagerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.elasticjob.lite.internal.config;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type;
-import org.apache.shardingsphere.elasticjob.lite.fixture.LiteJsonConstants;
+import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
import org.apache.shardingsphere.elasticjob.lite.handler.sharding.JobInstance;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduleController;
@@ -62,19 +62,19 @@ public final class RescheduleListenerManagerTest {
@Test
public void assertCronSettingChangedJobListenerWhenIsNotCronPath() {
- rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config/other", Type.NODE_ADDED, LiteJsonConstants.getJobYaml());
+ rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config/other", Type.NODE_ADDED, LiteYamlConstants.getJobYaml());
verify(jobScheduleController, times(0)).rescheduleJob(ArgumentMatchers.any());
}
@Test
public void assertCronSettingChangedJobListenerWhenIsCronPathButNotUpdate() {
- rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config", Type.NODE_ADDED, LiteJsonConstants.getJobYaml());
+ rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config", Type.NODE_ADDED, LiteYamlConstants.getJobYaml());
verify(jobScheduleController, times(0)).rescheduleJob(ArgumentMatchers.any());
}
@Test
public void assertCronSettingChangedJobListenerWhenIsCronPathAndUpdateButCannotFindJob() {
- rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteJsonConstants.getJobYaml());
+ rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteYamlConstants.getJobYaml());
verify(jobScheduleController, times(0)).rescheduleJob(ArgumentMatchers.any());
}
@@ -82,7 +82,7 @@ public final class RescheduleListenerManagerTest {
public void assertCronSettingChangedJobListenerWhenIsCronPathAndUpdateAndFindJob() {
JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0"));
JobRegistry.getInstance().registerJob("test_job", jobScheduleController, regCenter);
- rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteJsonConstants.getJobYaml());
+ rescheduleListenerManager.new CronSettingAndJobEventChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteYamlConstants.getJobYaml());
verify(jobScheduleController).rescheduleJob("0/1 * * * * ?");
JobRegistry.getInstance().shutdown("test_job");
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java
index df7a1c4..fdfd08f 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/failover/FailoverListenerManagerTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.elasticjob.lite.internal.failover;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type;
import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.LiteJsonConstants;
+import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
import org.apache.shardingsphere.elasticjob.lite.handler.sharding.JobInstance;
import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
import org.apache.shardingsphere.elasticjob.lite.internal.listener.AbstractJobListener;
@@ -127,7 +127,7 @@ public final class FailoverListenerManagerTest {
@Test
public void assertFailoverSettingsChangedJobListenerWhenIsNotFailoverPath() {
- failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged("/test_job/other", Type.NODE_ADDED, LiteJsonConstants.getJobYaml());
+ failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged("/test_job/other", Type.NODE_ADDED, LiteYamlConstants.getJobYaml());
verify(failoverService, times(0)).removeFailoverInfo();
}
@@ -139,13 +139,13 @@ public final class FailoverListenerManagerTest {
@Test
public void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover() {
- failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteJsonConstants.getJobYaml());
+ failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteYamlConstants.getJobYaml());
verify(failoverService, times(0)).removeFailoverInfo();
}
@Test
public void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover() {
- failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteJsonConstants.getJobJsonWithFailover(false));
+ failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteYamlConstants.getJobYamlWithFailover(false));
verify(failoverService).removeFailoverInfo();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java
index 1166f57..8e9631b 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/MonitorExecutionListenerManagerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.elasticjob.lite.internal.sharding;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
-import org.apache.shardingsphere.elasticjob.lite.fixture.LiteJsonConstants;
+import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodeStorage;
import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
import org.junit.Before;
@@ -49,7 +49,7 @@ public final class MonitorExecutionListenerManagerTest {
@Test
public void assertMonitorExecutionSettingsChangedJobListenerWhenIsNotFailoverPath() {
- monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().dataChanged("/test_job/other", TreeCacheEvent.Type.NODE_ADDED, LiteJsonConstants.getJobYaml());
+ monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().dataChanged("/test_job/other", TreeCacheEvent.Type.NODE_ADDED, LiteYamlConstants.getJobYaml());
verify(executionService, times(0)).clearAllRunningInfo();
}
@@ -61,14 +61,14 @@ public final class MonitorExecutionListenerManagerTest {
@Test
public void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover() {
- monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().dataChanged("/test_job/config", TreeCacheEvent.Type.NODE_UPDATED, LiteJsonConstants.getJobYaml());
+ monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().dataChanged("/test_job/config", TreeCacheEvent.Type.NODE_UPDATED, LiteYamlConstants.getJobYaml());
verify(executionService, times(0)).clearAllRunningInfo();
}
@Test
public void assertMonitorExecutionSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover() {
monitorExecutionListenerManager.new MonitorExecutionSettingsChangedJobListener().dataChanged(
- "/test_job/config", TreeCacheEvent.Type.NODE_UPDATED, LiteJsonConstants.getJobJsonWithMonitorExecution(false));
+ "/test_job/config", TreeCacheEvent.Type.NODE_UPDATED, LiteYamlConstants.getJobYamlWithMonitorExecution(false));
verify(executionService).clearAllRunningInfo();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java
index 411dfe4..ecd9614 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.elasticjob.lite.internal.sharding;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type;
-import org.apache.shardingsphere.elasticjob.lite.fixture.LiteJsonConstants;
+import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
import org.apache.shardingsphere.elasticjob.lite.handler.sharding.JobInstance;
import org.apache.shardingsphere.elasticjob.lite.internal.listener.AbstractJobListener;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
@@ -75,14 +75,14 @@ public final class ShardingListenerManagerTest {
@Test
public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathButCurrentShardingTotalCountIsZero() {
- shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged("/test_job/config", Type.NODE_ADDED, LiteJsonConstants.getJobYaml());
+ shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged("/test_job/config", Type.NODE_ADDED, LiteYamlConstants.getJobYaml());
verify(shardingService, times(0)).setReshardingFlag();
}
@Test
public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsEqualToNewShardingTotalCount() {
JobRegistry.getInstance().setCurrentShardingTotalCount("test_job", 3);
- shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged("/test_job/config", Type.NODE_ADDED, LiteJsonConstants.getJobYaml());
+ shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged("/test_job/config", Type.NODE_ADDED, LiteYamlConstants.getJobYaml());
verify(shardingService, times(0)).setReshardingFlag();
JobRegistry.getInstance().setCurrentShardingTotalCount("test_job", 0);
}
@@ -90,7 +90,7 @@ public final class ShardingListenerManagerTest {
@Test
public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsNotEqualToNewShardingTotalCount() {
JobRegistry.getInstance().setCurrentShardingTotalCount("test_job", 5);
- shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteJsonConstants.getJobYaml());
+ shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged("/test_job/config", Type.NODE_UPDATED, LiteYamlConstants.getJobYaml());
verify(shardingService).setReshardingFlag();
JobRegistry.getInstance().setCurrentShardingTotalCount("test_job", 0);
}
diff --git a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImpl.java b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImpl.java
index 909419b..bfc26aa 100644
--- a/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImpl.java
+++ b/elastic-job-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImpl.java
@@ -65,11 +65,11 @@ public final class JobStatisticsAPIImpl implements JobStatisticsAPI {
JobNodePath jobNodePath = new JobNodePath(jobName);
JobBriefInfo result = new JobBriefInfo();
result.setJobName(jobName);
- String jobConfigJson = regCenter.get(jobNodePath.getConfigNodePath());
- if (null == jobConfigJson) {
+ String jobConfigYaml = regCenter.get(jobNodePath.getConfigNodePath());
+ if (null == jobConfigYaml) {
return null;
}
- JobConfiguration jobConfig = YamlEngine.unmarshal(jobConfigJson, YamlJobConfiguration.class).toJobConfiguration();
+ JobConfiguration jobConfig = YamlEngine.unmarshal(jobConfigYaml, YamlJobConfiguration.class).toJobConfiguration();
result.setDescription(jobConfig.getDescription());
result.setCron(jobConfig.getCron());
result.setInstanceCount(getJobInstanceCount(jobName));
diff --git a/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleJsonConstants.java b/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleYamlConstants.java
similarity index 90%
rename from elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleJsonConstants.java
rename to elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleYamlConstants.java
index e39bf2e..b60c5d9 100644
--- a/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleJsonConstants.java
+++ b/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleYamlConstants.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class LifecycleJsonConstants {
+public final class LifecycleYamlConstants {
private static final String SIMPLE_JOB_YAML = "jobName: %s\n"
+ "jobType: SIMPLE\n"
@@ -73,31 +73,31 @@ public final class LifecycleJsonConstants {
+ "overwrite: false\n";
/**
- * Get the config of simple job in json format.
+ * Get the config of simple job in YAML format.
*
* @param jobName name of the job
* @param desc description of the job
* @return the string of job config
*/
- public static String getSimpleJobJson(final String jobName, final String desc) {
+ public static String getSimpleJobYaml(final String jobName, final String desc) {
return String.format(SIMPLE_JOB_YAML, jobName, desc);
}
/**
- * Get the config of dataflow job in json format.
+ * Get the config of dataflow job in YAML format.
*
* @return the string of job config
*/
- public static String getDataflowJobJson() {
+ public static String getDataflowJobYaml() {
return DATAFLOW_JOB_YAML;
}
/**
- * Get the config of script job in json format.
+ * Get the config of script job in YAML format.
*
* @return the string of job config
*/
- public static String getScriptJobJson() {
+ public static String getScriptJobYaml() {
return SCRIPT_JOB_YAML;
}
}
diff --git a/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImplTest.java b/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImplTest.java
index cca93b3..ee5a55a 100644
--- a/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImplTest.java
+++ b/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/settings/JobSettingsAPIImplTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.settings;
import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.lifecycle.api.JobSettingsAPI;
import org.apache.shardingsphere.elasticjob.lite.lifecycle.domain.JobSettings;
-import org.apache.shardingsphere.elasticjob.lite.lifecycle.fixture.LifecycleJsonConstants;
+import org.apache.shardingsphere.elasticjob.lite.lifecycle.fixture.LifecycleYamlConstants;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +51,7 @@ public final class JobSettingsAPIImplTest {
@Test
public void assertGetDataflowJobSettings() {
- when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getDataflowJobJson());
+ when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getDataflowJobYaml());
JobSettings actual = jobSettingsAPI.getJobSettings("test_job");
assertJobSettings(actual, "DATAFLOW");
verify(regCenter).get("/test_job/config");
@@ -59,7 +59,7 @@ public final class JobSettingsAPIImplTest {
@Test
public void assertGetScriptJobSettings() {
- when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getScriptJobJson());
+ when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getScriptJobYaml());
JobSettings actual = jobSettingsAPI.getJobSettings("test_job");
assertJobSettings(actual, "SCRIPT");
verify(regCenter).get("/test_job/config");
@@ -105,7 +105,7 @@ public final class JobSettingsAPIImplTest {
jobSettings.setDescription("");
jobSettings.setStreamingProcess(true);
jobSettingsAPI.updateJobSettings(jobSettings);
- verify(regCenter).update("/test_job/config", LifecycleJsonConstants.getDataflowJobJson());
+ verify(regCenter).update("/test_job/config", LifecycleYamlConstants.getDataflowJobYaml());
}
@Test(expected = IllegalArgumentException.class)
diff --git a/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java b/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java
index 6fd23c8..3b1b584 100644
--- a/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java
+++ b/elastic-job-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/JobStatisticsAPIImplTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.statistics;
import org.apache.shardingsphere.elasticjob.lite.lifecycle.api.JobStatisticsAPI;
import org.apache.shardingsphere.elasticjob.lite.lifecycle.domain.JobBriefInfo;
-import org.apache.shardingsphere.elasticjob.lite.lifecycle.fixture.LifecycleJsonConstants;
+import org.apache.shardingsphere.elasticjob.lite.lifecycle.fixture.LifecycleYamlConstants;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.junit.Before;
import org.junit.Test;
@@ -55,7 +55,7 @@ public final class JobStatisticsAPIImplTest {
@Test
public void assertGetOKJobBriefInfo() {
- when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
+ when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc"));
when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance"));
when(regCenter.getChildrenKeys("/test_job/sharding")).thenReturn(Arrays.asList("0", "1", "2"));
@@ -74,7 +74,7 @@ public final class JobStatisticsAPIImplTest {
@Test
public void assertGetOKJobBriefInfoWithPartialDisabledServer() {
- when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
+ when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc"));
when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
when(regCenter.get("/test_job/servers/ip1")).thenReturn("DISABLED");
when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance"));
@@ -87,7 +87,7 @@ public final class JobStatisticsAPIImplTest {
@Test
public void assertGetDisabledJobBriefInfo() {
- when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
+ when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc"));
when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
when(regCenter.get("/test_job/servers/ip1")).thenReturn("DISABLED");
when(regCenter.get("/test_job/servers/ip2")).thenReturn("DISABLED");
@@ -98,7 +98,7 @@ public final class JobStatisticsAPIImplTest {
@Test
public void assertGetShardingErrorJobBriefInfo() {
- when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
+ when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc"));
when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance"));
when(regCenter.getChildrenKeys("/test_job/sharding")).thenReturn(Arrays.asList("0", "1", "2"));
@@ -111,7 +111,7 @@ public final class JobStatisticsAPIImplTest {
@Test
public void assertGetCrashedJobBriefInfo() {
- when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
+ when(regCenter.get("/test_job/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job", "desc"));
JobBriefInfo jobBrief = jobStatisticsAPI.getJobBriefInfo("test_job");
assertThat(jobBrief.getStatus(), is(JobBriefInfo.JobStatus.CRASHED));
}
@@ -125,8 +125,8 @@ public final class JobStatisticsAPIImplTest {
@Test
public void assertGetAllJobsBriefInfo() {
when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2"));
- when(regCenter.get("/test_job_1/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job_1", "desc1"));
- when(regCenter.get("/test_job_2/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job_2", "desc2"));
+ when(regCenter.get("/test_job_1/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job_1", "desc1"));
+ when(regCenter.get("/test_job_2/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job_2", "desc2"));
when(regCenter.getChildrenKeys("/test_job_1/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
when(regCenter.getChildrenKeys("/test_job_2/servers")).thenReturn(Arrays.asList("ip3", "ip4"));
when(regCenter.getChildrenKeys("/test_job_1/sharding")).thenReturn(Arrays.asList("0", "1"));