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);
}
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();
}
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);
}
Aggregations