public void testSimpleExchange() throws InterruptedException, ExecutionException, TimeoutException, ImmediateDownstreamReplicationException {
  final long timeout=5000;
{
    final ByteBuffer tst1=getRandomData(50);
    final HAMessageWrapper msg1=newHAWriteMessage(50,tst1);
    final ByteBuffer rcv=ByteBuffer.allocate(2000);
    final Future<Void> futRec=receiveService.receiveData(msg1,rcv);
    final Future<Void> futSnd=sendService.send(tst1,msg1.getMarker());
    futSnd.get(timeout,TimeUnit.MILLISECONDS);
    futRec.get(timeout,TimeUnit.MILLISECONDS);
    assertEquals(tst1,rcv);
  }
{
    final ByteBuffer tst2=getRandomData(100);
    final HAMessageWrapper msg2=newHAWriteMessage(100,tst2);
    final ByteBuffer rcv2=ByteBuffer.allocate(2000);
    final Future<Void> futSnd=sendService.send(tst2,msg2.getMarker());
    final Future<Void> futRec=receiveService.receiveData(msg2,rcv2);
    futSnd.get(timeout,TimeUnit.MILLISECONDS);
    futRec.get(timeout,TimeUnit.MILLISECONDS);
    assertEquals(tst2,rcv2);
  }
}

public void testSimpleExchange ( ) throws InterruptedException , ExecutionException , TimeoutException , ImmediateDownstreamReplicationException { final long timeout = 5000 ; { final ByteBuffer tst1 = getRandomData ( 50 ) ; final HAMessageWrapper msg1 = newHAWriteMessage ( 50 , tst1 ) ; final ByteBuffer rcv = ByteBuffer . allocate ( 2000 ) ; final Future < Void > futRec = receiveService . receiveData ( msg1 , rcv ) ; final Future < Void > futSnd = sendService . send ( tst1 , msg1 . getMarker ( ) ) ; futSnd . get ( timeout , TimeUnit . MILLISECONDS ) ; futRec . get ( timeout , TimeUnit . MILLISECONDS ) ; assertEquals ( tst1 , rcv ) ; } { final ByteBuffer tst2 = getRandomData ( 100 ) ; final HAMessageWrapper msg2 = newHAWriteMessage ( 100 , tst2 ) ; final ByteBuffer rcv2 = ByteBuffer . allocate ( 2000 ) ; final Future < Void > futSnd = sendService . send ( tst2 , msg2 . getMarker ( ) ) ; final Future < Void > futRec = receiveService . receiveData ( msg2 , rcv2 ) ; futSnd . get ( timeout , TimeUnit . MILLISECONDS ) ; futRec . get ( timeout , TimeUnit . MILLISECONDS ) ; assertEquals ( tst2 , rcv2 ) ; } }
should we expect concurrency of the socket send and rmi ? it seems that we should be able to handle it whatever the logical argument . the only constraint should be on the processing of each pair of socket / rmi interactions . otoh , if we are intending to process the op_accept and op_read within the readtask that can only be processed after the rmi is received , then we should not sen the socket until we have a returned futuretask .
