这里会判断当前调用服务的状态，分析判断是否需要进入降级状态
如果服务在指定的时间区间内累积的错误，达到了配置的次数，则进入服务降级
如果满足上面条件，并且满足重试机制，则也不会进入降级流程，而是触发远程服务调用
@param invoker
@param invocation
@return
424874
private boolean checkNeedCircuitBreak(Invoker<?> invoker, Invocation invocation) {
        String interfaceName = invoker.getUrl().getParameter(Constants.INTERFACE_KEY);
        String method = invocation.getMethodName();
        String methodKey = Config.getMethodPropertyName(invoker, invocation).toString();
        int limit = Config.getBreakLimit(invoker, invocation);
        BreakCounter breakCounter = breakCounterMap.get(methodKey);
        if(breakCounter!=null&&breakCounter.isEnable()){
            long currentExceptionCount = breakCounter.getCurrentExceptionCount();
            long currentBreakCount = breakCounter.getCurrentBreakCount();
            logger.info("[{}] check invoke [{}.{}] circuit break,current exception count [{}]  limit [{}]", localHost, interfaceName, method, currentExceptionCount, limit);
            if(limit<=currentExceptionCount){
                if(currentBreakCount>0&&needRetry(invoker, invocation, currentBreakCount)){
                    logger.info("[{}] retry invoke [{}.{}] current break count [{}]",localHost,interfaceName,method,currentBreakCount);
                    breakCounter.incrementRetryTimes();
                    return false;
                }
                return true;
            }
        }
        return false;
    }
211167
protected Object invoke(Bindings bindings, ELContext context, Object base, Method method)
		throws InvocationTargetException, IllegalAccessException {
		Class<?>[] types = method.getParameterTypes();
		Object[] params = null;
		if (types.length > 0) {
			params = new Object[types.length];
			if (varargs && method.isVarArgs()) {
				for (int i = 0; i < params.length - 1; i++) {
					Object param = getParam(i).eval(bindings, context);
					if (param != null || types[i].isPrimitive()) {
						params[i] = bindings.convert(param, types[i]);
					}
				}
				int varargIndex = types.length - 1;
				Class<?> varargType = types[varargIndex].getComponentType();
				int length = getParamCount() - varargIndex;
				Object array = null;
				if (length == 1) { // special: eventually use argument as is
					Object param = getParam(varargIndex).eval(bindings, context);
					if (param != null && param.getClass().isArray()) {
						if (types[varargIndex].isInstance(param)) {
							array = param;
						} else { // coerce array elements
							length = Array.getLength(param);
							array = Array.newInstance(varargType, length);
							for (int i = 0; i < length; i++) {
								Object elem = Array.get(param, i);
								if (elem != null || varargType.isPrimitive()) {
									Array.set(array, i, bindings.convert(elem, varargType));
								}
							}
						}
					} else { // single element array
						array = Array.newInstance(varargType, 1);
						if (param != null || varargType.isPrimitive()) {
							Array.set(array, 0, bindings.convert(param, varargType));
						}
					}
				} else {
					array = Array.newInstance(varargType, length);
					for (int i = 0; i < length; i++) {
						Object param = getParam(varargIndex + i).eval(bindings, context);
						if (param != null || varargType.isPrimitive()) {
							Array.set(array, i, bindings.convert(param, varargType));
						}
					}
				}
				params[varargIndex] = array;
			} else {
				for (int i = 0; i < params.length; i++) {
					Object param = getParam(i).eval(bindings, context);
					if (param != null || types[i].isPrimitive()) {
						params[i] = bindings.convert(param, types[i]);
					}
				}
			}
		}
		return method.invoke(base, params);
	}
