public Future<SyncReply> sendRequest(int xid,SyncMessage request) throws RemoteStoreException {
  ensureConnected();
  RemoteSyncFuture future=new RemoteSyncFuture(xid,connectionGeneration);
  futureMap.put(Integer.valueOf(xid),future);
  if (futureMap.size() > MAX_PENDING_REQUESTS) {
synchronized (futureNotify) {
      while (futureMap.size() > MAX_PENDING_REQUESTS) {
        try {
          futureNotify.wait();
        }
 catch (        InterruptedException e) {
          throw new RemoteStoreException("Could not send request",e);
        }
      }
    }
  }
  channel.writeAndFlush(request);
  return future;
}

public Future < SyncReply > sendRequest ( int xid , SyncMessage request ) throws RemoteStoreException { ensureConnected ( ) ; RemoteSyncFuture future = new RemoteSyncFuture ( xid , connectionGeneration ) ; futureMap . put ( Integer . valueOf ( xid ) , future ) ; if ( futureMap . size ( ) > MAX_PENDING_REQUESTS ) { synchronized ( futureNotify ) { while ( futureMap . size ( ) > MAX_PENDING_REQUESTS ) { try { futureNotify . wait ( ) ; } catch ( InterruptedException e ) { throw new RemoteStoreException ( "Could not send request" , e ) ; } } } } channel . writeAndFlush ( request ) ; return future ; }
send a request to the server and generate a future for the eventual reply . note that this call can block if there is no active connection while a new connection is re - established or if the maximum number of requests is already pending
