Search in sources :

Example 1 with DefaultSlotChainBuilder

use of com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder in project Sentinel by alibaba.

the class SpiLoaderTest method testLoadFirstInstanceOrDefault.

@Test
public void testLoadFirstInstanceOrDefault() {
    SlotChainBuilder slotChainBuilder = SpiLoader.of(SlotChainBuilder.class).loadFirstInstanceOrDefault();
    assertNotNull(slotChainBuilder);
    assertTrue(slotChainBuilder instanceof DefaultSlotChainBuilder);
}
Also used : SlotChainBuilder(com.alibaba.csp.sentinel.slotchain.SlotChainBuilder) DefaultSlotChainBuilder(com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder) DefaultSlotChainBuilder(com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder) Test(org.junit.Test)

Example 2 with DefaultSlotChainBuilder

use of com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder in project Sentinel by alibaba.

the class SlotChainProvider method newSlotChain.

/**
 * The load and pick process is not thread-safe, but it's okay since the method should be only invoked
 * via {@code lookProcessChain} in {@link com.alibaba.csp.sentinel.CtSph} under lock.
 *
 * @return new created slot chain
 */
public static ProcessorSlotChain newSlotChain() {
    if (slotChainBuilder != null) {
        return slotChainBuilder.build();
    }
    // Resolve the slot chain builder SPI.
    slotChainBuilder = SpiLoader.of(SlotChainBuilder.class).loadFirstInstanceOrDefault();
    if (slotChainBuilder == null) {
        // Should not go through here.
        RecordLog.warn("[SlotChainProvider] Wrong state when resolving slot chain builder, using default");
        slotChainBuilder = new DefaultSlotChainBuilder();
    } else {
        RecordLog.info("[SlotChainProvider] Global slot chain builder resolved: {}", slotChainBuilder.getClass().getCanonicalName());
    }
    return slotChainBuilder.build();
}
Also used : DefaultSlotChainBuilder(com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder)

Example 3 with DefaultSlotChainBuilder

use of com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder in project Sentinel by alibaba.

the class SpiLoaderTest method testLoadDefaultInstance.

@Test
public void testLoadDefaultInstance() {
    SlotChainBuilder slotChainBuilder = SpiLoader.of(SlotChainBuilder.class).loadDefaultInstance();
    assertNotNull(slotChainBuilder);
    assertTrue(slotChainBuilder instanceof DefaultSlotChainBuilder);
}
Also used : SlotChainBuilder(com.alibaba.csp.sentinel.slotchain.SlotChainBuilder) DefaultSlotChainBuilder(com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder) DefaultSlotChainBuilder(com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder) Test(org.junit.Test)

Aggregations

DefaultSlotChainBuilder (com.alibaba.csp.sentinel.slots.DefaultSlotChainBuilder)3 SlotChainBuilder (com.alibaba.csp.sentinel.slotchain.SlotChainBuilder)2 Test (org.junit.Test)2