Search in sources :

Example 1 with ProcessorSlotExitCallback

use of com.alibaba.csp.sentinel.slotchain.ProcessorSlotExitCallback in project Sentinel by alibaba.

the class StatisticSlot method exit.

@Override
public void exit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) {
    Node node = context.getCurNode();
    if (context.getCurEntry().getBlockError() == null) {
        // Calculate response time (use completeStatTime as the time of completion).
        long completeStatTime = TimeUtil.currentTimeMillis();
        context.getCurEntry().setCompleteTimestamp(completeStatTime);
        long rt = completeStatTime - context.getCurEntry().getCreateTimestamp();
        Throwable error = context.getCurEntry().getError();
        // Record response time and success count.
        recordCompleteFor(node, count, rt, error);
        recordCompleteFor(context.getCurEntry().getOriginNode(), count, rt, error);
        if (resourceWrapper.getEntryType() == EntryType.IN) {
            recordCompleteFor(Constants.ENTRY_NODE, count, rt, error);
        }
    }
    // Handle exit event with registered exit callback handlers.
    Collection<ProcessorSlotExitCallback> exitCallbacks = StatisticSlotCallbackRegistry.getExitCallbacks();
    for (ProcessorSlotExitCallback handler : exitCallbacks) {
        handler.onExit(context, resourceWrapper, count, args);
    }
    // fix bug https://github.com/alibaba/Sentinel/issues/2374
    fireExit(context, resourceWrapper, count, args);
}
Also used : ProcessorSlotExitCallback(com.alibaba.csp.sentinel.slotchain.ProcessorSlotExitCallback) DefaultNode(com.alibaba.csp.sentinel.node.DefaultNode) Node(com.alibaba.csp.sentinel.node.Node) ClusterNode(com.alibaba.csp.sentinel.node.ClusterNode)

Aggregations

ClusterNode (com.alibaba.csp.sentinel.node.ClusterNode)1 DefaultNode (com.alibaba.csp.sentinel.node.DefaultNode)1 Node (com.alibaba.csp.sentinel.node.Node)1 ProcessorSlotExitCallback (com.alibaba.csp.sentinel.slotchain.ProcessorSlotExitCallback)1