Java Code Examples for com.alibaba.csp.sentinel.EntryType#OUT
The following examples show how to use
com.alibaba.csp.sentinel.EntryType#OUT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricExitCallbackTest.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
@Test public void onExit() { FakeMetricExtension extension = new FakeMetricExtension(); MetricExtensionProvider.addMetricExtension(extension); MetricExitCallback exitCallback = new MetricExitCallback(); StringResourceWrapper resourceWrapper = new StringResourceWrapper("resource", EntryType.OUT); int count = 2; Object[] args = {"args1", "args2"}; extension.rt = 20; extension.success = 6; extension.thread = 10; Context context = mock(Context.class); Entry entry = mock(Entry.class); when(entry.getError()).thenReturn(null); when(entry.getCreateTime()).thenReturn(TimeUtil.currentTimeMillis() - 100); when(context.getCurEntry()).thenReturn(entry); exitCallback.onExit(context, resourceWrapper, count, args); Assert.assertEquals(120, extension.rt, 10); Assert.assertEquals(extension.success, 6 + count); Assert.assertEquals(extension.thread, 10 - 1); }
Example 2
Source File: MetricEntryCallbackTest.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
@Test public void onPass() throws Exception { FakeMetricExtension extension = new FakeMetricExtension(); MetricExtensionProvider.addMetricExtension(extension); MetricEntryCallback entryCallback = new MetricEntryCallback(); StringResourceWrapper resourceWrapper = new StringResourceWrapper("resource", EntryType.OUT); int count = 2; Object[] args = {"args1", "args2"}; entryCallback.onPass(null, resourceWrapper, null, count, args); Assert.assertEquals(extension.pass, count); Assert.assertEquals(extension.thread, 1); }
Example 3
Source File: MetricEntryCallbackTest.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
@Test public void onBlocked() throws Exception { FakeMetricExtension extension = new FakeMetricExtension(); MetricExtensionProvider.addMetricExtension(extension); MetricEntryCallback entryCallback = new MetricEntryCallback(); StringResourceWrapper resourceWrapper = new StringResourceWrapper("resource", EntryType.OUT); Context context = mock(Context.class); when(context.getOrigin()).thenReturn("origin1"); int count = 2; Object[] args = {"args1", "args2"}; entryCallback.onBlocked(new FlowException("xx"), context, resourceWrapper, null, count, args); Assert.assertEquals(extension.block, count); }
Example 4
Source File: MetricExitCallbackTest.java From Sentinel with Apache License 2.0 | 5 votes |
@Test public void onExit() { FakeMetricExtension extension = new FakeMetricExtension(); MetricExtensionProvider.addMetricExtension(extension); MetricExitCallback exitCallback = new MetricExitCallback(); StringResourceWrapper resourceWrapper = new StringResourceWrapper("resource", EntryType.OUT); int count = 2; Object[] args = {"args1", "args2"}; long prevRt = 20; extension.rt = prevRt; extension.success = 6; extension.thread = 10; Context context = mock(Context.class); Entry entry = mock(Entry.class); // Mock current time long curMillis = System.currentTimeMillis(); setCurrentMillis(curMillis); int deltaMs = 100; when(entry.getError()).thenReturn(null); when(entry.getCreateTimestamp()).thenReturn(curMillis - deltaMs); when(context.getCurEntry()).thenReturn(entry); exitCallback.onExit(context, resourceWrapper, count, args); Assert.assertEquals(prevRt + deltaMs, extension.rt); Assert.assertEquals(extension.success, 6 + count); Assert.assertEquals(extension.thread, 10 - 1); }
Example 5
Source File: MetricEntryCallbackTest.java From Sentinel with Apache License 2.0 | 5 votes |
@Test public void onPass() throws Exception { FakeMetricExtension extension = new FakeMetricExtension(); MetricExtensionProvider.addMetricExtension(extension); MetricEntryCallback entryCallback = new MetricEntryCallback(); StringResourceWrapper resourceWrapper = new StringResourceWrapper("resource", EntryType.OUT); int count = 2; Object[] args = {"args1", "args2"}; entryCallback.onPass(null, resourceWrapper, null, count, args); Assert.assertEquals(extension.pass, count); Assert.assertEquals(extension.thread, 1); }
Example 6
Source File: MetricEntryCallbackTest.java From Sentinel with Apache License 2.0 | 5 votes |
@Test public void onBlocked() throws Exception { FakeMetricExtension extension = new FakeMetricExtension(); MetricExtensionProvider.addMetricExtension(extension); MetricEntryCallback entryCallback = new MetricEntryCallback(); StringResourceWrapper resourceWrapper = new StringResourceWrapper("resource", EntryType.OUT); Context context = mock(Context.class); when(context.getOrigin()).thenReturn("origin1"); int count = 2; Object[] args = {"args1", "args2"}; entryCallback.onBlocked(new FlowException("xx"), context, resourceWrapper, null, count, args); Assert.assertEquals(extension.block, count); }
Example 7
Source File: EntryConfig.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 4 votes |
public EntryConfig(String resourceName) { this(resourceName, EntryType.OUT); }
Example 8
Source File: EntryConfig.java From Sentinel with Apache License 2.0 | 4 votes |
public EntryConfig(String resourceName) { this(resourceName, EntryType.OUT); }
Example 9
Source File: SentinelCircuitBreaker.java From spring-cloud-alibaba with Apache License 2.0 | 4 votes |
public SentinelCircuitBreaker(String resourceName, List<DegradeRule> rules) { this(resourceName, EntryType.OUT, rules); }
Example 10
Source File: SentinelCircuitBreaker.java From spring-cloud-alibaba with Apache License 2.0 | 4 votes |
public SentinelCircuitBreaker(String resourceName) { this(resourceName, EntryType.OUT, Collections.emptyList()); }
Example 11
Source File: ReactiveSentinelCircuitBreaker.java From spring-cloud-alibaba with Apache License 2.0 | 4 votes |
public ReactiveSentinelCircuitBreaker(String resourceName, List<DegradeRule> rules) { this(resourceName, EntryType.OUT, rules); }
Example 12
Source File: ReactiveSentinelCircuitBreaker.java From spring-cloud-alibaba with Apache License 2.0 | 4 votes |
public ReactiveSentinelCircuitBreaker(String resourceName) { this(resourceName, EntryType.OUT, Collections.emptyList()); }