Search in sources :

Example 6 with HttpServer

use of org.apache.calcite.avatica.server.HttpServer 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)

Example 7 with HttpServer

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

the class SslDriverTest method parameters.

@Parameters(name = "{0}")
public static List<Object[]> parameters() throws Exception {
    // Skip TLS testing on IBM Java due the combination of:
    // - Jetty 9.4.12+ ignores SSL_* ciphers due to security - eclipse/jetty.project#2807
    // - IBM uses SSL_* cipher names for ALL ciphers not following RFC cipher names
    // See eclipse/jetty.project#2807 for details
    assumeFalse("Skip TLS testing on IBM Java due eclipse/jetty.project#2807", System.getProperty("java.vendor").contains("IBM"));
    final ArrayList<Object[]> parameters = new ArrayList<>();
    setupClass();
    for (Driver.Serialization serialization : new Driver.Serialization[] { Driver.Serialization.JSON, Driver.Serialization.PROTOBUF }) {
        for (boolean emptyPassword : new boolean[] { true, false }) {
            File keyStore = emptyPassword ? EMPTY_PW_KEYSTORE : KEYSTORE;
            String password = emptyPassword ? KEYSTORE_EMPTY_PASSWORD : KEYSTORE_PASSWORD;
            // Build and start the server, using TLS
            HttpServer httpServer = new HttpServer.Builder().withPort(0).withTLS(keyStore, password, keyStore, password).withHandler(localService, serialization).build();
            httpServer.start();
            SERVERS_TO_STOP.add(httpServer);
            String url = "jdbc:avatica:remote:url=https://localhost:" + httpServer.getPort() + ";serialization=" + serialization + ";truststore=" + keyStore.getAbsolutePath();
            if (!emptyPassword) {
                url += ";truststore_password=" + password;
            }
            LOG.info("JDBC URL {}", url);
            parameters.add(new Object[] { url });
        }
    }
    return parameters;
}
Also used : ArrayList(java.util.ArrayList) HttpServer(org.apache.calcite.avatica.server.HttpServer) Driver(org.apache.calcite.avatica.remote.Driver) File(java.io.File) Parameters(org.junit.runners.Parameterized.Parameters)

Aggregations

HttpServer (org.apache.calcite.avatica.server.HttpServer)7 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Driver (org.apache.calcite.avatica.remote.Driver)2 AvaticaJsonHandler (org.apache.calcite.avatica.server.AvaticaJsonHandler)2 Parameters (org.junit.runners.Parameterized.Parameters)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 Meta (org.apache.calcite.avatica.Meta)1 LocalService (org.apache.calcite.avatica.remote.LocalService)1 Service (org.apache.calcite.avatica.remote.Service)1 AvaticaHandler (org.apache.calcite.avatica.server.AvaticaHandler)1 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 Configuration (org.apache.hadoop.conf.Configuration)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 AbstractHandler (org.eclipse.jetty.server.handler.AbstractHandler)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1