Search in sources :

Example 1 with CutOffResult

use of com.pamirs.pradar.CutOffResult in project LinkAgent by shulieTech.

the class ScopedCutoffInterceptor method cutoff.

@Override
public CutOffResult cutoff(Advice advice) throws Throwable {
    final InterceptorScopeInvocation transaction = getScope(advice).getCurrentInvocation();
    CutOffResult result = CutOffResult.passed();
    try {
        final boolean success = transaction.tryEnter(policy);
        if (success) {
            return interceptor.cutoff(advice);
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("tryBefore() returns false: interceptorScopeTransaction: {}, executionPoint: {}. Skip interceptor {}", transaction, policy, interceptor.getClass());
            }
        }
    } finally {
        if (transaction.canLeave(policy)) {
            transaction.leave(policy);
        }
    }
    return result;
}
Also used : InterceptorScopeInvocation(com.shulie.instrument.simulator.api.scope.InterceptorScopeInvocation) CutOffResult(com.pamirs.pradar.CutOffResult)

Example 2 with CutOffResult

use of com.pamirs.pradar.CutOffResult in project LinkAgent by shulieTech.

the class AbstractProxiedConsumerInterceptor method cutoff0.

@Override
public CutOffResult cutoff0(Advice advice) throws Throwable {
    ConsumerProxy consumerProxy = ConsumerHolder.getProxy(advice.getTarget());
    if (consumerProxy == null) {
        return CutOffResult.passed();
    }
    Object result = doCutoff(consumerProxy, advice);
    if (result instanceof CutOffResult) {
        return (CutOffResult) result;
    } else {
        return CutOffResult.cutoff(result);
    }
}
Also used : CutOffResult(com.pamirs.pradar.CutOffResult) ConsumerProxy(com.pamirs.attach.plugin.apache.kafka.origin.ConsumerProxy)

Aggregations

CutOffResult (com.pamirs.pradar.CutOffResult)2 ConsumerProxy (com.pamirs.attach.plugin.apache.kafka.origin.ConsumerProxy)1 InterceptorScopeInvocation (com.shulie.instrument.simulator.api.scope.InterceptorScopeInvocation)1