4
4
5
5
package oracle .kubernetes .operator ;
6
6
7
- import static oracle .kubernetes .operator .helpers .LegalNames .toJobIntrospectorName ;
7
+ import java .util .ArrayList ;
8
+ import java .util .List ;
9
+ import java .util .Map ;
10
+ import java .util .Optional ;
11
+ import java .util .concurrent .ConcurrentHashMap ;
12
+ import java .util .concurrent .ConcurrentMap ;
13
+ import java .util .concurrent .ScheduledFuture ;
14
+ import java .util .concurrent .TimeUnit ;
15
+ import java .util .concurrent .atomic .AtomicInteger ;
16
+ import javax .annotation .Nullable ;
8
17
9
18
import io .kubernetes .client .models .V1ConfigMap ;
10
19
import io .kubernetes .client .models .V1ContainerState ;
17
26
import io .kubernetes .client .models .V1Service ;
18
27
import io .kubernetes .client .models .V1ServiceList ;
19
28
import io .kubernetes .client .util .Watch ;
20
- import java .util .ArrayList ;
21
- import java .util .List ;
22
- import java .util .Map ;
23
- import java .util .Optional ;
24
- import java .util .concurrent .ConcurrentHashMap ;
25
- import java .util .concurrent .ConcurrentMap ;
26
- import java .util .concurrent .ScheduledFuture ;
27
- import java .util .concurrent .TimeUnit ;
28
- import java .util .concurrent .atomic .AtomicInteger ;
29
- import javax .annotation .Nullable ;
30
29
import oracle .kubernetes .operator .TuningParameters .MainTuning ;
31
30
import oracle .kubernetes .operator .calls .CallResponse ;
32
31
import oracle .kubernetes .operator .helpers .CallBuilder ;
61
60
import oracle .kubernetes .weblogic .domain .model .Domain ;
62
61
import oracle .kubernetes .weblogic .domain .model .DomainSpec ;
63
62
63
+ import static oracle .kubernetes .operator .helpers .LegalNames .toJobIntrospectorName ;
64
+
64
65
public class DomainProcessorImpl implements DomainProcessor {
65
66
66
67
private static final LoggingFacade LOGGER = LoggingFactory .getLogger ("Operator" , "Operator" );
@@ -69,9 +70,9 @@ public class DomainProcessorImpl implements DomainProcessor {
69
70
private static final Map <String , FiberGate > statusFiberGates = new ConcurrentHashMap <>();
70
71
// Map from namespace to map of domainUID to Domain
71
72
private static final Map <String , Map <String , DomainPresenceInfo >> DOMAINS =
72
- new ConcurrentHashMap <>();
73
+ new ConcurrentHashMap <>();
73
74
private static final ConcurrentMap <String , ConcurrentMap <String , ScheduledFuture <?>>>
74
- statusUpdaters = new ConcurrentHashMap <>();
75
+ statusUpdaters = new ConcurrentHashMap <>();
75
76
private DomainProcessorDelegate delegate ;
76
77
77
78
public DomainProcessorImpl (DomainProcessorDelegate delegate ) {
@@ -84,8 +85,8 @@ private static DomainPresenceInfo getExistingDomainPresenceInfo(String ns, Strin
84
85
85
86
private static void registerDomainPresenceInfo (DomainPresenceInfo info ) {
86
87
DOMAINS
87
- .computeIfAbsent (info .getNamespace (), k -> new ConcurrentHashMap <>())
88
- .put (info .getDomainUid (), info );
88
+ .computeIfAbsent (info .getNamespace (), k -> new ConcurrentHashMap <>())
89
+ .put (info .getDomainUid (), info );
89
90
}
90
91
91
92
private static void unregisterPresenceInfo (String ns , String domainUid ) {
@@ -96,9 +97,9 @@ private static void unregisterPresenceInfo(String ns, String domainUid) {
96
97
}
97
98
98
99
private static void registerStatusUpdater (
99
- String ns , String domainUid , ScheduledFuture <?> future ) {
100
+ String ns , String domainUid , ScheduledFuture <?> future ) {
100
101
ScheduledFuture <?> existing =
101
- statusUpdaters .computeIfAbsent (ns , k -> new ConcurrentHashMap <>()).put (domainUid , future );
102
+ statusUpdaters .computeIfAbsent (ns , k -> new ConcurrentHashMap <>()).put (domainUid , future );
102
103
if (existing != null ) {
103
104
existing .cancel (false );
104
105
}
@@ -125,29 +126,29 @@ private static void onEvent(V1Event event) {
125
126
if (status == null ) return ;
126
127
127
128
Optional .ofNullable (DOMAINS .get (event .getMetadata ().getNamespace ()))
128
- .map (m -> m .get (domainUid ))
129
- .ifPresent (info -> info .updateLastKnownServerStatus (serverName , status ));
129
+ .map (m -> m .get (domainUid ))
130
+ .ifPresent (info -> info .updateLastKnownServerStatus (serverName , status ));
130
131
}
131
132
132
133
private static String getReadinessStatus (V1Event event ) {
133
134
return Optional .ofNullable (event .getMessage ())
134
- .filter (m -> m .contains (WebLogicConstants .READINESS_PROBE_NOT_READY_STATE ))
135
- .map (m -> m .substring (m .lastIndexOf (':' ) + 1 ).trim ())
136
- .orElse (null );
135
+ .filter (m -> m .contains (WebLogicConstants .READINESS_PROBE_NOT_READY_STATE ))
136
+ .map (m -> m .substring (m .lastIndexOf (':' ) + 1 ).trim ())
137
+ .orElse (null );
137
138
}
138
139
139
140
private static Step readExistingPods (DomainPresenceInfo info ) {
140
141
return new CallBuilder ()
141
- .withLabelSelectors (
142
- LabelConstants .forDomainUidSelector (info .getDomainUid ()),
143
- LabelConstants .CREATEDBYOPERATOR_LABEL )
144
- .listPodAsync (info .getNamespace (), new PodListStep (info ));
142
+ .withLabelSelectors (
143
+ LabelConstants .forDomainUidSelector (info .getDomainUid ()),
144
+ LabelConstants .CREATEDBYOPERATOR_LABEL )
145
+ .listPodAsync (info .getNamespace (), new PodListStep (info ));
145
146
}
146
147
147
148
// pre-conditions: DomainPresenceInfo SPI
148
149
// "principal"
149
150
static Step bringAdminServerUp (
150
- DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
151
+ DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
151
152
return Step .chain (bringAdminServerUpSteps (info , podAwaiterStepFactory , next ));
152
153
}
153
154
@@ -159,7 +160,7 @@ private static Step[] domainIntrospectionSteps(Step next) {
159
160
}
160
161
161
162
private static Step [] bringAdminServerUpSteps (
162
- DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
163
+ DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
163
164
List <Step > resources = new ArrayList <>();
164
165
resources .add (new BeforeAdminServiceStep (null ));
165
166
resources .add (PodHelper .createAdminPodStep (null ));
@@ -625,8 +626,8 @@ private static class PodListStep extends ResponseStep<V1PodList> {
625
626
@ Override
626
627
public NextAction onFailure (Packet packet , CallResponse <V1PodList > callResponse ) {
627
628
return callResponse .getStatusCode () == CallBuilder .NOT_FOUND
628
- ? onSuccess (packet , callResponse )
629
- : super .onFailure (packet , callResponse );
629
+ ? onSuccess (packet , callResponse )
630
+ : super .onFailure (packet , callResponse );
630
631
}
631
632
632
633
@ Override
@@ -682,8 +683,8 @@ private class ServiceListStep extends ResponseStep<V1ServiceList> {
682
683
@ Override
683
684
public NextAction onFailure (Packet packet , CallResponse <V1ServiceList > callResponse ) {
684
685
return callResponse .getStatusCode () == CallBuilder .NOT_FOUND
685
- ? onSuccess (packet , callResponse )
686
- : super .onFailure (packet , callResponse );
686
+ ? onSuccess (packet , callResponse )
687
+ : super .onFailure (packet , callResponse );
687
688
}
688
689
689
690
@ Override
@@ -717,10 +718,10 @@ public NextAction apply(Packet packet) {
717
718
PodAwaiterStepFactory pw = delegate .getPodAwaiterStepFactory (info .getNamespace ());
718
719
info .setDeleting (false );
719
720
packet
720
- .getComponents ()
721
- .put (
722
- ProcessingConstants .DOMAIN_COMPONENT_NAME ,
723
- Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
721
+ .getComponents ()
722
+ .put (
723
+ ProcessingConstants .DOMAIN_COMPONENT_NAME ,
724
+ Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
724
725
return doNext (packet );
725
726
}
726
727
}
@@ -760,10 +761,10 @@ public NextAction apply(Packet packet) {
760
761
unregisterStatusUpdater (ns , info .getDomainUid ());
761
762
PodAwaiterStepFactory pw = delegate .getPodAwaiterStepFactory (ns );
762
763
packet
763
- .getComponents ()
764
- .put (
765
- ProcessingConstants .DOMAIN_COMPONENT_NAME ,
766
- Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
764
+ .getComponents ()
765
+ .put (
766
+ ProcessingConstants .DOMAIN_COMPONENT_NAME ,
767
+ Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
767
768
return doNext (packet );
768
769
}
769
770
}
@@ -781,8 +782,8 @@ private class DomainStatusUpdate {
781
782
782
783
public void invoke () {
783
784
Optional .ofNullable (getMatchingContainerStatus (pod , domainUid ).getState ())
784
- .map (V1ContainerState ::getWaiting )
785
- .ifPresent (waiting -> updateStatus (waiting .getReason (), waiting .getMessage ()));
785
+ .map (V1ContainerState ::getWaiting )
786
+ .ifPresent (waiting -> updateStatus (waiting .getReason (), waiting .getMessage ()));
786
787
}
787
788
788
789
private void updateStatus (String reason , String message ) {
@@ -791,9 +792,9 @@ private void updateStatus(String reason, String message) {
791
792
792
793
private V1ContainerStatus getMatchingContainerStatus (V1Pod pod , String domainUid ) {
793
794
return pod .getStatus ().getContainerStatuses ().stream ()
794
- .filter (s -> toJobIntrospectorName (domainUid ).equals (s .getName ()))
795
- .findFirst ()
796
- .orElse (null );
795
+ .filter (s -> toJobIntrospectorName (domainUid ).equals (s .getName ()))
796
+ .findFirst ()
797
+ .orElse (null );
797
798
}
798
799
}
799
800
}
0 commit comments