protected boolean changeState(State oldState,State newState,boolean force) throws RemoteException {
  Object service=_electTemplate.getService();
  ActiveElectionState oldJoinState=new ActiveElectionState(oldState);
  ActiveElectionState newJoinState=new ActiveElectionState(newState);
  while (!isTerminate()) {
    try {
      _namingService.modifyNamingAttributes(service,new Entry[]{oldJoinState},new Entry[]{newJoinState});
      setCurrentState(newState);
      if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("Changed state from [" + (oldState == null ? "any" : oldState) + "] to ["+ newState+ "]");
      }
      return true;
    }
 catch (    RemoteException ex) {
      String msg="ChangeState failed for service: " + service.getClass();
      if (force)       msg=msg + ".ForceChange enabled - Retry again...";
      if (_logger.isLoggable(Level.FINE))       _logger.log(Level.FINE,msg,ex);
      if (force) {
        try {
          Thread.sleep(_config.getYieldTime());
          continue;
        }
 catch (        InterruptedException e) {
          return false;
        }
      }
      throw new RemoteException(msg,ex);
    }
  }
  return false;
}

protected boolean changeState ( State oldState , State newState , boolean force ) throws RemoteException { Object service = _electTemplate . getService ( ) ; ActiveElectionState oldJoinState = new ActiveElectionState ( oldState ) ; ActiveElectionState newJoinState = new ActiveElectionState ( newState ) ; while ( ! isTerminate ( ) ) { try { _namingService . modifyNamingAttributes ( service , new Entry [ ] { oldJoinState } , new Entry [ ] { newJoinState } ) ; setCurrentState ( newState ) ; if ( _logger . isLoggable ( Level . FINE ) ) { _logger . fine ( "Changed state from [" + ( oldState == null ? "any" : oldState ) + "] to [" + newState + "]" ) ; } return true ; } catch ( RemoteException ex ) { String msg = "ChangeState failed for service: " + service . getClass ( ) ; if ( force ) msg = msg + ".ForceChange enabled - Retry again..." ; if ( _logger . isLoggable ( Level . FINE ) ) _logger . log ( Level . FINE , msg , ex ) ; if ( force ) { try { Thread . sleep ( _config . getYieldTime ( ) ) ; continue ; } catch ( InterruptedException e ) { return false ; } } throw new RemoteException ( msg , ex ) ; } } return false ; }
change the service state on naming service .
