Package org.apache.avro.ipc

Examples of org.apache.avro.ipc.Transceiver


      for (File f : SERVER_PORTS_DIR.listFiles()) {
        LineNumberReader reader = new LineNumberReader(new FileReader(f));
        int port = Integer.parseInt(reader.readLine());
        System.out.println("Validating java client to "+
            f.getName()+" - " + port);
        Transceiver client = new SocketTransceiver(
            new InetSocketAddress("localhost", port));
        proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
        TestProtocolSpecific proto = new TestProtocolSpecific();
        proto.testHello();
        proto.testEcho();
View Full Code Here


  public void helpTestProtocolIterator(int resultRows) throws Exception {
    DummySherpaServer server = new DummySherpaServer(resultRows);
    InetSocketAddress serverAddress = server.getAddress();
   
    try {
      Transceiver tr = new SaslSocketTransceiver(serverAddress);
      SpecificRequestor requestor = new SpecificRequestor(SherpaServer.class, tr);
      SherpaServer queryApi = SpecificRequestor.getClient(SherpaServer.class, requestor);
      QueryExecution protocol = new QueryExecution(queryApi);

      protocol.query("fake command",null,null);     
View Full Code Here

 
    DummySherpaServer server = new DummySherpaServer(resultRows);
    InetSocketAddress serverAddress = server.getAddress();
   
    try {
      Transceiver tr = new SaslSocketTransceiver(serverAddress);
      SpecificRequestor requestor = new SpecificRequestor(SherpaServer.class, tr);
      SherpaServer queryApi = SpecificRequestor.getClient(SherpaServer.class, requestor);

      for(int i=0; i<3; i++) {
        //logger.debug("running command {}", i);
View Full Code Here

          + hostname + " port:" + port, e);
    }

    LogLog.debug("using url:" + url);

    Transceiver transciever = new HttpTransceiver(url);
    FlumeEventAvroServer client = null;

    try {
      client = SpecificRequestor.getClient(FlumeEventAvroServer.class,
          transciever);
View Full Code Here

   */
  @Override
  public void open() throws IOException {

    URL url = new URL("http", host, port, "/");
    Transceiver http = new HttpTransceiver(url);
    transport = new AccountingTransceiver(http);
    try {
      this.avroClient = (FlumeEventAvroServer) SpecificRequestor.getClient(
          FlumeEventAvroServer.class, transport);
    } catch (Exception e) {
View Full Code Here

      for (File f : SERVER_PORTS_DIR.listFiles()) {
        LineNumberReader reader = new LineNumberReader(new FileReader(f));
        int port = Integer.parseInt(reader.readLine());
        System.out.println("Validating java client to "+
            f.getName()+" - " + port);
        Transceiver client = new SocketTransceiver(
            new InetSocketAddress("localhost", port));
        proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
        TestProtocolSpecific proto = new TestProtocolSpecific();
        proto.testHello();
        proto.testEcho();
View Full Code Here

      return 1;
    }

    URI uri = URI.create(args.get(0));

    Transceiver transceiver = null;
    try {
      transceiver = Ipc.createTransceiver(uri);

      // write an empty HandshakeRequest
      HandshakeRequest rq = HandshakeRequest.newBuilder()
          .setClientHash(new MD5(new byte[16]))
          .setServerHash(new MD5(new byte[16]))
          .setClientProtocol(null)
          .setMeta(new LinkedHashMap<String, ByteBuffer>())
          .build();

      DatumWriter<HandshakeRequest> handshakeWriter = new SpecificDatumWriter<HandshakeRequest>(HandshakeRequest.class);

      ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream();

      BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(byteBufferOutputStream, null);

      handshakeWriter.write(rq, encoder);
      encoder.flush();

      // send it and get the response
      List<ByteBuffer> response = transceiver.transceive(byteBufferOutputStream.getBufferList());


      // parse the response
      ByteBufferInputStream byteBufferInputStream = new ByteBufferInputStream(response);

      DatumReader<HandshakeResponse> handshakeReader = new SpecificDatumReader<HandshakeResponse>(HandshakeResponse.class);

      HandshakeResponse handshakeResponse = handshakeReader.read(null, DecoderFactory.get().binaryDecoder(byteBufferInputStream, null));

      Protocol p = Protocol.parse(handshakeResponse.getServerProtocol());

      // finally output the protocol
      out.println(p.toString(true));

    } finally {
      if( transceiver != null )
        transceiver.close();
    }
    return 0;
  }
View Full Code Here

    }
  }
 
  @Test(expected = Exception.class)
  public void testConnectionRefusedOneWay() throws IOException {
    Transceiver client = new HttpTransceiver(new URL("http://localhost:4444"));
    SpecificRequestor req = new SpecificRequestor(Simple.class, client);
    addRpcPlugins(req);
    Simple proxy = SpecificRequestor.getClient(Simple.class, (SpecificRequestor)req);
    proxy.ack();
  }
View Full Code Here

                             null /* doc */,
                             Schema.createRecord(fields),
                             Schema.create(Schema.Type.STRING),
                             Schema.createUnion(new ArrayList<Schema>()));
    protocol.getMessages().put("hello", message);
    Transceiver t = createTransceiver();
    try {
      GenericRequestor r = new GenericRequestor(protocol, t);
      addRpcPlugins(r);
      GenericRecord params = new GenericData.Record(message.getRequest());
      params.put("extra", Boolean.TRUE);
      params.put("greeting", "bob");
      String response = r.request("hello", params).toString();
      assertEquals("goodbye", response);
    } finally {
      t.close();
      server.close();
    }
  }
View Full Code Here

      for (File f : SERVER_PORTS_DIR.listFiles()) {
        LineNumberReader reader = new LineNumberReader(new FileReader(f));
        int port = Integer.parseInt(reader.readLine());
        System.out.println("Validating java client to "+
            f.getName()+" - " + port);
        Transceiver client = new SocketTransceiver(
            new InetSocketAddress("localhost", port));
        proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
        TestProtocolSpecific proto = new TestProtocolSpecific();
        proto.testHello();
        proto.testEcho();
View Full Code Here

TOP

Related Classes of org.apache.avro.ipc.Transceiver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.