@@ -509,7 +509,7 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex
509
509
getChildren ();
510
510
}
511
511
} else {
512
- log .error ("getChildren () failed. rc = {}" , event .getResultCode ());
512
+ log .error ("creatingParentContainersIfNeeded () failed ( rc = {}) " , event .getResultCode ());
513
513
}
514
514
}
515
515
};
@@ -528,7 +528,7 @@ private synchronized void internalStart() {
528
528
reset ();
529
529
} catch (Exception e ) {
530
530
ThreadUtils .checkInterrupted (e );
531
- log .error ("An error occurred checking resetting leadership." , e );
531
+ log .error ("failed to check resetting leadership." , e );
532
532
}
533
533
}
534
534
}
@@ -548,7 +548,7 @@ private void checkLeadership(List<String> children) throws Exception {
548
548
log .debug ("checkLeadership with id: {}, ourPath: {}, children: {}" , id , localOurPath , sortedChildren );
549
549
550
550
if (ourIndex < 0 ) {
551
- log .error ("Can't find our node. Resetting. Index : {}" , ourIndex );
551
+ log .error ("failed to find our node; resetting (index : {}) " , ourIndex );
552
552
reset ();
553
553
return ;
554
554
}
@@ -582,7 +582,7 @@ public void process(WatchedEvent event) {
582
582
getChildren ();
583
583
} catch (Exception ex ) {
584
584
ThreadUtils .checkInterrupted (ex );
585
- log .error ("An error occurred checking the leadership." , ex );
585
+ log .error ("failed to check the leadership." , ex );
586
586
}
587
587
}
588
588
}
@@ -607,6 +607,17 @@ private void getChildren() throws Exception {
607
607
public void processResult (CuratorFramework client , CuratorEvent event ) throws Exception {
608
608
if (event .getResultCode () == KeeperException .Code .OK .intValue ()) {
609
609
checkLeadership (event .getChildren ());
610
+ } else if (event .getResultCode () == KeeperException .Code .NONODE .intValue ()) {
611
+ // latchPath has gone - reset
612
+ //
613
+ // This is possible when RECONNECTED during:
614
+ // (1) Scale the zk cluster to 0 nodes.
615
+ // (2) Scale it back.
616
+ //
617
+ // See also https://issues.apache.org/jira/browse/CURATOR-724
618
+ reset ();
619
+ } else {
620
+ log .error ("getChildren() failed (rc = {})" , event .getResultCode ());
610
621
}
611
622
}
612
623
};
@@ -616,11 +627,6 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex
616
627
@ VisibleForTesting
617
628
protected void handleStateChange (ConnectionState newState ) {
618
629
switch (newState ) {
619
- default : {
620
- // NOP
621
- break ;
622
- }
623
-
624
630
case RECONNECTED : {
625
631
try {
626
632
if (client .getConnectionStateErrorPolicy ().isErrorState (ConnectionState .SUSPENDED )
@@ -629,7 +635,7 @@ protected void handleStateChange(ConnectionState newState) {
629
635
}
630
636
} catch (Exception e ) {
631
637
ThreadUtils .checkInterrupted (e );
632
- log .error ("Could not reset leader latch" , e );
638
+ log .error ("failed to reset leader latch" , e );
633
639
setLeadership (false );
634
640
}
635
641
break ;
@@ -646,6 +652,11 @@ protected void handleStateChange(ConnectionState newState) {
646
652
setLeadership (false );
647
653
break ;
648
654
}
655
+
656
+ default : {
657
+ // NOP
658
+ break ;
659
+ }
649
660
}
650
661
}
651
662
0 commit comments