public void setPrimary ( InstanceId ofPrimary ) throws IOException { if ( ofPrimary == null ) { // failover in progress primaryNode = null ; standbyNode = null ; return ; } switch ( ofPrimary ) { case NODEZERO : primaryNode = getNodeZero ( ) ; standbyNode = getNodeOne ( ) ; case NODEONE : primaryNode = getNodeOne ( ) ; standbyNode = getNodeZero ( ) ; } }
The purpose of this method is to update in memory references to primary and standby . Please override this method and do the zookeeper specific logic in the method and call this method on successful zookeeper write .