139485
@Override
  public Object invoke(Object proxy, Method method, Object[] args) /* CSOFF: IllegalThrows */
                throws Throwable /* CSON: IllegalThrows */ {
    final long startTime = System.currentTimeMillis();
    Object result = null;
    try {
      result = method.invoke(target, args);
      if ((result != null) && !method.getReturnType().equals(Void.TYPE) && method.getReturnType().isInterface()) {
        result = wrapObject(method.getReturnType(), result, reporter);
      }
    } catch (InvocationTargetException t) {
      if (t.getCause() != null) {
        throw t.getCause();
      }
    } finally {
      final long endTime = System.currentTimeMillis();
      reporter.reportTimedOperation(targetClass, method, startTime, endTime);
    }
    return result;
  }
788942
public static InvocationHandler getInvocationHandler(Object instance) {
        try {
            Field field = instance.getClass().getDeclaredField(FIELD_NAME_HANDLER);
            field.setAccessible(true);
            return (InvocationHandler) field.get(instance);
        } catch (NoSuchFieldException e) {
            throw new IllegalArgumentException("Not a valid proxy instance", e);
        } catch (IllegalAccessException e) {
            // Should not be thrown, we just set the field to accessible.
            throw new AssertionError(e);
        }
    }
1089047
public boolean cancelInvocation(Long invokeId) throws TCAPException {
        if (this.previewMode)
            return false;

        try {
            this.dialogLock.lock();
            int index = getIndexFromInvokeId(invokeId);
            if (index < 0 || index >= this.operationsSent.length) {
                throw new TCAPException("Wrong invoke id passed.");
            }

            // lookup through send buffer.
            for (index = 0; index < this.scheduledComponentList.size(); index++) {
                Component cr = this.scheduledComponentList.get(index);
                if (cr.getType() == ComponentType.Invoke && cr.getInvokeId().equals(invokeId)) {
                    // lucky
                    // TCInvokeRequestImpl invoke = (TCInvokeRequestImpl) cr;
                    // there is no notification on cancel?
                    this.scheduledComponentList.remove(index);
                    ((InvokeImpl) cr).stopTimer();
                    ((InvokeImpl) cr).setState(OperationState.Idle);
                    return true;
                }
            }

            return false;
        } finally {
            this.dialogLock.unlock();
        }
    }
1016901
public Object invoke(MethodInvocation invocation) throws Throwable {
		ProxyMethodInvocation pmi = (ProxyMethodInvocation) invocation;
		TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
		TargetMetaDef targetMetaDef = targetMetaRequest.getTargetMetaDef();
		if (targetMetaDef.isEJB())
			return invocation.proceed();

		if (!isSessionContextAcceptable(targetMetaDef)) {
			// Debug.logVerbose("[JdonFramework] target service is not SessionContextAcceptable: "
			// + targetMetaDef.getClassName() +
			// " SessionContextInterceptor unactiive", module);
			return invocation.proceed();
		}
		Debug.logVerbose("[JdonFramework] enter SessionContextInterceptor", module);

		Object result = null;
		try {
			Object targetObject = pmi.getThis();
			if (targetObject == null) {
				throw new Exception("targetObject is null, add @Poolable and try again");
			}
			Debug.logVerbose("[JdonFramework] targetObject should be SessionContextAcceptable: " + targetObject.getClass().getName(), module);
			setSessionContext(targetObject, targetMetaRequest);

			result = invocation.proceed();

		} catch (Exception ex) {
			Debug.logError("[JdonFramework]SessionContextInterceptor error: " + ex, module);
		}
		return result;
	}
