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/07/14 10:30:12 UTC
[shardingsphere-elasticjob-lite] branch master updated: Decouple
some guava usage (#1057)
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 de24213 Decouple some guava usage (#1057)
de24213 is described below
commit de24213f19d18347767f524e4f54ff5416101dff
Author: Liang Zhang <te...@163.com>
AuthorDate: Tue Jul 14 18:30:05 2020 +0800
Decouple some guava usage (#1057)
* Decouple guava Lists's dependency
* Decouple guava ImmutableList's dependency
* Decouple guava Joiner's dependency
---
.../cloud/executor/local/LocalTaskExecutor.java | 6 ++--
.../elasticjob/cloud/restful/RestfulServer.java | 4 +--
.../scheduler/mesos/AppConstraintEvaluator.java | 10 +++----
.../cloud/scheduler/mesos/FacadeService.java | 14 +++++----
.../cloud/scheduler/mesos/MesosStateService.java | 7 +++--
.../mesos/TaskLaunchScheduledService.java | 13 +++++++--
.../cloud/scheduler/producer/ProducerManager.java | 10 +++----
.../scheduler/restful/CloudAppRestfulApi.java | 7 +++--
.../restful/search/JobEventRdbSearch.java | 6 ++--
.../scheduler/state/failover/FailoverNode.java | 6 ++--
.../scheduler/state/failover/FailoverService.java | 15 +++++-----
.../scheduler/state/failover/FailoverTaskInfo.java | 4 +--
.../cloud/scheduler/state/running/RunningNode.java | 6 ++--
.../scheduler/state/running/RunningService.java | 2 +-
.../elasticjob/cloud/security/WwwAuthFilter.java | 6 ++--
.../scheduler/fixture/EmbedTestingServer.java | 11 +-------
.../cloud/scheduler/fixture/TaskNode.java | 20 +++++++------
.../mesos/AppConstraintEvaluatorTest.java | 10 +++----
.../cloud/scheduler/mesos/FacadeServiceTest.java | 3 +-
.../scheduler/mesos/MesosStateServiceTest.java | 9 +++---
.../mesos/TaskLaunchScheduledServiceTest.java | 22 +++++++--------
.../scheduler/producer/ProducerManagerTest.java | 6 ++--
.../scheduler/restful/CloudAppRestfulApiTest.java | 9 +++---
.../scheduler/restful/CloudJobRestfulApiTest.java | 33 ++++++++++------------
.../state/failover/FailoverServiceTest.java | 24 ++++++++--------
.../scheduler/state/ready/ReadyServiceTest.java | 5 ++--
.../state/running/RunningServiceTest.java | 9 +++---
.../scheduler/statistics/StatisticManagerTest.java | 18 ++++++------
.../job/RegisteredJobStatisticJobTest.java | 6 ++--
.../concurrent/ElasticJobExecutorService.java | 4 +--
.../elasticjob/infra/context/TaskContext.java | 10 +++----
.../elasticjob/infra/context/TaskContextTest.java | 22 ++++++++-------
.../elasticjob/infra/context/fixture/TaskNode.java | 8 ++++--
.../reg/zookeeper/fixture/EmbedTestingServer.java | 3 +-
.../elasticjob/tracing/JobEventBus.java | 8 +++---
.../lite/internal/guarantee/GuaranteeNode.java | 7 +++--
.../internal/sharding/ExecutionContextService.java | 10 ++++---
.../lite/internal/snapshot/SnapshotService.java | 13 +++++----
.../lite/internal/util/SensitiveInfoUtils.java | 3 +-
.../lite/fixture/EmbedTestingServer.java | 3 +-
.../lite/internal/schedule/LiteJobFacadeTest.java | 16 +++++------
.../lifecycle/AbstractEmbedZookeeperBaseTest.java | 5 ++--
42 files changed, 211 insertions(+), 202 deletions(-)
diff --git a/elasticjob-cloud/elasticjob-cloud-executor/src/main/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutor.java b/elasticjob-cloud/elasticjob-cloud-executor/src/main/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutor.java
index 9af4c64..0e9103b 100755
--- a/elasticjob-cloud/elasticjob-cloud-executor/src/main/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutor.java
+++ b/elasticjob-cloud/elasticjob-cloud-executor/src/main/java/org/apache/shardingsphere/elasticjob/cloud/executor/local/LocalTaskExecutor.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.executor.local;
-import com.google.common.base.Joiner;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.elasticjob.api.ElasticJob;
@@ -32,6 +31,7 @@ import org.apache.shardingsphere.elasticjob.tracing.JobEventBus;
import java.util.HashMap;
import java.util.Map;
+import java.util.StringJoiner;
/**
* Local task executor.
@@ -71,8 +71,8 @@ public final class LocalTaskExecutor {
private ShardingContexts getShardingContexts() {
Map<Integer, String> shardingItemMap = new HashMap<>(1, 1);
shardingItemMap.put(shardingItem, new ShardingItemParameters(jobConfiguration.getShardingItemParameters()).getMap().get(shardingItem));
- return new ShardingContexts(Joiner.on("@-@").join(jobConfiguration.getJobName(), shardingItem, "READY", "foo_slave_id", "foo_uuid"),
- jobConfiguration.getJobName(), jobConfiguration.getShardingTotalCount(), jobConfiguration.getJobParameter(), shardingItemMap);
+ String taskId = new StringJoiner("@-@").add(jobConfiguration.getJobName()).add(shardingItem + "").add("READY").add("foo_slave_id").add("foo_uuid").toString();
+ return new ShardingContexts(taskId, jobConfiguration.getJobName(), jobConfiguration.getShardingTotalCount(), jobConfiguration.getJobParameter(), shardingItemMap);
}
private JobConfiguration getJobConfiguration() {
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulServer.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulServer.java
index 290f26a..a38c352 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulServer.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/RestfulServer.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.restful;
-import com.google.common.base.Joiner;
import com.sun.jersey.api.core.PackagesResourceConfig;
import com.sun.jersey.spi.container.servlet.ServletContainer;
import lombok.extern.slf4j.Slf4j;
@@ -31,6 +30,7 @@ import org.eclipse.jetty.util.resource.Resource;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import java.util.EnumSet;
+import java.util.StringJoiner;
/**
* Rest api embed server.
@@ -100,7 +100,7 @@ public final class RestfulServer {
private ServletHolder getServletHolder(final String packages) {
ServletHolder result = new ServletHolder(ServletContainer.class);
- result.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, Joiner.on(",").join(RestfulServer.class.getPackage().getName(), packages));
+ result.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, new StringJoiner(",").add(RestfulServer.class.getPackage().getName()).add(packages).toString());
result.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", PackagesResourceConfig.class.getName());
result.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", Boolean.TRUE.toString());
result.setInitParameter("resteasy.scan.providers", Boolean.TRUE.toString());
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluator.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluator.java
index a03f875..3424b7c 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluator.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluator.java
@@ -28,9 +28,10 @@ import com.sun.jersey.api.client.UniformInterfaceException;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
-import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfiguration;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.MesosStateService.ExecutorStateInfo;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.codehaus.jettison.json.JSONException;
import java.util.ArrayList;
@@ -62,13 +63,12 @@ public final class AppConstraintEvaluator implements ConstraintEvaluator {
}
static AppConstraintEvaluator getInstance() {
- Preconditions.checkNotNull(instance);
- return instance;
+ return Preconditions.checkNotNull(instance);
}
void loadAppRunningState() {
try {
- for (MesosStateService.ExecutorStateInfo each : facadeService.loadExecutorInfo()) {
+ for (ExecutorStateInfo each : facadeService.loadExecutorInfo()) {
runningApps.add(each.getId());
}
} catch (final JSONException | UniformInterfaceException | ClientHandlerException e) {
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeService.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeService.java
index 9b91d89..c445d71 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeService.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeService.java
@@ -18,20 +18,22 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
+import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfigurationService;
-import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
-import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.context.JobContext;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.MesosStateService.ExecutorStateInfo;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.disable.app.DisableAppService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.disable.job.DisableJobService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.failover.FailoverService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.failover.FailoverTaskInfo;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.ready.ReadyService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running.RunningService;
+import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.codehaus.jettison.json.JSONException;
@@ -209,7 +211,7 @@ public final class FacadeService {
* @param metaInfo task meta info
* @return failover task id
*/
- public Optional<String> getFailoverTaskId(final TaskContext.MetaInfo metaInfo) {
+ public Optional<String> getFailoverTaskId(final MetaInfo metaInfo) {
return failoverService.getTaskId(metaInfo);
}
@@ -322,7 +324,7 @@ public final class FacadeService {
* @return collection of executor info
* @throws JSONException json exception
*/
- public Collection<MesosStateService.ExecutorStateInfo> loadExecutorInfo() throws JSONException {
+ public Collection<ExecutorStateInfo> loadExecutorInfo() throws JSONException {
return mesosStateService.executors();
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateService.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateService.java
index c0e0c50..9e03836 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateService.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateService.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.sun.jersey.api.client.Client;
@@ -33,6 +32,8 @@ import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -134,14 +135,14 @@ public class MesosStateService {
}
private Collection<JSONObject> findExecutors(final JSONArray frameworks, final String appName) throws JSONException {
- List<JSONObject> result = Lists.newArrayList();
Optional<String> frameworkIDOptional = frameworkIDService.fetch();
String frameworkID;
if (frameworkIDOptional.isPresent()) {
frameworkID = frameworkIDOptional.get();
} else {
- return result;
+ return Collections.emptyList();
}
+ List<JSONObject> result = new LinkedList<>();
for (int i = 0; i < frameworks.length(); i++) {
JSONObject framework = frameworks.getJSONObject(i);
if (!framework.getString("id").equals(frameworkID)) {
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledService.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledService.java
index fa15197..840a73c 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledService.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledService.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos;
-import com.google.common.base.Joiner;
import com.google.common.util.concurrent.AbstractScheduledService;
import com.google.protobuf.ByteString;
import com.netflix.fenzo.TaskAssignmentResult;
@@ -42,12 +41,14 @@ import org.apache.shardingsphere.elasticjob.cloud.util.config.ShardingItemParame
import org.apache.shardingsphere.elasticjob.cloud.util.json.GsonFactory;
import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.script.props.ScriptJobProperties;
import org.apache.shardingsphere.elasticjob.tracing.JobEventBus;
import org.apache.shardingsphere.elasticjob.tracing.event.JobStatusTraceEvent;
import org.apache.shardingsphere.elasticjob.tracing.event.JobStatusTraceEvent.Source;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
@@ -55,7 +56,9 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.StringJoiner;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
/**
* Task launch schedule service.
@@ -227,20 +230,24 @@ public final class TaskLaunchScheduledService extends AbstractScheduledService {
if (isCommandExecutor) {
CommandLine commandLine = CommandLine.parse(script);
commandLine.addArgument(GsonFactory.getGson().toJson(shardingContexts), false);
- result.setValue(Joiner.on(" ").join(commandLine.getExecutable(), Joiner.on(" ").join(commandLine.getArguments())));
+ result.setValue(new StringJoiner("-").add(commandLine.getExecutable()).add(getArguments(commandLine)).toString());
} else {
result.setValue(script);
}
return result.build();
}
+ private String getArguments(final CommandLine commandLine) {
+ return Arrays.stream(commandLine.getArguments()).collect(Collectors.joining(" "));
+ }
+
private Protos.Resource buildResource(final String type, final double resourceValue, final List<Protos.Resource> resources) {
return Protos.Resource.newBuilder().mergeFrom(
resources.stream().filter(input -> input.getName().equals(type)).findFirst().get()).setScalar(Protos.Value.Scalar.newBuilder().setValue(resourceValue)).build();
}
private JobStatusTraceEvent createJobStatusTraceEvent(final TaskContext taskContext) {
- TaskContext.MetaInfo metaInfo = taskContext.getMetaInfo();
+ MetaInfo metaInfo = taskContext.getMetaInfo();
JobStatusTraceEvent result = new JobStatusTraceEvent(metaInfo.getJobName(), taskContext.getId(), taskContext.getSlaveId(),
Source.CLOUD_SCHEDULER, taskContext.getType().toString(), String.valueOf(metaInfo.getShardingItems()), JobStatusTraceEvent.State.TASK_STAGING, "");
if (ExecutionType.FAILOVER == taskContext.getType()) {
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManager.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManager.java
index cae6cfe..ebbed8e 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManager.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManager.java
@@ -17,26 +17,26 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.producer;
-import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.mesos.Protos;
import org.apache.mesos.Protos.ExecutorID;
import org.apache.mesos.Protos.SlaveID;
import org.apache.mesos.SchedulerDriver;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
+import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.exception.AppConfigurationException;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfigurationService;
-import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
-import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.disable.app.DisableAppService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.disable.job.DisableJobService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.ready.ReadyService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running.RunningService;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.apache.shardingsphere.elasticjob.infra.exception.JobConfigurationException;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
+import java.util.Collections;
import java.util.Optional;
/**
@@ -158,7 +158,7 @@ public final class ProducerManager {
schedulerDriver.killTask(Protos.TaskID.newBuilder().setValue(each.getId()).build());
}
runningService.remove(jobName);
- readyService.remove(Lists.newArrayList(jobName));
+ readyService.remove(Collections.singletonList(jobName));
Optional<CloudJobConfiguration> jobConfig = configService.load(jobName);
jobConfig.ifPresent(transientProducerScheduler::deregister);
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApi.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApi.java
index 76a6314..13b1229 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApi.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApi.java
@@ -19,13 +19,14 @@ package org.apache.shardingsphere.elasticjob.cloud.scheduler.restful;
import org.apache.mesos.Protos.ExecutorID;
import org.apache.mesos.Protos.SlaveID;
+import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.exception.AppConfigurationException;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfigurationGsonFactory;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.CloudAppConfigurationService;
-import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.MesosStateService;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.MesosStateService.ExecutorStateInfo;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.producer.ProducerManager;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.disable.app.DisableAppService;
import org.apache.shardingsphere.elasticjob.cloud.util.json.GsonFactory;
@@ -214,8 +215,8 @@ public final class CloudAppRestfulApi {
private void stopExecutors(final String appName) {
try {
- Collection<MesosStateService.ExecutorStateInfo> executorBriefInfo = mesosStateService.executors(appName);
- for (MesosStateService.ExecutorStateInfo each : executorBriefInfo) {
+ Collection<ExecutorStateInfo> executorBriefInfo = mesosStateService.executors(appName);
+ for (ExecutorStateInfo each : executorBriefInfo) {
producerManager.sendFrameworkMessage(ExecutorID.newBuilder().setValue(each.getId()).build(),
SlaveID.newBuilder().setValue(each.getSlaveId()).build(), "STOP".getBytes());
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/search/JobEventRdbSearch.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/search/JobEventRdbSearch.java
index d60c4d1..688aaa0 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/search/JobEventRdbSearch.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/search/JobEventRdbSearch.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.elasticjob.cloud.scheduler.restful.search;
import com.google.common.base.CaseFormat;
import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -32,6 +31,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
@@ -50,10 +50,10 @@ public final class JobEventRdbSearch {
private static final String TABLE_JOB_STATUS_TRACE_LOG = "JOB_STATUS_TRACE_LOG";
private static final List<String> FIELDS_JOB_EXECUTION_LOG =
- Lists.newArrayList("id", "hostname", "ip", "task_id", "job_name", "execution_source", "sharding_item", "start_time", "complete_time", "is_success", "failure_cause");
+ Arrays.asList("id", "hostname", "ip", "task_id", "job_name", "execution_source", "sharding_item", "start_time", "complete_time", "is_success", "failure_cause");
private static final List<String> FIELDS_JOB_STATUS_TRACE_LOG =
- Lists.newArrayList("id", "job_name", "original_task_id", "task_id", "slave_id", "source", "execution_type", "sharding_item", "state", "message", "creation_time");
+ Arrays.asList("id", "job_name", "original_task_id", "task_id", "slave_id", "source", "execution_type", "sharding_item", "state", "message", "creation_time");
private final DataSource dataSource;
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNode.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNode.java
index c34c01c..be68137 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNode.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverNode.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.state.failover;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
-import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.StateNode;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.StateNode;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
/**
* Failover node.
@@ -39,6 +39,6 @@ final class FailoverNode {
}
static String getFailoverTaskNodePath(final String taskMetaInfo) {
- return String.format(FAILOVER_TASK, TaskContext.MetaInfo.from(taskMetaInfo).getJobName(), taskMetaInfo);
+ return String.format(FAILOVER_TASK, MetaInfo.from(taskMetaInfo).getJobName(), taskMetaInfo);
}
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java
index 5d4f41e..b0ca769 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverService.java
@@ -22,13 +22,14 @@ import com.google.common.base.Strings;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobConfiguration;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.context.JobContext;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.env.BootstrapEnvironment;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running.RunningService;
+import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import java.util.ArrayList;
@@ -112,7 +113,7 @@ public final class FailoverService {
private List<Integer> getAssignedShardingItems(final String jobName, final List<String> taskIdList, final Set<HashCode> assignedTasks) {
List<Integer> result = new ArrayList<>(taskIdList.size());
for (String each : taskIdList) {
- TaskContext.MetaInfo metaInfo = TaskContext.MetaInfo.from(each);
+ MetaInfo metaInfo = MetaInfo.from(each);
if (assignedTasks.add(Hashing.md5().newHasher().putString(jobName, Charsets.UTF_8).putInt(metaInfo.getShardingItems().get(0)).hash()) && !runningService.isTaskRunning(metaInfo)) {
result.add(metaInfo.getShardingItems().get(0));
}
@@ -125,8 +126,8 @@ public final class FailoverService {
*
* @param metaInfoList collection of task meta infos to be removed
*/
- public void remove(final Collection<TaskContext.MetaInfo> metaInfoList) {
- for (TaskContext.MetaInfo each : metaInfoList) {
+ public void remove(final Collection<MetaInfo> metaInfoList) {
+ for (MetaInfo each : metaInfoList) {
regCenter.remove(FailoverNode.getFailoverTaskNodePath(each.toString()));
}
}
@@ -137,7 +138,7 @@ public final class FailoverService {
* @param metaInfo task meta info
* @return failover task id
*/
- public Optional<String> getTaskId(final TaskContext.MetaInfo metaInfo) {
+ public Optional<String> getTaskId(final MetaInfo metaInfo) {
String failoverTaskNodePath = FailoverNode.getFailoverTaskNodePath(metaInfo.toString());
return regCenter.isExisted(failoverTaskNodePath) ? Optional.of(regCenter.get(failoverTaskNodePath)) : Optional.empty();
}
@@ -174,7 +175,7 @@ public final class FailoverService {
for (String each : failOverTasks) {
String originalTaskId = regCenter.get(FailoverNode.getFailoverTaskNodePath(each));
if (!Strings.isNullOrEmpty(originalTaskId)) {
- result.add(new FailoverTaskInfo(TaskContext.MetaInfo.from(each), originalTaskId));
+ result.add(new FailoverTaskInfo(MetaInfo.from(each), originalTaskId));
}
}
return result;
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverTaskInfo.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverTaskInfo.java
index a05d340..fa13828 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverTaskInfo.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverTaskInfo.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.state.failover;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
/**
* Failover task info.
@@ -28,7 +28,7 @@ import lombok.RequiredArgsConstructor;
@Getter
public final class FailoverTaskInfo {
- private final TaskContext.MetaInfo taskInfo;
+ private final MetaInfo taskInfo;
private final String originalTaskId;
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNode.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNode.java
index d9d1b01..bfd18f8 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNode.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningNode.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running;
-import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.StateNode;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.StateNode;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
/**
* Running node.
@@ -39,6 +39,6 @@ final class RunningNode {
}
static String getRunningTaskNodePath(final String taskMetaInfo) {
- return String.format(RUNNING_TASK, TaskContext.MetaInfo.from(taskMetaInfo).getJobName(), taskMetaInfo);
+ return String.format(RUNNING_TASK, MetaInfo.from(taskMetaInfo).getJobName(), taskMetaInfo);
}
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningService.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningService.java
index b208d23..cec47fe 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningService.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningService.java
@@ -172,7 +172,7 @@ public final class RunningService {
* @param metaInfo task meta info
* @return true is running, otherwise not
*/
- public boolean isTaskRunning(final TaskContext.MetaInfo metaInfo) {
+ public boolean isTaskRunning(final MetaInfo metaInfo) {
for (TaskContext each : getRunningTasks(metaInfo.getJobName())) {
if (each.getMetaInfo().equals(metaInfo)) {
return true;
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/security/WwwAuthFilter.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/security/WwwAuthFilter.java
index 297e584..57d62e5 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/security/WwwAuthFilter.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/security/WwwAuthFilter.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.security;
-import com.google.common.base.Joiner;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
@@ -33,6 +32,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
+import java.util.StringJoiner;
/**
* WWW auth filter.
@@ -65,11 +65,11 @@ public final class WwwAuthFilter implements Filter {
private String guestPassword;
@Override
- public void init(final FilterConfig filterConfig) throws ServletException {
+ public void init(final FilterConfig filterConfig) {
Properties props = new Properties();
URL classLoaderURL = Thread.currentThread().getContextClassLoader().getResource("");
if (null != classLoaderURL) {
- String configFilePath = Joiner.on(FILE_SEPARATOR).join(classLoaderURL.getPath(), "conf", "auth.properties");
+ String configFilePath = new StringJoiner(FILE_SEPARATOR).add(classLoaderURL.getPath()).add("conf").add("auth.properties").toString();
try {
props.load(new FileInputStream(configFilePath));
} catch (final IOException ex) {
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/EmbedTestingServer.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/EmbedTestingServer.java
index 6c0afda..07f1065 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/EmbedTestingServer.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/EmbedTestingServer.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture;
-import com.google.common.base.Joiner;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.curator.test.TestingServer;
@@ -32,15 +31,7 @@ public final class EmbedTestingServer {
private static final int PORT = 3181;
private static volatile TestingServer testingServer;
-
- /**
- * Get connection url.
- * @return connection url
- */
- public static String getConnectionString() {
- return Joiner.on(":").join("localhost", PORT);
- }
-
+
/**
* Start the embed server.
*/
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/TaskNode.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/TaskNode.java
index 4c523c8..37f2207 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/TaskNode.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/fixture/TaskNode.java
@@ -17,14 +17,17 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture;
-import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
-import com.google.common.base.Joiner;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import lombok.Builder;
+import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
+
+import java.util.StringJoiner;
@Builder
public final class TaskNode {
+ private static final String DELIMITER = "@-@";
+
private String jobName;
private int shardingItem;
@@ -34,13 +37,13 @@ public final class TaskNode {
private String slaveId;
private String uuid;
-
+
/**
* Get task node path.
* @return task node path
*/
public String getTaskNodePath() {
- return Joiner.on("@-@").join(null == jobName ? "test_job" : jobName, shardingItem);
+ return new StringJoiner(DELIMITER).add(null == jobName ? "test_job" : jobName).add("" + shardingItem).toString();
}
/**
@@ -48,14 +51,15 @@ public final class TaskNode {
* @return task node value
*/
public String getTaskNodeValue() {
- return Joiner.on("@-@").join(getTaskNodePath(), null == type ? ExecutionType.READY : type, null == slaveId ? "slave-S0" : slaveId, null == uuid ? "0" : uuid);
+ return new StringJoiner(DELIMITER)
+ .add(getTaskNodePath()).add(null == type ? ExecutionType.READY.toString() : type.toString()).add(null == slaveId ? "slave-S0" : slaveId).add(null == uuid ? "0" : uuid).toString();
}
/**
* Get task meta info.
* @return meta info
*/
- public TaskContext.MetaInfo getMetaInfo() {
- return TaskContext.MetaInfo.from(Joiner.on("@-@").join("test_job", 0));
+ public MetaInfo getMetaInfo() {
+ return MetaInfo.from(new StringJoiner(DELIMITER).add("test_job").add("0").toString());
}
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java
index 1905440..c221c70 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/AppConstraintEvaluatorTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos;
-import com.google.common.collect.ImmutableList;
import com.netflix.fenzo.ConstraintEvaluator;
import com.netflix.fenzo.SchedulingResult;
import com.netflix.fenzo.TaskRequest;
@@ -26,10 +25,11 @@ import com.netflix.fenzo.VMAssignmentResult;
import com.netflix.fenzo.VirtualMachineLease;
import com.netflix.fenzo.plugins.VMLeaseObject;
import org.apache.mesos.Protos;
-import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudAppConfigurationBuilder;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudJobConfigurationBuilder;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.MesosStateService.ExecutorStateInfo;
+import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.codehaus.jettison.json.JSONException;
import org.junit.After;
import org.junit.Before;
@@ -103,7 +103,7 @@ public final class AppConstraintEvaluatorTest {
@Test
public void assertExistExecutorOnS0() throws Exception {
- when(facadeService.loadExecutorInfo()).thenReturn(ImmutableList.of(new MesosStateService.ExecutorStateInfo("foo-app@-@S0", "S0")));
+ when(facadeService.loadExecutorInfo()).thenReturn(Collections.singletonList(new ExecutorStateInfo("foo-app@-@S0", "S0")));
AppConstraintEvaluator.getInstance().loadAppRunningState();
SchedulingResult result = taskScheduler.scheduleOnce(getTasks(), Arrays.asList(getLease(0, INSUFFICIENT_CPU, INSUFFICIENT_MEM), getLease(1, INSUFFICIENT_CPU, INSUFFICIENT_MEM)));
assertThat(result.getResultMap().size(), is(2));
@@ -171,7 +171,7 @@ public final class AppConstraintEvaluatorTest {
TaskRequest result = mock(TaskRequest.class);
when(result.getCPUs()).thenReturn(1.0d);
when(result.getMemory()).thenReturn(128.0d);
- when(result.getHardConstraints()).thenAnswer((Answer<List<? extends ConstraintEvaluator>>) invocationOnMock -> ImmutableList.of(AppConstraintEvaluator.getInstance()));
+ when(result.getHardConstraints()).thenAnswer((Answer<List<? extends ConstraintEvaluator>>) invocationOnMock -> Collections.singletonList(AppConstraintEvaluator.getInstance()));
when(result.getId()).thenReturn(new TaskContext(jobName, Collections.singletonList(0), ExecutionType.READY).getId());
return result;
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java
index e98dd70..ca8e0f2 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/FacadeServiceTest.java
@@ -35,6 +35,7 @@ import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.ready.ReadySer
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running.RunningService;
import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.junit.Before;
import org.junit.Test;
@@ -135,7 +136,7 @@ public final class FacadeServiceTest {
facadeService.removeLaunchTasksFromQueue(Arrays.asList(
TaskContext.from(TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodeValue()),
TaskContext.from(TaskNode.builder().build().getTaskNodeValue())));
- verify(failoverService).remove(Collections.singletonList(TaskContext.MetaInfo.from(TaskNode.builder().build().getTaskNodePath())));
+ verify(failoverService).remove(Collections.singletonList(MetaInfo.from(TaskNode.builder().build().getTaskNodePath())));
verify(readyService).remove(Sets.newHashSet("test_job"));
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java
index e8775e1..e4f2396 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/MesosStateServiceTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos;
import com.google.gson.JsonArray;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.ha.HANode;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.MesosStateService.ExecutorStateInfo;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.restful.AbstractCloudRestfulApiTest;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.junit.Test;
@@ -53,9 +54,9 @@ public class MesosStateServiceTest extends AbstractCloudRestfulApiTest {
public void assertExecutors() throws Exception {
when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000");
MesosStateService service = new MesosStateService(registryCenter);
- Collection<MesosStateService.ExecutorStateInfo> executorStateInfo = service.executors("foo_app");
+ Collection<ExecutorStateInfo> executorStateInfo = service.executors("foo_app");
assertThat(executorStateInfo.size(), is(1));
- MesosStateService.ExecutorStateInfo executor = executorStateInfo.iterator().next();
+ ExecutorStateInfo executor = executorStateInfo.iterator().next();
assertThat(executor.getId(), is("foo_app@-@d8701508-41b7-471e-9b32-61cf824a660d-S0"));
assertThat(executor.getSlaveId(), is("d8701508-41b7-471e-9b32-61cf824a660d-S0"));
}
@@ -64,9 +65,9 @@ public class MesosStateServiceTest extends AbstractCloudRestfulApiTest {
public void assertAllExecutors() throws Exception {
when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000");
MesosStateService service = new MesosStateService(registryCenter);
- Collection<MesosStateService.ExecutorStateInfo> executorStateInfo = service.executors();
+ Collection<ExecutorStateInfo> executorStateInfo = service.executors();
assertThat(executorStateInfo.size(), is(1));
- MesosStateService.ExecutorStateInfo executor = executorStateInfo.iterator().next();
+ ExecutorStateInfo executor = executorStateInfo.iterator().next();
assertThat(executor.getId(), is("foo_app@-@d8701508-41b7-471e-9b32-61cf824a660d-S0"));
assertThat(executor.getSlaveId(), is("d8701508-41b7-471e-9b32-61cf824a660d-S0"));
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java
index ef82f0d..212662d 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/mesos/TaskLaunchScheduledServiceTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.AbstractScheduledService.Scheduler;
import com.netflix.fenzo.SchedulingResult;
@@ -27,13 +26,14 @@ import com.netflix.fenzo.VMAssignmentResult;
import com.netflix.fenzo.functions.Action2;
import com.netflix.fenzo.plugins.VMLeaseObject;
import org.apache.mesos.SchedulerDriver;
-import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.context.JobContext;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudAppConfigurationBuilder;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudJobConfigurationBuilder;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.fixture.OfferBuilder;
+import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.tracing.JobEventBus;
import org.apache.shardingsphere.elasticjob.tracing.event.JobStatusTraceEvent;
import org.junit.After;
@@ -44,6 +44,7 @@ import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -87,15 +88,14 @@ public final class TaskLaunchScheduledServiceTest {
@Test
public void assertRunOneIteration() {
- when(facadeService.getEligibleJobContext()).thenReturn(Lists.newArrayList(
- JobContext.from(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job", CloudJobExecutionType.DAEMON, 1), ExecutionType.FAILOVER)));
+ when(facadeService.getEligibleJobContext()).thenReturn(
+ Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job", CloudJobExecutionType.DAEMON, 1), ExecutionType.FAILOVER)));
Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();
- vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),
+ vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Collections.singletonList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),
Sets.newHashSet(mockTaskAssignmentResult("failover_job", ExecutionType.FAILOVER))));
when(taskScheduler.scheduleOnce(ArgumentMatchers.anyList(), ArgumentMatchers.anyList())).thenReturn(new SchedulingResult(vmAssignmentResultMap));
when(facadeService.load("failover_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job")));
- when(facadeService.getFailoverTaskId(any(TaskContext.MetaInfo.class)))
- .thenReturn(Optional.of(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", "failover_job", ExecutionType.FAILOVER.name())));
+ when(facadeService.getFailoverTaskId(any(MetaInfo.class))).thenReturn(Optional.of(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", "failover_job", ExecutionType.FAILOVER.name())));
when(taskScheduler.getTaskAssigner()).thenReturn(mock(Action2.class));
taskLaunchScheduledService.runOneIteration();
verify(facadeService).removeLaunchTasksFromQueue(ArgumentMatchers.anyList());
@@ -105,10 +105,10 @@ public final class TaskLaunchScheduledServiceTest {
@Test
public void assertRunOneIterationWithScriptJob() {
- when(facadeService.getEligibleJobContext()).thenReturn(Lists.newArrayList(
- JobContext.from(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1), ExecutionType.READY)));
+ when(facadeService.getEligibleJobContext()).thenReturn(
+ Collections.singletonList(JobContext.from(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1), ExecutionType.READY)));
Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();
- vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),
+ vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Collections.singletonList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),
Sets.newHashSet(mockTaskAssignmentResult("script_job", ExecutionType.READY))));
when(taskScheduler.scheduleOnce(ArgumentMatchers.anyList(), ArgumentMatchers.anyList())).thenReturn(new SchedulingResult(vmAssignmentResultMap));
when(facadeService.loadAppConfig("test_app")).thenReturn(Optional.of(CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app")));
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java
index d992c50..9242d8f 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/ProducerManagerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.producer;
-import com.google.common.collect.Lists;
import org.apache.mesos.Protos;
import org.apache.mesos.SchedulerDriver;
import org.apache.shardingsphere.elasticjob.cloud.ReflectionUtils;
@@ -42,6 +41,7 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -159,7 +159,7 @@ public final class ProducerManagerTest {
verify(schedulerDriver).killTask(Protos.TaskID.newBuilder().setValue(each.getId()).build());
}
verify(runningService).remove("transient_test_job");
- verify(readyService).remove(Lists.newArrayList("transient_test_job"));
+ verify(readyService).remove(Collections.singletonList("transient_test_job"));
}
@Test
@@ -182,7 +182,7 @@ public final class ProducerManagerTest {
verify(disableJobService).remove("transient_test_job");
verify(configService).remove("transient_test_job");
verify(runningService).remove("transient_test_job");
- verify(readyService).remove(Lists.newArrayList("transient_test_job"));
+ verify(readyService).remove(Collections.singletonList("transient_test_job"));
}
@Test
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApiTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApiTest.java
index f02af4b..f3f9b8f 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApiTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudAppRestfulApiTest.java
@@ -17,13 +17,14 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.restful;
-import com.google.common.collect.Lists;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudAppJsonConstants;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudJsonConstants;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import java.util.Collections;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
@@ -83,7 +84,7 @@ public final class CloudAppRestfulApiTest extends AbstractCloudRestfulApiTest {
@Test
public void assertFindAllJobs() throws Exception {
when(getRegCenter().isExisted("/config/app")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/config/app")).thenReturn(Lists.newArrayList("test_app"));
+ when(getRegCenter().getChildrenKeys("/config/app")).thenReturn(Collections.singletonList("test_app"));
when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app"));
assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/app/list"), is("[" + CloudAppJsonConstants.getAppJson("test_app") + "]"));
verify(getRegCenter()).isExisted("/config/app");
@@ -107,7 +108,7 @@ public final class CloudAppRestfulApiTest extends AbstractCloudRestfulApiTest {
@Test
public void assertDisable() throws Exception {
when(getRegCenter().isExisted("/config/job")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Lists.newArrayList("test_job"));
+ when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job"));
when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app"));
when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson());
assertThat(RestfulTestsUtil.sentRequest("http://127.0.0.1:19000/api/app/test_app/disable", "POST"), is(204));
@@ -118,7 +119,7 @@ public final class CloudAppRestfulApiTest extends AbstractCloudRestfulApiTest {
@Test
public void assertEnable() throws Exception {
when(getRegCenter().isExisted("/config/job")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Lists.newArrayList("test_job"));
+ when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job"));
when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app"));
when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson());
assertThat(RestfulTestsUtil.sentRequest("http://127.0.0.1:19000/api/app/test_app/enable", "POST"), is(204));
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudJobRestfulApiTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudJobRestfulApiTest.java
index 6cb5aed..5960f69 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudJobRestfulApiTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/restful/CloudJobRestfulApiTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.restful;
-import com.google.common.collect.Lists;
import org.apache.shardingsphere.elasticjob.cloud.ReflectionUtils;
import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudAppJsonConstants;
@@ -32,6 +31,7 @@ import org.apache.shardingsphere.elasticjob.cloud.statistics.type.task.TaskResul
import org.apache.shardingsphere.elasticjob.cloud.util.json.GsonFactory;
import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.tracing.event.JobExecutionEvent;
import org.apache.shardingsphere.elasticjob.tracing.event.JobStatusTraceEvent;
import org.junit.Test;
@@ -150,7 +150,7 @@ public final class CloudJobRestfulApiTest extends AbstractCloudRestfulApiTest {
@Test
public void assertFindAllJobs() throws Exception {
when(getRegCenter().isExisted("/config/job")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Lists.newArrayList("test_job"));
+ when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job"));
when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson());
assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/jobs"), is("[" + CloudJsonConstants.getJobJson() + "]"));
verify(getRegCenter()).isExisted("/config/job");
@@ -164,19 +164,18 @@ public final class CloudJobRestfulApiTest extends AbstractCloudRestfulApiTest {
TaskContext actualTaskContext = TaskContext.from(TaskNode.builder().build().getTaskNodeValue());
when(getRegCenter().get("/config/job/" + actualTaskContext.getMetaInfo().getJobName())).thenReturn(CloudJsonConstants.getJobJson());
runningService.add(actualTaskContext);
- assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/tasks/running"), is(GsonFactory.getGson().toJson(Lists.newArrayList(actualTaskContext))));
+ assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/tasks/running"), is(GsonFactory.getGson().toJson(Collections.singletonList(actualTaskContext))));
}
@Test
public void assertFindAllReadyTasks() throws Exception {
when(getRegCenter().isExisted("/state/ready")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/state/ready")).thenReturn(Lists.newArrayList("test_job"));
+ when(getRegCenter().getChildrenKeys("/state/ready")).thenReturn(Collections.singletonList("test_job"));
when(getRegCenter().get("/state/ready/test_job")).thenReturn("1");
Map<String, String> expectedMap = new HashMap<>();
expectedMap.put("jobName", "test_job");
expectedMap.put("times", "1");
- @SuppressWarnings("unchecked")
- Collection<Map<String, String>> expectedResult = Lists.newArrayList(expectedMap);
+ Collection<Map<String, String>> expectedResult = Collections.singletonList(expectedMap);
assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/tasks/ready"), is(GsonFactory.getGson().toJson(expectedResult)));
verify(getRegCenter()).isExisted("/state/ready");
verify(getRegCenter()).getChildrenKeys("/state/ready");
@@ -186,12 +185,12 @@ public final class CloudJobRestfulApiTest extends AbstractCloudRestfulApiTest {
@Test
public void assertFindAllFailoverTasks() throws Exception {
when(getRegCenter().isExisted("/state/failover")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/state/failover")).thenReturn(Lists.newArrayList("test_job"));
- when(getRegCenter().getChildrenKeys("/state/failover/test_job")).thenReturn(Lists.newArrayList("test_job@-@0"));
+ when(getRegCenter().getChildrenKeys("/state/failover")).thenReturn(Collections.singletonList("test_job"));
+ when(getRegCenter().getChildrenKeys("/state/failover/test_job")).thenReturn(Collections.singletonList("test_job@-@0"));
String originalTaskId = UUID.randomUUID().toString();
when(getRegCenter().get("/state/failover/test_job/test_job@-@0")).thenReturn(originalTaskId);
- FailoverTaskInfo expectedFailoverTask = new FailoverTaskInfo(TaskContext.MetaInfo.from("test_job@-@0"), originalTaskId);
- Collection<FailoverTaskInfo> expectedResult = Lists.newArrayList(expectedFailoverTask);
+ FailoverTaskInfo expectedFailoverTask = new FailoverTaskInfo(MetaInfo.from("test_job@-@0"), originalTaskId);
+ Collection<FailoverTaskInfo> expectedResult = Collections.singletonList(expectedFailoverTask);
assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/tasks/failover"), is(GsonFactory.getGson().toJson(expectedResult)));
verify(getRegCenter()).isExisted("/state/failover");
verify(getRegCenter()).getChildrenKeys("/state/failover");
@@ -210,10 +209,9 @@ public final class CloudJobRestfulApiTest extends AbstractCloudRestfulApiTest {
public void assertFindJobExecutionEvents() throws Exception {
ReflectionUtils.setStaticFieldValue(CloudJobRestfulApi.class, "jobEventRdbSearch", getJobEventRdbSearch());
JobExecutionEvent jobExecutionEvent = new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
- when(getJobEventRdbSearch().findJobExecutionEvents(any(JobEventRdbSearch.Condition.class))).thenReturn(new JobEventRdbSearch.Result<>(0,
- Lists.newArrayList(jobExecutionEvent)));
+ when(getJobEventRdbSearch().findJobExecutionEvents(any(JobEventRdbSearch.Condition.class))).thenReturn(new JobEventRdbSearch.Result<>(0, Collections.singletonList(jobExecutionEvent)));
assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/events/executions?" + buildFindJobEventsQueryParameter()),
- is(GsonFactory.getGson().toJson(new JobEventRdbSearch.Result<>(0, Lists.newArrayList(jobExecutionEvent)))));
+ is(GsonFactory.getGson().toJson(new JobEventRdbSearch.Result<>(0, Collections.singletonList(jobExecutionEvent)))));
verify(getJobEventRdbSearch()).findJobExecutionEvents(any(JobEventRdbSearch.Condition.class));
}
@@ -229,10 +227,9 @@ public final class CloudJobRestfulApiTest extends AbstractCloudRestfulApiTest {
ReflectionUtils.setStaticFieldValue(CloudJobRestfulApi.class, "jobEventRdbSearch", getJobEventRdbSearch());
JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent("test-job",
"fake_task_id", "fake_slave_id", JobStatusTraceEvent.Source.LITE_EXECUTOR, ExecutionType.READY.toString(), "0", JobStatusTraceEvent.State.TASK_RUNNING, "message is empty.");
- when(getJobEventRdbSearch().findJobStatusTraceEvents(any(JobEventRdbSearch.Condition.class))).thenReturn(new Result<>(0,
- Lists.newArrayList(jobStatusTraceEvent)));
+ when(getJobEventRdbSearch().findJobStatusTraceEvents(any(JobEventRdbSearch.Condition.class))).thenReturn(new Result<>(0, Collections.singletonList(jobStatusTraceEvent)));
assertThat(RestfulTestsUtil.sentGetRequest("http://127.0.0.1:19000/api/job/events/statusTraces?" + buildFindJobEventsQueryParameter()),
- is(GsonFactory.getGson().toJson(new JobEventRdbSearch.Result<>(0, Lists.newArrayList(jobStatusTraceEvent)))));
+ is(GsonFactory.getGson().toJson(new JobEventRdbSearch.Result<>(0, Collections.singletonList(jobStatusTraceEvent)))));
verify(getJobEventRdbSearch()).findJobStatusTraceEvents(any(JobEventRdbSearch.Condition.class));
}
@@ -319,7 +316,7 @@ public final class CloudJobRestfulApiTest extends AbstractCloudRestfulApiTest {
@Test
public void assertDisable() throws Exception {
when(getRegCenter().isExisted("/config/job")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Lists.newArrayList("test_job"));
+ when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job"));
when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app"));
when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson());
assertThat(RestfulTestsUtil.sentRequest("http://127.0.0.1:19000/api/job/test_job/disable", "POST"), is(204));
@@ -329,7 +326,7 @@ public final class CloudJobRestfulApiTest extends AbstractCloudRestfulApiTest {
@Test
public void assertEnable() throws Exception {
when(getRegCenter().isExisted("/config/job")).thenReturn(true);
- when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Lists.newArrayList("test_job"));
+ when(getRegCenter().getChildrenKeys("/config/job")).thenReturn(Collections.singletonList("test_job"));
when(getRegCenter().get("/config/app/test_app")).thenReturn(CloudAppJsonConstants.getAppJson("test_app"));
when(getRegCenter().get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson());
assertThat(RestfulTestsUtil.sentRequest("http://127.0.0.1:19000/api/job/test_job/enable", "POST", "test_job"), is(204));
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java
index 41f9c0b..eef4525 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/failover/FailoverServiceTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.state.failover;
-import com.google.common.collect.Lists;
import org.apache.shardingsphere.elasticjob.cloud.ReflectionUtils;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.context.JobContext;
@@ -27,6 +26,7 @@ import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.TaskNode;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running.RunningService;
import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.junit.Before;
import org.junit.Test;
@@ -90,10 +90,10 @@ public final class FailoverServiceTest {
public void assertAddWhenNotExistedAndTaskIsRunning() {
TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(false);
- when(runningService.isTaskRunning(TaskContext.MetaInfo.from(taskNode.getTaskNodePath()))).thenReturn(true);
+ when(runningService.isTaskRunning(MetaInfo.from(taskNode.getTaskNodePath()))).thenReturn(true);
failoverService.add(TaskContext.from(taskNode.getTaskNodeValue()));
verify(regCenter).isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath());
- verify(runningService).isTaskRunning(TaskContext.MetaInfo.from(taskNode.getTaskNodePath()));
+ verify(runningService).isTaskRunning(MetaInfo.from(taskNode.getTaskNodePath()));
verify(regCenter, times(0)).persist("/state/failover/test_job/" + taskNode.getTaskNodePath(), taskNode.getTaskNodeValue());
}
@@ -101,10 +101,10 @@ public final class FailoverServiceTest {
public void assertAddWhenNotExistedAndTaskIsNotRunning() {
TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
when(regCenter.isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath())).thenReturn(false);
- when(runningService.isTaskRunning(TaskContext.MetaInfo.from(taskNode.getTaskNodePath()))).thenReturn(false);
+ when(runningService.isTaskRunning(MetaInfo.from(taskNode.getTaskNodePath()))).thenReturn(false);
failoverService.add(TaskContext.from(taskNode.getTaskNodeValue()));
verify(regCenter).isExisted("/state/failover/test_job/" + taskNode.getTaskNodePath());
- verify(runningService).isTaskRunning(TaskContext.MetaInfo.from(taskNode.getTaskNodePath()));
+ verify(runningService).isTaskRunning(MetaInfo.from(taskNode.getTaskNodePath()));
verify(regCenter).persist("/state/failover/test_job/" + taskNode.getTaskNodePath(), taskNode.getTaskNodeValue());
}
@@ -127,8 +127,8 @@ public final class FailoverServiceTest {
when(regCenter.getChildrenKeys("/state/failover/eligible_job")).thenReturn(Arrays.asList(eligibleJobNodePath1, eligibleJobNodePath2));
when(configService.load("not_existed_job")).thenReturn(Optional.empty());
when(configService.load("eligible_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("eligible_job")));
- when(runningService.isTaskRunning(TaskContext.MetaInfo.from(eligibleJobNodePath1))).thenReturn(true);
- when(runningService.isTaskRunning(TaskContext.MetaInfo.from(eligibleJobNodePath2))).thenReturn(false);
+ when(runningService.isTaskRunning(MetaInfo.from(eligibleJobNodePath1))).thenReturn(true);
+ when(runningService.isTaskRunning(MetaInfo.from(eligibleJobNodePath2))).thenReturn(false);
Collection<JobContext> actual = failoverService.getAllEligibleJobContexts();
assertThat(actual.size(), is(1));
assertThat(actual.iterator().next().getAssignedShardingItems().size(), is(1));
@@ -142,7 +142,7 @@ public final class FailoverServiceTest {
public void assertRemove() {
String jobNodePath1 = TaskNode.builder().type(ExecutionType.FAILOVER).build().getTaskNodePath();
String jobNodePath2 = TaskNode.builder().shardingItem(1).type(ExecutionType.FAILOVER).build().getTaskNodePath();
- failoverService.remove(Arrays.asList(TaskContext.MetaInfo.from(jobNodePath1), TaskContext.MetaInfo.from(jobNodePath2)));
+ failoverService.remove(Arrays.asList(MetaInfo.from(jobNodePath1), MetaInfo.from(jobNodePath2)));
verify(regCenter).remove("/state/failover/test_job/" + jobNodePath1);
verify(regCenter).remove("/state/failover/test_job/" + jobNodePath2);
}
@@ -176,7 +176,7 @@ public final class FailoverServiceTest {
@Test
public void assertGetAllFailoverTasksWhenJobNodeHasNoChild() {
when(regCenter.isExisted(FailoverNode.ROOT)).thenReturn(true);
- when(regCenter.getChildrenKeys(FailoverNode.ROOT)).thenReturn(Lists.newArrayList("test_job"));
+ when(regCenter.getChildrenKeys(FailoverNode.ROOT)).thenReturn(Collections.singletonList("test_job"));
when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job"))).thenReturn(Collections.emptyList());
assertTrue(failoverService.getAllFailoverTasks().isEmpty());
verify(regCenter).isExisted(FailoverNode.ROOT);
@@ -190,9 +190,9 @@ public final class FailoverServiceTest {
String uuid2 = UUID.randomUUID().toString();
String uuid3 = UUID.randomUUID().toString();
when(regCenter.isExisted(FailoverNode.ROOT)).thenReturn(true);
- when(regCenter.getChildrenKeys(FailoverNode.ROOT)).thenReturn(Lists.newArrayList("test_job_1", "test_job_2"));
- when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_1"))).thenReturn(Lists.newArrayList("test_job_1@-@0", "test_job_1@-@1"));
- when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_2"))).thenReturn(Lists.newArrayList("test_job_2@-@0"));
+ when(regCenter.getChildrenKeys(FailoverNode.ROOT)).thenReturn(Arrays.asList("test_job_1", "test_job_2"));
+ when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_1"))).thenReturn(Arrays.asList("test_job_1@-@0", "test_job_1@-@1"));
+ when(regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath("test_job_2"))).thenReturn(Collections.singletonList("test_job_2@-@0"));
when(regCenter.get(FailoverNode.getFailoverTaskNodePath("test_job_1@-@0"))).thenReturn(uuid1);
when(regCenter.get(FailoverNode.getFailoverTaskNodePath("test_job_1@-@1"))).thenReturn(uuid2);
when(regCenter.get(FailoverNode.getFailoverTaskNodePath("test_job_2@-@0"))).thenReturn(uuid3);
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java
index caaaec2..53be431 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/ready/ReadyServiceTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.state.ready;
-import com.google.common.collect.Lists;
import org.apache.shardingsphere.elasticjob.cloud.ReflectionUtils;
import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
@@ -261,7 +260,7 @@ public final class ReadyServiceTest {
@Test
public void assertGetAllTasksWhenNodeIsEmpty() {
when(regCenter.isExisted(ReadyNode.ROOT)).thenReturn(true);
- when(regCenter.getChildrenKeys(ReadyNode.ROOT)).thenReturn(Lists.newArrayList("test_job"));
+ when(regCenter.getChildrenKeys(ReadyNode.ROOT)).thenReturn(Collections.singletonList("test_job"));
when(regCenter.get(ReadyNode.getReadyJobNodePath("test_job"))).thenReturn("");
assertTrue(readyService.getAllReadyTasks().isEmpty());
verify(regCenter).isExisted(ReadyNode.ROOT);
@@ -272,7 +271,7 @@ public final class ReadyServiceTest {
@Test
public void assertGetAllTasksWithRootNode() {
when(regCenter.isExisted(ReadyNode.ROOT)).thenReturn(true);
- when(regCenter.getChildrenKeys(ReadyNode.ROOT)).thenReturn(Lists.newArrayList("test_job_1", "test_job_2"));
+ when(regCenter.getChildrenKeys(ReadyNode.ROOT)).thenReturn(Arrays.asList("test_job_1", "test_job_2"));
when(regCenter.get(ReadyNode.getReadyJobNodePath("test_job_1"))).thenReturn("1");
when(regCenter.get(ReadyNode.getReadyJobNodePath("test_job_2"))).thenReturn("5");
Map<String, Integer> result = readyService.getAllReadyTasks();
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java
index b4c6fb8..95e4e16 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/state/running/RunningServiceTest.java
@@ -17,11 +17,12 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running;
-import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
-import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudJsonConstants;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.TaskNode;
+import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.junit.After;
import org.junit.Before;
@@ -138,12 +139,12 @@ public final class RunningServiceTest {
@Test
public void assertIsTaskRunning() {
- assertTrue(runningService.isTaskRunning(TaskContext.MetaInfo.from(TaskNode.builder().build().getTaskNodePath())));
+ assertTrue(runningService.isTaskRunning(MetaInfo.from(TaskNode.builder().build().getTaskNodePath())));
}
@Test
public void assertIsTaskNotRunning() {
- assertFalse(runningService.isTaskRunning(TaskContext.MetaInfo.from(TaskNode.builder().shardingItem(2).build().getTaskNodePath())));
+ assertFalse(runningService.isTaskRunning(MetaInfo.from(TaskNode.builder().shardingItem(2).build().getTaskNodePath())));
}
@Test
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java
index f8b3b2f..b70a7d0 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/StatisticManagerTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.statistics;
-import com.google.common.collect.Lists;
import org.apache.shardingsphere.elasticjob.cloud.ReflectionUtils;
import org.apache.shardingsphere.elasticjob.cloud.config.CloudJobExecutionType;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
@@ -36,6 +35,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.Optional;
@@ -132,8 +133,8 @@ public final class StatisticManagerTest {
@Test
public void assertJobExecutionTypeStatistics() {
ReflectionUtils.setFieldValue(statisticManager, "configurationService", configurationService);
- when(configurationService.loadAll()).thenReturn(Lists.newArrayList(
- CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job_1", CloudJobExecutionType.DAEMON),
+ when(configurationService.loadAll()).thenReturn(Arrays.asList(
+ CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job_1", CloudJobExecutionType.DAEMON),
CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job_2", CloudJobExecutionType.TRANSIENT)));
assertThat(statisticManager.getJobExecutionTypeStatistics().getDaemonJobCount(), is(1));
assertThat(statisticManager.getJobExecutionTypeStatistics().getTransientJobCount(), is(1));
@@ -149,8 +150,7 @@ public final class StatisticManagerTest {
@Test
public void assertFindTaskRunningStatisticsWhenRdbIsConfigured() {
ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository);
- when(rdbRepository.findTaskRunningStatistics(any(Date.class)))
- .thenReturn(Lists.newArrayList(new TaskRunningStatistics(10, new Date())));
+ when(rdbRepository.findTaskRunningStatistics(any(Date.class))).thenReturn(Collections.singletonList(new TaskRunningStatistics(10, new Date())));
assertThat(statisticManager.findTaskRunningStatisticsWeekly().size(), is(1));
verify(rdbRepository).findTaskRunningStatistics(any(Date.class));
}
@@ -164,8 +164,7 @@ public final class StatisticManagerTest {
@Test
public void assertFindJobRunningStatisticsWhenRdbIsConfigured() {
ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository);
- when(rdbRepository.findJobRunningStatistics(any(Date.class)))
- .thenReturn(Lists.newArrayList(new JobRunningStatistics(10, new Date())));
+ when(rdbRepository.findJobRunningStatistics(any(Date.class))).thenReturn(Collections.singletonList(new JobRunningStatistics(10, new Date())));
assertThat(statisticManager.findJobRunningStatisticsWeekly().size(), is(1));
verify(rdbRepository).findJobRunningStatistics(any(Date.class));
}
@@ -179,8 +178,7 @@ public final class StatisticManagerTest {
@Test
public void assertFindJobRegisterStatisticsWhenRdbIsConfigured() {
ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository);
- when(rdbRepository.findJobRegisterStatistics(any(Date.class)))
- .thenReturn(Lists.newArrayList(new JobRegisterStatistics(10, new Date())));
+ when(rdbRepository.findJobRegisterStatistics(any(Date.class))).thenReturn(Collections.singletonList(new JobRegisterStatistics(10, new Date())));
assertThat(statisticManager.findJobRegisterStatisticsSinceOnline().size(), is(1));
verify(rdbRepository).findJobRegisterStatistics(any(Date.class));
}
@@ -218,7 +216,7 @@ public final class StatisticManagerTest {
public void assertFindTaskResultStatisticsDailyWhenRdbIsConfigured() {
ReflectionUtils.setFieldValue(statisticManager, "rdbRepository", rdbRepository);
when(rdbRepository.findTaskResultStatistics(any(Date.class), any(StatisticInterval.class)))
- .thenReturn(Lists.newArrayList(new TaskResultStatistics(10, 5, StatisticInterval.MINUTE, new Date())));
+ .thenReturn(Collections.singletonList(new TaskResultStatistics(10, 5, StatisticInterval.MINUTE, new Date())));
assertThat(statisticManager.findTaskResultStatisticsDaily().size(), is(1));
verify(rdbRepository).findTaskResultStatistics(any(Date.class), any(StatisticInterval.class));
}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java
index 171a5e6..983ea1d 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/statistics/job/RegisteredJobStatisticJobTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.cloud.scheduler.statistics.job;
-import com.google.common.collect.Lists;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.job.CloudJobConfigurationService;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.fixture.CloudJobConfigurationBuilder;
import org.apache.shardingsphere.elasticjob.cloud.scheduler.statistics.util.StatisticTimeUtils;
@@ -31,6 +30,7 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.quartz.Trigger;
+import java.util.Collections;
import java.util.Optional;
import static org.hamcrest.CoreMatchers.is;
@@ -80,7 +80,7 @@ public class RegisteredJobStatisticJobTest {
Optional<JobRegisterStatistics> latestOne = Optional.empty();
when(repository.findLatestJobRegisterStatistics()).thenReturn(latestOne);
when(repository.add(any(JobRegisterStatistics.class))).thenReturn(true);
- when(configurationService.loadAll()).thenReturn(Lists.newArrayList(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
+ when(configurationService.loadAll()).thenReturn(Collections.singletonList(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
registeredJobStatisticJob.execute(null);
verify(repository).findLatestJobRegisterStatistics();
verify(repository).add(any(JobRegisterStatistics.class));
@@ -92,7 +92,7 @@ public class RegisteredJobStatisticJobTest {
Optional<JobRegisterStatistics> latestOne = Optional.of(new JobRegisterStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.DAY, -3)));
when(repository.findLatestJobRegisterStatistics()).thenReturn(latestOne);
when(repository.add(any(JobRegisterStatistics.class))).thenReturn(true);
- when(configurationService.loadAll()).thenReturn(Lists.newArrayList(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
+ when(configurationService.loadAll()).thenReturn(Collections.singletonList(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
registeredJobStatisticJob.execute(null);
verify(repository).findLatestJobRegisterStatistics();
verify(repository, times(3)).add(any(JobRegisterStatistics.class));
diff --git a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorService.java b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorService.java
index 8e4bdbc..98ab677 100644
--- a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorService.java
+++ b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/concurrent/ElasticJobExecutorService.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.elasticjob.infra.concurrent;
-import com.google.common.base.Joiner;
import com.google.common.util.concurrent.MoreExecutors;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+import java.util.StringJoiner;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
@@ -39,7 +39,7 @@ public final class ElasticJobExecutorService {
public ElasticJobExecutorService(final String namingPattern, final int threadSize) {
workQueue = new LinkedBlockingQueue<>();
threadPoolExecutor = new ThreadPoolExecutor(
- threadSize, threadSize, 5L, TimeUnit.MINUTES, workQueue, new BasicThreadFactory.Builder().namingPattern(Joiner.on("-").join(namingPattern, "%s")).build());
+ threadSize, threadSize, 5L, TimeUnit.MINUTES, workQueue, new BasicThreadFactory.Builder().namingPattern(new StringJoiner("-").add(namingPattern).add("%s").toString()).build());
threadPoolExecutor.allowCoreThreadTimeOut(true);
}
diff --git a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContext.java b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContext.java
index 99bd580..bcf207c 100755
--- a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContext.java
+++ b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContext.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.infra.context;
-import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import lombok.EqualsAndHashCode;
@@ -28,6 +27,7 @@ import lombok.ToString;
import java.util.Collections;
import java.util.List;
+import java.util.StringJoiner;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -62,7 +62,7 @@ public final class TaskContext {
metaInfo = new MetaInfo(jobName, shardingItem);
this.type = type;
this.slaveId = slaveId;
- id = Joiner.on(DELIMITER).join(metaInfo, type, slaveId, UUID.randomUUID().toString());
+ id = new StringJoiner(DELIMITER).add(metaInfo.toString()).add(type.toString()).add(slaveId).add(UUID.randomUUID().toString()).toString();
}
private TaskContext(final String id, final MetaInfo metaInfo, final ExecutionType type, final String slaveId) {
@@ -110,7 +110,7 @@ public final class TaskContext {
* @return task name
*/
public String getTaskName() {
- return Joiner.on(DELIMITER).join(metaInfo, type, slaveId);
+ return new StringJoiner(DELIMITER).add(metaInfo.toString()).add(type.toString()).add(slaveId).toString();
}
/**
@@ -120,7 +120,7 @@ public final class TaskContext {
* @return executor ID
*/
public String getExecutorId(final String appName) {
- return Joiner.on(DELIMITER).join(appName, slaveId);
+ return new StringJoiner(DELIMITER).add(appName).add(slaveId).toString();
}
/**
@@ -150,7 +150,7 @@ public final class TaskContext {
@Override
public String toString() {
- return Joiner.on(DELIMITER).join(jobName, Joiner.on(",").join(shardingItems));
+ return new StringJoiner(DELIMITER).add(jobName).add(shardingItems.stream().map(Object::toString).collect(Collectors.joining(","))).toString();
}
}
}
diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java
index 569ddd1..fdea68d 100644
--- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java
+++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/TaskContextTest.java
@@ -17,10 +17,12 @@
package org.apache.shardingsphere.elasticjob.infra.context;
-import com.google.common.collect.Lists;
+import org.apache.shardingsphere.elasticjob.infra.context.TaskContext.MetaInfo;
import org.apache.shardingsphere.elasticjob.infra.context.fixture.TaskNode;
import org.junit.Test;
+import java.util.Collections;
+
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertFalse;
@@ -31,7 +33,7 @@ public final class TaskContextTest {
@Test
public void assertNew() {
- TaskContext actual = new TaskContext("test_job", Lists.newArrayList(0), ExecutionType.READY, "slave-S0");
+ TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0");
assertThat(actual.getMetaInfo().getJobName(), is("test_job"));
assertThat(actual.getMetaInfo().getShardingItems().get(0), is(0));
assertThat(actual.getType(), is(ExecutionType.READY));
@@ -41,13 +43,13 @@ public final class TaskContextTest {
@Test
public void assertNewWithoutSlaveId() {
- TaskContext actual = new TaskContext("test_job", Lists.newArrayList(0), ExecutionType.READY);
+ TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY);
assertThat(actual.getSlaveId(), is("unassigned-slave"));
}
@Test
public void assertGetMetaInfo() {
- TaskContext actual = new TaskContext("test_job", Lists.newArrayList(0), ExecutionType.READY, "slave-S0");
+ TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0");
assertThat(actual.getMetaInfo().toString(), is("test_job@-@0"));
}
@@ -63,28 +65,28 @@ public final class TaskContextTest {
@Test
public void assertMetaInfoFromWithMetaInfo() {
- TaskContext.MetaInfo actual = TaskContext.MetaInfo.from("test_job@-@1");
+ MetaInfo actual = MetaInfo.from("test_job@-@1");
assertThat(actual.getJobName(), is("test_job"));
assertThat(actual.getShardingItems().get(0), is(1));
}
@Test
public void assertMetaInfoFromWithTaskId() {
- TaskContext.MetaInfo actual = TaskContext.MetaInfo.from("test_job@-@1@-@READY@-@unassigned-slave@-@0");
+ MetaInfo actual = MetaInfo.from("test_job@-@1@-@READY@-@unassigned-slave@-@0");
assertThat(actual.getJobName(), is("test_job"));
assertThat(actual.getShardingItems().get(0), is(1));
}
@Test
public void assertMetaInfoFromWithMetaInfoWithoutShardingItems() {
- TaskContext.MetaInfo actual = TaskContext.MetaInfo.from("test_job@-@");
+ MetaInfo actual = MetaInfo.from("test_job@-@");
assertThat(actual.getJobName(), is("test_job"));
assertTrue(actual.getShardingItems().isEmpty());
}
@Test
public void assertMetaInfoFromWithTaskIdWithoutShardingItems() {
- TaskContext.MetaInfo actual = TaskContext.MetaInfo.from("test_job@-@@-@READY@-@unassigned-slave@-@0");
+ MetaInfo actual = MetaInfo.from("test_job@-@@-@READY@-@unassigned-slave@-@0");
assertThat(actual.getJobName(), is("test_job"));
assertTrue(actual.getShardingItems().isEmpty());
}
@@ -108,7 +110,7 @@ public final class TaskContextTest {
@Test
public void assertSetSlaveId() {
- TaskContext actual = new TaskContext("test_job", Lists.newArrayList(0), ExecutionType.READY, "slave-S0");
+ TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0");
assertThat(actual.getSlaveId(), is("slave-S0"));
actual.setSlaveId("slave-S1");
assertThat(actual.getSlaveId(), is("slave-S1"));
@@ -116,7 +118,7 @@ public final class TaskContextTest {
@Test
public void assertSetIdle() {
- TaskContext actual = new TaskContext("test_job", Lists.newArrayList(0), ExecutionType.READY, "slave-S0");
+ TaskContext actual = new TaskContext("test_job", Collections.singletonList(0), ExecutionType.READY, "slave-S0");
assertFalse(actual.isIdle());
actual.setIdle(true);
assertTrue(actual.isIdle());
diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/fixture/TaskNode.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/fixture/TaskNode.java
index 21677cf..bd1e202 100644
--- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/fixture/TaskNode.java
+++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/context/fixture/TaskNode.java
@@ -17,10 +17,11 @@
package org.apache.shardingsphere.elasticjob.infra.context.fixture;
-import com.google.common.base.Joiner;
import lombok.Builder;
import org.apache.shardingsphere.elasticjob.infra.context.ExecutionType;
+import java.util.StringJoiner;
+
@Builder
public final class TaskNode {
@@ -40,10 +41,11 @@ public final class TaskNode {
* @return the value of task node
*/
public String getTaskNodeValue() {
- return Joiner.on("@-@").join(getTaskNodePath(), null == type ? ExecutionType.READY : type, null == slaveId ? "slave-S0" : slaveId, null == uuid ? "0" : uuid);
+ return new StringJoiner("@-@")
+ .add(getTaskNodePath()).add(null == type ? ExecutionType.READY.toString() : type.toString()).add(null == slaveId ? "slave-S0" : slaveId).add(null == uuid ? "0" : uuid).toString();
}
private String getTaskNodePath() {
- return Joiner.on("@-@").join(null == jobName ? "test_job" : jobName, shardingItem);
+ return new StringJoiner("@-@").add(null == jobName ? "test_job" : jobName).add(shardingItem + "").toString();
}
}
diff --git a/elasticjob-infra/elasticjob-registry-center/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/fixture/EmbedTestingServer.java b/elasticjob-infra/elasticjob-registry-center/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/fixture/EmbedTestingServer.java
index 58dc6e2..f5dcbaa 100644
--- a/elasticjob-infra/elasticjob-registry-center/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/fixture/EmbedTestingServer.java
+++ b/elasticjob-infra/elasticjob-registry-center/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/fixture/EmbedTestingServer.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.reg.zookeeper.fixture;
-import com.google.common.base.Joiner;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.curator.test.TestingServer;
@@ -39,7 +38,7 @@ public final class EmbedTestingServer {
* @return connection string
*/
public static String getConnectionString() {
- return Joiner.on(":").join("localhost", PORT);
+ return "localhost:" + PORT;
}
/**
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/JobEventBus.java b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/JobEventBus.java
index 68fa466..08bd472 100644
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/JobEventBus.java
+++ b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-api/src/main/java/org/apache/shardingsphere/elasticjob/tracing/JobEventBus.java
@@ -17,17 +17,17 @@
package org.apache.shardingsphere.elasticjob.tracing;
-import com.google.common.base.Joiner;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import com.google.common.util.concurrent.MoreExecutors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
-import org.apache.shardingsphere.elasticjob.tracing.listener.TracingListenerFactory;
import org.apache.shardingsphere.elasticjob.tracing.event.JobEvent;
import org.apache.shardingsphere.elasticjob.tracing.exception.TracingConfigurationException;
+import org.apache.shardingsphere.elasticjob.tracing.listener.TracingListenerFactory;
+import java.util.StringJoiner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -57,8 +57,8 @@ public final class JobEventBus {
}
private ExecutorService createExecutorService(final int threadSize) {
- ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
- threadSize, threadSize, 5L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new BasicThreadFactory.Builder().namingPattern(Joiner.on("-").join("job-event", "%s")).build());
+ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(threadSize, threadSize, 5L, TimeUnit.MINUTES,
+ new LinkedBlockingQueue<>(), new BasicThreadFactory.Builder().namingPattern(new StringJoiner("-").add("job-event").add("%s").toString()).build());
threadPoolExecutor.allowCoreThreadTimeOut(true);
return MoreExecutors.listeningDecorator(MoreExecutors.getExitingExecutorService(threadPoolExecutor));
}
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNode.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNode.java
index 249b9a4..73ff0fd 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNode.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/guarantee/GuaranteeNode.java
@@ -18,7 +18,8 @@
package org.apache.shardingsphere.elasticjob.lite.internal.guarantee;
import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodePath;
-import com.google.common.base.Joiner;
+
+import java.util.StringJoiner;
/**
* Guarantee node.
@@ -38,11 +39,11 @@ public final class GuaranteeNode {
}
static String getStartedNode(final int shardingItem) {
- return Joiner.on("/").join(STARTED_ROOT, shardingItem);
+ return new StringJoiner("/").add(STARTED_ROOT).add(shardingItem + "").toString();
}
static String getCompletedNode(final int shardingItem) {
- return Joiner.on("/").join(COMPLETED_ROOT, shardingItem);
+ return new StringJoiner("/").add(COMPLETED_ROOT).add(shardingItem + "").toString();
}
boolean isStartedRootNode(final String path) {
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextService.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextService.java
index 95dd807..1d05579 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextService.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ExecutionContextService.java
@@ -17,10 +17,9 @@
package org.apache.shardingsphere.elasticjob.lite.internal.sharding;
-import com.google.common.base.Joiner;
-import org.apache.shardingsphere.elasticjob.infra.handler.sharding.JobInstance;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.api.listener.ShardingContexts;
+import org.apache.shardingsphere.elasticjob.infra.handler.sharding.JobInstance;
import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodeStorage;
@@ -31,6 +30,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.StringJoiner;
+import java.util.stream.Collectors;
/**
* Execution context service.
@@ -69,8 +70,9 @@ public final class ExecutionContextService {
private String buildTaskId(final JobConfiguration jobConfig, final List<Integer> shardingItems) {
JobInstance jobInstance = JobRegistry.getInstance().getJobInstance(jobName);
- return Joiner.on("@-@").join(jobConfig.getJobName(), Joiner.on(",").join(shardingItems), "READY",
- null == jobInstance.getJobInstanceId() ? "127.0.0.1@-@1" : jobInstance.getJobInstanceId());
+ String shardingItemsString = shardingItems.stream().map(Object::toString).collect(Collectors.joining(","));
+ String jobInstanceId = null == jobInstance.getJobInstanceId() ? "127.0.0.1@-@1" : jobInstance.getJobInstanceId();
+ return new StringJoiner("@-@").add(jobConfig.getJobName()).add(shardingItemsString).add("READY").add(jobInstanceId).toString();
}
private void removeRunningIfMonitorExecution(final boolean monitorExecution, final List<Integer> shardingItems) {
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotService.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotService.java
index df2ad05..ddd49ff 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotService.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/snapshot/SnapshotService.java
@@ -17,12 +17,11 @@
package org.apache.shardingsphere.elasticjob.lite.internal.snapshot;
-import com.google.common.base.Joiner;
-import org.apache.shardingsphere.elasticjob.lite.internal.util.SensitiveInfoUtils;
-import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import lombok.extern.slf4j.Slf4j;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.TreeCache;
+import org.apache.shardingsphere.elasticjob.lite.internal.util.SensitiveInfoUtils;
+import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -33,6 +32,8 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
+import java.util.StringJoiner;
+import java.util.stream.Collectors;
/**
* Snapshot service.
@@ -100,7 +101,7 @@ public final class SnapshotService {
List<String> result = new ArrayList<>();
String jobName = cmdLine.split("@")[1];
dumpDirectly("/" + jobName, jobName, result);
- outputMessage(writer, Joiner.on("\n").join(SensitiveInfoUtils.filterSensitiveIps(result)) + "\n");
+ outputMessage(writer, SensitiveInfoUtils.filterSensitiveIps(result).stream().collect(Collectors.joining("\n")) + "\n");
}
}
}
@@ -117,9 +118,9 @@ public final class SnapshotService {
String treeCachePath = null == treeCacheData ? "" : treeCacheData.getPath();
String treeCacheValue = null == treeCacheData ? "" : new String(treeCacheData.getData());
if (zkValue.equals(treeCacheValue) && zkPath.equals(treeCachePath)) {
- result.add(Joiner.on(" | ").join(zkPath, zkValue));
+ result.add(new StringJoiner(" | ").add(zkPath).add(zkValue).toString());
} else {
- result.add(Joiner.on(" | ").join(zkPath, zkValue, treeCachePath, treeCacheValue));
+ result.add(new StringJoiner(" | ").add(zkPath).add(zkValue).add(treeCachePath).add(treeCacheValue).toString());
}
dumpDirectly(zkPath, jobName, result);
}
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtils.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtils.java
index bda7cb8..1620622 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtils.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/util/SensitiveInfoUtils.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.lite.internal.util;
-import com.google.common.base.Joiner;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.elasticjob.infra.env.IpUtils;
@@ -58,7 +57,7 @@ public final class SensitiveInfoUtils {
if (fakeIpMap.containsKey(realIp)) {
fakeIp = fakeIpMap.get(realIp);
} else {
- fakeIp = Joiner.on("").join(FAKE_IP_SAMPLE, step.incrementAndGet());
+ fakeIp = FAKE_IP_SAMPLE + step.incrementAndGet();
fakeIpMap.put(realIp, fakeIp);
}
result = result.replace(realIp, fakeIp);
diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/EmbedTestingServer.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/EmbedTestingServer.java
index 5c7504f..2872abd 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/EmbedTestingServer.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/EmbedTestingServer.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.elasticjob.lite.fixture;
-import com.google.common.base.Joiner;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.curator.test.TestingServer;
@@ -39,7 +38,7 @@ public final class EmbedTestingServer {
* @return connection string
*/
public static String getConnectionString() {
- return Joiner.on(":").join("localhost", PORT);
+ return "localhost:" + PORT;
}
/**
diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
index d05005f..1642ab6 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/LiteJobFacadeTest.java
@@ -18,18 +18,18 @@
package org.apache.shardingsphere.elasticjob.lite.internal.schedule;
import com.google.common.collect.Lists;
-import org.apache.shardingsphere.elasticjob.lite.api.listener.fixture.ElasticJobListenerCaller;
-import org.apache.shardingsphere.elasticjob.lite.api.listener.fixture.TestElasticJobListener;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.infra.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.api.listener.ShardingContexts;
+import org.apache.shardingsphere.elasticjob.infra.exception.JobExecutionEnvironmentException;
+import org.apache.shardingsphere.elasticjob.lite.api.listener.fixture.ElasticJobListenerCaller;
+import org.apache.shardingsphere.elasticjob.lite.api.listener.fixture.TestElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
import org.apache.shardingsphere.elasticjob.lite.internal.failover.FailoverService;
import org.apache.shardingsphere.elasticjob.lite.internal.sharding.ExecutionContextService;
import org.apache.shardingsphere.elasticjob.lite.internal.sharding.ExecutionService;
import org.apache.shardingsphere.elasticjob.lite.internal.sharding.ShardingService;
-import org.apache.shardingsphere.elasticjob.tracing.JobEventBus;
import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.tracing.JobEventBus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -160,8 +160,8 @@ public final class LiteJobFacadeTest {
public void assertGetShardingContextWhenIsFailoverDisable() {
ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap());
when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(false).build());
- when(shardingService.getLocalShardingItems()).thenReturn(Lists.newArrayList(0, 1));
- when(executionContextService.getJobShardingContext(Lists.newArrayList(0, 1))).thenReturn(shardingContexts);
+ when(shardingService.getLocalShardingItems()).thenReturn(Arrays.asList(0, 1));
+ when(executionContextService.getJobShardingContext(Arrays.asList(0, 1))).thenReturn(shardingContexts);
assertThat(liteJobFacade.getShardingContexts(), is(shardingContexts));
verify(shardingService).shardingIfNecessary();
}
@@ -171,8 +171,8 @@ public final class LiteJobFacadeTest {
ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap());
when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").failover(false).build());
when(shardingService.getLocalShardingItems()).thenReturn(Lists.newArrayList(0, 1));
- when(executionService.getDisabledItems(Lists.newArrayList(0, 1))).thenReturn(Collections.singletonList(1));
- when(executionContextService.getJobShardingContext(Lists.newArrayList(0))).thenReturn(shardingContexts);
+ when(executionService.getDisabledItems(Arrays.asList(0, 1))).thenReturn(Collections.singletonList(1));
+ when(executionContextService.getJobShardingContext(Collections.singletonList(0))).thenReturn(shardingContexts);
assertThat(liteJobFacade.getShardingContexts(), is(shardingContexts));
verify(shardingService).shardingIfNecessary();
}
diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java
index bce4bf4..1b62c56 100644
--- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java
+++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/AbstractEmbedZookeeperBaseTest.java
@@ -17,9 +17,8 @@
package org.apache.shardingsphere.elasticjob.lite.lifecycle;
-import com.google.common.base.Joiner;
-import org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler;
import org.apache.curator.test.TestingServer;
+import org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler;
import org.junit.BeforeClass;
import java.io.File;
@@ -63,6 +62,6 @@ public abstract class AbstractEmbedZookeeperBaseTest {
* @return connection string
*/
public static String getConnectionString() {
- return Joiner.on(":").join("localhost", PORT);
+ return "localhost:" + PORT;
}
}