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/20 10:05:04 UTC

[shardingsphere-elasticjob] branch master updated: Remove useless code for elasticjob-cloud-common (#1194)

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.git


The following commit(s) were added to refs/heads/master by this push:
     new 714c190  Remove useless code for elasticjob-cloud-common (#1194)
714c190 is described below

commit 714c1907f9564ad39acb03658bde12ee381f4ae2
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon Jul 20 18:04:12 2020 +0800

    Remove useless code for elasticjob-cloud-common (#1194)
    
    * Remove useless CloudConfigurationConstants
    
    * Remove useless GsonFactory
---
 .../util/json/CloudConfigurationConstants.java     | 44 -----------------
 .../elasticjob/cloud/util/json/GsonFactory.java    | 57 ----------------------
 .../cloud/util/json/GsonFactoryTest.java           | 56 ---------------------
 .../elasticjob/cloud/restful/GsonJsonProvider.java |  2 +-
 .../mesos/TaskLaunchScheduledService.java          |  4 +-
 .../scheduler/restful/CloudJobRestfulApiTest.java  |  2 +-
 .../spring/boot/job/ElasticJobSpringBootTest.java  |  4 +-
 .../src/test/resources/application-elasticjob.yml  |  2 +-
 8 files changed, 7 insertions(+), 164 deletions(-)

diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/main/java/org/apache/shardingsphere/elasticjob/cloud/util/json/CloudConfigurationConstants.java b/elasticjob-cloud/elasticjob-cloud-common/src/main/java/org/apache/shardingsphere/elasticjob/cloud/util/json/CloudConfigurationConstants.java
deleted file mode 100755
index 4546549..0000000
--- a/elasticjob-cloud/elasticjob-cloud-common/src/main/java/org/apache/shardingsphere/elasticjob/cloud/util/json/CloudConfigurationConstants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *  
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.cloud.util.json;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Cloud configuration constants.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class CloudConfigurationConstants {
-    
-    public static final String APP_NAME = "appName";
-    
-    public static final String BOOTSTRAP_SCRIPT = "bootstrapScript";
-    
-    public static final String APP_CACHE_ENABLE = "appCacheEnable";
-    
-    public static final String APP_URL = "appURL";
-    
-    public static final String EVENT_TRACE_SAMPLING_COUNT = "eventTraceSamplingCount";
-    
-    public static final String CPU_COUNT = "cpuCount";
-    
-    public static final String MEMORY_MB = "memoryMB";
-    
-    public static final String JOB_EXECUTION_TYPE = "jobExecutionType";
-}
diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/main/java/org/apache/shardingsphere/elasticjob/cloud/util/json/GsonFactory.java b/elasticjob-cloud/elasticjob-cloud-common/src/main/java/org/apache/shardingsphere/elasticjob/cloud/util/json/GsonFactory.java
deleted file mode 100755
index 0e70d61..0000000
--- a/elasticjob-cloud/elasticjob-cloud-common/src/main/java/org/apache/shardingsphere/elasticjob/cloud/util/json/GsonFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.cloud.util.json;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.TypeAdapter;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-import java.lang.reflect.Type;
-
-/**
- * Gson factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class GsonFactory {
-    
-    private static final GsonBuilder GSON_BUILDER = new GsonBuilder();
-    
-    private static volatile Gson gson = GSON_BUILDER.create();
-    
-    /**
-     * Register type adapter.
-     *
-     * @param type Gson type
-     * @param typeAdapter Gson type adapter
-     */
-    public static synchronized void registerTypeAdapter(final Type type, final TypeAdapter typeAdapter) {
-        GSON_BUILDER.registerTypeAdapter(type, typeAdapter);
-        gson = GSON_BUILDER.create();
-    }
-    
-    /**
-     * Get gson instance.
-     *
-     * @return gson instance
-     */
-    public static Gson getGson() {
-        return gson;
-    }
-}
diff --git a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/util/json/GsonFactoryTest.java b/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/util/json/GsonFactoryTest.java
deleted file mode 100755
index fa3b6cd..0000000
--- a/elasticjob-cloud/elasticjob-cloud-common/src/test/java/org/apache/shardingsphere/elasticjob/cloud/util/json/GsonFactoryTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.cloud.util.json;
-
-import com.google.gson.Gson;
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-import org.junit.Test;
-
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class GsonFactoryTest {
-    
-    @Test
-    public void assertGetGson() {
-        assertThat(GsonFactory.getGson(), is(GsonFactory.getGson()));
-    }
-    
-    @Test
-    public void assertRegisterTypeAdapter() {
-        Gson beforeRegisterGson = GsonFactory.getGson();
-        GsonFactory.registerTypeAdapter(GsonFactoryTest.class, new TypeAdapter() {
-            
-            @Override
-            public Object read(final JsonReader in) throws IOException {
-                return null;
-            }
-            
-            @Override
-            public void write(final JsonWriter out, final Object value) throws IOException {
-                out.jsonValue("test");
-            }
-        });
-        assertThat(beforeRegisterGson.toJson(new GsonFactoryTest()), is("{}"));
-        assertThat(GsonFactory.getGson().toJson(new GsonFactoryTest()), is("test"));
-    }
-}
diff --git a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/GsonJsonProvider.java b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/GsonJsonProvider.java
index 28b9c48..c60aa94 100755
--- a/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/GsonJsonProvider.java
+++ b/elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/restful/GsonJsonProvider.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.elasticjob.cloud.restful;
 
-import org.apache.shardingsphere.elasticjob.cloud.util.json.GsonFactory;
+import org.apache.shardingsphere.elasticjob.infra.json.GsonFactory;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
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 86bc173..e6c301a 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
@@ -35,14 +35,14 @@ import org.apache.mesos.SchedulerDriver;
 import org.apache.shardingsphere.elasticjob.api.listener.ShardingContexts;
 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.pojo.CloudAppConfigurationPOJO;
 import org.apache.shardingsphere.elasticjob.cloud.config.pojo.CloudJobConfigurationPOJO;
+import org.apache.shardingsphere.elasticjob.cloud.scheduler.config.app.pojo.CloudAppConfigurationPOJO;
 import org.apache.shardingsphere.elasticjob.cloud.scheduler.env.BootstrapEnvironment;
 import org.apache.shardingsphere.elasticjob.cloud.util.config.ShardingItemParameters;
-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.infra.json.GsonFactory;
 import org.apache.shardingsphere.elasticjob.script.props.ScriptJobProperties;
 import org.apache.shardingsphere.elasticjob.tracing.JobEventBus;
 import org.apache.shardingsphere.elasticjob.tracing.event.JobStatusTraceEvent;
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 7749f54..672691c 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
@@ -28,10 +28,10 @@ import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.failover.Failo
 import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.running.RunningService;
 import org.apache.shardingsphere.elasticjob.cloud.statistics.type.job.JobExecutionTypeStatistics;
 import org.apache.shardingsphere.elasticjob.cloud.statistics.type.task.TaskResultStatistics;
-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.infra.json.GsonFactory;
 import org.apache.shardingsphere.elasticjob.tracing.event.JobExecutionEvent;
 import org.apache.shardingsphere.elasticjob.tracing.event.JobStatusTraceEvent;
 import org.junit.Test;
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java
index 151889f..9e531e9 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/job/ElasticJobSpringBootTest.java
@@ -37,12 +37,12 @@ import static org.junit.Assert.assertNotNull;
 @SpringBootApplication
 @ActiveProfiles("elasticjob")
 public class ElasticJobSpringBootTest extends AbstractJUnit4SpringContextTests {
-
+    
     @BeforeClass
     public static void init() {
         EmbedTestingServer.start();
     }
-
+    
     @Test
     public void testJobScheduleCreation() {
         assertNotNull(applicationContext);
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/resources/application-elasticjob.yml b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/resources/application-elasticjob.yml
index bf91eb0..5d0da31 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/resources/application-elasticjob.yml
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/resources/application-elasticjob.yml
@@ -30,7 +30,7 @@ elasticjob:
     namespace: elasticjob-lite-spring-boot-starter
   jobs:
     classed:
-      org.apache.shardingsphere.elasticjob.lite.spring.boot.job.impl.CustomTestJob:
+      org.apache.shardingsphere.elasticjob.lite.spring.boot.job.fixture.job.impl.CustomTestJob:
         - jobName: customTestJob
           shardingTotalCount: 3
     typed: