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

[incubator-servicecomb-java-chassis] branch master updated (5ae1e63 -> f6da714)

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

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


    from 5ae1e63  SCB-146 Upgarded Zipkin Brave to 4.13.1
     new 89a4788  SCB-126 add consumer event trigger to collect InvocationType.CONSUMER data
     new 8f2d6cc  SCB-126 change event trigger from client to InvokerUtils
     new 858a0d7  SCB-126 remove useless code
     new 72399e9  SCB-126 fix ci failed
     new f6da714  SCB-126 fix pr comment

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/java/io/servicecomb/core/Invocation.java  |  4 ++--
 .../core/metrics/InvocationFinishedEvent.java      |  5 +----
 .../metrics/InvocationStartProcessingEvent.java    |  5 +----
 .../core/provider/consumer/InvokerUtils.java       | 22 +++++++++++++++++++++-
 .../metrics/core/TestEventAndRunner.java           | 14 +++++++-------
 metrics/pom.xml                                    |  1 -
 .../transport/highway/HighwayClient.java           |  4 ++--
 7 files changed, 34 insertions(+), 21 deletions(-)

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

[incubator-servicecomb-java-chassis] 03/05: SCB-126 remove useless code

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 858a0d7c3e225f09d09aedd64a7bb6c243576591
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Wed Dec 27 16:10:42 2017 +0800

    SCB-126 remove useless code
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../java/io/servicecomb/core/metrics/InvocationFinishedEvent.java    | 5 +----
 .../io/servicecomb/core/metrics/InvocationStartProcessingEvent.java  | 5 +----
 metrics/pom.xml                                                      | 1 -
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/core/src/main/java/io/servicecomb/core/metrics/InvocationFinishedEvent.java b/core/src/main/java/io/servicecomb/core/metrics/InvocationFinishedEvent.java
index 077e9a8..a1a5f8c 100644
--- a/core/src/main/java/io/servicecomb/core/metrics/InvocationFinishedEvent.java
+++ b/core/src/main/java/io/servicecomb/core/metrics/InvocationFinishedEvent.java
@@ -25,8 +25,6 @@ public class InvocationFinishedEvent implements Event {
 
   private final InvocationType invocationType;
 
-  private final long finishedTime;
-
   private final long processElapsedNanoTime;
 
   private final long totalElapsedNanoTime;
@@ -47,12 +45,11 @@ public class InvocationFinishedEvent implements Event {
     return totalElapsedNanoTime;
   }
 
-  public InvocationFinishedEvent(String operationName, InvocationType invocationType, long finishedTime,
+  public InvocationFinishedEvent(String operationName, InvocationType invocationType,
       long processElapsedNanoTime,
       long totalElapsedNanoTime) {
     this.operationName = operationName;
     this.invocationType = invocationType;
-    this.finishedTime = finishedTime;
     this.processElapsedNanoTime = processElapsedNanoTime;
     this.totalElapsedNanoTime = totalElapsedNanoTime;
   }
diff --git a/core/src/main/java/io/servicecomb/core/metrics/InvocationStartProcessingEvent.java b/core/src/main/java/io/servicecomb/core/metrics/InvocationStartProcessingEvent.java
index 9f8ec94..133d02a 100644
--- a/core/src/main/java/io/servicecomb/core/metrics/InvocationStartProcessingEvent.java
+++ b/core/src/main/java/io/servicecomb/core/metrics/InvocationStartProcessingEvent.java
@@ -25,8 +25,6 @@ public class InvocationStartProcessingEvent implements Event {
 
   private final InvocationType invocationType;
 
-  private final long startProcessingTime;
-
   private final long inQueueNanoTime;
 
   public String getOperationName() {
@@ -41,11 +39,10 @@ public class InvocationStartProcessingEvent implements Event {
     return inQueueNanoTime;
   }
 
-  public InvocationStartProcessingEvent(String operationName, InvocationType invocationType, long startProcessingTime,
+  public InvocationStartProcessingEvent(String operationName, InvocationType invocationType,
       long inQueueNanoTime) {
     this.operationName = operationName;
     this.invocationType = invocationType;
-    this.startProcessingTime = startProcessingTime;
     this.inQueueNanoTime = inQueueNanoTime;
   }
 }
diff --git a/metrics/pom.xml b/metrics/pom.xml
index 80e53d3..8ff8394 100644
--- a/metrics/pom.xml
+++ b/metrics/pom.xml
@@ -28,7 +28,6 @@
   </parent>
 
   <artifactId>metrics</artifactId>
-  <version>0.6.0-SNAPSHOT</version>
 
   <modules>
     <module>metrics-core</module>

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

[incubator-servicecomb-java-chassis] 05/05: SCB-126 fix pr comment

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f6da71462c5b909df55391116b6a6906ed46ff62
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Mon Jan 1 11:30:47 2018 +0800

    SCB-126 fix pr comment
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../io/servicecomb/core/provider/consumer/InvokerUtils.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java b/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java
index 3005ce1..3a9b310 100644
--- a/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java
+++ b/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java
@@ -87,12 +87,16 @@ public final class InvokerUtils {
       ReactiveResponseExecutor respExecutor = new ReactiveResponseExecutor();
       invocation.setResponseExecutor(respExecutor);
 
-      invocation.next(asyncResp);
+      AsyncResponse wrappedAsyncResponse = response -> {
+        invocation.triggerFinishedEvent();
+        asyncResp.handle(response);
+      };
+
+      invocation.next(wrappedAsyncResponse);
     } catch (Throwable e) {
+      invocation.triggerFinishedEvent();
       LOGGER.error("invoke failed, {}", invocation.getOperationMeta().getMicroserviceQualifiedName());
       asyncResp.consumerFail(e);
-    } finally {
-      invocation.triggerFinishedEvent();
     }
   }
 

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

[incubator-servicecomb-java-chassis] 02/05: SCB-126 change event trigger from client to InvokerUtils

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8f2d6cce7a4a7df17e35eedc17b5f3bbdd312abf
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Wed Dec 27 13:05:23 2017 +0800

    SCB-126 change event trigger from client to InvokerUtils
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../core/provider/consumer/InvokerUtils.java       | 16 +++++++
 .../transport/highway/HighwayClient.java           | 49 +++++++++-------------
 .../rest/client/http/VertxHttpMethod.java          | 10 -----
 3 files changed, 36 insertions(+), 39 deletions(-)

diff --git a/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java b/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java
index c142493..3005ce1 100644
--- a/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java
+++ b/core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java
@@ -23,7 +23,10 @@ import org.slf4j.LoggerFactory;
 import io.servicecomb.core.Invocation;
 import io.servicecomb.core.definition.SchemaMeta;
 import io.servicecomb.core.invocation.InvocationFactory;
+import io.servicecomb.core.metrics.InvocationStartedEvent;
+import io.servicecomb.foundation.common.utils.EventUtils;
 import io.servicecomb.swagger.invocation.AsyncResponse;
+import io.servicecomb.swagger.invocation.InvocationType;
 import io.servicecomb.swagger.invocation.Response;
 import io.servicecomb.swagger.invocation.exception.ExceptionFactory;
 import io.servicecomb.swagger.invocation.exception.InvocationException;
@@ -61,6 +64,7 @@ public final class InvokerUtils {
 
   public static Response innerSyncInvoke(Invocation invocation) {
     try {
+      triggerStartedEvent(invocation);
       SyncResponseExecutor respExecutor = new SyncResponseExecutor();
       invocation.setResponseExecutor(respExecutor);
 
@@ -72,11 +76,14 @@ public final class InvokerUtils {
           String.format("invoke failed, %s", invocation.getOperationMeta().getMicroserviceQualifiedName());
       LOGGER.debug(msg, e);
       return Response.createConsumerFail(e);
+    } finally {
+      invocation.triggerFinishedEvent();
     }
   }
 
   public static void reactiveInvoke(Invocation invocation, AsyncResponse asyncResp) {
     try {
+      triggerStartedEvent(invocation);
       ReactiveResponseExecutor respExecutor = new ReactiveResponseExecutor();
       invocation.setResponseExecutor(respExecutor);
 
@@ -84,6 +91,8 @@ public final class InvokerUtils {
     } catch (Throwable e) {
       LOGGER.error("invoke failed, {}", invocation.getOperationMeta().getMicroserviceQualifiedName());
       asyncResp.consumerFail(e);
+    } finally {
+      invocation.triggerFinishedEvent();
     }
   }
 
@@ -91,4 +100,11 @@ public final class InvokerUtils {
   public static Object invoke(Invocation invocation) {
     return syncInvoke(invocation);
   }
+
+  private static void triggerStartedEvent(Invocation invocation) {
+    long startTime = System.nanoTime();
+    EventUtils.triggerEvent(new InvocationStartedEvent(invocation.getMicroserviceQualifiedName(),
+        InvocationType.CONSUMER, startTime));
+    invocation.setStartTime(startTime);
+  }
 }
diff --git a/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java b/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java
index 967fc1f..a2be8f2 100644
--- a/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java
+++ b/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java
@@ -26,9 +26,7 @@ import io.servicecomb.codec.protobuf.definition.OperationProtobuf;
 import io.servicecomb.codec.protobuf.definition.ProtobufManager;
 import io.servicecomb.core.Invocation;
 import io.servicecomb.core.definition.OperationMeta;
-import io.servicecomb.core.metrics.InvocationStartedEvent;
 import io.servicecomb.core.transport.AbstractTransport;
-import io.servicecomb.foundation.common.utils.EventUtils;
 import io.servicecomb.foundation.ssl.SSLCustom;
 import io.servicecomb.foundation.ssl.SSLOption;
 import io.servicecomb.foundation.ssl.SSLOptionFactory;
@@ -37,7 +35,6 @@ import io.servicecomb.foundation.vertx.VertxUtils;
 import io.servicecomb.foundation.vertx.client.ClientPoolManager;
 import io.servicecomb.foundation.vertx.client.tcp.TcpClientConfig;
 import io.servicecomb.swagger.invocation.AsyncResponse;
-import io.servicecomb.swagger.invocation.InvocationType;
 import io.servicecomb.swagger.invocation.Response;
 import io.vertx.core.DeploymentOptions;
 import io.vertx.core.Vertx;
@@ -69,7 +66,11 @@ public class HighwayClient {
   private TcpClientConfig createTcpClientConfig() {
     TcpClientConfig tcpClientConfig = new TcpClientConfig();
     DynamicLongProperty prop = AbstractTransport.getRequestTimeoutProperty();
-    prop.addCallback(() -> tcpClientConfig.setRequestTimeoutMillis(prop.get()));
+    prop.addCallback(new Runnable() {
+      public void run() {
+        tcpClientConfig.setRequestTimeoutMillis(prop.get());
+      }
+    });
     tcpClientConfig.setRequestTimeoutMillis(prop.get());
 
     if (this.sslEnabled) {
@@ -88,12 +89,6 @@ public class HighwayClient {
   }
 
   public void send(Invocation invocation, AsyncResponse asyncResp) throws Exception {
-
-    long startTime = System.nanoTime();
-    EventUtils.triggerEvent(new InvocationStartedEvent(invocation.getMicroserviceQualifiedName(),
-        InvocationType.CONSUMER, startTime));
-    invocation.setStartTime(startTime);
-
     HighwayClientConnectionPool tcpClientPool = clientMgr.findThreadBindClientPool();
 
     OperationMeta operationMeta = invocation.getOperationMeta();
@@ -105,26 +100,22 @@ public class HighwayClient {
     tcpClientPool.send(tcpClient, clientPackage, ar -> {
       // 此时是在网络线程中,转换线程
       invocation.getResponseExecutor().execute(() -> {
+        if (ar.failed()) {
+          // 只会是本地异常
+          asyncResp.consumerFail(ar.cause());
+          return;
+        }
+
+        // 处理应答
         try {
-          if (ar.failed()) {
-            // 只会是本地异常
-            asyncResp.consumerFail(ar.cause());
-            return;
-          }
-
-          // 处理应答
-          try {
-            Response response =
-                HighwayCodec.decodeResponse(invocation,
-                    operationProtobuf,
-                    ar.result(),
-                    tcpClient.getProtobufFeature());
-            asyncResp.complete(response);
-          } catch (Throwable e) {
-            asyncResp.consumerFail(e);
-          }
-        } finally {
-          invocation.triggerFinishedEvent();
+          Response response =
+              HighwayCodec.decodeResponse(invocation,
+                  operationProtobuf,
+                  ar.result(),
+                  tcpClient.getProtobufFeature());
+          asyncResp.complete(response);
+        } catch (Throwable e) {
+          asyncResp.consumerFail(e);
         }
       });
     });
diff --git a/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java b/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java
index c15866e..b432cc8 100644
--- a/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java
+++ b/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java
@@ -30,11 +30,9 @@ import io.servicecomb.common.rest.definition.RestOperationMeta;
 import io.servicecomb.common.rest.filter.HttpClientFilter;
 import io.servicecomb.core.Invocation;
 import io.servicecomb.core.definition.OperationMeta;
-import io.servicecomb.core.metrics.InvocationStartedEvent;
 import io.servicecomb.core.transport.AbstractTransport;
 import io.servicecomb.foundation.common.net.IpPort;
 import io.servicecomb.foundation.common.net.URIEndpointObject;
-import io.servicecomb.foundation.common.utils.EventUtils;
 import io.servicecomb.foundation.common.utils.JsonUtils;
 import io.servicecomb.foundation.common.utils.SPIServiceUtils;
 import io.servicecomb.foundation.vertx.client.http.HttpClientWithContext;
@@ -44,7 +42,6 @@ import io.servicecomb.foundation.vertx.http.VertxClientRequestToHttpServletReque
 import io.servicecomb.foundation.vertx.http.VertxClientResponseToHttpServletResponse;
 import io.servicecomb.serviceregistry.api.Const;
 import io.servicecomb.swagger.invocation.AsyncResponse;
-import io.servicecomb.swagger.invocation.InvocationType;
 import io.servicecomb.swagger.invocation.Response;
 import io.vertx.core.buffer.Buffer;
 import io.vertx.core.http.HttpClient;
@@ -70,11 +67,6 @@ public class VertxHttpMethod {
     OperationMeta operationMeta = invocation.getOperationMeta();
     RestOperationMeta swaggerRestOperation = operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
 
-    long startTime = System.nanoTime();
-    EventUtils.triggerEvent(new InvocationStartedEvent(invocation.getMicroserviceQualifiedName(),
-        InvocationType.CONSUMER, startTime));
-    invocation.setStartTime(startTime);
-
     String path = this.createRequestPath(invocation, swaggerRestOperation);
     IpPort ipPort = (IpPort) invocation.getEndpoint().getAddress();
 
@@ -155,8 +147,6 @@ public class VertxHttpMethod {
           }
         } catch (Throwable e) {
           asyncResp.fail(invocation.getInvocationType(), e);
-        } finally {
-          invocation.triggerFinishedEvent();
         }
       });
     });

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

[incubator-servicecomb-java-chassis] 01/05: SCB-126 add consumer event trigger to collect InvocationType.CONSUMER data

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 89a4788136fa06c1a54bf2bf7e77fbdad3cd75ce
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Wed Dec 27 10:04:25 2017 +0800

    SCB-126 add consumer event trigger to collect InvocationType.CONSUMER data
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../transport/highway/HighwayClient.java           | 49 +++++++++++++---------
 .../rest/client/http/VertxHttpMethod.java          | 10 +++++
 2 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java b/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java
index b58e5e6..967fc1f 100644
--- a/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java
+++ b/transports/transport-highway/src/main/java/io/servicecomb/transport/highway/HighwayClient.java
@@ -26,7 +26,9 @@ import io.servicecomb.codec.protobuf.definition.OperationProtobuf;
 import io.servicecomb.codec.protobuf.definition.ProtobufManager;
 import io.servicecomb.core.Invocation;
 import io.servicecomb.core.definition.OperationMeta;
+import io.servicecomb.core.metrics.InvocationStartedEvent;
 import io.servicecomb.core.transport.AbstractTransport;
+import io.servicecomb.foundation.common.utils.EventUtils;
 import io.servicecomb.foundation.ssl.SSLCustom;
 import io.servicecomb.foundation.ssl.SSLOption;
 import io.servicecomb.foundation.ssl.SSLOptionFactory;
@@ -35,6 +37,7 @@ import io.servicecomb.foundation.vertx.VertxUtils;
 import io.servicecomb.foundation.vertx.client.ClientPoolManager;
 import io.servicecomb.foundation.vertx.client.tcp.TcpClientConfig;
 import io.servicecomb.swagger.invocation.AsyncResponse;
+import io.servicecomb.swagger.invocation.InvocationType;
 import io.servicecomb.swagger.invocation.Response;
 import io.vertx.core.DeploymentOptions;
 import io.vertx.core.Vertx;
@@ -66,11 +69,7 @@ public class HighwayClient {
   private TcpClientConfig createTcpClientConfig() {
     TcpClientConfig tcpClientConfig = new TcpClientConfig();
     DynamicLongProperty prop = AbstractTransport.getRequestTimeoutProperty();
-    prop.addCallback(new Runnable(){
-      public void run(){
-        tcpClientConfig.setRequestTimeoutMillis(prop.get());
-      }
-    });
+    prop.addCallback(() -> tcpClientConfig.setRequestTimeoutMillis(prop.get()));
     tcpClientConfig.setRequestTimeoutMillis(prop.get());
 
     if (this.sslEnabled) {
@@ -89,6 +88,12 @@ public class HighwayClient {
   }
 
   public void send(Invocation invocation, AsyncResponse asyncResp) throws Exception {
+
+    long startTime = System.nanoTime();
+    EventUtils.triggerEvent(new InvocationStartedEvent(invocation.getMicroserviceQualifiedName(),
+        InvocationType.CONSUMER, startTime));
+    invocation.setStartTime(startTime);
+
     HighwayClientConnectionPool tcpClientPool = clientMgr.findThreadBindClientPool();
 
     OperationMeta operationMeta = invocation.getOperationMeta();
@@ -100,22 +105,26 @@ public class HighwayClient {
     tcpClientPool.send(tcpClient, clientPackage, ar -> {
       // 此时是在网络线程中,转换线程
       invocation.getResponseExecutor().execute(() -> {
-        if (ar.failed()) {
-          // 只会是本地异常
-          asyncResp.consumerFail(ar.cause());
-          return;
-        }
-
-        // 处理应答
         try {
-          Response response =
-              HighwayCodec.decodeResponse(invocation,
-                  operationProtobuf,
-                  ar.result(),
-                  tcpClient.getProtobufFeature());
-          asyncResp.complete(response);
-        } catch (Throwable e) {
-          asyncResp.consumerFail(e);
+          if (ar.failed()) {
+            // 只会是本地异常
+            asyncResp.consumerFail(ar.cause());
+            return;
+          }
+
+          // 处理应答
+          try {
+            Response response =
+                HighwayCodec.decodeResponse(invocation,
+                    operationProtobuf,
+                    ar.result(),
+                    tcpClient.getProtobufFeature());
+            asyncResp.complete(response);
+          } catch (Throwable e) {
+            asyncResp.consumerFail(e);
+          }
+        } finally {
+          invocation.triggerFinishedEvent();
         }
       });
     });
diff --git a/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java b/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java
index b432cc8..c15866e 100644
--- a/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java
+++ b/transports/transport-rest/transport-rest-client/src/main/java/io/servicecomb/transport/rest/client/http/VertxHttpMethod.java
@@ -30,9 +30,11 @@ import io.servicecomb.common.rest.definition.RestOperationMeta;
 import io.servicecomb.common.rest.filter.HttpClientFilter;
 import io.servicecomb.core.Invocation;
 import io.servicecomb.core.definition.OperationMeta;
+import io.servicecomb.core.metrics.InvocationStartedEvent;
 import io.servicecomb.core.transport.AbstractTransport;
 import io.servicecomb.foundation.common.net.IpPort;
 import io.servicecomb.foundation.common.net.URIEndpointObject;
+import io.servicecomb.foundation.common.utils.EventUtils;
 import io.servicecomb.foundation.common.utils.JsonUtils;
 import io.servicecomb.foundation.common.utils.SPIServiceUtils;
 import io.servicecomb.foundation.vertx.client.http.HttpClientWithContext;
@@ -42,6 +44,7 @@ import io.servicecomb.foundation.vertx.http.VertxClientRequestToHttpServletReque
 import io.servicecomb.foundation.vertx.http.VertxClientResponseToHttpServletResponse;
 import io.servicecomb.serviceregistry.api.Const;
 import io.servicecomb.swagger.invocation.AsyncResponse;
+import io.servicecomb.swagger.invocation.InvocationType;
 import io.servicecomb.swagger.invocation.Response;
 import io.vertx.core.buffer.Buffer;
 import io.vertx.core.http.HttpClient;
@@ -67,6 +70,11 @@ public class VertxHttpMethod {
     OperationMeta operationMeta = invocation.getOperationMeta();
     RestOperationMeta swaggerRestOperation = operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
 
+    long startTime = System.nanoTime();
+    EventUtils.triggerEvent(new InvocationStartedEvent(invocation.getMicroserviceQualifiedName(),
+        InvocationType.CONSUMER, startTime));
+    invocation.setStartTime(startTime);
+
     String path = this.createRequestPath(invocation, swaggerRestOperation);
     IpPort ipPort = (IpPort) invocation.getEndpoint().getAddress();
 
@@ -147,6 +155,8 @@ public class VertxHttpMethod {
           }
         } catch (Throwable e) {
           asyncResp.fail(invocation.getInvocationType(), e);
+        } finally {
+          invocation.triggerFinishedEvent();
         }
       });
     });

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

[incubator-servicecomb-java-chassis] 04/05: SCB-126 fix ci failed

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 72399e9c39bbb1774a6fd9f286670992db4c224a
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Wed Dec 27 17:35:38 2017 +0800

    SCB-126 fix ci failed
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 core/src/main/java/io/servicecomb/core/Invocation.java     |  4 ++--
 .../io/servicecomb/metrics/core/TestEventAndRunner.java    | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/core/src/main/java/io/servicecomb/core/Invocation.java b/core/src/main/java/io/servicecomb/core/Invocation.java
index ec9abe6..40a79d1 100644
--- a/core/src/main/java/io/servicecomb/core/Invocation.java
+++ b/core/src/main/java/io/servicecomb/core/Invocation.java
@@ -197,14 +197,14 @@ public class Invocation extends SwaggerInvocation {
   public void triggerStartProcessingEvent() {
     this.startProcessingTime = System.nanoTime();
     EventUtils.triggerEvent(new InvocationStartProcessingEvent(
-        operationMeta.getMicroserviceQualifiedName(),this.invocationType, startProcessingTime, startProcessingTime - startTime));
+        operationMeta.getMicroserviceQualifiedName(), this.invocationType, startProcessingTime - startTime));
   }
 
   public void triggerFinishedEvent() {
     long finishedTime = System.nanoTime();
     EventUtils
         .triggerEvent(new InvocationFinishedEvent(operationMeta.getMicroserviceQualifiedName(),
-            this.invocationType, finishedTime, finishedTime - startProcessingTime,
+            this.invocationType, finishedTime - startProcessingTime,
             finishedTime - startTime));
   }
 }
diff --git a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java
index d9a7e2b..63d2275 100644
--- a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java
+++ b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java
@@ -77,33 +77,33 @@ public class TestEventAndRunner {
     //fun1 is a PRODUCER invocation call twice and all is completed
     EventUtils.triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
     EventUtils.triggerEvent(
-        new InvocationStartProcessingEvent("fun1", InvocationType.PRODUCER, System.nanoTime(),
+        new InvocationStartProcessingEvent("fun1", InvocationType.PRODUCER,
             TimeUnit.MILLISECONDS.toNanos(100)));
     EventUtils
-        .triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, System.nanoTime(),
+        .triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER,
             TimeUnit.MILLISECONDS.toNanos(200), TimeUnit.MILLISECONDS.toNanos(300)));
 
     EventUtils.triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
     EventUtils.triggerEvent(
-        new InvocationStartProcessingEvent("fun1", InvocationType.PRODUCER, System.nanoTime(),
+        new InvocationStartProcessingEvent("fun1", InvocationType.PRODUCER,
             TimeUnit.MILLISECONDS.toNanos(300)));
     EventUtils
-        .triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, System.nanoTime(),
+        .triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER,
             TimeUnit.MILLISECONDS.toNanos(400), TimeUnit.MILLISECONDS.toNanos(700)));
 
     //fun3 is a PRODUCER invocation call uncompleted
     EventUtils.triggerEvent(new InvocationStartedEvent("fun3", InvocationType.PRODUCER, System.nanoTime()));
     EventUtils.triggerEvent(
-        new InvocationStartProcessingEvent("fun3", InvocationType.PRODUCER, System.nanoTime(),
+        new InvocationStartProcessingEvent("fun3", InvocationType.PRODUCER,
             TimeUnit.MILLISECONDS.toNanos(500)));
 
     //fun2 is a CONSUMER invocation call once and completed
     EventUtils.triggerEvent(new InvocationStartedEvent("fun2", InvocationType.CONSUMER, System.nanoTime()));
     EventUtils.triggerEvent(
-        new InvocationStartProcessingEvent("fun2", InvocationType.CONSUMER, System.nanoTime(),
+        new InvocationStartProcessingEvent("fun2", InvocationType.CONSUMER,
             TimeUnit.MILLISECONDS.toNanos(100)));
     EventUtils
-        .triggerEvent(new InvocationFinishedEvent("fun2", InvocationType.CONSUMER, System.nanoTime(),
+        .triggerEvent(new InvocationFinishedEvent("fun2", InvocationType.CONSUMER,
             TimeUnit.MILLISECONDS.toNanos(200), TimeUnit.MILLISECONDS.toNanos(300)));
 
     //fun4 is a invocation call only started and no processing start and finished

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