Example usage for io.vertx.core.net.impl ConnectionBase metric

List of usage examples for io.vertx.core.net.impl ConnectionBase metric

Introduction

In this page you can find the example usage for io.vertx.core.net.impl ConnectionBase metric.

Prototype

Object metric

To view the source code for io.vertx.core.net.impl ConnectionBase metric.

Click Source Link

Usage

From source file:org.apache.servicecomb.transport.rest.client.http.RestClientInvocation.java

License:Apache License

protected void fail(Throwable e) {
    if (invocation.isFinished()) {
        return;// ww w .j  a  v  a 2s.  c o m
    }

    InvocationStageTrace stageTrace = invocation.getInvocationStageTrace();
    ConnectionBase connection = (ConnectionBase) clientRequest.connection();
    // connection maybe null when exception happens such as ssl handshake failure
    if (connection != null) {
        DefaultHttpSocketMetric httpSocketMetric = (DefaultHttpSocketMetric) connection.metric();
        stageTrace.finishGetConnection(httpSocketMetric.getRequestBeginTime());
        stageTrace.finishWriteToBuffer(httpSocketMetric.getRequestEndTime());
    }

    // even failed and did not received response, still set time for it
    // that will help to know the real timeout time
    if (stageTrace.getFinishReceiveResponse() == 0) {
        stageTrace.finishReceiveResponse();
    }
    if (stageTrace.getStartClientFiltersResponse() == 0) {
        stageTrace.startClientFiltersResponse();
    }

    stageTrace.finishClientFiltersResponse();
    asyncResp.fail(invocation.getInvocationType(), e);
}