386959
private InjectorMethod createInvoker(String invokeeName, String invokeeTypeName,
      boolean hasInvokee, boolean isNative, boolean isThrowing, String invokerMethodName,
      String invokerPackageName, int invokerParamCount, MethodLiteral<?, ?> method,
      String returnTypeString, boolean returning, boolean isLongAccess)
      throws NoSourceNameException {

    List<String> invokerSignatureParams = new ArrayList<String>(invokerParamCount);

    if (hasInvokee) {
      invokerSignatureParams.add(invokeeTypeName + " invokee");
    }

    List<String> invokeeCallParams = new ArrayList<String>(method.getParameterTypes().size());

    int paramCount = 0;
    for (Key<?> paramKey : method.getParameterKeys()) {
      String paramName = ReflectUtil.formatParameterName(paramCount);
      // We cannot use the type literal of the key here: It is canonicalized
      // during key creation, destroying some information, for example
      // auto-boxing any primitives. This leads to type-mismatches when calling
      // into JSNI. Instead we'll access the parameter's original type.
      TypeLiteral<?> paramLiteral = method.getParameterTypes().get(paramCount);
      invokerSignatureParams.add(ReflectUtil.getSourceName(paramLiteral) + " " + paramName);
      invokeeCallParams.add(paramName);
      paramCount++;
    }

    String annotation = isLongAccess ? "@com.google.gwt.core.client.UnsafeNativeLong " : "";

    String invokerSignature = annotation + "public " + (isNative ? "native " : "")
        + returnTypeString + " " + invokerMethodName + "(" + join(", ", invokerSignatureParams)
        + ")";

    return new InvokerMethod(hasInvokee, invokeeCallParams, invokeeTypeName, invokerPackageName,
        invokerSignature, isNative, isThrowing, method, returning, returnTypeString);
  }
800546
public Object invoke(MethodInvocation mi) throws Exception {
        Method method = mi.getMethod();
        return simulatorAdapter.service(method.getDeclaringClass().getCanonicalName(), method.getName(), mi.getArguments(), rootPath, useRootRelativePath);
    }
1245737
public Object invoke(MethodInvocation mi) throws Throwable {
		if (!Modifier.isPublic(mi.getMethod().getModifiers())) {
			return mi.proceed();
		}

		Method daoMethod = mi.getMethod();
		Object[] args = mi.getArguments();
		String appid = AOPUtils.getFirstArgOfString(args);

		Method superMethod = null;
		Indexed indexedAnno = null;
		Cached cachedAnno = null;

		try {
			superMethod = DAO.class.getMethod(daoMethod.getName(), daoMethod.getParameterTypes());
			indexedAnno = Config.isSearchEnabled() ? superMethod.getAnnotation(Indexed.class) : null;
			cachedAnno = Config.isCacheEnabled() ? superMethod.getAnnotation(Cached.class) : null;
			detectNestedInvocations(daoMethod);
		} catch (Exception e) {
			logger.error("Error in AOP layer!", e);
		}

		Set<IOListener> ioListeners = Para.getIOListeners();
		for (IOListener ioListener : ioListeners) {
			ioListener.onPreInvoke(superMethod, args);
			logger.debug("Executed {}.onPreInvoke().", ioListener.getClass().getName());
		}

		Object result = handleIndexing(indexedAnno, appid, daoMethod, args, mi);
		Object cachingResult = handleCaching(cachedAnno, appid, daoMethod, args, mi);

		// we have a read operation without any result but we get back objects from cache
		if (result == null && cachingResult != null) {
			result = cachingResult;
		}

		// both searching and caching are disabled - pass it through
		if (indexedAnno == null && cachedAnno == null) {
			result = invokeDAO(appid, daoMethod, mi);
		}

		for (IOListener ioListener : ioListeners) {
			ioListener.onPostInvoke(superMethod, result);
			logger.debug("Executed {}.onPostInvoke().", ioListener.getClass().getName());
		}

		return result;
	}
201959
public void invokeRequest (byte[] arg1, InvocationService.ResultListener arg2)
    {
        InvocationMarshaller.ResultMarshaller listener2 = new InvocationMarshaller.ResultMarshaller();
        listener2.listener = arg2;
        sendRequest(INVOKE_REQUEST, new Object[] {
            arg1, listener2
        });
    }
722654
public static StoredProcedureInvocation roundTripForCL(StoredProcedureInvocation invocation) throws IOException
    {
        if (invocation.getSerializedParams() != null) {
            return invocation;
        }
        ByteBuffer buf = ByteBuffer.allocate(invocation.getSerializedSize());
        invocation.flattenToBuffer(buf);
        buf.flip();

        StoredProcedureInvocation rti = new StoredProcedureInvocation();
        rti.initFromBuffer(buf);
        return rti;
    }
