private boolean clearPrimary ( ) throws InterruptedException { try { if ( ! isPrimaryServiceCached ( ) ) { InetSocketAddress addr1 = servicePair . avatarAddr1 ; InetSocketAddress addr2 = servicePair . avatarAddr2 ; if ( avatarnodeAddress . equals ( addr2 ) ) { LOG . info ( "Restarting service for AvatarNode : " + addr1 ) ; servicePair . restartService1 ( ) ; } else if ( avatarnodeAddress . equals ( addr1 ) ) { LOG . info ( "Restarting service for AvatarNode : " + addr2 ) ; servicePair . restartService2 ( ) ; } else { throw new IOException ( "Address : " + avatarnodeAddress + " does not match any avatar address" ) ; } LOG . info ( "Finished Processing CLEAR PRIMARY requested by : " + this . avatarnodeAddress ) ; this . forceIncrementalReport = true ; this . donotDelayIncrementalBlockReports = true ; } InjectionHandler . processEvent ( InjectionEvent . OFFERSERVICE_CLEAR_PRIMARY ) ; } catch ( IOException e ) { LOG . error ( "Exception processing CLEAR PRIMARY" , e ) ; return false ; } return true ; }
This is clears up the thread heartbeating to the primary Avatar by restarting it . This makes sure all commands from the primary have been processed by the datanode . This method is used during failover .