@Override public ServiceUnavailableException getThrownException() { return new ServiceUnavailableException(msg + " correlationId=" + correlationId); } }
private UnaryOperator<Exception> serviceUnavailable() { return e -> new ServiceUnavailableException("Failed to submit remote invocation task", e); }
return HystrixResult.exception(new ServiceUnavailableException(String.format("cause=%s service=%s executionTime=%s", Objects.toString(cause), getCommandKey().name(), getExecutionTimeInMilliseconds())));
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { T target = this.target; if (target == null) { throw new ServiceUnavailableException("Proxy not bound to a type=" + type.getName() + ". " + "Call AstrixRule.registerProvider to register a provider for the given bean"); } return ReflectionUtil.invokeMethod(method, target, args); } }
@Override public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { try { return ReflectionUtil.invokeMethod(method, gigaSpace, args); } catch (SpaceCacheException e) { throw new ServiceUnavailableException("SpaceCacheNotAvailable", e); } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getDeclaringClass().equals(StatefulAstrixBean.class)) { try { return method.invoke(this, args); } catch (InvocationTargetException e) { throw e.getCause(); } } if (method.getDeclaringClass().equals(Object.class)) { return method.invoke(this, args); } if (!this.available.get()) { throw new ServiceUnavailableException("Service is explicitly set in unavailable state"); } return this.currentState.invoke(proxy, method, args); }
private ClusterMember getTargetMember(RoutingKey routingKey) { int targetPartition = routingKey.hashCode() % partitionCount(); ClusterMember target = this.clusterMembers.get(targetPartition); if (target == null) { throw new ServiceUnavailableException("Failed to find cluster member with id: " + targetPartition); } return target; }
return new ServiceUnavailableException(String.format("cause=%s service=%s", "REJECTED_EXECUTION", getCommandKey().name())); return new ServiceUnavailableException(String.format("cause=%s service=%s executionTime=%s", "TIMEOUT", getCommandKey().name(), getExecutionTimeInMilliseconds())); return new ServiceUnavailableException(String.format("cause=%s service=%s", "SHORT_CIRCUITED", getCommandKey().name())); appendStackTrace(result, new ServiceUnavailableException(String.format("service=%s", getCommandKey().name()))); return result; return new ServiceUnavailableException(String.format("cause=%s service=%s", "UNKNOWN", getCommandKey().name())); return Observable.error(new ServiceUnavailableException(e.getFailureType().toString()));
private ServiceUnavailableException createServiceUnavailableException() { if (isResponseRejected()) { return new ServiceUnavailableException(String.format("cause=%s service=%s", "REJECTED_EXECUTION", getCommandKey().name())); } if (isResponseTimedOut()) { return new ServiceUnavailableException(String.format("cause=%s service=%s executionTime=%s", "TIMEOUT", getCommandKey().name(), getExecutionTimeInMilliseconds())); } if (isResponseShortCircuited()) { return new ServiceUnavailableException(String.format("cause=%s service=%s", "SHORT_CIRCUITED", getCommandKey().name())); } if (isFailedExecution() && (getFailedExecutionException() instanceof ServiceUnavailableException)) { ServiceUnavailableException result = (ServiceUnavailableException) getFailedExecutionException(); appendStackTrace(result, new ServiceUnavailableException(String.format("service=%s", getCommandKey().name()))); return result; } return new ServiceUnavailableException(String.format("cause=%s service=%s", "UNKNOWN", getCommandKey().name())); } }.observe(); // Eagerly start execution of underlying observable to fulfill contract of BeanProxy.proxyAsyncInvocation
@Override protected HystrixResult<T> getFallback() { // getFallback is only invoked when the underlying api threw an ServiceUnavailableException, or the // when the invocation reached timeout. In any case, treat this as service unavailable. String cause = resolveUnavailableCause(); log.info(String.format("Aborted command execution: cause=%s circuit=%s", cause, this.getCommandKey().name())); if (isFailedExecution()) { // Underlying service threw ServiceUnavailableException return HystrixResult.exception(getFailedExecutionException()); } // Timeout or rejected in queue return HystrixResult.exception(new ServiceUnavailableException(String.format("cause=%s service=%s executionTime=%s", Objects.toString(cause), getCommandKey().name(), getExecutionTimeInMilliseconds()))); }
protected T execute() throws Throwable { HystrixCommand<HystrixResult<T>> command = createHystrixCommand(); HystrixResult<T> result; try { result = command.execute(); } catch (HystrixRuntimeException e) { // TODO: Add unit test for this case e.printStackTrace(); throw new ServiceUnavailableException(e.getFailureType().toString()); } throwExceptionIfExecutionFailed(result); return result.getResult(); }