void waitForLogEntry(int index,int timeout) throws GondolaException, InterruptedException, TimeoutException {
  reset();
  this.index=index;
  long endTs=timeout < 0 ? Long.MAX_VALUE : gondola.getClock().now() + timeout;
  lock.lock();
  try {
    while (status == Command.STATUS_NONE && gondola.getClock().now() < endTs) {
      if (timeout < 0) {
        updateCond.await();
      }
 else {
        updateCond.await(timeout,TimeUnit.MILLISECONDS);
      }
    }
    if (this.index != index) {
      logger.error("This command object is being used by another thread");
    }
  }
  finally {
    lock.unlock();
  }
switch (status) {
case Command.STATUS_NONE:
    status=Command.STATUS_TIMEOUT;
  throw new TimeoutException(String.format("Timeout (%d ms) for index %d",timeout,index));
case Command.STATUS_NOT_LEADER:
assert false;
break;
case Command.STATUS_SLAVE_MODE:
throw new GondolaException(GondolaException.Code.SLAVE_MODE,cmember.memberId);
case Command.STATUS_ERROR:
throw new IllegalStateException("Error getting index " + index + ": "+ errorMessage);
case Command.STATUS_OK:
break;
}
}

void waitForLogEntry ( int index , int timeout ) throws GondolaException , InterruptedException , TimeoutException { reset ( ) ; this . index = index ; long endTs = timeout < 0 ? Long . MAX_VALUE : gondola . getClock ( ) . now ( ) + timeout ; lock . lock ( ) ; try { while ( status == Command . STATUS_NONE && gondola . getClock ( ) . now ( ) < endTs ) { if ( timeout < 0 ) { updateCond . await ( ) ; } else { updateCond . await ( timeout , TimeUnit . MILLISECONDS ) ; } } if ( this . index != index ) { logger . error ( "This command object is being used by another thread" ) ; } } finally { lock . unlock ( ) ; } switch ( status ) { case Command . STATUS_NONE : status = Command . STATUS_TIMEOUT ; throw new TimeoutException ( String . format ( "Timeout (%d ms) for index %d" , timeout , index ) ) ; case Command . STATUS_NOT_LEADER : assert false ; break ; case Command . STATUS_SLAVE_MODE : throw new GondolaException ( GondolaException . Code . SLAVE_MODE , cmember . memberId ) ; case Command . STATUS_ERROR : throw new IllegalStateException ( "Error getting index " + index + ": " + errorMessage ) ; case Command . STATUS_OK : break ; } }
this should not be called by clients . this method is called indirectly via a client call to shard . getcommittedcommand ( ) , when the requested index has not been committed yet . after this call , this command object can be used again .
