Esempio n. 1
0
 @Override
 public void clientSendRequest(RPCContext context) {
   ByteBuffer buf = ByteBuffer.wrap("ap".getBytes());
   context.requestCallMeta().put(key, buf);
   Assert.assertNotNull(context.getMessage());
   Assert.assertNotNull(context.getRequestPayload());
   Assert.assertNull(context.getResponsePayload());
 }
Esempio n. 2
0
  @Override
  public void serverSendResponse(RPCContext context) {
    Assert.assertNotNull(context.requestCallMeta());
    Assert.assertNotNull(context.responseCallMeta());

    Assert.assertNotNull(context.getResponsePayload());

    if (!context.requestCallMeta().containsKey(key)) return;

    ByteBuffer buf = context.requestCallMeta().get(key);
    Assert.assertNotNull(buf);
    Assert.assertNotNull(buf.array());

    String partialstr = new String(buf.array());
    Assert.assertNotNull(partialstr);
    Assert.assertEquals("partial string mismatch", "apa", partialstr);

    buf = ByteBuffer.wrap((partialstr + "c").getBytes());
    Assert.assertTrue(buf.remaining() > 0);
    context.responseCallMeta().put(key, buf);
  }
Esempio n. 3
0
  @Override
  public void serverReceiveRequest(RPCContext context) {
    Map<String, ByteBuffer> meta = context.requestCallMeta();

    Assert.assertNotNull(meta);
    Assert.assertNotNull(context.getMessage());
    Assert.assertNull(context.getResponsePayload());

    if (!meta.containsKey(key)) return;

    ByteBuffer buf = meta.get(key);
    Assert.assertNotNull(buf);
    Assert.assertNotNull(buf.array());

    String partialstr = new String(buf.array());
    Assert.assertNotNull(partialstr);
    Assert.assertEquals("partial string mismatch", "ap", partialstr);

    buf = ByteBuffer.wrap((partialstr + "a").getBytes());
    Assert.assertTrue(buf.remaining() > 0);
    meta.put(key, buf);
  }
Esempio n. 4
0
  @Override
  public void clientFinishConnect(RPCContext context) {
    Map<String, ByteBuffer> handshakeMeta = context.responseHandshakeMeta();

    Assert.assertNull(context.getRequestPayload());
    Assert.assertNull(context.getResponsePayload());
    Assert.assertNotNull(handshakeMeta);

    if (!handshakeMeta.containsKey(key)) return;

    ByteBuffer buf = handshakeMeta.get(key);
    Assert.assertNotNull(buf);
    Assert.assertNotNull(buf.array());

    String partialstr = new String(buf.array());
    Assert.assertNotNull(partialstr);
    Assert.assertEquals("partial string mismatch", "apac", partialstr);

    buf = ByteBuffer.wrap((partialstr + "he").getBytes());
    Assert.assertTrue(buf.remaining() > 0);
    handshakeMeta.put(key, buf);

    checkRPCMetaMap(handshakeMeta);
  }