public void testNullMessageToAll() throws Exception {
    d1.setRequestHandler(new MyHandler(null));

    c2 = createChannel(c1);
    c2.setName("B");
    disableBundling(c2);
    long stop, start = System.currentTimeMillis();
    d2 = new MessageDispatcher(c2, null, null, new MyHandler(null));
    stop = System.currentTimeMillis();
    c2.connect("MessageDispatcherUnitTest");
    Assert.assertEquals(2, c2.getView().size());
    System.out.println("view: " + c2.getView());

    System.out.println("casting message");
    start = System.currentTimeMillis();
    RspList rsps = d1.castMessage(null, new Message(), new RequestOptions(ResponseMode.GET_ALL, 0));
    stop = System.currentTimeMillis();
    System.out.println("rsps:\n" + rsps);
    System.out.println("call took " + (stop - start) + " ms");
    assertNotNull(rsps);
    Assert.assertEquals(2, rsps.size());
    Rsp rsp = rsps.get(c1.getAddress());
    assertNotNull(rsp);
    Object ret = rsp.getValue();
    assert ret == null;

    rsp = rsps.get(c2.getAddress());
    assertNotNull(rsp);
    ret = rsp.getValue();
    assert ret == null;

    Util.close(c2);
  }
  private void sendMessageToBothChannels(int size) throws Exception {
    long start, stop;
    d1.setRequestHandler(new MyHandler(new byte[size]));

    c2 = createChannel(c1);
    c2.setName("B");
    disableBundling(c2);
    d2 = new MessageDispatcher(c2, null, null, new MyHandler(new byte[size]));
    c2.connect("MessageDispatcherUnitTest");
    Assert.assertEquals(2, c2.getView().size());

    System.out.println("casting message");
    start = System.currentTimeMillis();
    RspList rsps = d1.castMessage(null, new Message(), new RequestOptions(ResponseMode.GET_ALL, 0));
    stop = System.currentTimeMillis();
    System.out.println("rsps:\n" + rsps);
    System.out.println("call took " + (stop - start) + " ms");
    assertNotNull(rsps);
    Assert.assertEquals(2, rsps.size());
    Rsp rsp = rsps.get(c1.getAddress());
    assertNotNull(rsp);
    byte[] ret = (byte[]) rsp.getValue();
    Assert.assertEquals(size, ret.length);

    rsp = rsps.get(c2.getAddress());
    assertNotNull(rsp);
    ret = (byte[]) rsp.getValue();
    Assert.assertEquals(size, ret.length);

    Util.close(c2);
  }
示例#3
0
  public Results startTest() throws Throwable {
    System.out.println(
        "invoking "
            + num_msgs
            + " RPCs of "
            + Util.printBytes(msg_size)
            + ", sync="
            + sync
            + ", oob="
            + oob);
    int total_gets = 0, total_puts = 0;
    final AtomicInteger num_msgs_sent = new AtomicInteger(0);

    Invoker[] invokers = new Invoker[num_threads];
    for (int i = 0; i < invokers.length; i++)
      invokers[i] = new Invoker(members, num_msgs, num_msgs_sent);

    long start = System.currentTimeMillis();
    for (Invoker invoker : invokers) invoker.start();

    for (Invoker invoker : invokers) {
      invoker.join();
      total_gets += invoker.numGets();
      total_puts += invoker.numPuts();
    }

    long total_time = System.currentTimeMillis() - start;
    System.out.println("done (in " + total_time + " ms)");
    return new Results(total_gets, total_puts, total_time);
  }
 private void sendMessage(int size) throws Exception {
   long start, stop;
   MyHandler handler = new MyHandler(new byte[size]);
   d1.setRequestHandler(handler);
   start = System.currentTimeMillis();
   RspList rsps = d1.castMessage(null, new Message(), new RequestOptions(ResponseMode.GET_ALL, 0));
   stop = System.currentTimeMillis();
   System.out.println("rsps:\n" + rsps);
   System.out.println("call took " + (stop - start) + " ms");
   assertNotNull(rsps);
   Assert.assertEquals(1, rsps.size());
   byte[] buf = (byte[]) rsps.getFirst();
   assertNotNull(buf);
   Assert.assertEquals(size, buf.length);
 }