40
40
import oracle .kubernetes .operator .helpers .PodHelper ;
41
41
import oracle .kubernetes .operator .helpers .ResponseStep ;
42
42
import oracle .kubernetes .operator .helpers .ServiceHelper ;
43
+ import oracle .kubernetes .operator .logging .LoggingFacade ;
44
+ import oracle .kubernetes .operator .logging .LoggingFactory ;
43
45
import oracle .kubernetes .operator .logging .LoggingFilter ;
44
46
import oracle .kubernetes .operator .logging .MessageKeys ;
45
47
import oracle .kubernetes .operator .logging .OncePerMessageLoggingFilter ;
63
65
import oracle .kubernetes .weblogic .domain .model .DomainSpec ;
64
66
65
67
import static oracle .kubernetes .operator .helpers .LegalNames .toJobIntrospectorName ;
66
- import static oracle .kubernetes .operator .logging .LoggingFacade .LOGGER ;
67
68
68
69
public class DomainProcessorImpl implements DomainProcessor {
69
70
71
+ private static final LoggingFacade LOGGER = LoggingFactory .getLogger ("Operator" , "Operator" );
72
+
70
73
private static final Map <String , FiberGate > makeRightFiberGates = new ConcurrentHashMap <>();
71
74
private static final Map <String , FiberGate > statusFiberGates = new ConcurrentHashMap <>();
72
75
// Map from namespace to map of domainUID to Domain
73
76
private static final Map <String , Map <String , DomainPresenceInfo >> DOMAINS =
74
- new ConcurrentHashMap <>();
77
+ new ConcurrentHashMap <>();
75
78
private static final ConcurrentMap <String , ConcurrentMap <String , ScheduledFuture <?>>>
76
- statusUpdaters = new ConcurrentHashMap <>();
79
+ statusUpdaters = new ConcurrentHashMap <>();
77
80
private DomainProcessorDelegate delegate ;
78
81
79
82
public DomainProcessorImpl (DomainProcessorDelegate delegate ) {
@@ -86,8 +89,8 @@ private static DomainPresenceInfo getExistingDomainPresenceInfo(String ns, Strin
86
89
87
90
private static void registerDomainPresenceInfo (DomainPresenceInfo info ) {
88
91
DOMAINS
89
- .computeIfAbsent (info .getNamespace (), k -> new ConcurrentHashMap <>())
90
- .put (info .getDomainUid (), info );
92
+ .computeIfAbsent (info .getNamespace (), k -> new ConcurrentHashMap <>())
93
+ .put (info .getDomainUid (), info );
91
94
}
92
95
93
96
private static void unregisterPresenceInfo (String ns , String domainUid ) {
@@ -98,9 +101,9 @@ private static void unregisterPresenceInfo(String ns, String domainUid) {
98
101
}
99
102
100
103
private static void registerStatusUpdater (
101
- String ns , String domainUid , ScheduledFuture <?> future ) {
104
+ String ns , String domainUid , ScheduledFuture <?> future ) {
102
105
ScheduledFuture <?> existing =
103
- statusUpdaters .computeIfAbsent (ns , k -> new ConcurrentHashMap <>()).put (domainUid , future );
106
+ statusUpdaters .computeIfAbsent (ns , k -> new ConcurrentHashMap <>()).put (domainUid , future );
104
107
if (existing != null ) {
105
108
existing .cancel (false );
106
109
}
@@ -127,29 +130,29 @@ private static void onEvent(V1Event event) {
127
130
if (status == null ) return ;
128
131
129
132
Optional .ofNullable (DOMAINS .get (event .getMetadata ().getNamespace ()))
130
- .map (m -> m .get (domainUid ))
131
- .ifPresent (info -> info .updateLastKnownServerStatus (serverName , status ));
133
+ .map (m -> m .get (domainUid ))
134
+ .ifPresent (info -> info .updateLastKnownServerStatus (serverName , status ));
132
135
}
133
136
134
137
private static String getReadinessStatus (V1Event event ) {
135
138
return Optional .ofNullable (event .getMessage ())
136
- .filter (m -> m .contains (WebLogicConstants .READINESS_PROBE_NOT_READY_STATE ))
137
- .map (m -> m .substring (m .lastIndexOf (':' ) + 1 ).trim ())
138
- .orElse (null );
139
+ .filter (m -> m .contains (WebLogicConstants .READINESS_PROBE_NOT_READY_STATE ))
140
+ .map (m -> m .substring (m .lastIndexOf (':' ) + 1 ).trim ())
141
+ .orElse (null );
139
142
}
140
143
141
144
private static Step readExistingPods (DomainPresenceInfo info ) {
142
145
return new CallBuilder ()
143
- .withLabelSelectors (
144
- LabelConstants .forDomainUidSelector (info .getDomainUid ()),
145
- LabelConstants .CREATEDBYOPERATOR_LABEL )
146
- .listPodAsync (info .getNamespace (), new PodListStep (info ));
146
+ .withLabelSelectors (
147
+ LabelConstants .forDomainUidSelector (info .getDomainUid ()),
148
+ LabelConstants .CREATEDBYOPERATOR_LABEL )
149
+ .listPodAsync (info .getNamespace (), new PodListStep (info ));
147
150
}
148
151
149
152
// pre-conditions: DomainPresenceInfo SPI
150
153
// "principal"
151
154
static Step bringAdminServerUp (
152
- DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
155
+ DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
153
156
return Step .chain (bringAdminServerUpSteps (info , podAwaiterStepFactory , next ));
154
157
}
155
158
@@ -161,7 +164,7 @@ private static Step[] domainIntrospectionSteps(Step next) {
161
164
}
162
165
163
166
private static Step [] bringAdminServerUpSteps (
164
- DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
167
+ DomainPresenceInfo info , PodAwaiterStepFactory podAwaiterStepFactory , Step next ) {
165
168
List <Step > resources = new ArrayList <>();
166
169
resources .add (new BeforeAdminServiceStep (null ));
167
170
resources .add (PodHelper .createAdminPodStep (null ));
@@ -469,7 +472,8 @@ private void internalMakeRightDomainPresence(
469
472
Step strategy =
470
473
new StartPlanStep (
471
474
info , isDeleting ? createDomainDownPlan (info ) : createDomainUpPlan (info ));
472
- if (!isDeleting && dom != null ) strategy = new DomainValidationStep (dom , strategy );
475
+ if (!isDeleting && dom != null )
476
+ strategy = new DomainValidationStep (dom , strategy );
473
477
474
478
runDomainPlan (
475
479
dom ,
@@ -628,8 +632,8 @@ private static class PodListStep extends ResponseStep<V1PodList> {
628
632
@ Override
629
633
public NextAction onFailure (Packet packet , CallResponse <V1PodList > callResponse ) {
630
634
return callResponse .getStatusCode () == CallBuilder .NOT_FOUND
631
- ? onSuccess (packet , callResponse )
632
- : super .onFailure (packet , callResponse );
635
+ ? onSuccess (packet , callResponse )
636
+ : super .onFailure (packet , callResponse );
633
637
}
634
638
635
639
@ Override
@@ -685,8 +689,8 @@ private class ServiceListStep extends ResponseStep<V1ServiceList> {
685
689
@ Override
686
690
public NextAction onFailure (Packet packet , CallResponse <V1ServiceList > callResponse ) {
687
691
return callResponse .getStatusCode () == CallBuilder .NOT_FOUND
688
- ? onSuccess (packet , callResponse )
689
- : super .onFailure (packet , callResponse );
692
+ ? onSuccess (packet , callResponse )
693
+ : super .onFailure (packet , callResponse );
690
694
}
691
695
692
696
@ Override
@@ -720,10 +724,10 @@ public NextAction apply(Packet packet) {
720
724
PodAwaiterStepFactory pw = delegate .getPodAwaiterStepFactory (info .getNamespace ());
721
725
info .setDeleting (false );
722
726
packet
723
- .getComponents ()
724
- .put (
725
- ProcessingConstants .DOMAIN_COMPONENT_NAME ,
726
- Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
727
+ .getComponents ()
728
+ .put (
729
+ ProcessingConstants .DOMAIN_COMPONENT_NAME ,
730
+ Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
727
731
return doNext (packet );
728
732
}
729
733
}
@@ -763,10 +767,10 @@ public NextAction apply(Packet packet) {
763
767
unregisterStatusUpdater (ns , info .getDomainUid ());
764
768
PodAwaiterStepFactory pw = delegate .getPodAwaiterStepFactory (ns );
765
769
packet
766
- .getComponents ()
767
- .put (
768
- ProcessingConstants .DOMAIN_COMPONENT_NAME ,
769
- Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
770
+ .getComponents ()
771
+ .put (
772
+ ProcessingConstants .DOMAIN_COMPONENT_NAME ,
773
+ Component .createFor (info , delegate .getVersion (), PodAwaiterStepFactory .class , pw ));
770
774
return doNext (packet );
771
775
}
772
776
}
@@ -784,9 +788,9 @@ private class DomainStatusUpdate {
784
788
785
789
public void invoke () {
786
790
Optional .ofNullable (getMatchingContainerStatus ())
787
- .map (V1ContainerStatus ::getState )
788
- .map (V1ContainerState ::getWaiting )
789
- .ifPresent (waiting -> updateStatus (waiting .getReason (), waiting .getMessage ()));
791
+ .map (V1ContainerStatus ::getState )
792
+ .map (V1ContainerState ::getWaiting )
793
+ .ifPresent (waiting -> updateStatus (waiting .getReason (), waiting .getMessage ()));
790
794
}
791
795
792
796
private void updateStatus (String reason , String message ) {
@@ -795,13 +799,12 @@ private void updateStatus(String reason, String message) {
795
799
796
800
private V1ContainerStatus getMatchingContainerStatus () {
797
801
return Optional .ofNullable (pod .getStatus ())
798
- .map (V1PodStatus ::getContainerStatuses )
799
- .flatMap (this ::getMatchingContainerStatus )
800
- .orElse (null );
802
+ .map (V1PodStatus ::getContainerStatuses )
803
+ .flatMap (this ::getMatchingContainerStatus )
804
+ .orElse (null );
801
805
}
802
806
803
- private Optional <V1ContainerStatus > getMatchingContainerStatus (
804
- Collection <V1ContainerStatus > statuses ) {
807
+ private Optional <V1ContainerStatus > getMatchingContainerStatus (Collection <V1ContainerStatus > statuses ) {
805
808
return statuses .stream ().filter (this ::hasInstrospectorJobName ).findFirst ();
806
809
}
807
810
0 commit comments