static boolean chunkSet(InternalDistributedMember recipient,Set set,int CHUNK_SIZE_IN_BYTES,boolean includeValues,ObjectIntProcedure proc) throws IOException {
  Iterator it=set.iterator();
  boolean keepGoing=true;
  boolean sentLastChunk=false;
  final HeapDataOutputStream mos=new HeapDataOutputStream(InitialImageOperation.CHUNK_SIZE_IN_BYTES + 2048,recipient.getVersionObject());
  do {
    mos.reset();
    int avgItemSize=0;
    int itemCount=0;
    while ((mos.size() + avgItemSize) < InitialImageOperation.CHUNK_SIZE_IN_BYTES && it.hasNext()) {
      Object key=it.next();
      DataSerializer.writeObject(key,mos);
      itemCount++;
      avgItemSize=mos.size() / itemCount;
    }
    DataSerializer.writeObject((Object)null,mos);
    int lastMsg=it.hasNext() ? 0 : 1;
    keepGoing=proc.executeWith(mos,lastMsg);
    sentLastChunk=lastMsg == 1 && keepGoing;
  }
 while (keepGoing && it.hasNext());
  return sentLastChunk;
}

static boolean chunkSet ( InternalDistributedMember recipient , Set set , int CHUNK_SIZE_IN_BYTES , boolean includeValues , ObjectIntProcedure proc ) throws IOException { Iterator it = set . iterator ( ) ; boolean keepGoing = true ; boolean sentLastChunk = false ; final HeapDataOutputStream mos = new HeapDataOutputStream ( InitialImageOperation . CHUNK_SIZE_IN_BYTES + 2048 , recipient . getVersionObject ( ) ) ; do { mos . reset ( ) ; int avgItemSize = 0 ; int itemCount = 0 ; while ( ( mos . size ( ) + avgItemSize ) < InitialImageOperation . CHUNK_SIZE_IN_BYTES && it . hasNext ( ) ) { Object key = it . next ( ) ; DataSerializer . writeObject ( key , mos ) ; itemCount ++ ; avgItemSize = mos . size ( ) / itemCount ; } DataSerializer . writeObject ( ( Object ) null , mos ) ; int lastMsg = it . hasNext ( ) ? 0 : 1 ; keepGoing = proc . executeWith ( mos , lastMsg ) ; sentLastChunk = lastMsg == 1 && keepGoing ; } while ( keepGoing && it . hasNext ( ) ) ; return sentLastChunk ; }
serialize the given set ' s elments into byte [ ] chunks , calling proc for each one . proc args : the byte [ ] chunk and an int indicating whether it is the last chunk ( positive means last chunk , zero othewise ) . the return value of proc indicates whether to continue to the next chunk ( true ) or abort ( false ) .
