[GitHub] [servicecomb-java-chassis] GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie

2020-02-09 Thread GitBox
GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1518#discussion_r376887681
 
 

 ##
 File path: 
dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/model/ValueType.java
 ##
 @@ -0,0 +1,31 @@
+/*
+ * 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.servicecomb.config.kie.model;
+
+/**
+ * @Author GuoYl123
+ * @Date 2020/1/8
+ **/
+public enum ValueType {
+  yml,
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [servicecomb-java-chassis] GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie

2020-02-09 Thread GitBox
GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1518#discussion_r376887467
 
 

 ##
 File path: 
dynamic-config/config-kie/src/test/java/org/apache/servicecomb/config/kie/client/TestKieUtil.java
 ##
 @@ -0,0 +1,40 @@
+/*
+ * 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.servicecomb.config.kie.client;
+
+import mockit.Expectations;
+import mockit.Mocked;
+import org.apache.servicecomb.config.kie.model.KVResponse;
+import org.junit.Test;
+
+public class TestKieUtil {
+
+  @Test
+  public void testGetConfigByLabel(final @Mocked KVResponse resp) {
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [servicecomb-java-chassis] GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie

2020-02-09 Thread GitBox
GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1518#discussion_r376887422
 
 

 ##
 File path: 
dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/archaius/sources/KieConfigurationSourceImpl.java
 ##
 @@ -0,0 +1,135 @@
+/*
+ * 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.servicecomb.config.kie.archaius.sources;
+
+import static com.netflix.config.WatchedUpdateResult.createIncremental;
+
+import com.google.common.collect.ImmutableMap;
+import com.netflix.config.ConcurrentCompositeConfiguration;
+import com.netflix.config.WatchedUpdateListener;
+import com.netflix.config.WatchedUpdateResult;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.commons.configuration.Configuration;
+import org.apache.servicecomb.config.ConfigMapping;
+import org.apache.servicecomb.config.kie.client.KieClient;
+import org.apache.servicecomb.config.kie.client.KieConfig;
+import org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @Author GuoYl123
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [servicecomb-java-chassis] GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie

2020-02-09 Thread GitBox
GuoYL123 commented on a change in pull request #1518: [SCB-1711] support kie
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1518#discussion_r376887441
 
 

 ##
 File path: 
dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/client/KieClient.java
 ##
 @@ -0,0 +1,170 @@
+/*
+ * 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.servicecomb.config.kie.client;
+
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.DeploymentOptions;
+import io.vertx.core.Vertx;
+import io.vertx.core.VertxOptions;
+import io.vertx.core.http.HttpClientOptions;
+import io.vertx.core.http.HttpClientRequest;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.http.HttpStatus;
+import 
org.apache.servicecomb.config.kie.archaius.sources.KieConfigurationSourceImpl.UpdateHandler;
+import org.apache.servicecomb.config.kie.model.KVResponse;
+import org.apache.servicecomb.foundation.common.event.EventManager;
+import org.apache.servicecomb.foundation.common.net.IpPort;
+import org.apache.servicecomb.foundation.common.net.NetUtils;
+import org.apache.servicecomb.foundation.common.utils.JsonUtils;
+import org.apache.servicecomb.foundation.vertx.AddressResolverConfig;
+import org.apache.servicecomb.foundation.vertx.VertxUtils;
+import org.apache.servicecomb.foundation.vertx.client.ClientPoolManager;
+import org.apache.servicecomb.foundation.vertx.client.ClientVerticle;
+import 
org.apache.servicecomb.foundation.vertx.client.http.HttpClientPoolFactory;
+import 
org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @Author GuoYl123
+ * @Date 2020/1/9
+ **/
+public class KieClient {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(KieClient.class);
+
+  private ScheduledExecutorService EXECUTOR = 
Executors.newScheduledThreadPool(1);
+
+  private static final long TIME_OUT = 1;
+
+  private static final KieConfig KIE_CONFIG = KieConfig.INSTANCE;
+
+  private final int refreshInterval = KIE_CONFIG.getRefreshInterval();
+
+  private final int firstRefreshInterval = 
KIE_CONFIG.getFirstRefreshInterval();
+
+  private final String serviceUri = KIE_CONFIG.getServerUri();
+
+  private ClientPoolManager clientMgr;
+
+  public KieClient(UpdateHandler updateHandler) {
+KieWatcher.INSTANCE.setUpdateHandler(updateHandler);
+  }
+
+  public void refreshKieConfig() {
+try {
+  deployConfigClient();
+} catch (InterruptedException e) {
+  throw new IllegalStateException(e);
+}
+EXECUTOR
+.scheduleWithFixedDelay(new ConfigRefresh(serviceUri), 
firstRefreshInterval,
+refreshInterval, TimeUnit.SECONDS);
+  }
+
+  private void deployConfigClient() throws InterruptedException {
+VertxOptions vertxOptions = new VertxOptions();
+//todo :  how to deal with it
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services