private <T extends ClientRequestResult>Collection<T> executeRequest(final Collection<Long> ids,final Class<T> clazz,final ClientRequestReportListener reportListener,final String requestQueue){
  LOGGER.debug("Initiating client request.");
  ClientRequestImpl<T> clientRequest=new ClientRequestImpl<T>(clazz);
  Iterator<Long> it=ids.iterator();
  Collection<Future<Collection<T>>> results=new ArrayList<Future<Collection<T>>>();
  int counter=0;
  while (it.hasNext()) {
    while (it.hasNext() && counter < maxRequestSize) {
      clientRequest.addTagId(it.next());
      counter++;
    }
    RequestValuesTask<T> task=new RequestValuesTask<T>(clientRequest,reportListener,requestQueue);
    results.add(executor.submit(task));
    clientRequest=new ClientRequestImpl<T>(clazz);
    counter=0;
  }
  Collection<T> finalCollection=new ArrayList<T>();
  for (  Future<Collection<T>> result : results) {
    try {
      finalCollection.addAll(result.get());
    }
 catch (    InterruptedException e) {
      LOGGER.error("InterruptedException caught while executing RequestValuesTask.",e);
      throw new RuntimeException(e);
    }
catch (    ExecutionException e) {
      LOGGER.error("ExecutionException caught while executing RequestValuesTask.",e);
      throw new RuntimeException(e);
    }
  }
  LOGGER.debug("Client request completed.");
  return finalCollection;
}

private < T extends ClientRequestResult > Collection < T > executeRequest ( final Collection < Long > ids , final Class < T > clazz , final ClientRequestReportListener reportListener , final String requestQueue ) { LOGGER . debug ( "Initiating client request." ) ; ClientRequestImpl < T > clientRequest = new ClientRequestImpl < T > ( clazz ) ; Iterator < Long > it = ids . iterator ( ) ; Collection < Future < Collection < T > > > results = new ArrayList < Future < Collection < T > > > ( ) ; int counter = 0 ; while ( it . hasNext ( ) ) { while ( it . hasNext ( ) && counter < maxRequestSize ) { clientRequest . addTagId ( it . next ( ) ) ; counter ++ ; } RequestValuesTask < T > task = new RequestValuesTask < T > ( clientRequest , reportListener , requestQueue ) ; results . add ( executor . submit ( task ) ) ; clientRequest = new ClientRequestImpl < T > ( clazz ) ; counter = 0 ; } Collection < T > finalCollection = new ArrayList < T > ( ) ; for ( Future < Collection < T > > result : results ) { try { finalCollection . addAll ( result . get ( ) ) ; } catch ( InterruptedException e ) { LOGGER . error ( "InterruptedException caught while executing RequestValuesTask." , e ) ; throw new RuntimeException ( e ) ; } catch ( ExecutionException e ) { LOGGER . error ( "ExecutionException caught while executing RequestValuesTask." , e ) ; throw new RuntimeException ( e ) ; } } LOGGER . debug ( "Client request completed." ) ; return finalCollection ; }
splits and executes a id - base request , splitting the collection into smaller requests .
