@@ -106,7 +106,7 @@ public class DomainProcessorImpl implements DomainProcessor, MakeRightExecutor {
106106 private static Map <String , Map <String , ScheduledFuture <?>>> statusUpdaters = new ConcurrentHashMap <>();
107107
108108 // List of clusters in a namespace.
109- private static Map <String , Map <String , ClusterPresenceInfo >> clusters = new ConcurrentHashMap <>();
109+ private static final Map <String , Map <String , ClusterPresenceInfo >> clusters = new ConcurrentHashMap <>();
110110
111111 private final DomainProcessorDelegate delegate ;
112112 private final SemanticVersion productVersion ;
@@ -132,11 +132,12 @@ public DomainProcessorImpl(DomainProcessorDelegate delegate, SemanticVersion pro
132132 this .productVersion = productVersion ;
133133 }
134134
135- private static DomainPresenceInfo getExistingDomainPresenceInfo (String ns , String domainUid ) {
135+ @ Override
136+ public DomainPresenceInfo getExistingDomainPresenceInfo (String ns , String domainUid ) {
136137 return domains .computeIfAbsent (ns , k -> new ConcurrentHashMap <>()).get (domainUid );
137138 }
138139
139- private static DomainPresenceInfo getExistingDomainPresenceInfo (DomainPresenceInfo newPresence ) {
140+ private DomainPresenceInfo getExistingDomainPresenceInfo (DomainPresenceInfo newPresence ) {
140141 return getExistingDomainPresenceInfo (newPresence .getNamespace (), newPresence .getDomainUid ());
141142 }
142143
@@ -158,6 +159,11 @@ public Map<String, Map<String,ClusterPresenceInfo>> getClusterPresenceInfoMap()
158159 return clusters ;
159160 }
160161
162+ @ Override
163+ public Map <String , FiberGate > getMakeRightFiberGateMap () {
164+ return makeRightFiberGates ;
165+ }
166+
161167 private static List <DomainPresenceInfo > getExistingDomainPresenceInfoForCluster (String ns , String cluster ) {
162168 List <DomainPresenceInfo > referencingDomains = new ArrayList <>();
163169 Optional .ofNullable (domains .get (ns )).ifPresent (d -> d .values ().stream ()
@@ -244,21 +250,10 @@ private static void deleteEventK8SObjects(CoreV1Event event) {
244250 getEventK8SObjects (event ).remove (event );
245251 }
246252
247- private static void onCreateModifyEvent (CoreV1Event event ) {
248- V1ObjectReference ref = event .getInvolvedObject ();
249-
250- if (ref == null || ref .getName () == null ) {
251- return ;
252- }
253-
254- String kind = ref .getKind ();
255- if (kind == null ) {
256- return ;
257- }
258-
253+ private static void onCreateModifyEvent (@ Nonnull String kind , @ Nonnull String name , CoreV1Event event ) {
259254 switch (kind ) {
260255 case EventConstants .EVENT_KIND_POD :
261- processPodEvent (event );
256+ processPodEvent (name , event );
262257 break ;
263258 case EventConstants .EVENT_KIND_DOMAIN :
264259 case EventConstants .EVENT_KIND_NAMESPACE :
@@ -272,13 +267,8 @@ private static void onCreateModifyEvent(CoreV1Event event) {
272267 }
273268 }
274269
275- private static void processPodEvent (CoreV1Event event ) {
276- V1ObjectReference ref = event .getInvolvedObject ();
277-
278- if (ref == null || ref .getName () == null ) {
279- return ;
280- }
281- if (ref .getName ().equals (NamespaceHelper .getOperatorPodName ())) {
270+ private static void processPodEvent (@ Nonnull String name , CoreV1Event event ) {
271+ if (name .equals (NamespaceHelper .getOperatorPodName ())) {
282272 updateEventK8SObjects (event );
283273 } else {
284274 processServerEvent (event );
@@ -313,30 +303,19 @@ public static List<DomainResource> getDomains(String ns) {
313303 }
314304
315305 private static void addToList (List <DomainResource > list , DomainPresenceInfo info ) {
316- if (info . isNotDeleting ()) {
306+ if (isNotDeleting (info )) {
317307 list .add (info .getDomain ());
318308 }
319309 }
320310
321- private void onDeleteEvent (CoreV1Event event ) {
322- V1ObjectReference ref = event .getInvolvedObject ();
323-
324- if (ref == null || ref .getName () == null ) {
325- return ;
326- }
327-
328- String kind = ref .getKind ();
329- if (kind == null ) {
330- return ;
331- }
332-
311+ private void onDeleteEvent (@ Nonnull String kind , @ Nonnull String name , CoreV1Event event ) {
333312 switch (kind ) {
334313 case EventConstants .EVENT_KIND_DOMAIN :
335314 case EventConstants .EVENT_KIND_NAMESPACE :
336315 deleteEventK8SObjects (event );
337316 break ;
338317 case EventConstants .EVENT_KIND_POD :
339- if (ref . getName () .equals (NamespaceHelper .getOperatorPodName ())) {
318+ if (name .equals (NamespaceHelper .getOperatorPodName ())) {
340319 deleteEventK8SObjects (event );
341320 }
342321 break ;
@@ -432,7 +411,11 @@ private boolean findClusterPresenceInfo(String namespace, String clusterName) {
432411 }
433412
434413 private boolean hasDeletedClusterEventData (MakeRightClusterOperation operation ) {
435- return operation .getEventData () != null && operation .getEventData ().getItem ().name ().equals ("CLUSTER_DELETED" );
414+ return EventItem .CLUSTER_DELETED == getEventItem (operation );
415+ }
416+
417+ private EventItem getEventItem (MakeRightClusterOperation operation ) {
418+ return Optional .ofNullable (operation .getEventData ()).map (EventData ::getItem ).orElse (null );
436419 }
437420
438421 private void logStartingDomain (DomainPresenceInfo presenceInfo ) {
@@ -477,6 +460,10 @@ public void registerClusterPresenceInfo(ClusterPresenceInfo info) {
477460 @ Override
478461 public void unregisterDomainPresenceInfo (DomainPresenceInfo info ) {
479462 unregisterPresenceInfo (info .getNamespace (), info .getDomainUid ());
463+ }
464+
465+ @ Override
466+ public void unregisterDomainEventK8SObjects (DomainPresenceInfo info ) {
480467 unregisterEventK8SObject (info .getNamespace (), info .getDomainUid ());
481468 }
482469
@@ -595,7 +582,7 @@ private void processServerPodWatch(V1Pod pod, String watchType) {
595582 break ;
596583 case DELETED :
597584 boolean removed = info .deleteServerPodFromEvent (serverName , pod );
598- if (removed && info . isNotDeleting () && Boolean .FALSE .equals (info .isServerPodBeingDeleted (serverName ))) {
585+ if (removed && isNotDeleting (info ) && Boolean .FALSE .equals (info .isServerPodBeingDeleted (serverName ))) {
599586 LOGGER .info (MessageKeys .POD_DELETED , domainUid , getPodNamespace (pod ), serverName );
600587 createMakeRightOperation (info ).interrupt ().withExplicitRecheck ().execute ();
601588 }
@@ -670,7 +657,7 @@ public void dispatchServiceWatch(Watch.Response<V1Service> item) {
670657 break ;
671658 case DELETED :
672659 boolean removed = ServiceHelper .deleteFromEvent (info , item .object );
673- if (removed && info . isNotDeleting ()) {
660+ if (removed && isNotDeleting (info )) {
674661 createMakeRightOperation (info ).interrupt ().withExplicitRecheck ().execute ();
675662 }
676663 break ;
@@ -702,14 +689,18 @@ public void dispatchPodDisruptionBudgetWatch(Watch.Response<V1PodDisruptionBudge
702689 break ;
703690 case DELETED :
704691 boolean removed = PodDisruptionBudgetHelper .deleteFromEvent (info , item .object );
705- if (removed && info . isNotDeleting ()) {
692+ if (removed && isNotDeleting (info )) {
706693 createMakeRightOperation (info ).interrupt ().withExplicitRecheck ().execute ();
707694 }
708695 break ;
709696 default :
710697 }
711698 }
712699
700+ private static boolean isNotDeleting (DomainPresenceInfo info ) {
701+ return info .isNotDeleting () && info .getDomain () != null ;
702+ }
703+
713704 private String getPDBNamespace (V1PodDisruptionBudget pdb ) {
714705 return Optional .ofNullable (pdb ).map (V1PodDisruptionBudget ::getMetadata )
715706 .map (V1ObjectMeta ::getNamespace ).orElse (null );
@@ -721,7 +712,7 @@ private String getPDBNamespace(V1PodDisruptionBudget pdb) {
721712 */
722713 public void dispatchConfigMapWatch (Watch .Response <V1ConfigMap > item ) {
723714 V1ConfigMap c = item .object ;
724- if (c != null && c .getMetadata () != null ) {
715+ if (c .getMetadata () != null ) {
725716 switch (item .type ) {
726717 case MODIFIED :
727718 case DELETED :
@@ -742,18 +733,22 @@ public void dispatchConfigMapWatch(Watch.Response<V1ConfigMap> item) {
742733 */
743734 public void dispatchEventWatch (Watch .Response <CoreV1Event > item ) {
744735 CoreV1Event e = item .object ;
745- if (e != null ) {
746- switch (item .type ) {
747- case ADDED :
748- case MODIFIED :
749- onCreateModifyEvent (e );
750- break ;
751- case DELETED :
752- onDeleteEvent (e );
753- break ;
754- case ERROR :
755- default :
756- }
736+ V1ObjectReference ref = e .getInvolvedObject ();
737+
738+ if (ref == null || ref .getName () == null || ref .getKind () == null ) {
739+ return ;
740+ }
741+
742+ switch (item .type ) {
743+ case ADDED :
744+ case MODIFIED :
745+ onCreateModifyEvent (ref .getKind (), ref .getName (), e );
746+ break ;
747+ case DELETED :
748+ onDeleteEvent (ref .getKind (), ref .getName (), e );
749+ break ;
750+ case ERROR :
751+ default :
757752 }
758753 }
759754
0 commit comments