@Override public void handle(Invocation invocation, AsyncResponse asyncResp) { HystrixObservable<Response> command = delegate.createBizkeeperCommand(invocation); Observable<Response> observable = command.toObservable(); observable.subscribe(asyncResp::complete, error -> { LOG.warn("catch error in bizkeeper:" + error.getMessage()); asyncResp.fail(invocation.getInvocationType(), error); }, () -> { }); }
@Override public Response getFallbackResponse(Invocation invocation) { return Response.failResp(invocation.getInvocationType(), BizkeeperExceptionUtils .createBizkeeperException(BizkeeperExceptionUtils.SERVICECOMB_BIZKEEPER_FALLBACK, null, invocation.getOperationMeta().getMicroserviceQualifiedName())); } }
invocationName = MeterInvocationConst.EDGE_INVOCATION_NAME; } else { invocationName = invocation.getInvocationType().name();
public static Response getFallbackResponse(String type, Throwable error, Invocation invocation) { FallbackPolicy policy = getPolicy(type, invocation); if (policy != null) { return policy.getFallbackResponse(invocation); } else { return Response.failResp(invocation.getInvocationType(), BizkeeperExceptionUtils .createBizkeeperException(BizkeeperExceptionUtils.SERVICECOMB_BIZKEEPER_FALLBACK, error, invocation.getOperationMeta().getMicroserviceQualifiedName())); } }
public void send(Invocation invocation, AsyncResponse asyncResp) { URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress(); HttpClientWithContext httpClientWithContext; if (endpoint.isHttp2Enabled()) { httpClientWithContext = findHttp2ClientPool(invocation); } else { httpClientWithContext = findHttpClientPool(invocation); } RestClientInvocation restClientInvocation = new RestClientInvocation(httpClientWithContext, httpClientFilters); try { restClientInvocation.invoke(invocation, asyncResp); } catch (Throwable e) { asyncResp.fail(invocation.getInvocationType(), e); LOGGER.error("vertx rest transport send error.", e); } }
protected void fail(Throwable e) { if (invocation.isFinished()) { return; } 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); }
@Override public void handle(Invocation invocation, AsyncResponse asyncResp) { HystrixObservable<Response> command = delegate.createBizkeeperCommand(invocation); Observable<Response> observable = command.toObservable(); observable.subscribe(asyncResp::complete, error -> { LOG.warn("catch error in bizkeeper:" + error.getMessage()); asyncResp.fail(invocation.getInvocationType(), error); }, () -> { }); }
public CircutBreakerEvent(HystrixCommandKey commandKey, Type type) { super(type); HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(commandKey); if (hystrixCommandMetrics != null) { if (hystrixCommandMetrics.getCommandGroup() instanceof CustomizeCommandGroupKey) { CustomizeCommandGroupKey customCommandGroupKey = (CustomizeCommandGroupKey) hystrixCommandMetrics.getCommandGroup(); this.microservice = customCommandGroupKey.getInstance().getMicroserviceName(); this.role = customCommandGroupKey.getInstance().getInvocationType().name(); this.schema = customCommandGroupKey.getInstance().getSchemaId(); this.operation = customCommandGroupKey.getInstance().getOperationName(); } this.currentTotalRequest = hystrixCommandMetrics.getHealthCounts().getTotalRequests(); this.currentErrorPercentage = hystrixCommandMetrics.getHealthCounts().getErrorCount(); this.currentErrorCount = hystrixCommandMetrics.getHealthCounts().getErrorPercentage(); this.requestVolumeThreshold = hystrixCommandMetrics.getProperties().circuitBreakerRequestVolumeThreshold().get(); this.sleepWindowInMilliseconds = hystrixCommandMetrics.getProperties().circuitBreakerSleepWindowInMilliseconds().get(); this.errorThresholdPercentage = hystrixCommandMetrics.getProperties().circuitBreakerErrorThresholdPercentage().get(); } }
@Override public Response getFallbackResponse(Invocation invocation) { return Response.failResp(invocation.getInvocationType(), BizkeeperExceptionUtils .createBizkeeperException(BizkeeperExceptionUtils.SERVICECOMB_BIZKEEPER_FALLBACK, null, invocation.getOperationMeta().getMicroserviceQualifiedName())); } }
invocationName = MeterInvocationConst.EDGE_INVOCATION_NAME; } else { invocationName = invocation.getInvocationType().name();
public static Response getFallbackResponse(String type, Throwable error, Invocation invocation) { FallbackPolicy policy = getPolicy(type, invocation); if (policy != null) { return policy.getFallbackResponse(invocation); } else { return Response.failResp(invocation.getInvocationType(), BizkeeperExceptionUtils .createBizkeeperException(BizkeeperExceptionUtils.SERVICECOMB_BIZKEEPER_FALLBACK, error, invocation.getOperationMeta().getMicroserviceQualifiedName())); } }
public void send(Invocation invocation, AsyncResponse asyncResp) { URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress(); HttpClientWithContext httpClientWithContext; if (endpoint.isHttp2Enabled()) { httpClientWithContext = findHttp2ClientPool(invocation); } else { httpClientWithContext = findHttpClientPool(invocation); } RestClientInvocation restClientInvocation = new RestClientInvocation(httpClientWithContext, httpClientFilters); try { restClientInvocation.invoke(invocation, asyncResp); } catch (Throwable e) { asyncResp.fail(invocation.getInvocationType(), e); LOGGER.error("vertx rest transport send error.", e); } }
protected void fail(Throwable e) { if (invocation.isFinished()) { return; } 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); }
public CircutBreakerEvent(HystrixCommandKey commandKey, Type type) { super(type); HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(commandKey); if (hystrixCommandMetrics != null) { if (hystrixCommandMetrics.getCommandGroup() instanceof CustomizeCommandGroupKey) { CustomizeCommandGroupKey customCommandGroupKey = (CustomizeCommandGroupKey) hystrixCommandMetrics.getCommandGroup(); this.microservice = customCommandGroupKey.getInstance().getMicroserviceName(); this.role = customCommandGroupKey.getInstance().getInvocationType().name(); this.schema = customCommandGroupKey.getInstance().getSchemaId(); this.operation = customCommandGroupKey.getInstance().getOperationName(); } this.currentTotalRequest = hystrixCommandMetrics.getHealthCounts().getTotalRequests(); this.currentErrorPercentage = hystrixCommandMetrics.getHealthCounts().getErrorCount(); this.currentErrorCount = hystrixCommandMetrics.getHealthCounts().getErrorPercentage(); this.requestVolumeThreshold = hystrixCommandMetrics.getProperties().circuitBreakerRequestVolumeThreshold().get(); this.sleepWindowInMilliseconds = hystrixCommandMetrics.getProperties().circuitBreakerSleepWindowInMilliseconds().get(); this.errorThresholdPercentage = hystrixCommandMetrics.getProperties().circuitBreakerErrorThresholdPercentage().get(); } }