1209550
private long getInvocationLeastWindowCount(InvocationStat invocationStat, Integer weight, long leastWindowCount) {
        InvocationStatDimension statDimension = invocationStat.getDimension();
        Integer originWeight = statDimension.getOriginWeight();
        if (originWeight == 0) {
            LOGGER.errorWithApp(statDimension.getAppName(), "originWeight is 0,but is invoked. service["
                + statDimension.getService() + "];ip["
                + statDimension.getIp() + "].");
            return -1;
        } else if (weight == null) { //如果地址还未被调控过或者已经恢复。
            return leastWindowCount;
        } else if (weight == -1) { //如果地址被剔除
            return -1;
        }

        double rate = CalculateUtils.divide(weight, originWeight);
        long invocationLeastWindowCount = CalculateUtils.multiply(leastWindowCount, rate);
        return invocationLeastWindowCount < LEGAL_LEAST_WINDOW_COUNT ? LEGAL_LEAST_WINDOW_COUNT
            : invocationLeastWindowCount;
    }
467565
public ArrayList<I> getInvocations()
  {
    LruCache<Object,I> invocationCache = _invocationCache;

    ArrayList<I> invocationList = new ArrayList<>();
      
    synchronized (invocationCache) {
      Iterator<I> iter;
      iter = invocationCache.values();

      while (iter.hasNext()) {
        invocationList.add(iter.next());
      }
    }

    return invocationList;
  }
1194676
public Invoker create(Object service, Invoker rootInvoker) {

        List<Method> timedmethods = new ArrayList<>();
        List<Method> meteredmethods = new ArrayList<>();
        List<Method> exceptionmeteredmethods = new ArrayList<>();

        for (Method m : service.getClass().getMethods()) {

            if (m.isAnnotationPresent(Timed.class)) {
                timedmethods.add(m);
            }

            if (m.isAnnotationPresent(Metered.class)) {
                meteredmethods.add(m);
            }

            if (m.isAnnotationPresent(ExceptionMetered.class)) {
                exceptionmeteredmethods.add(m);
            }
        }

        Invoker invoker = rootInvoker;

        if (timedmethods.size() > 0) {
            invoker = this.timed(invoker, timedmethods);
        }

        if (meteredmethods.size() > 0) {
            invoker = this.metered(invoker, meteredmethods);
        }

        if (exceptionmeteredmethods.size() > 0) {
            invoker = this.exceptionMetered(invoker, exceptionmeteredmethods);
        }

        return invoker;
    }
817124
public function invoke(MethodInvocation $invocation)
    {
        /** @var Cacheable $annotation */
        $annotation = $invocation->getMethod()->getAnnotation($this->annotation);
        $keys = $this->generateCacheName($annotation->cacheName, $invocation);
        if (!is_array($annotation->key)) {
            $annotation->key = [$annotation->key];
        }
        $keys = $this->detectCacheKeys($invocation, $annotation, $keys);
        // detect use cache driver
        $cache = $this->detectCacheRepository($annotation);
        $key = $this->recursiveImplode($this->join, $keys);
        if ($cache->has($key)) {
            return $cache->get($key);
        }
        $result = $invocation->proceed();
        if (!$annotation->negative) {
            if ($result) {
                $cache->add($key, $result, $annotation->lifetime);
            }

            return $result;
        }
        if (is_null($result)) {
            $cache->add($key, $result, $annotation->lifetime);
        }

        return $result;
    }
835002
private Object invokeImpl(Object thiz, String name, Object... args)
            throws ScriptException, NoSuchMethodException {
        if (name == null) {
            throw new NullPointerException("method name is null");
        }

        try {
            if (thiz != null) {
                return InvokerHelper.invokeMethod(thiz, name, args);
            } else {
                return callGlobal(name, args);
            }
        } catch (MissingMethodException mme) {
            throw new NoSuchMethodException(mme.getMessage());
        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
470541
public static <T> void invoke(String expression,
                                  QueryExprInvoker<T> invoker,
                                  ExprApplier<T> exprApplier) {
        QueryExprInvoker.invoke(parse(expression), invoker, exprApplier);
    }