Search in sources :

Example 1 with DefaultProcessorSlotChain

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

the class DefaultSlotChainBuilder method build.

@Override
public ProcessorSlotChain build() {
    ProcessorSlotChain chain = new DefaultProcessorSlotChain();
    List<ProcessorSlot> sortedSlotList = SpiLoader.of(ProcessorSlot.class).loadInstanceListSorted();
    for (ProcessorSlot slot : sortedSlotList) {
        if (!(slot instanceof AbstractLinkedProcessorSlot)) {
            RecordLog.warn("The ProcessorSlot(" + slot.getClass().getCanonicalName() + ") is not an instance of AbstractLinkedProcessorSlot, can't be added into ProcessorSlotChain");
            continue;
        }
        chain.addLast((AbstractLinkedProcessorSlot<?>) slot);
    }
    return chain;
}
Also used : DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain) ProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.ProcessorSlotChain) DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain) AbstractLinkedProcessorSlot(com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot) ProcessorSlot(com.alibaba.csp.sentinel.slotchain.ProcessorSlot) AbstractLinkedProcessorSlot(com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot)

Example 2 with DefaultProcessorSlotChain

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

the class CtSphTest method addShouldNotPassSlotFor.

private void addShouldNotPassSlotFor(ResourceWrapper resourceWrapper) {
    ProcessorSlotChain slotChain = new DefaultProcessorSlotChain();
    slotChain.addLast(new ShouldNotPassSlot());
    CtSph.getChainMap().put(resourceWrapper, slotChain);
}
Also used : ProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.ProcessorSlotChain) DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain) DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain)

Example 3 with DefaultProcessorSlotChain

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

the class CtSphTest method addMustBlockSlot.

private MustBlockSlot addMustBlockSlot(ResourceWrapper resourceWrapper) {
    ProcessorSlotChain slotChain = new DefaultProcessorSlotChain();
    MustBlockSlot mustBlockSlot = new MustBlockSlot();
    slotChain.addLast(mustBlockSlot);
    CtSph.getChainMap().put(resourceWrapper, slotChain);
    return mustBlockSlot;
}
Also used : ProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.ProcessorSlotChain) DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain) DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain)

Example 4 with DefaultProcessorSlotChain

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

the class CtSphTest method addShouldPassSlotFor.

private ShouldPassSlot addShouldPassSlotFor(ResourceWrapper resourceWrapper) {
    ProcessorSlotChain slotChain = new DefaultProcessorSlotChain();
    ShouldPassSlot shouldPassSlot = new ShouldPassSlot();
    slotChain.addLast(shouldPassSlot);
    CtSph.getChainMap().put(resourceWrapper, slotChain);
    return shouldPassSlot;
}
Also used : ProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.ProcessorSlotChain) DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain) DefaultProcessorSlotChain(com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain)

Aggregations

DefaultProcessorSlotChain (com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain)4 ProcessorSlotChain (com.alibaba.csp.sentinel.slotchain.ProcessorSlotChain)4 AbstractLinkedProcessorSlot (com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot)1 ProcessorSlot (com.alibaba.csp.sentinel.slotchain.ProcessorSlot)1