This is an automated email from the ASF dual-hosted git repository. wujimin pushed a commit to branch 1.3.x in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/1.3.x by this push: new fb97eb4 [SCB-2137]Upgrade Vert.x version to 3.9.4 fb97eb4 is described below commit fb97eb45c2ffd4d5ba1fc8b1c1a97623bb9c3938 Author: liubao <bi...@qq.com> AuthorDate: Thu Dec 3 20:32:46 2020 +0800 [SCB-2137]Upgrade Vert.x version to 3.9.4 --- .../codec/param/TestRestClientRequestImpl.java | 3 +- demo/perf/pom.xml | 79 ------------ demo/perf/readme.MD | 45 ------- .../org/apache/servicecomb/demo/perf/Impl.java | 81 ------------- .../org/apache/servicecomb/demo/perf/Intf.java | 26 ---- .../servicecomb/demo/perf/PerfConfiguration.java | 133 --------------------- .../apache/servicecomb/demo/perf/PerfConsumer.java | 101 ---------------- .../org/apache/servicecomb/demo/perf/PerfMain.java | 40 ------- .../servicecomb/demo/perf/RedisClientUtils.java | 74 ------------ .../apache/servicecomb/demo/perf/RedisSession.java | 71 ----------- demo/perf/src/main/resources/logback.xml | 29 ----- demo/perf/src/main/resources/microservice.yaml | 76 ------------ demo/pom.xml | 1 - .../ConfigCenterConfigurationSourceImpl.java | 2 +- .../config/client/ConfigCenterClient.java | 48 ++++---- .../main/java/io/vertx/core/impl/SyncContext.java | 3 +- .../vertx/client/http/HttpClientPoolFactory.java | 17 ++- .../vertx/TestAddressResolverConfig.java | 32 ++--- java-chassis-dependencies/default/pom.xml | 2 +- java-chassis-distribution/src/release/LICENSE | 10 +- .../metrics/core/TestVertxMetersInitializer.java | 16 ++- .../serviceregistry/client/http/RestUtils.java | 3 +- .../client/http/WebsocketUtils.java | 6 +- .../transport/highway/HighwayServerVerticle.java | 16 ++- .../highway/TestHighwayServerConnection.java | 4 +- .../transport/highway/TestHighwayVerticle.java | 8 +- .../rest/client/http/RestClientInvocation.java | 12 -- .../client/http/TestDefaultHttpClientFilter.java | 9 +- .../transport/rest/vertx/RestServerVerticle.java | 18 ++- .../rest/vertx/TestRestServerVerticle.java | 26 ++-- 30 files changed, 115 insertions(+), 876 deletions(-) diff --git a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/codec/param/TestRestClientRequestImpl.java b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/codec/param/TestRestClientRequestImpl.java index 3e25612..0ae44b4 100644 --- a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/codec/param/TestRestClientRequestImpl.java +++ b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/codec/param/TestRestClientRequestImpl.java @@ -34,7 +34,6 @@ import com.google.common.collect.Multimap; import io.vertx.core.MultiMap; import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.CaseInsensitiveHeaders; import io.vertx.core.http.HttpClientRequest; import mockit.Deencapsulation; import mockit.Expectations; @@ -60,7 +59,7 @@ public class TestRestClientRequestImpl { public void testCookie() throws Exception { HttpClientRequest request = new MockUp<HttpClientRequest>() { - MultiMap map = new CaseInsensitiveHeaders(); + MultiMap map = MultiMap.caseInsensitiveMultiMap(); @Mock public HttpClientRequest putHeader(CharSequence key, CharSequence val) { diff --git a/demo/perf/pom.xml b/demo/perf/pom.xml deleted file mode 100644 index b577bc3..0000000 --- a/demo/perf/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" 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"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.servicecomb.demo</groupId> - <artifactId>demo-parent</artifactId> - <version>1.3.2-SNAPSHOT</version> - </parent> - <artifactId>perf</artifactId> - <name>Java Chassis::Demo::Perf</name> - - <dependencies> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>provider-pojo</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>provider-springmvc</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-highway</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-rest-vertx</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>inspector</artifactId> - </dependency> - - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - </dependency> - - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-redis-client</artifactId> - <version>${vertx.version}</version> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>metrics-core</artifactId> - </dependency> - </dependencies> - - <properties> - <demo.main>org.apache.servicecomb.demo.perf.PerfMain</demo.main> - </properties> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file diff --git a/demo/perf/readme.MD b/demo/perf/readme.MD deleted file mode 100644 index 00062ab..0000000 --- a/demo/perf/readme.MD +++ /dev/null @@ -1,45 +0,0 @@ -suppose jar named perf.jar -1.copy perf.jar to different directory - -2.create microservice.yaml in each directory -# change microserviceName to be perf1/perf2/perf3, and so on -service_description: - name: perf1 -cse: - references: - # use which transport to invoke - transport: rest - -# sync mode consumer count -sync-count: 10 -# async mode consumer count -async-count: 20 -# use sync mode or not -# sync: /v1/syncQuery/{id}?step={step}&all={all}&fromDB={fromDB} -# async:/v1/asyncQuery/{id}?step={step}&all={all}&fromDB={fromDB} -sync: false -# producer microserviceName -producer: perf1 -id: 1 -# every producer determine: -# 1)if step equals all, then this is final step, direct return or query from db -# 2)otherwise inc step and invoke next microservice -# 3)if self name if perf1, then next microservice is perf2 -step: 1 -all: 1 -fromDB: false -response-size: 1 - -# redis parameter -redis: - client: - count: 8 - host: - port: - password: - -3.start producers -java -jar perf.jar - -4.start consumer -java -jar perf.jar -c \ No newline at end of file diff --git a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/Impl.java b/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/Impl.java deleted file mode 100644 index e2505ed..0000000 --- a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/Impl.java +++ /dev/null @@ -1,81 +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.servicecomb.demo.perf; - -import java.util.concurrent.CompletableFuture; - -import org.apache.servicecomb.provider.pojo.Invoker; -import org.apache.servicecomb.provider.rest.common.RestSchema; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@RestSchema(schemaId = "impl") -@RequestMapping(path = "/v1") -public class Impl { - private Intf intf; - - @Value(value = "${service_description.name}") - public void setSelfMicroserviceName(String selfMicroserviceName) { - // self: perf-1/perf-a - // next: perf-2/perf-b - char last = selfMicroserviceName.charAt(selfMicroserviceName.length() - 1); - String nextMicroserviceName = - selfMicroserviceName.substring(0, selfMicroserviceName.length() - 1) + (char) (last + 1); - intf = Invoker.createProxy(nextMicroserviceName, - "impl", - Intf.class); - } - - @GetMapping(path = "/syncQuery/{id}") - public String syncQuery(@PathVariable(name = "id") String id, - @RequestParam(name = "step") int step, @RequestParam(name = "all") int all, - @RequestParam(name = "fromDB") boolean fromDB) { - if (step == all) { - if (fromDB) { - return RedisClientUtils.syncQuery(id); - } - - return buildFromMemoryResponse(id); - } - - return intf.syncQuery(id, step + 1, all, fromDB); - } - - public String buildFromMemoryResponse(String id) { - return PerfConfiguration.buildResponse("memory", id); - } - - @GetMapping(path = "/asyncQuery/{id}") - public CompletableFuture<String> asyncQuery(@PathVariable(name = "id") String id, - @RequestParam(name = "step") int step, @RequestParam(name = "all") int all, - @RequestParam(name = "fromDB") boolean fromDB) { - if (step == all) { - if (fromDB) { - return RedisClientUtils.asyncQuery(id); - } - - CompletableFuture<String> future = new CompletableFuture<>(); - future.complete(buildFromMemoryResponse(id)); - return future; - } - - return intf.asyncQuery(id, step + 1, all, fromDB); - } -} diff --git a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/Intf.java b/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/Intf.java deleted file mode 100644 index c671fda..0000000 --- a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/Intf.java +++ /dev/null @@ -1,26 +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.servicecomb.demo.perf; - -import java.util.concurrent.CompletableFuture; - -public interface Intf { - String syncQuery(String id, int step, int all, boolean fromDB); - - CompletableFuture<String> asyncQuery(String id, int step, int all, boolean fromDB); -} diff --git a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfConfiguration.java b/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfConfiguration.java deleted file mode 100644 index 8d750b0..0000000 --- a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfConfiguration.java +++ /dev/null @@ -1,133 +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.servicecomb.demo.perf; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import com.google.common.base.Strings; - -@Component -public class PerfConfiguration { - public static int syncCount; - - public static int asyncCount; - - public static boolean sync; - - public static String producer; - - public static String id; - - public static int step; - - public static int all; - - public static boolean fromDB; - - public static int responseSize; - - public static String responseData; - - public static int redisClientCount; - - public static String redisHost; - - public static int redisPort; - - public static String redisPassword; - - public static String buildResponse(String from, String id) { - return new StringBuilder(64 + PerfConfiguration.responseData.length()) - .append(id) - .append(" from ") - .append(from) - .append(": ") - .append(PerfConfiguration.responseData) - .toString(); - } - - @Value(value = "${response-size}") - public void setResponseSize(int responseSize) { - PerfConfiguration.responseSize = responseSize; - PerfConfiguration.responseData = Strings.repeat("a", responseSize); - } - - @Value(value = "${sync-count}") - public void setSyncCount(int syncCount) { - PerfConfiguration.syncCount = syncCount; - } - - @Value(value = "${async-count}") - public void setAsyncCount(int asyncCount) { - PerfConfiguration.asyncCount = asyncCount; - } - - @Value(value = "${sync}") - public void setSync(boolean sync) { - PerfConfiguration.sync = sync; - } - - @Value(value = "${producer}") - public void setProducer(String producer) { - PerfConfiguration.producer = producer; - } - - @Value(value = "${id}") - public void setId(String id) { - PerfConfiguration.id = id; - } - - @Value(value = "${step}") - public void setStep(int step) { - PerfConfiguration.step = step; - } - - @Value(value = "${all}") - public void setAll(int all) { - PerfConfiguration.all = all; - } - - @Value(value = "${fromDB}") - public void setFromDB(boolean fromDB) { - PerfConfiguration.fromDB = fromDB; - } - - @Value(value = "${redis.client.count}") - public void setRedisClientCount(int redisClientCount) { - PerfConfiguration.redisClientCount = redisClientCount; - } - - @Value(value = "${redis.host}") - public void setRedisHost(String redisHost) { - PerfConfiguration.redisHost = redisHost; - } - - @Value(value = "${redis.port}") - public void setRedisPort(int redisPort) { - PerfConfiguration.redisPort = redisPort; - } - - @Value(value = "${redis.password:}") - public void setRedisPassword(String redisPassword) { - if (StringUtils.isEmpty(redisPassword)) { - return; - } - PerfConfiguration.redisPassword = redisPassword; - } -} diff --git a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfConsumer.java b/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfConsumer.java deleted file mode 100644 index a73b768..0000000 --- a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfConsumer.java +++ /dev/null @@ -1,101 +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.servicecomb.demo.perf; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; - -import org.apache.servicecomb.provider.pojo.Invoker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -public class PerfConsumer { - private static final Logger LOGGER = LoggerFactory.getLogger(PerfConsumer.class); - - private Intf intf; - - public void runConsumer() throws InterruptedException, ExecutionException { - intf = Invoker.createProxy( - PerfConfiguration.producer, - "impl", - Intf.class); - - if (PerfConfiguration.sync) { - runSyncConsumers(); - return; - } - - runAsyncConsumers(); - } - - private void runAsyncConsumers() throws InterruptedException, ExecutionException { - CompletableFuture<String> future = intf.asyncQuery(PerfConfiguration.id, - PerfConfiguration.step, - PerfConfiguration.all, - PerfConfiguration.fromDB); - LOGGER.info("runAsyncConsumer: {}", future.get()); - - for (int idx = 0; idx < PerfConfiguration.asyncCount; idx++) { - runAsyncConsumer(); - } - } - - private void runAsyncConsumer() { - CompletableFuture<String> future = intf.asyncQuery(PerfConfiguration.id, - PerfConfiguration.step, - PerfConfiguration.all, - PerfConfiguration.fromDB); - future.whenComplete((r, e) -> { - if (e == null) { - runAsyncConsumer(); - return; - } - - throw new IllegalStateException("invoke failed.", e); - }); - } - - private void runSyncConsumers() { - LOGGER.info("runSyncConsumer: {}", - intf.syncQuery(PerfConfiguration.id, - PerfConfiguration.step, - PerfConfiguration.all, - PerfConfiguration.fromDB)); - - Executor executor = Executors.newFixedThreadPool(PerfConfiguration.syncCount); - for (int idx = 0; idx < PerfConfiguration.syncCount; idx++) { - executor.execute(this::runSyncConsumer); - } - } - - private void runSyncConsumer() { - try { - for (; ; ) { - intf.syncQuery(PerfConfiguration.id, - PerfConfiguration.step, - PerfConfiguration.all, - PerfConfiguration.fromDB); - } - } catch (Throwable e) { - throw new IllegalStateException("invoke failed.", e); - } - } -} diff --git a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfMain.java b/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfMain.java deleted file mode 100644 index 871ccb4..0000000 --- a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfMain.java +++ /dev/null @@ -1,40 +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.servicecomb.demo.perf; - -import java.util.Arrays; -import java.util.List; - -import org.apache.servicecomb.foundation.common.utils.BeanUtils; -import org.apache.servicecomb.foundation.vertx.VertxUtils; - -public class PerfMain { - - public static void main(String[] args) throws Exception { - BeanUtils.init(); - - // redis - RedisClientUtils.init(VertxUtils.getOrCreateVertxByName("transport", null)); - - List<String> argList = Arrays.asList(args); - if (argList.contains("-c")) { - PerfConsumer consumer = BeanUtils.getContext().getBean(PerfConsumer.class); - consumer.runConsumer(); - } - } -} diff --git a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/RedisClientUtils.java b/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/RedisClientUtils.java deleted file mode 100644 index 0ce693a..0000000 --- a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/RedisClientUtils.java +++ /dev/null @@ -1,74 +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.servicecomb.demo.perf; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -import javax.ws.rs.core.Response.Status; - -import org.apache.servicecomb.foundation.vertx.VertxUtils; -import org.apache.servicecomb.foundation.vertx.client.ClientPoolFactory; -import org.apache.servicecomb.foundation.vertx.client.ClientPoolManager; -import org.apache.servicecomb.foundation.vertx.client.ClientVerticle; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; - -import io.vertx.core.DeploymentOptions; -import io.vertx.core.Vertx; -import io.vertx.redis.RedisClient; -import io.vertx.redis.RedisOptions; - -public class RedisClientUtils { - private static ClientPoolManager<RedisClient> clientMgr; - - public static void init(Vertx vertx) throws InterruptedException { - RedisOptions redisOptions = new RedisOptions() - .setHost(PerfConfiguration.redisHost) - .setPort(PerfConfiguration.redisPort) - .setAuth(PerfConfiguration.redisPassword); - ClientPoolFactory<RedisClient> factory = (ctx) -> { - return RedisClient.create(vertx, redisOptions); - }; - clientMgr = new ClientPoolManager<>(vertx, factory); - - DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, - PerfConfiguration.redisClientCount); - VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions); - } - - public static String syncQuery(String id) { - CompletableFuture<String> future = doQuery(id, true); - try { - return future.get(); - } catch (InterruptedException | ExecutionException e) { - throw new InvocationException(Status.INTERNAL_SERVER_ERROR.getStatusCode(), - Status.INTERNAL_SERVER_ERROR.getReasonPhrase(), (Object) "Failed to query from redis.", e); - } - } - - public static CompletableFuture<String> asyncQuery(String id) { - return doQuery(id, false); - } - - private static CompletableFuture<String> doQuery(String id, boolean sync) { - CompletableFuture<String> future = new CompletableFuture<>(); - RedisClient redisClient = clientMgr.findClientPool(sync); - RedisSession session = new RedisSession(redisClient, id, future); - session.query(); - return future; - } -} diff --git a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/RedisSession.java b/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/RedisSession.java deleted file mode 100644 index f9d657f..0000000 --- a/demo/perf/src/main/java/org/apache/servicecomb/demo/perf/RedisSession.java +++ /dev/null @@ -1,71 +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.servicecomb.demo.perf; - -import java.util.concurrent.CompletableFuture; - -import io.vertx.core.AsyncResult; -import io.vertx.redis.RedisClient; - -public class RedisSession { - RedisClient redis; - - String id; - - CompletableFuture<String> future; - - String createResult; - - public RedisSession(RedisClient redis, String id, CompletableFuture<String> future) { - this.redis = redis; - this.id = id; - this.future = future; - } - - public void query() { - redis.get(id, this::onGetResponse); - } - - private void onGetResponse(AsyncResult<String> ar) { - if (ar.succeeded()) { - if (ar.result() == null) { - createCache(); - return; - } - - future.complete(ar.result()); - return; - } - - future.completeExceptionally(ar.cause()); - } - - private void createCache() { - createResult = PerfConfiguration.buildResponse("redis", id); - redis.set(id, createResult, this::onCreateCacheResponse); - } - - private void onCreateCacheResponse(AsyncResult<Void> ar) { - if (ar.succeeded()) { - future.complete(createResult); - return; - } - - future.completeExceptionally(ar.cause()); - } -} diff --git a/demo/perf/src/main/resources/logback.xml b/demo/perf/src/main/resources/logback.xml deleted file mode 100644 index 5264742..0000000 --- a/demo/perf/src/main/resources/logback.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<configuration scan="true"> - <jmxConfigurator/> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>%d[%level][%thread][%marker] - %msg (%F:%L\)%n</pattern> - </encoder> - </appender> - <root level="INFO"> - <appender-ref ref="STDOUT"/> - </root> -</configuration> \ No newline at end of file diff --git a/demo/perf/src/main/resources/microservice.yaml b/demo/perf/src/main/resources/microservice.yaml deleted file mode 100644 index 426d428..0000000 --- a/demo/perf/src/main/resources/microservice.yaml +++ /dev/null @@ -1,76 +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. -## --------------------------------------------------------------------------- - -APPLICATION_ID: perfTest -service_description: - name: perf1 - version: 0.0.1 -servicecomb: - service: - registry: - address: http://127.0.0.1:30100 - rest: - address: 0.0.0.0:8080?sslEnabled=false - server: - verticle-count: 8 - client: - verticle-count: 8 - connection: - maxPoolSize: 30 - highway: - address: 0.0.0.0:7070?sslEnabled=false - server: - verticle-count: 8 - client: - verticle-count: 8 - executor: - default: - group: 4 - maxThreads-per-group: 4 - references: - transport: highway - metrics: - window_time: 1000 - invocation.latencyDistribution: 0,1,3,10,100 - Consumer.invocation.slow: - enabled: true - msTime: 40 - Provider.invocation.slow: - enabled: true - msTime: 40 - publisher.defaultLog: - enabled: true - endpoints.client.detail.enabled: true - invocation.latencyDistribution: - minScopeLength: 9 - -sync-count: 10 -async-count: 20 -sync: false -producer: perf1 -id: 1 -step: 1 -all: 1 -fromDB: false -response-size: 1 - -redis: - client: - count: 8 - host: localhost - port: 6379 -# password: diff --git a/demo/pom.xml b/demo/pom.xml index d3f9b29..2177ed8 100644 --- a/demo/pom.xml +++ b/demo/pom.xml @@ -46,7 +46,6 @@ <module>demo-multiple</module> <module>demo-signature</module> <module>demo-edge</module> - <module>perf</module> </modules> <dependencyManagement> diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java index 3764fc1..44adad9 100644 --- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java +++ b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/archaius/sources/ConfigCenterConfigurationSourceImpl.java @@ -140,7 +140,7 @@ public class ConfigCenterConfigurationSourceImpl implements ConfigCenterConfigur LOGGER.error("action: {} is invalid.", action); return; } - LOGGER.warn("Config value cache changed: action:{}; item:{}", action, configuration.keySet()); + LOGGER.info("Config value cache changed: action:{}; item:{}", action, configuration.keySet()); } } } diff --git a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterClient.java b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterClient.java index 8ad91bd..2663c5d 100644 --- a/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterClient.java +++ b/dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterClient.java @@ -63,10 +63,10 @@ import com.fasterxml.jackson.core.type.TypeReference; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.DeploymentOptions; +import io.vertx.core.MultiMap; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.CaseInsensitiveHeaders; import io.vertx.core.http.HttpClientOptions; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.WebSocket; @@ -288,7 +288,7 @@ public class ConfigCenterClient { createSignRequest(null, configCenter + url, headers, null)))); WebSocketConnectOptions options = new WebSocketConnectOptions(); options.setHost(ipPort.getHostOrIp()).setPort(refreshPort).setURI(url) - .setHeaders(new CaseInsensitiveHeaders().addAll(headers) + .setHeaders(MultiMap.caseInsensitiveMultiMap().addAll(headers) .addAll(authHeaders)); client.webSocket(options, asyncResult -> { if (asyncResult.failed()) { @@ -299,24 +299,24 @@ public class ConfigCenterClient { asyncResult.cause().getMessage()); waiter.countDown(); } else { - { - asyncResult.result().exceptionHandler(e -> { - LOGGER.error("watch config read fail", e); - stopHeartBeatThread(); - isWatching = false; - }); - asyncResult.result().closeHandler(v -> { - LOGGER.warn("watching config connection is closed accidentally"); - stopHeartBeatThread(); - isWatching = false; - }); - - asyncResult.result().pongHandler(pong -> { - // ignore, just prevent NPE. - }); - asyncResult.result().frameHandler(frame -> { + asyncResult.result().exceptionHandler(e -> { + LOGGER.error("watch config read fail", e); + stopHeartBeatThread(); + isWatching = false; + }); + asyncResult.result().closeHandler(v -> { + LOGGER.warn("watching config connection is closed accidentally"); + stopHeartBeatThread(); + isWatching = false; + }); + + asyncResult.result().pongHandler(pong -> { + // ignore, just prevent NPE. + }); + asyncResult.result().frameHandler(frame -> { + if (frame.isText() || frame.isBinary()) { Buffer action = frame.binaryData(); - LOGGER.info("watching config recieved {}", action); + LOGGER.debug("watching config recieved {}", action); Map<String, Object> mAction = action.toJsonObject().getMap(); if ("CREATE".equals(mAction.get("action"))) { //event loop can not be blocked,we just keep nothing changed in push mode @@ -326,11 +326,11 @@ public class ConfigCenterClient { } else { parseConfigUtils.refreshConfigItemsIncremental(mAction); } - }); - startHeartBeatThread(asyncResult.result()); - isWatching = true; - waiter.countDown(); - } + } + }); + startHeartBeatThread(asyncResult.result()); + isWatching = true; + waiter.countDown(); } }); }); diff --git a/foundations/foundation-test-scaffolding/src/main/java/io/vertx/core/impl/SyncContext.java b/foundations/foundation-test-scaffolding/src/main/java/io/vertx/core/impl/SyncContext.java index 0640b48..b8a80b6 100644 --- a/foundations/foundation-test-scaffolding/src/main/java/io/vertx/core/impl/SyncContext.java +++ b/foundations/foundation-test-scaffolding/src/main/java/io/vertx/core/impl/SyncContext.java @@ -21,7 +21,6 @@ import java.util.concurrent.Executor; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Promise; -import io.vertx.core.Vertx; import io.vertx.core.spi.metrics.PoolMetrics; public class SyncContext extends EventLoopContext { @@ -59,7 +58,7 @@ public class SyncContext extends EventLoopContext { return; } - res.future().setHandler(asyncResultHandler); + res.future().onComplete(asyncResultHandler); } @Override diff --git a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientPoolFactory.java b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientPoolFactory.java index a6b1f60..685ddf8 100644 --- a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientPoolFactory.java +++ b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientPoolFactory.java @@ -18,6 +18,8 @@ package org.apache.servicecomb.foundation.vertx.client.http; import org.apache.servicecomb.foundation.vertx.client.ClientPoolFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import io.vertx.core.Context; import io.vertx.core.http.HttpClient; @@ -25,6 +27,8 @@ import io.vertx.core.http.HttpClientOptions; // execute in vertx context public class HttpClientPoolFactory implements ClientPoolFactory<HttpClientWithContext> { + private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientPoolFactory.class); + private HttpClientOptions httpClientOptions; public HttpClientPoolFactory(HttpClientOptions httpClientOptions) { @@ -34,7 +38,18 @@ public class HttpClientPoolFactory implements ClientPoolFactory<HttpClientWithCo @Override public HttpClientWithContext createClientPool(Context context) { HttpClient httpClient = context.owner().createHttpClient(httpClientOptions); - + httpClient.connectionHandler(connection -> { + LOGGER.debug("http connection connected, local:{}, remote:{}.", + connection.localAddress(), connection.remoteAddress()); + connection.closeHandler(v -> + LOGGER.debug("http connection closed, local:{}, remote:{}.", + connection.localAddress(), connection.remoteAddress()) + ); + connection.exceptionHandler(e -> + LOGGER.info("http connection exception, local:{}, remote:{}.", + connection.localAddress(), connection.remoteAddress(), e) + ); + }); return new HttpClientWithContext(httpClient, context); } } diff --git a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java index da4bc2c..2cf4bb8 100644 --- a/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java +++ b/foundations/foundation-vertx/src/test/java/org/apache/servicecomb/foundation/vertx/TestAddressResolverConfig.java @@ -20,6 +20,7 @@ package org.apache.servicecomb.foundation.vertx; import static org.hamcrest.CoreMatchers.is; import java.util.Arrays; +import java.util.Collections; import org.apache.commons.configuration.Configuration; import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils; @@ -45,7 +46,7 @@ public class TestAddressResolverConfig { } @Test - public void testGetResoverFromResource(@Mocked Configuration finalConfig) { + public void testGetResolverFromResource(@Mocked Configuration finalConfig) { ArchaiusUtils.resetConfig(); ArchaiusUtils.setProperty("addressResolver.servers", "8.8.8.8,8.8.4.4"); new Expectations() { @@ -60,18 +61,18 @@ public class TestAddressResolverConfig { result = -2; } }; - AddressResolverOptions aroc = AddressResolverConfig.getAddressResover("test", finalConfig); - Assert.assertThat(aroc.getServers(), is(Arrays.asList("6.6.6.6", "6.6.4.4"))); - Assert.assertThat(aroc.getSearchDomains(), - is(Arrays.asList("default.svc.local.cluster"))); - Assert.assertEquals(aroc.getQueryTimeout(), + AddressResolverOptions resolverOptions = AddressResolverConfig.getAddressResover("test", finalConfig); + Assert.assertThat(resolverOptions.getServers(), is(Arrays.asList("6.6.6.6", "6.6.4.4"))); + Assert.assertThat(resolverOptions.getSearchDomains(), + is(Collections.singletonList("default.svc.local.cluster"))); + Assert.assertEquals(resolverOptions.getQueryTimeout(), 2000); - Assert.assertNotEquals(aroc.getMaxQueries(), + Assert.assertNotEquals(resolverOptions.getMaxQueries(), -2); } @Test - public void testGetResover() { + public void testGetResolver() { ArchaiusUtils.resetConfig(); ArchaiusUtils.setProperty("addressResolver.servers", "8.8.8.8,8.8.4.4"); ArchaiusUtils.setProperty("addressResolver.optResourceEnabled", true); @@ -95,19 +96,20 @@ public class TestAddressResolverConfig { AddressResolverOptions aroc1 = AddressResolverConfig.getAddressResover("test1"); Assert.assertThat(aroc1.getSearchDomains(), is(Arrays.asList("default.svc.local.cluster", "svc.local.cluster", "local.cluster"))); + Assert.assertTrue(aroc.isOptResourceEnabled()); } @Test - public void testGetResoverDefault() { + public void testGetResolverDefault() { ArchaiusUtils.resetConfig(); ArchaiusUtils.setProperty("addressResolver.servers", "8.8.8.8,8.8.4.4"); ArchaiusUtils.setProperty("addressResolver.maxQueries", 3); ArchaiusUtils.setProperty("addressResolver.rdFlag", false); - AddressResolverOptions aroc = AddressResolverConfig.getAddressResover("test"); - Assert.assertThat(aroc.getServers(), is(Arrays.asList("8.8.8.8", "8.8.4.4"))); - Assert.assertEquals(3, aroc.getMaxQueries()); - Assert.assertEquals(Integer.MAX_VALUE, aroc.getCacheMaxTimeToLive()); - Assert.assertTrue(aroc.isOptResourceEnabled()); - Assert.assertNull(aroc.getSearchDomains()); + AddressResolverOptions resolverOptions = AddressResolverConfig.getAddressResover("test"); + Assert.assertThat(resolverOptions.getServers(), is(Arrays.asList("8.8.8.8", "8.8.4.4"))); + Assert.assertEquals(3, resolverOptions.getMaxQueries()); + Assert.assertEquals(Integer.MAX_VALUE, resolverOptions.getCacheMaxTimeToLive()); + Assert.assertFalse(resolverOptions.isOptResourceEnabled()); + Assert.assertNull(resolverOptions.getSearchDomains()); } } diff --git a/java-chassis-dependencies/default/pom.xml b/java-chassis-dependencies/default/pom.xml index 885ca7d..cadc03d 100644 --- a/java-chassis-dependencies/default/pom.xml +++ b/java-chassis-dependencies/default/pom.xml @@ -108,7 +108,7 @@ <tcnetty.version>2.0.31.Final</tcnetty.version> <tec-zkclient.version>0.10</tec-zkclient.version> <tomakehurst.version>2.6.0</tomakehurst.version> - <vertx.version>3.8.3</vertx.version> + <vertx.version>3.9.4</vertx.version> <xstream.version>1.4.11.1</xstream.version> <zipkin.version>2.19.1</zipkin.version> <zipkin-reporter.version>2.7.13</zipkin-reporter.version> diff --git a/java-chassis-distribution/src/release/LICENSE b/java-chassis-distribution/src/release/LICENSE index 71233df..1750db7 100644 --- a/java-chassis-distribution/src/release/LICENSE +++ b/java-chassis-distribution/src/release/LICENSE @@ -242,7 +242,7 @@ You can find a copy of the License at licenses/LICENSE-epl-v20 * JRuby Core (org.jruby:jruby-core:9.2.6.0 - https://github.com/jruby/jruby/jruby-core) * JRuby Lib Setup (org.jruby:jruby-stdlib:9.2.6.0 - https://github.com/jruby/jruby/jruby-stdlib) * JRuby Main Maven Artifact (org.jruby:jruby:9.2.6.0 - https://github.com/jruby/jruby/jruby-artifacts/jruby) -* Vert.x Core (io.vertx:vertx-core:3.8.3 - https://github.com/eclipse-vertx/vert.x) +* Vert.x Core (io.vertx:vertx-core:3.9.4 - https://github.com/eclipse-vertx/vert.x) ================================================================ This product bundles libraries which are licensed under the @@ -634,7 +634,7 @@ For details, see their respective project links. * msg-simple (com.github.fge:msg-simple:1.1 - https://github.com/fge/msg-simple) * uri-template (com.github.fge:uri-template:0.9 - https://github.com/fge/uri-template) * Javassist (org.javassist:javassist:3.24.0-GA - http://www.javassist.org/) -* Vert.x Bridge Common (io.vertx:vertx-bridge-common:3.8.3 - https://github.com/vert-x3/vertx-bridge-common) -* vertx-auth-common (io.vertx:vertx-auth-common:3.8.3 - https://github.com/vert-x3/vertx-auth) -* vertx-web-common (io.vertx:vertx-web-common:3.8.3 - https://github.com/vert-x3/vertx-web) -* vertx-web (io.vertx:vertx-web:3.8.3 - https://github.com/vert-x3/vertx-web) \ No newline at end of file +* Vert.x Bridge Common (io.vertx:vertx-bridge-common:3.9.4 - https://github.com/vert-x3/vertx-bridge-common) +* vertx-auth-common (io.vertx:vertx-auth-common:3.9.4 - https://github.com/vert-x3/vertx-auth) +* vertx-web-common (io.vertx:vertx-web-common:3.9.4 - https://github.com/vert-x3/vertx-web) +* vertx-web (io.vertx:vertx-web:3.9.4 - https://github.com/vert-x3/vertx-web) \ No newline at end of file diff --git a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java index 17850ff..c6562d0 100644 --- a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java +++ b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java @@ -42,7 +42,7 @@ import com.netflix.spectator.api.Registry; import io.vertx.core.AbstractVerticle; import io.vertx.core.DeploymentOptions; -import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.http.HttpClient; import io.vertx.core.http.HttpServer; import io.vertx.ext.web.Router; @@ -67,9 +67,7 @@ public class TestVertxMetersInitializer { public static class TestServerVerticle extends AbstractVerticle { @Override - @SuppressWarnings("deprecation") - // TODO: vert.x 3.8.3 does not update startListen to promise, so we keep use deprecated API now. update in newer version. - public void start(Future<Void> startFuture) { + public void start(Promise<Void> startPromise) { Router mainRouter = Router.router(vertx); mainRouter.route("/").handler(context -> { context.response().end(context.getBody()); @@ -80,23 +78,23 @@ public class TestVertxMetersInitializer { server.listen(0, "0.0.0.0", ar -> { if (ar.succeeded()) { port = ar.result().actualPort(); - startFuture.complete(); + startPromise.complete(); return; } - startFuture.fail(ar.cause()); + startPromise.fail(ar.cause()); }); } } public static class TestClientVerticle extends AbstractVerticle { - @SuppressWarnings("deprecation") @Override - public void start(Future<Void> startFuture) { + @SuppressWarnings("deprecation") + public void start(Promise<Void> startPromise) { HttpClient client = vertx.createHttpClient(); client.post(port, "127.127.127.127", "/").handler(resp -> { resp.bodyHandler((buffer) -> { - startFuture.complete(); + startPromise.complete(); }); }).end(body); } diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RestUtils.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RestUtils.java index 42d1e03..a7e8c72 100644 --- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RestUtils.java +++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RestUtils.java @@ -36,7 +36,6 @@ import org.slf4j.LoggerFactory; import io.vertx.core.Handler; import io.vertx.core.MultiMap; import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.CaseInsensitiveHeaders; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpMethod; @@ -190,7 +189,7 @@ final class RestUtils { } public static MultiMap getDefaultHeaders() { - return new CaseInsensitiveHeaders().addAll(defaultHeaders()); + return MultiMap.caseInsensitiveMultiMap().addAll(defaultHeaders()); } public static void get(IpPort ipPort, String uri, RequestParam requestParam, diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/WebsocketUtils.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/WebsocketUtils.java index 1426de9..04a8590 100644 --- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/WebsocketUtils.java +++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/WebsocketUtils.java @@ -66,7 +66,11 @@ public final class WebsocketUtils { asyncResult.result().pongHandler(pong -> { // ignore, just prevent NPE. }); - asyncResult.result().frameHandler((frame) -> onMessage.handle(frame.binaryData())); + asyncResult.result().frameHandler((frame) -> { + if (frame.isBinary() || frame.isText()) { + onMessage.handle(frame.binaryData()); + } + }); } }); }); diff --git a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java index 8104ecc..b4c3c31 100644 --- a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java +++ b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java @@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory; import io.vertx.core.AbstractVerticle; import io.vertx.core.Context; -import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; public class HighwayServerVerticle extends AbstractVerticle { @@ -48,10 +48,10 @@ public class HighwayServerVerticle extends AbstractVerticle { } @Override - public void start(Future<Void> startFuture) throws Exception { + public void start(Promise<Void> startPromise) throws Exception { try { super.start(); - startListen(startFuture); + startListen(startPromise); } catch (Throwable e) { // vert.x got some states that not print error and execute call back in VertexUtils.blockDeploy, we add a log our self. LOGGER.error("", e); @@ -59,13 +59,11 @@ public class HighwayServerVerticle extends AbstractVerticle { } } - @SuppressWarnings("deprecation") - // TODO: vert.x 3.8.3 does not update startListen to promise, so we keep use deprecated API now. update in newer version. - protected void startListen(Future<Void> startFuture) { + protected void startListen(Promise<Void> startPromise) { // if listen address is not provided, do not fail and maybe a consumer service. if (endpointObject == null) { LOGGER.warn("highway listen address is not configured, will not listen."); - startFuture.complete(); + startPromise.complete(); return; } @@ -76,12 +74,12 @@ public class HighwayServerVerticle extends AbstractVerticle { LOGGER.info("highway listen success. address={}:{}", socketAddress.getHostString(), socketAddress.getPort()); - startFuture.complete(); + startPromise.complete(); return; } LOGGER.error(Const.HIGHWAY, ar.cause()); - startFuture.fail(ar.cause()); + startPromise.fail(ar.cause()); }); } } diff --git a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java index 5375b0a..32f149f 100644 --- a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java +++ b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java @@ -16,8 +16,6 @@ */ package org.apache.servicecomb.transport.highway; -import java.net.InetSocketAddress; - import javax.xml.ws.Holder; import org.apache.servicecomb.codec.protobuf.definition.ProtobufManager; @@ -68,7 +66,7 @@ public class TestHighwayServerConnection { new Expectations(CseContext.getInstance()) { { netSocket.remoteAddress(); - result = new SocketAddressImpl(new InetSocketAddress("127.0.0.1", 80)); + result = new SocketAddressImpl(80, "127.0.0.1"); } }; connection = new HighwayServerConnection(endpoint); diff --git a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayVerticle.java b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayVerticle.java index f2ac8d6..6c7ff66 100644 --- a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayVerticle.java +++ b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayVerticle.java @@ -28,7 +28,7 @@ import org.junit.Test; import org.mockito.Mockito; import io.vertx.core.Context; -import io.vertx.core.Future; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.json.JsonObject; import mockit.Expectations; @@ -60,11 +60,11 @@ public class TestHighwayVerticle { highwayVerticle.init(vertx, context); @SuppressWarnings("unchecked") - Future<Void> startFuture = Mockito.mock(Future.class); - highwayVerticle.startListen(startFuture); + Promise<Void> startPromise = Mockito.mock(Promise.class); + highwayVerticle.startListen(startPromise); MockUtil.getInstance().mockHighwayConfig(); try { - highwayVerticle.startListen(startFuture); + highwayVerticle.startListen(startPromise); assertTrue(true); } catch (Exception e) { Assert.fail(); diff --git a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java index 756ce18..20fd784 100644 --- a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java +++ b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java @@ -114,18 +114,6 @@ public class RestClientInvocation { getLocalAddress(), ipPort.getSocketAddress(), e); throwableHandler.handle(e); }); - clientRequest.connectionHandler(connection -> { - LOGGER.debug("http connection connected, local:{}, remote:{}.", - connection.localAddress(), connection.remoteAddress()); - connection.closeHandler(v -> - LOGGER.debug("http connection closed, local:{}, remote:{}.", - connection.localAddress(), connection.remoteAddress()) - ); - connection.exceptionHandler(e -> - LOGGER.info("http connection exception, local:{}, remote:{}.", - connection.localAddress(), connection.remoteAddress(), e) - ); - }); // 从业务线程转移到网络线程中去发送 invocation.getInvocationStageTrace().startSend(); diff --git a/transports/transport-rest/transport-rest-client/src/test/java/org/apache/servicecomb/transport/rest/client/http/TestDefaultHttpClientFilter.java b/transports/transport-rest/transport-rest-client/src/test/java/org/apache/servicecomb/transport/rest/client/http/TestDefaultHttpClientFilter.java index f8d0a04..84ed552 100644 --- a/transports/transport-rest/transport-rest-client/src/test/java/org/apache/servicecomb/transport/rest/client/http/TestDefaultHttpClientFilter.java +++ b/transports/transport-rest/transport-rest-client/src/test/java/org/apache/servicecomb/transport/rest/client/http/TestDefaultHttpClientFilter.java @@ -46,7 +46,6 @@ import com.fasterxml.jackson.databind.type.SimpleType; import io.vertx.core.MultiMap; import io.vertx.core.buffer.Buffer; import io.vertx.core.buffer.impl.BufferImpl; -import io.vertx.core.http.CaseInsensitiveHeaders; import mockit.Expectations; import mockit.Injectable; import mockit.Mock; @@ -161,7 +160,8 @@ public class TestDefaultHttpClientFilter { Assert.assertEquals( "InvocationException: code=400;msg=CommonExceptionData [message=method null, path null, statusCode 400, reasonPhrase null, response content-type null is not supported]", invocationException.getMessage()); - Assert.assertEquals("Unrecognized token 'abc': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n" + Assert.assertEquals( + "Unrecognized token 'abc': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n" + " at [Source: (org.apache.servicecomb.foundation.vertx.stream.BufferInputStream); line: 1, column: 7]", invocationException.getCause().getMessage()); Assert.assertEquals(CommonExceptionData.class, invocationException.getErrorData().getClass()); @@ -209,7 +209,8 @@ public class TestDefaultHttpClientFilter { Assert.assertEquals( "InvocationException: code=400;msg=CommonExceptionData [message=method null, path null, statusCode 200, reasonPhrase null, response content-type null is not supported]", invocationException.getMessage()); - Assert.assertEquals("Unrecognized token 'abc': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n" + Assert.assertEquals( + "Unrecognized token 'abc': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n" + " at [Source: (org.apache.servicecomb.foundation.vertx.stream.BufferInputStream); line: 1, column: 7]", invocationException.getCause().getMessage()); Assert.assertEquals(CommonExceptionData.class, invocationException.getErrorData().getClass()); @@ -266,7 +267,7 @@ public class TestDefaultHttpClientFilter { @Mocked ResponseMeta responseMeta, @Mocked RestOperationMeta swaggerRestOperation, @Mocked ProduceProcessor produceProcessor) throws Exception { - MultiMap responseHeader = new CaseInsensitiveHeaders(); + MultiMap responseHeader = MultiMap.caseInsensitiveMultiMap(); responseHeader.add("b", "bValue"); Object decodedResult = new Object(); diff --git a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java index 1047464..6ac5235 100644 --- a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java +++ b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java @@ -47,8 +47,8 @@ import com.netflix.config.DynamicPropertyFactory; import io.vertx.core.AbstractVerticle; import io.vertx.core.Context; -import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.http.Http2Settings; import io.vertx.core.http.HttpMethod; @@ -76,16 +76,14 @@ public class RestServerVerticle extends AbstractVerticle { this.endpointObject = (URIEndpointObject) endpoint.getAddress(); } - @SuppressWarnings("deprecation") - // TODO: vert.x 3.8.3 does not update startListen to promise, so we keep use deprecated API now. update in newer version. @Override - public void start(Future<Void> startFuture) throws Exception { + public void start(Promise<Void> startPromise) throws Exception { try { super.start(); // 如果本地未配置地址,则表示不必监听,只需要作为客户端使用即可 if (endpointObject == null) { LOGGER.warn("rest listen address is not configured, will not start."); - startFuture.complete(); + startPromise.complete(); return; } Router mainRouter = Router.router(vertx); @@ -114,7 +112,7 @@ public class RestServerVerticle extends AbstractVerticle { LOGGER.error("Unexpected error in server.{}", ExceptionUtils.getExceptionMessageWithoutTrace(e)); } }); - startListen(httpServer, startFuture); + startListen(httpServer, startPromise); } catch (Throwable e) { // vert.x got some states that not print error and execute call back in VertexUtils.blockDeploy, we add a log our self. LOGGER.error("", e); @@ -214,15 +212,13 @@ public class RestServerVerticle extends AbstractVerticle { } } - @SuppressWarnings("deprecation") - // TODO: vert.x 3.8.3 does not update startListen to promise, so we keep use deprecated API now. update in newer version. - private void startListen(HttpServer server, Future<Void> startFuture) { + private void startListen(HttpServer server, Promise<Void> startPromise) { server.listen(endpointObject.getPort(), endpointObject.getHostOrIp(), ar -> { if (ar.succeeded()) { LOGGER.info("rest listen success. address={}:{}", endpointObject.getHostOrIp(), ar.result().actualPort()); - startFuture.complete(); + startPromise.complete(); return; } @@ -230,7 +226,7 @@ public class RestServerVerticle extends AbstractVerticle { endpointObject.getHostOrIp(), endpointObject.getPort()); LOGGER.error(msg, ar.cause()); - startFuture.fail(ar.cause()); + startPromise.fail(ar.cause()); }); } diff --git a/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java b/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java index 5808aa5..306df2f 100644 --- a/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java +++ b/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java @@ -38,8 +38,8 @@ import org.junit.Test; import org.mockito.Mockito; import io.vertx.core.Context; -import io.vertx.core.Future; import io.vertx.core.Handler; +import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServerResponse; @@ -58,14 +58,12 @@ public class TestRestServerVerticle { private RestServerVerticle instance = null; - Future<Void> startFuture = null; + Promise<Void> startPromise = null; @Before - @SuppressWarnings("deprecation") - // TODO: vert.x 3.8.3 does not update startListen to promise, so we keep use deprecated API now. update in newer version. public void setUp() { instance = new RestServerVerticle(); - startFuture = Future.future(); + startPromise = Promise.promise(); CseContext.getInstance().setTransportManager(new TransportManager()); } @@ -73,13 +71,13 @@ public class TestRestServerVerticle { @After public void tearDown() { instance = null; - startFuture = null; + startPromise = null; } @Test public void testRestServerVerticleWithRouter(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, - @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception { + @Mocked JsonObject jsonObject, @Mocked Promise<Void> startPromise) throws Exception { URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080"); new Expectations() { { @@ -100,13 +98,13 @@ public class TestRestServerVerticle { RestServerVerticle server = new RestServerVerticle(); // process stuff done by Expectations server.init(vertx, context); - server.start(startFuture); + server.start(startPromise); } @Test public void testRestServerVerticleWithRouterSSL(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, - @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception { + @Mocked JsonObject jsonObject, @Mocked Promise<Void> startPromise) throws Exception { URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080?sslEnabled=true"); new Expectations() { { @@ -127,13 +125,13 @@ public class TestRestServerVerticle { RestServerVerticle server = new RestServerVerticle(); // process stuff done by Expectations server.init(vertx, context); - server.start(startFuture); + server.start(startPromise); } @Test public void testRestServerVerticleWithHttp2(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, - @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) { + @Mocked JsonObject jsonObject, @Mocked Promise<Void> startPromise) { URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080?protocol=http2"); new Expectations() { { @@ -155,7 +153,7 @@ public class TestRestServerVerticle { boolean status = false; try { server.init(vertx, context); - server.start(startFuture); + server.start(startPromise); } catch (Exception e) { status = true; } @@ -166,7 +164,7 @@ public class TestRestServerVerticle { public void testStartFutureAddressEmpty() { boolean status = false; try { - instance.start(startFuture); + instance.start(startPromise); } catch (Exception ex) { status = true; } @@ -179,7 +177,7 @@ public class TestRestServerVerticle { MockForRestServerVerticle.getInstance().mockTransportConfig(); MockForRestServerVerticle.getInstance().mockRestServerVerticle(); try { - instance.start(startFuture); + instance.start(startPromise); } catch (Exception ex) { status = true; }