@@ -84,8 +84,6 @@ public class Main {
8484 private static final String RUNNING_STATE = "RUNNING" ;
8585 private static final String ADMIN_STATE = "ADMIN" ;
8686
87- private static final String PODWATCHER_COMPONENT_NAME = "podWatcher" ;
88-
8987 private static final Container container = new Container ();
9088 private static final Engine engine = new Engine ("operator" , container );
9189
@@ -481,6 +479,10 @@ private static void scheduleDomainStatusUpdating(DomainPresenceInfo info) {
481479 AtomicReference <ScheduledFuture <?>> statusUpdater = info .getStatusUpdater ();
482480 Runnable command = new Runnable () {
483481 public void run () {
482+
483+ // TEST
484+ System .out .println ("**** 2 **** domainUID: " + info .getDomain ().getSpec ().getDomainUID ());
485+
484486 Runnable r = this ; // resolve visibility
485487 Packet packet = new Packet ();
486488 packet .getComponents ().put (ProcessingConstants .DOMAIN_COMPONENT_NAME ,
@@ -526,10 +528,22 @@ public void onThrowable(Packet packet, Throwable throwable) {
526528 });
527529 }
528530 };
531+
532+ // TEST
533+ System .out .println ("**** 3 **** domainUID: " + info .getDomain ().getSpec ().getDomainUID ());
534+
529535 MainTuning main = tuningAndConfig .getMainTuning ();
530536 ScheduledFuture <?> existing = statusUpdater .getAndSet (
531537 engine .getExecutor ().scheduleWithFixedDelay (command , main .initialShortDelay , main .initialShortDelay , TimeUnit .SECONDS ));
538+
539+ // TEST
540+ System .out .println ("**** 4 **** domainUID: " + info .getDomain ().getSpec ().getDomainUID ());
541+
532542 if (existing != null ) {
543+
544+ // TEST
545+ System .out .println ("**** 5 **** domainUID: " + info .getDomain ().getSpec ().getDomainUID ());
546+
533547 existing .cancel (false );
534548 }
535549 }
@@ -580,23 +594,26 @@ private static void doCheckAndCreateDomainPresence(
580594 info .setDomain (dom );
581595 }
582596
583- LOGGER .info (MessageKeys .PROCESSING_DOMAIN , domainUID );
584-
585- Step managedServerStrategy = bringManagedServersUp (
586- DomainStatusUpdater .createEndProgressingStep (null ));
587- Step adminServerStrategy = bringAdminServerUp (
588- connectToAdminAndInspectDomain (
589- managedServerStrategy ));
590-
591- Step strategy = DomainStatusUpdater .createProgressingStep (
592- DomainStatusUpdater .INSPECTING_DOMAIN_PROGRESS_REASON ,
593- true ,
594- new DomainPrescenceStep (adminServerStrategy , managedServerStrategy ));
595-
596- Packet p = new Packet ();
597-
598597 String ns = dom .getMetadata ().getNamespace ();
599- if (initialized .getOrDefault (ns , Boolean .FALSE )) {
598+ if (initialized .getOrDefault (ns , Boolean .FALSE ) && !stopping .get ()) {
599+ LOGGER .info (MessageKeys .PROCESSING_DOMAIN , domainUID );
600+
601+ // TEST
602+ System .out .println ("**** 0 **** domainUID: " + domainUID );
603+
604+ Step managedServerStrategy = bringManagedServersUp (
605+ DomainStatusUpdater .createEndProgressingStep (null ));
606+ Step adminServerStrategy = bringAdminServerUp (
607+ connectToAdminAndInspectDomain (
608+ managedServerStrategy ));
609+
610+ Step strategy = DomainStatusUpdater .createProgressingStep (
611+ DomainStatusUpdater .INSPECTING_DOMAIN_PROGRESS_REASON ,
612+ true ,
613+ new DomainPrescenceStep (adminServerStrategy , managedServerStrategy ));
614+
615+ Packet p = new Packet ();
616+
600617 PodWatcher pw = podWatchers .get (ns );
601618 p .getComponents ().put (ProcessingConstants .DOMAIN_COMPONENT_NAME ,
602619 Component .createFor (info , version , pw ));
@@ -618,43 +635,45 @@ private static void doCheckAndCreateDomainPresence(
618635 LOGGER .info (MessageKeys .ROLLING_CLUSTERS_STARTING , domainUID , explicitRestartClusters );
619636 }
620637
621- if (!stopping .get ()) {
622- domainUpdaters .startFiber (domainUID , strategy , p , new CompletionCallback () {
623- @ Override
624- public void onCompletion (Packet packet ) {
625- if (explicitRestartAdmin ) {
626- LOGGER .info (MessageKeys .RESTART_ADMIN_COMPLETE , domainUID );
627- }
628- if (explicitRestartServers != null ) {
629- LOGGER .info (MessageKeys .RESTART_SERVERS_COMPLETE , domainUID , explicitRestartServers );
630- }
631- if (explicitRestartClusters != null ) {
632- LOGGER .info (MessageKeys .ROLLING_CLUSTERS_COMPLETE , domainUID , explicitRestartClusters );
633- }
638+ domainUpdaters .startFiber (domainUID , strategy , p , new CompletionCallback () {
639+ @ Override
640+ public void onCompletion (Packet packet ) {
641+ if (explicitRestartAdmin ) {
642+ LOGGER .info (MessageKeys .RESTART_ADMIN_COMPLETE , domainUID );
634643 }
635-
636- @ Override
637- public void onThrowable (Packet packet , Throwable throwable ) {
638- LOGGER .severe (MessageKeys .EXCEPTION , throwable );
639-
640- domainUpdaters .startFiberIfLastFiberMatches (domainUID , Fiber .getCurrentIfSet (), DomainStatusUpdater .createFailedStep (throwable , null ), p , new CompletionCallback () {
641- @ Override
642- public void onCompletion (Packet packet ) {
643- // no-op
644- }
645-
646- @ Override
647- public void onThrowable (Packet packet , Throwable throwable ) {
648- LOGGER .severe (MessageKeys .EXCEPTION , throwable );
649- }
650- });
651-
652- // TODO: consider retrying domain update after a delay
644+ if (explicitRestartServers != null ) {
645+ LOGGER .info (MessageKeys .RESTART_SERVERS_COMPLETE , domainUID , explicitRestartServers );
653646 }
654- });
655-
656- scheduleDomainStatusUpdating (info );
657- }
647+ if (explicitRestartClusters != null ) {
648+ LOGGER .info (MessageKeys .ROLLING_CLUSTERS_COMPLETE , domainUID , explicitRestartClusters );
649+ }
650+ }
651+
652+ @ Override
653+ public void onThrowable (Packet packet , Throwable throwable ) {
654+ LOGGER .severe (MessageKeys .EXCEPTION , throwable );
655+
656+ domainUpdaters .startFiberIfLastFiberMatches (domainUID , Fiber .getCurrentIfSet (),
657+ DomainStatusUpdater .createFailedStep (throwable , null ), p , new CompletionCallback () {
658+ @ Override
659+ public void onCompletion (Packet packet ) {
660+ // no-op
661+ }
662+
663+ @ Override
664+ public void onThrowable (Packet packet , Throwable throwable ) {
665+ LOGGER .severe (MessageKeys .EXCEPTION , throwable );
666+ }
667+ });
668+
669+ // TODO: consider retrying domain update after a delay
670+ }
671+ });
672+
673+ // TEST
674+ System .out .println ("**** 1 **** domainUID: " + domainUID );
675+
676+ scheduleDomainStatusUpdating (info );
658677 }
659678 LOGGER .exiting ();
660679 }
@@ -779,7 +798,7 @@ public NextAction apply(Packet packet) {
779798 V1Pod adminPod = info .getAdmin ().getPod ().get ();
780799
781800 PodWatcher pw = podWatchers .get (adminPod .getMetadata ().getNamespace ());
782- packet .getComponents ().put (PODWATCHER_COMPONENT_NAME , Component .createFor (pw ));
801+ packet .getComponents ().put (ProcessingConstants . PODWATCHER_COMPONENT_NAME , Component .createFor (pw ));
783802
784803 return doNext (pw .waitForReady (adminPod , next ), packet );
785804 }
0 commit comments