Search in sources :

Example 1 with AvaticaJsonHandler

use of org.apache.calcite.avatica.server.AvaticaJsonHandler in project calcite-avatica by apache.

the class AvaticaServersForTest method startServers.

/**
 * Starts an Avatica server for each serialization type.
 */
public void startServers() throws Exception {
    // Bind to '0' to pluck an ephemeral port instead of expecting a certain one to be free
    final HttpServer jsonServer = Main.start(SERVER_ARGS, 0, new Main.HandlerFactory() {

        @Override
        public AvaticaJsonHandler createHandler(Service service) {
            return new AvaticaJsonHandler(service);
        }
    });
    serversBySerialization.put(Serialization.JSON, jsonServer);
    final HttpServer protobufServer = Main.start(SERVER_ARGS, 0, new Main.HandlerFactory() {

        @Override
        public AvaticaProtobufHandler createHandler(Service service) {
            return new AvaticaProtobufHandler(service);
        }
    });
    serversBySerialization.put(Serialization.PROTOBUF, protobufServer);
}
Also used : AvaticaProtobufHandler(org.apache.calcite.avatica.server.AvaticaProtobufHandler) AvaticaJsonHandler(org.apache.calcite.avatica.server.AvaticaJsonHandler) HttpServer(org.apache.calcite.avatica.server.HttpServer) Main(org.apache.calcite.avatica.server.Main)

Example 2 with AvaticaJsonHandler

use of org.apache.calcite.avatica.server.AvaticaJsonHandler in project calcite-avatica by apache.

the class AlternatingRemoteMetaTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    final String[] mainArgs = new String[] { FullyRemoteJdbcMetaFactory.class.getName() };
    // Bind to '0' to pluck an ephemeral port instead of expecting a certain one to be free
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 2; i++) {
        if (sb.length() > 0) {
            sb.append(",");
        }
        HttpServer jsonServer = Main.start(mainArgs, 0, new HandlerFactory() {

            @Override
            public AbstractHandler createHandler(Service service) {
                return new AvaticaJsonHandler(service);
            }
        });
        ACTIVE_SERVERS.add(jsonServer);
        sb.append("http://localhost:").append(jsonServer.getPort());
    }
    url = AlternatingDriver.PREFIX + "url=" + sb.toString();
}
Also used : HandlerFactory(org.apache.calcite.avatica.server.Main.HandlerFactory) AvaticaJsonHandler(org.apache.calcite.avatica.server.AvaticaJsonHandler) HttpServer(org.apache.calcite.avatica.server.HttpServer) AbstractHandler(org.eclipse.jetty.server.handler.AbstractHandler) BeforeClass(org.junit.BeforeClass)

Aggregations

AvaticaJsonHandler (org.apache.calcite.avatica.server.AvaticaJsonHandler)2 HttpServer (org.apache.calcite.avatica.server.HttpServer)2 AvaticaProtobufHandler (org.apache.calcite.avatica.server.AvaticaProtobufHandler)1 Main (org.apache.calcite.avatica.server.Main)1 HandlerFactory (org.apache.calcite.avatica.server.Main.HandlerFactory)1 AbstractHandler (org.eclipse.jetty.server.handler.AbstractHandler)1 BeforeClass (org.junit.BeforeClass)1