File tree 6 files changed +38
-6
lines changed
projects/stage-1/middleware-frameworks/my-fault-tolerance/src/main/java/org/geektimes/microprofile/faulttolerance
6 files changed +38
-6
lines changed Original file line number Diff line number Diff line change 21
21
import org .geektimes .commons .function .ThrowableSupplier ;
22
22
import org .geektimes .interceptor .AnnotatedInterceptor ;
23
23
24
+ import javax .annotation .Priority ;
24
25
import javax .interceptor .Interceptor ;
25
26
import javax .interceptor .InvocationContext ;
26
27
import java .lang .reflect .Method ;
27
28
import java .util .concurrent .*;
28
29
29
30
import static java .util .concurrent .CompletableFuture .supplyAsync ;
31
+ import static org .geektimes .microprofile .faulttolerance .AsynchronousInterceptor .ASYNCHRONOUS_PRIORITY ;
32
+ import static org .geektimes .microprofile .faulttolerance .TimeoutInterceptor .TIMEOUT_PRIORITY ;
30
33
31
34
/**
32
35
* The interceptor implementation for the annotation {@link Asynchronous} of
37
40
*/
38
41
@ Asynchronous
39
42
@ Interceptor
43
+ @ Priority (ASYNCHRONOUS_PRIORITY )
40
44
public class AsynchronousInterceptor extends AnnotatedInterceptor <Asynchronous > {
41
45
46
+ public static final int ASYNCHRONOUS_PRIORITY = TIMEOUT_PRIORITY + 100 ;
47
+
42
48
// TODO ExecutorService fixed size = external Server Thread numbers
43
49
private final ExecutorService executor = ForkJoinPool .commonPool ();
44
50
45
51
public AsynchronousInterceptor () {
46
52
super ();
47
- setPriority (500 );
48
53
}
49
54
50
55
@ Override
Original file line number Diff line number Diff line change 21
21
import org .eclipse .microprofile .faulttolerance .exceptions .BulkheadException ;
22
22
import org .geektimes .interceptor .AnnotatedInterceptor ;
23
23
24
+ import javax .annotation .Priority ;
24
25
import javax .interceptor .Interceptor ;
25
26
import javax .interceptor .InvocationContext ;
26
27
import java .lang .reflect .Method ;
27
28
import java .util .concurrent .*;
28
29
import java .util .concurrent .atomic .AtomicInteger ;
29
30
30
31
import static java .lang .String .format ;
32
+ import static org .geektimes .microprofile .faulttolerance .BulkheadInterceptor .BULKHEAD_PRIORITY ;
33
+ import static org .geektimes .microprofile .faulttolerance .CircuitBreakerInterceptor .CIRCUIT_BREAKER_PRIORITY ;
31
34
32
35
/**
33
36
* The interceptor implementation for the annotation {@link Bulkhead} of
38
41
*/
39
42
@ Bulkhead
40
43
@ Interceptor
44
+ @ Priority (BULKHEAD_PRIORITY )
41
45
public class BulkheadInterceptor extends AnnotatedInterceptor <Bulkhead > {
42
46
47
+ public static final int BULKHEAD_PRIORITY = CIRCUIT_BREAKER_PRIORITY + 100 ;
48
+
43
49
private final ConcurrentMap <Bulkhead , ExecutorService > executorsCache = new ConcurrentHashMap <>();
44
50
45
51
private final ConcurrentHashMap <Bulkhead , Semaphore > semaphoresCache = new ConcurrentHashMap <>();
46
52
47
53
public BulkheadInterceptor () {
48
54
super ();
49
- setPriority (100 );
50
55
}
51
56
52
57
@ Override
Original file line number Diff line number Diff line change 21
21
import org .geektimes .commons .util .TimeUtils ;
22
22
import org .geektimes .interceptor .AnnotatedInterceptor ;
23
23
24
+ import javax .annotation .Priority ;
24
25
import javax .interceptor .Interceptor ;
25
26
import javax .interceptor .InvocationContext ;
26
27
import java .util .Arrays ;
29
30
import java .util .concurrent .TimeUnit ;
30
31
import java .util .concurrent .atomic .LongAdder ;
31
32
33
+ import static javax .interceptor .Interceptor .Priority .LIBRARY_BEFORE ;
32
34
import static org .geektimes .commons .reflect .util .ClassUtils .isDerived ;
35
+ import static org .geektimes .microprofile .faulttolerance .CircuitBreakerInterceptor .CIRCUIT_BREAKER_PRIORITY ;
33
36
34
37
/**
35
38
* The interceptor implementation for the annotation {@link CircuitBreaker} of
40
43
*/
41
44
@ CircuitBreaker
42
45
@ Interceptor
46
+ @ Priority (CIRCUIT_BREAKER_PRIORITY )
43
47
public class CircuitBreakerInterceptor extends AnnotatedInterceptor <CircuitBreaker > {
44
48
49
+ public static final int CIRCUIT_BREAKER_PRIORITY = LIBRARY_BEFORE + 100 ;
50
+
45
51
private final ConcurrentMap <CircuitBreaker , CountableSlidingWindow > slidingWindowsCache = new ConcurrentHashMap <>();
46
52
47
53
public CircuitBreakerInterceptor () {
48
54
super ();
49
- setPriority (0 );
50
55
}
51
56
52
57
@ Override
Original file line number Diff line number Diff line change 22
22
import org .eclipse .microprofile .faulttolerance .exceptions .FaultToleranceDefinitionException ;
23
23
import org .geektimes .interceptor .AnnotatedInterceptor ;
24
24
25
+ import javax .annotation .Priority ;
25
26
import javax .interceptor .Interceptor ;
26
27
import javax .interceptor .InvocationContext ;
27
28
import java .lang .reflect .Method ;
28
29
29
30
import static java .lang .String .format ;
30
31
import static org .geektimes .commons .reflect .util .ClassUtils .getTypes ;
31
32
import static org .geektimes .commons .reflect .util .ClassUtils .isDerived ;
33
+ import static org .geektimes .microprofile .faulttolerance .BulkheadInterceptor .BULKHEAD_PRIORITY ;
34
+ import static org .geektimes .microprofile .faulttolerance .FallbackInterceptor .FALLBACK_PRIORITY ;
32
35
33
36
/**
34
37
* The interceptor implementation for the annotation {@link Fallback} of
38
41
* @since 1.0.0
39
42
*/
40
43
@ Interceptor
44
+ @ Priority (FALLBACK_PRIORITY )
41
45
public class FallbackInterceptor extends AnnotatedInterceptor <Fallback > {
42
46
47
+ public static final int FALLBACK_PRIORITY = BULKHEAD_PRIORITY + 100 ;
48
+
43
49
public FallbackInterceptor () {
44
50
super ();
45
- setPriority (200 );
46
51
}
47
52
48
53
@ Override
Original file line number Diff line number Diff line change 19
19
import org .eclipse .microprofile .faulttolerance .Retry ;
20
20
import org .geektimes .interceptor .AnnotatedInterceptor ;
21
21
22
+ import javax .annotation .Priority ;
22
23
import javax .interceptor .Interceptor ;
23
24
import javax .interceptor .InvocationContext ;
24
25
import java .util .Optional ;
28
29
import static java .util .Optional .empty ;
29
30
import static java .util .Optional .of ;
30
31
import static java .util .concurrent .Executors .newScheduledThreadPool ;
32
+ import static javax .interceptor .Interceptor .Priority .LIBRARY_BEFORE ;
31
33
import static org .geektimes .commons .reflect .util .ClassUtils .isDerived ;
32
34
import static org .geektimes .commons .util .TimeUtils .toTimeUnit ;
35
+ import static org .geektimes .microprofile .faulttolerance .BulkheadInterceptor .BULKHEAD_PRIORITY ;
36
+ import static org .geektimes .microprofile .faulttolerance .FallbackInterceptor .FALLBACK_PRIORITY ;
37
+ import static org .geektimes .microprofile .faulttolerance .RetryInterceptor .RETRY_PRIORITY ;
33
38
34
39
/**
35
40
* The interceptor implementation for the annotation {@link Retry} of
40
45
*/
41
46
@ Retry
42
47
@ Interceptor
48
+ @ Priority (RETRY_PRIORITY )
43
49
public class RetryInterceptor extends AnnotatedInterceptor <Retry > {
44
50
51
+ public static final int RETRY_PRIORITY = FALLBACK_PRIORITY + 100 ;
52
+
45
53
private final ScheduledExecutorService executorService = newScheduledThreadPool (2 );
46
54
47
55
48
56
public RetryInterceptor () {
49
57
super ();
50
- setPriority (300 );
51
58
}
52
59
53
60
@ Override
Original file line number Diff line number Diff line change 19
19
import org .eclipse .microprofile .faulttolerance .Timeout ;
20
20
import org .geektimes .interceptor .AnnotatedInterceptor ;
21
21
22
+ import javax .annotation .Priority ;
22
23
import javax .interceptor .Interceptor ;
23
24
import javax .interceptor .InvocationContext ;
24
25
import java .time .temporal .ChronoUnit ;
25
26
import java .util .concurrent .*;
26
27
27
28
import static org .geektimes .commons .util .TimeUtils .toTimeUnit ;
29
+ import static org .geektimes .microprofile .faulttolerance .RetryInterceptor .RETRY_PRIORITY ;
30
+ import static org .geektimes .microprofile .faulttolerance .TimeoutInterceptor .TIMEOUT_PRIORITY ;
28
31
29
32
/**
30
33
* The interceptor implementation for the annotation {@link Timeout} of
35
38
*/
36
39
@ Timeout
37
40
@ Interceptor
41
+ @ Priority (TIMEOUT_PRIORITY )
38
42
public class TimeoutInterceptor extends AnnotatedInterceptor <Timeout > {
39
43
44
+ public static final int TIMEOUT_PRIORITY = RETRY_PRIORITY + 100 ;
45
+
40
46
// TODO ExecutorService fixed size = external Server Thread numbers
41
47
private final ExecutorService executor = ForkJoinPool .commonPool ();
42
48
43
49
public TimeoutInterceptor () {
44
50
super ();
45
- setPriority (400 );
46
51
}
47
52
48
53
@ Override
You can’t perform that action at this time.
0 commit comments