49
49
import oracle .kubernetes .operator .work .Fiber ;
50
50
import oracle .kubernetes .operator .work .Fiber .CompletionCallback ;
51
51
import oracle .kubernetes .operator .work .FiberGate ;
52
+ import oracle .kubernetes .operator .work .FiberGateFactory ;
52
53
import oracle .kubernetes .operator .work .NextAction ;
53
54
import oracle .kubernetes .operator .work .Packet ;
54
55
import oracle .kubernetes .operator .work .Step ;
@@ -62,7 +63,15 @@ public class DomainProcessorImpl implements DomainProcessor {
62
63
63
64
private static final LoggingFacade LOGGER = LoggingFactory .getLogger ("Operator" , "Operator" );
64
65
65
- private static final FiberGate FIBER_GATE = new FiberGate (Main .engine );
66
+ private static final FiberGateFactory FACTORY =
67
+ () -> {
68
+ return new FiberGate (Main .engine );
69
+ };
70
+ private static final ConcurrentMap <String , FiberGate > fiberGates = new ConcurrentHashMap <>();
71
+
72
+ private static FiberGate getFiberGate (String ns ) {
73
+ return fiberGates .computeIfAbsent (ns , k -> FACTORY .get ());
74
+ }
66
75
67
76
// Map from namespace to map of domainUID to Domain
68
77
private static final ConcurrentMap <String , ConcurrentMap <String , DomainPresenceInfo >> domains =
@@ -859,6 +868,7 @@ void runDomainPlan(
859
868
Step .StepAndPacket plan ,
860
869
boolean isDeleting ,
861
870
boolean isWillInterrupt ) {
871
+ FiberGate gate = getFiberGate (ns );
862
872
CompletionCallback cc =
863
873
new CompletionCallback () {
864
874
@ Override
@@ -870,7 +880,7 @@ public void onCompletion(Packet packet) {
870
880
public void onThrowable (Packet packet , Throwable throwable ) {
871
881
LOGGER .severe (MessageKeys .EXCEPTION , throwable );
872
882
873
- FIBER_GATE .startFiberIfLastFiberMatches (
883
+ gate .startFiberIfLastFiberMatches (
874
884
domainUID ,
875
885
Fiber .getCurrentIfSet (),
876
886
DomainStatusUpdater .createFailedStep (throwable , null ),
@@ -887,8 +897,7 @@ public void onThrowable(Packet packet, Throwable throwable) {
887
897
}
888
898
});
889
899
890
- FIBER_GATE
891
- .getExecutor ()
900
+ gate .getExecutor ()
892
901
.schedule (
893
902
() -> {
894
903
DomainPresenceInfo existing = getExisting (ns , domainUID );
@@ -903,9 +912,9 @@ public void onThrowable(Packet packet, Throwable throwable) {
903
912
};
904
913
905
914
if (isWillInterrupt ) {
906
- FIBER_GATE .startFiber (domainUID , plan .step , plan .packet , cc );
915
+ gate .startFiber (domainUID , plan .step , plan .packet , cc );
907
916
} else {
908
- FIBER_GATE .startFiberIfNoCurrentFiber (domainUID , plan .step , plan .packet , cc );
917
+ gate .startFiberIfNoCurrentFiber (domainUID , plan .step , plan .packet , cc );
909
918
}
910
919
}
911
920
0 commit comments