You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/01/10 06:29:16 UTC

[incubator-servicecomb-java-chassis] 02/07: SCB-36 resolve problems of dependencies, final variables, create rest template each time, etc.

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 1234e3ad4bc7936a4266c2796a30d4fe537eb402
Author: lijasonvip <ei...@163.com>
AuthorDate: Fri Jan 5 16:04:53 2018 +0800

    SCB-36 resolve problems of dependencies, final variables, create rest template each time, etc.
    
    Signed-off-by: lijasonvip <li...@huawei.com>
---
 coverage-reports/pom.xml                           |   4 +
 dynamic-config/config-apollo/pom.xml               |  15 ---
 .../sources/ApolloConfigurationSourceImpl.java     |  21 ++--
 .../io/servicecomb/config/client/ApolloClient.java |  44 ++++----
 .../sources/ApolloConfigurationSourceImplTest.java |  76 +++++++++++++
 .../config/client/ApolloClientTest.java            | 118 +++++++++++++++++++++
 .../config/client/ApolloConfigTest.java            |  44 ++++++++
 .../src/test}/resources/microservice.yaml          |   5 +-
 dynamic-config/pom.xml                             |   3 +-
 samples/config-apollo-sample/pom.xml               |   4 +
 .../src/main/resources/log4j.properties            |  17 +++
 .../src/main/resources/microservice.yaml           |   1 -
 12 files changed, 303 insertions(+), 49 deletions(-)

diff --git a/coverage-reports/pom.xml b/coverage-reports/pom.xml
index e7f950a..117ba26 100644
--- a/coverage-reports/pom.xml
+++ b/coverage-reports/pom.xml
@@ -168,6 +168,10 @@
       <artifactId>handler-tracing-zipkin</artifactId>
     </dependency>
     <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>config-apollo</artifactId>
+    </dependency>
+    <dependency>
       <groupId>io.servicecomb.demo</groupId>
       <artifactId>pojo-client</artifactId>
       <version>0.6.0-SNAPSHOT</version>
diff --git a/dynamic-config/config-apollo/pom.xml b/dynamic-config/config-apollo/pom.xml
index 9e13d4b..856f53e 100644
--- a/dynamic-config/config-apollo/pom.xml
+++ b/dynamic-config/config-apollo/pom.xml
@@ -41,21 +41,6 @@
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-web</artifactId>
-      <version>4.3.11.RELEASE</version>
     </dependency>
   </dependencies>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <source>1.7</source>
-          <target>1.7</target>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
-
 </project>
\ No newline at end of file
diff --git a/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/archaius/sources/ApolloConfigurationSourceImpl.java b/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/archaius/sources/ApolloConfigurationSourceImpl.java
index fce9988..37b79f4 100644
--- a/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/archaius/sources/ApolloConfigurationSourceImpl.java
+++ b/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/archaius/sources/ApolloConfigurationSourceImpl.java
@@ -21,6 +21,8 @@ import static com.netflix.config.WatchedUpdateResult.createIncremental;
 
 import java.util.List;
 import java.util.Map;
+
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.commons.configuration.Configuration;
@@ -28,7 +30,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
 import com.netflix.config.ConcurrentCompositeConfiguration;
 import com.netflix.config.WatchedUpdateListener;
 import com.netflix.config.WatchedUpdateResult;
@@ -41,14 +42,14 @@ import io.servicecomb.config.spi.ConfigCenterConfigurationSource;
 public class ApolloConfigurationSourceImpl implements ConfigCenterConfigurationSource {
   private static final Logger LOGGER = LoggerFactory.getLogger(ConfigCenterConfigurationSource.class);
 
-  private final Map<String, Object> valueCache = Maps.newConcurrentMap();
+  private final Map<String, Object> valueCache = new ConcurrentHashMap<>();
 
-  private List<WatchedUpdateListener> listeners = new CopyOnWriteArrayList<WatchedUpdateListener>();
+  private List<WatchedUpdateListener> listeners = new CopyOnWriteArrayList<>();
 
   public ApolloConfigurationSourceImpl() {
   }
 
-  private UpdateHandler updateHandler = new UpdateHandler();
+  private final UpdateHandler updateHandler = new UpdateHandler();
 
   @Override
   public void init(Configuration localConfiguration) {
@@ -56,7 +57,7 @@ public class ApolloConfigurationSourceImpl implements ConfigCenterConfigurationS
     init();
   }
 
-  public void init() {
+  private void init() {
     ApolloClient apolloClient = new ApolloClient(updateHandler);
     apolloClient.refreshApolloConfig();
   }
@@ -75,7 +76,7 @@ public class ApolloConfigurationSourceImpl implements ConfigCenterConfigurationS
     }
   }
 
