Search in sources :

Example 1 with HttpServer

use of org.apache.avro.ipc.HttpServer in project camel by apache.

the class AvroListener method initAndStartServer.

/**
     * Initializes and starts http or netty server on basis of transport protocol from configuration.
     *
     *
     * @param configuration
     * @return Initialized and started server
     * @throws java.io.IOException
     */
private Server initAndStartServer(AvroConfiguration configuration) throws Exception {
    SpecificResponder responder;
    Server server;
    if (configuration.isReflectionProtocol()) {
        responder = new AvroReflectResponder(configuration.getProtocol(), this);
    } else {
        responder = new AvroSpecificResponder(configuration.getProtocol(), this);
    }
    if (AVRO_HTTP_TRANSPORT.equalsIgnoreCase(configuration.getTransport().name())) {
        server = new HttpServer(responder, configuration.getPort());
    } else if (AVRO_NETTY_TRANSPORT.equalsIgnoreCase(configuration.getTransport().name())) {
        server = new NettyServer(responder, new InetSocketAddress(configuration.getHost(), configuration.getPort()));
    } else {
        throw new IllegalArgumentException("Unknown transport " + configuration.getTransport());
    }
    server.start();
    return server;
}
Also used : SpecificResponder(org.apache.avro.ipc.specific.SpecificResponder) HttpServer(org.apache.avro.ipc.HttpServer) Server(org.apache.avro.ipc.Server) NettyServer(org.apache.avro.ipc.NettyServer) InetSocketAddress(java.net.InetSocketAddress) HttpServer(org.apache.avro.ipc.HttpServer) NettyServer(org.apache.avro.ipc.NettyServer)

Example 2 with HttpServer

use of org.apache.avro.ipc.HttpServer in project camel by apache.

the class AvroHttpProducerTest method initializeServer.

@Override
protected void initializeServer() throws IOException {
    if (server == null) {
        server = new HttpServer(new SpecificResponder(KeyValueProtocol.PROTOCOL, keyValue), avroPort);
        server.start();
    }
    if (serverReflection == null) {
        serverReflection = new HttpServer(new ReflectResponder(TestReflection.class, testReflection), avroPortReflection);
        serverReflection.start();
    }
}
Also used : SpecificResponder(org.apache.avro.ipc.specific.SpecificResponder) HttpServer(org.apache.avro.ipc.HttpServer) ReflectResponder(org.apache.avro.ipc.reflect.ReflectResponder)

Aggregations

HttpServer (org.apache.avro.ipc.HttpServer)2 SpecificResponder (org.apache.avro.ipc.specific.SpecificResponder)2 InetSocketAddress (java.net.InetSocketAddress)1 NettyServer (org.apache.avro.ipc.NettyServer)1 Server (org.apache.avro.ipc.Server)1 ReflectResponder (org.apache.avro.ipc.reflect.ReflectResponder)1