-  public void updateConfiguration(WatchedUpdateResult result) {
+  private void updateConfiguration(WatchedUpdateResult result) {
     for (WatchedUpdateListener l : listeners) {
       try {
         l.updateConfiguration(result);
@@ -102,12 +103,14 @@ public class ApolloConfigurationSourceImpl implements ConfigCenterConfigurationS
       Map<String, Object> configuration = ConfigMapping.getConvertedMap(config);
       if ("create".equals(action)) {
         valueCache.putAll(configuration);
-        updateConfiguration(createIncremental(ImmutableMap.<String, Object>copyOf(configuration),
+
+        updateConfiguration(createIncremental(ImmutableMap.copyOf(configuration),
             null,
             null));
       } else if ("set".equals(action)) {
         valueCache.putAll(configuration);
-        updateConfiguration(createIncremental(null, ImmutableMap.<String, Object>copyOf(configuration),
+
+        updateConfiguration(createIncremental(null, ImmutableMap.copyOf(configuration),
             null));
       } else if ("delete".equals(action)) {
         for (String itemKey : configuration.keySet()) {
@@ -115,7 +118,7 @@ public class ApolloConfigurationSourceImpl implements ConfigCenterConfigurationS
         }
         updateConfiguration(createIncremental(null,
             null,
-            ImmutableMap.<String, Object>copyOf(configuration)));
+            ImmutableMap.copyOf(configuration)));
       } else {
         LOGGER.error("action: {} is invalid.", action);
         return;
diff --git a/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/client/ApolloClient.java b/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/client/ApolloClient.java
index ad6bbaa..065c724 100644
--- a/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/client/ApolloClient.java
+++ b/dynamic-config/config-apollo/src/main/java/io/servicecomb/config/client/ApolloClient.java
@@ -20,6 +20,7 @@ package io.servicecomb.config.client;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -37,8 +38,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
 import io.netty.handler.codec.http.HttpResponseStatus;
 import io.servicecomb.config.archaius.sources.ApolloConfigurationSourceImpl.UpdateHandler;
 import io.servicecomb.foundation.common.utils.JsonUtils;
-import io.servicecomb.foundation.vertx.client.ClientPoolManager;
-import io.servicecomb.foundation.vertx.client.http.HttpClientWithContext;
 
 public class ApolloClient {
 
@@ -46,29 +45,29 @@ public class ApolloClient {
 
   private static final ApolloConfig APOLLO_CONFIG = ApolloConfig.INSTANCE;
 
-  public static final Map<String, Object> originalConfigMap = new HashMap<>();
+  private static final Map<String, Object> originalConfigMap = new ConcurrentHashMap<>();
 
-  private static ScheduledExecutorService EXECUTOR = Executors.newScheduledThreadPool(1);
+  private static final ScheduledExecutorService EXECUTOR = Executors.newScheduledThreadPool(1);
 
-  private int refreshInterval = APOLLO_CONFIG.getRefreshInterval();
+  private final int refreshInterval = APOLLO_CONFIG.getRefreshInterval();
 
-  private int firstRefreshInterval = APOLLO_CONFIG.getFirstRefreshInterval();
+  private final int firstRefreshInterval = APOLLO_CONFIG.getFirstRefreshInterval();
 
-  private String serviceUri = APOLLO_CONFIG.getServerUri();
+  private final String serviceUri = APOLLO_CONFIG.getServerUri();
 
-  private String serviceName = APOLLO_CONFIG.getServiceName();
+  private final String serviceName = APOLLO_CONFIG.getServiceName();
 
-  private String token = APOLLO_CONFIG.getToken();
+  private final String token = APOLLO_CONFIG.getToken();
 
-  private String env = APOLLO_CONFIG.getEnv();
+  private final String env = APOLLO_CONFIG.getEnv();
 
-  private String clusters = APOLLO_CONFIG.getServerClusters();
+  private final String clusters = APOLLO_CONFIG.getServerClusters();
 
-  private String namespace = APOLLO_CONFIG.getNamespace();
+  private final String namespace = APOLLO_CONFIG.getNamespace();
 
-  private UpdateHandler updateHandler;
+  private final UpdateHandler updateHandler;
 
-  private static ClientPoolManager<HttpClientWithContext> clientMgr = new ClientPoolManager<>();
+  private static RestTemplate rest = new RestTemplate();
 
   public ApolloClient(UpdateHandler updateHandler) {
     this.updateHandler = updateHandler;
@@ -82,7 +81,7 @@ public class ApolloClient {
   class ConfigRefresh implements Runnable {
     private String serviceUri;
 
-    public ConfigRefresh(String serviceUris) {
+    ConfigRefresh(String serviceUris) {
       this.serviceUri = serviceUris;
     }
 
@@ -91,16 +90,16 @@ public class ApolloClient {
       try {
         refreshConfig();
       } catch (Exception e) {
-        LOGGER.error("client refresh thread exception", e);
+
+        LOGGER.error("client refresh thread exception ", e);
       }
     }
 
-    public void refreshConfig() {
-      RestTemplate rest = new RestTemplate();
+    void refreshConfig() {
       HttpHeaders headers = new HttpHeaders();
       headers.add("Content-Type", "application/json;charset=UTF-8");
       headers.add("Authorization", token);
-      HttpEntity<String> entity = new HttpEntity<String>(headers);
+      HttpEntity<String> entity = new HttpEntity<>(headers);
       ResponseEntity<String> exchange = rest.exchange(composeAPI(), HttpMethod.GET, entity, String.class);
       if (HttpResponseStatus.OK.code() == exchange.getStatusCode().value()) {
         try {
@@ -109,8 +108,11 @@ public class ApolloClient {
               });
           refreshConfigItems((Map<String, Object>) body.get("configurations"));
         } catch (IOException e) {
-          e.printStackTrace();
+          LOGGER.error("JsonObject parse config center response error: ", e);
         }
+      } else {
+        LOGGER.error("fetch configuration failed, error code:{} for {}", exchange.getStatusCodeValue(),
+            exchange.getBody());
       }
     }
 
@@ -129,7 +131,7 @@ public class ApolloClient {
       originalConfigMap.putAll(map);
     }
 
-    private void compareChangedConfig(Map<String, Object> before, Map<String, Object> after) {
+    void compareChangedConfig(Map<String, Object> before, Map<String, Object> after) {
       Map<String, Object> itemsCreated = new HashMap<>();
       Map<String, Object> itemsDeleted = new HashMap<>();
       Map<String, Object> itemsModified = new HashMap<>();
diff --git a/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/archaius/sources/ApolloConfigurationSourceImplTest.java b/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/archaius/sources/ApolloConfigurationSourceImplTest.java
new file mode 100644
index 0000000..83d7614
--- /dev/null
+++ b/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/archaius/sources/ApolloConfigurationSourceImplTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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 io.servicecomb.config.archaius.sources;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.netflix.config.WatchedUpdateListener;
+
+import io.servicecomb.config.archaius.sources.ApolloConfigurationSourceImpl.UpdateHandler;
+import mockit.Deencapsulation;
+
+public class ApolloConfigurationSourceImplTest {
+  @Test
+  public void testCreate() throws Exception {
+
+    ApolloConfigurationSourceImpl apolloConfigurationSource = new ApolloConfigurationSourceImpl();
+    apolloConfigurationSource.addUpdateListener(result -> Assert.assertTrue(!result.getAdded().isEmpty()));
+    UpdateHandler udateHandler = Deencapsulation.getField(apolloConfigurationSource, UpdateHandler.class);
+    Map<String, Object> createItems = new HashMap<>();
+    createItems.put("testKey", "testValue");
+    udateHandler.handle("create", createItems);
+  }
+
+  @Test
+  public void testUpdate() throws Exception {
+
+    ApolloConfigurationSourceImpl apolloConfigurationSource = new ApolloConfigurationSourceImpl();
+    apolloConfigurationSource.addUpdateListener(result -> Assert.assertTrue(!result.getChanged().isEmpty()));
+    UpdateHandler udateHandler = Deencapsulation.getField(apolloConfigurationSource, UpdateHandler.class);
+    Map<String, Object> updateItems = new HashMap<>();
+    updateItems.put("testKey", "testValue");
+    udateHandler.handle("set", updateItems);
+  }
+
+  @Test
+  public void testDelete() throws Exception {
+    ApolloConfigurationSourceImpl apolloConfigurationSource = new ApolloConfigurationSourceImpl();
+    apolloConfigurationSource.addUpdateListener(result -> Assert.assertTrue(!result.getDeleted().isEmpty()));
+    UpdateHandler udateHandler = Deencapsulation.getField(apolloConfigurationSource, UpdateHandler.class);
+    Map<String, Object> deleteItems = new HashMap<>();
+    deleteItems.put("testKey", "testValue");
+
+    apolloConfigurationSource.getCurrentData().put("testKey", "testValue");
+    udateHandler.handle("delete", deleteItems);
+    Assert.assertTrue(apolloConfigurationSource.getCurrentData().isEmpty());
+  }
+
+  @Test
+  public void testRemoveUpdateListener() {
+    ApolloConfigurationSourceImpl apolloConfigurationSource = new ApolloConfigurationSourceImpl();
+    WatchedUpdateListener watchedUpdateListener = Mockito.mock(WatchedUpdateListener.class);
+    apolloConfigurationSource.addUpdateListener(watchedUpdateListener);
+    apolloConfigurationSource.removeUpdateListener(watchedUpdateListener);
+    Assert.assertTrue(apolloConfigurationSource.getCurrentListeners().isEmpty());
+  }
+}
\ No newline at end of file
diff --git a/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/client/ApolloClientTest.java b/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/client/ApolloClientTest.java
new file mode 100644
index 0000000..74a250d
--- /dev/null
+++ b/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/client/ApolloClientTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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 io.servicecomb.config.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+import io.servicecomb.config.ConfigUtil;
+import io.servicecomb.config.archaius.sources.ApolloConfigurationSourceImpl;
+import io.servicecomb.config.archaius.sources.ApolloConfigurationSourceImpl.UpdateHandler;
+import io.servicecomb.config.client.ApolloClient.ConfigRefresh;
+import mockit.Deencapsulation;
+
+public class ApolloClientTest {
+  @BeforeClass
+  public static void setUpClass() {
+
+    ApolloConfig.setConcurrentCompositeConfiguration(ConfigUtil.createLocalConfig());
+  }
+
+  @Test
+  public void refreshApolloConfig() {
+    ApolloConfig apolloConfig = ApolloConfig.INSTANCE;
+    RestTemplate rest = Mockito.mock(RestTemplate.class);
+
+    ResponseEntity<String> responseEntity = new ResponseEntity<>(
+        "{\"apollo\":\"mocked\", \"configurations\":{\"timeout\":1000}}", HttpStatus.OK);
+    Mockito.when(rest.exchange(
+        Matchers.anyString(),
+        Matchers.any(HttpMethod.class),
+        Matchers.<HttpEntity<String>>any(),
+        Matchers.<Class<String>>any()
+        )
+    ).thenReturn(responseEntity);
+    ApolloConfigurationSourceImpl impl = new ApolloConfigurationSourceImpl();
+    UpdateHandler updateHandler = impl.new UpdateHandler();
+    ApolloClient apolloClient = new ApolloClient(updateHandler);
+    Deencapsulation.setField(apolloClient, "rest", rest);
+    ConfigRefresh cr = apolloClient.new ConfigRefresh(apolloConfig.getServerUri());
+    cr.run();
+
+    Map<String, Object> originMap = Deencapsulation.getField(apolloClient, "originalConfigMap");
+    Assert.assertEquals(1, originMap.size());
+  }
+
+  @Test
+  public void testCompareChangedConfig() {
+    boolean status = true;
+    Map<String, Object> before = new HashMap<>();
+    Map<String, Object> after = new HashMap<>();
+
+    ApolloConfigurationSourceImpl impl = new ApolloConfigurationSourceImpl();
+    UpdateHandler updateHandler = impl.new UpdateHandler();
+    ApolloClient apolloClient = new ApolloClient(updateHandler);
+
+    ConfigRefresh cr = apolloClient.new ConfigRefresh("");
+
+    ApolloConfig instance = ApolloConfig.INSTANCE;
+    try {
+      Deencapsulation.invoke(cr, "compareChangedConfig", before, after);
+    } catch (Exception e) {
+      status = false;
+    }
+    Assert.assertTrue(status);
+
+    status = true;
+    before.put("test", "testValue");
+    try {
+      Deencapsulation.invoke(cr, "compareChangedConfig", before, after);
+    } catch (Exception e) {
+      status = false;
+    }
+    Assert.assertTrue(status);
+
+    status = true;
+    after.put("test", "testValue2");
+    try {
+      Deencapsulation.invoke(cr, "compareChangedConfig", before, after);
+    } catch (Exception e) {
+      status = false;
+    }
+    Assert.assertTrue(status);
+
+    status = true;
+    try {
+      Deencapsulation.invoke(cr, "compareChangedConfig", before, after);
+    } catch (Exception e) {
+      status = false;
+    }
+    Assert.assertTrue(status);
+  }
+}
\ No newline at end of file
diff --git a/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/client/ApolloConfigTest.java b/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/client/ApolloConfigTest.java
new file mode 100644
index 0000000..e343cc9
--- /dev/null
+++ b/dynamic-config/config-apollo/src/test/java/io/servicecomb/config/client/ApolloConfigTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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 io.servicecomb.config.client;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import io.servicecomb.config.ConfigUtil;
+
+public class ApolloConfigTest {
+  @BeforeClass
+  public static void setUpClass() {
+    ApolloConfig.setConcurrentCompositeConfiguration(ConfigUtil.createLocalConfig());
+  }
+
+  @Test
+  public void getServiceName() {
+    ApolloConfig instance = ApolloConfig.INSTANCE;
+    Assert.assertEquals("apollo-test", instance.getServiceName());
+    Assert.assertEquals("http://127.0.0.1:8070", instance.getServerUri());
+    Assert.assertEquals("DEV", instance.getEnv());
+    Assert.assertEquals("test-cluster", instance.getServerClusters());
+    Assert.assertEquals("application", instance.getNamespace());
+    Assert.assertEquals("xxx", instance.getToken());
+    Assert.assertEquals(30, instance.getRefreshInterval());
+    Assert.assertEquals(0, instance.getFirstRefreshInterval());
+  }
+}
\ No newline at end of file
diff --git a/samples/config-apollo-sample/src/main/resources/microservice.yaml b/dynamic-config/config-apollo/src/test/resources/microservice.yaml
similarity index 94%
copy from samples/config-apollo-sample/src/main/resources/microservice.yaml
copy to dynamic-config/config-apollo/src/test/resources/microservice.yaml
index 1bbd3c2..05efe7f 100644
--- a/samples/config-apollo-sample/src/main/resources/microservice.yaml
+++ b/dynamic-config/config-apollo/src/test/resources/microservice.yaml
@@ -32,8 +32,9 @@ apollo:
     env: DEV
     clusters: test-cluster
     namespace: application
-    token: #get token from Apollo web pages
-
+    token: xxx
+    refreshInterval: 30
+    firstRefreshInterval: 0
 cse:
   service:
     registry:
diff --git a/dynamic-config/pom.xml b/dynamic-config/pom.xml
index 4d25131..d627783 100644
--- a/dynamic-config/pom.xml
+++ b/dynamic-config/pom.xml
@@ -21,9 +21,10 @@
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <parent>
-    <artifactId>java-chassis</artifactId>
     <groupId>io.servicecomb</groupId>
+    <artifactId>java-chassis-parent</artifactId>
     <version>0.6.0-SNAPSHOT</version>
+    <relativePath>../parent</relativePath>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
diff --git a/samples/config-apollo-sample/pom.xml b/samples/config-apollo-sample/pom.xml
index c2a3f58..e08aceb 100644
--- a/samples/config-apollo-sample/pom.xml
+++ b/samples/config-apollo-sample/pom.xml
@@ -41,6 +41,10 @@
       <groupId>io.servicecomb</groupId>
       <artifactId>config-apollo</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
   </dependencies>
 
 
diff --git a/samples/config-apollo-sample/src/main/resources/log4j.properties b/samples/config-apollo-sample/src/main/resources/log4j.properties
new file mode 100644
index 0000000..ba21655
--- /dev/null
+++ b/samples/config-apollo-sample/src/main/resources/log4j.properties
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+log4j.rootLogger=INFO
\ No newline at end of file
diff --git a/samples/config-apollo-sample/src/main/resources/microservice.yaml b/samples/config-apollo-sample/src/main/resources/microservice.yaml
index 1bbd3c2..8035c47 100644
--- a/samples/config-apollo-sample/src/main/resources/microservice.yaml
+++ b/samples/config-apollo-sample/src/main/resources/microservice.yaml
@@ -33,7 +33,6 @@ apollo:
     clusters: test-cluster
     namespace: application
     token: #get token from Apollo web pages
-
 cse:
   service:
     registry:

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.