org.apache.calcite.avatica.server.Main Java Examples

The following examples show how to use org.apache.calcite.avatica.server.Main. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JdbcServer.java    From Quicksql with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    OptionsParser parser = new OptionsParser(args);
    final int port = Integer.parseInt(parser.getOptionValue(SubmitOption.PORT));
    final String[] mainArgs = new String[]{FullyRemoteJdbcMetaFactory.class.getName()};

    HttpServer server = Main.start(mainArgs, port, new HandlerFactory() {
        @Override
        public AbstractHandler createHandler(Service service) {
            return new AvaticaJsonHandler(service);
        }
    });
    InetAddress address = InetAddress.getLocalHost();
    String hostName = "localhost";
    if (address != null) {
         hostName = StringUtils.isNotBlank(address.getHostName()) ? address.getHostName() : address
            .getHostAddress();
    }
    String url = Driver.CONNECT_STRING_PREFIX + "url=http://" + hostName + ":" + server.getPort();
    System.out.println("Quicksql server started, Please connect : " + url);
    server.join();
}
 
Example #2
Source File: AlternatingRemoteMetaTest.java    From calcite-avatica with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #3
Source File: CalciteRemoteDriverTest.java    From Quicksql with MIT License 5 votes vote down vote up
@BeforeClass public static void beforeClass() throws Exception {
  localConnection = CalciteAssert.hr().connect();

  // Make sure we pick an ephemeral port for the server
  start = Main.start(new String[]{Factory.class.getName()}, 0,
      AvaticaJsonHandler::new);
}
 
Example #4
Source File: JdbcRemoteTest.java    From Quicksql with MIT License 5 votes vote down vote up
@Before
public void testJdbcServer()
    throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, InterruptedException {
    final String[] mainArgs = new String[]{FullyRemoteJdbcMetaFactory.class.getName()};
    jsonServer = Main.start(mainArgs, 5888, AvaticaJsonHandler::new);
    String url = Driver.CONNECT_STRING_PREFIX + "url=http://localhost:" + jsonServer.getPort();
    System.out.println(url);
    new Thread(() -> {
        try {
            jsonServer.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    });
}
 
Example #5
Source File: CalciteRemoteDriverTest.java    From calcite with Apache License 2.0 5 votes vote down vote up
@BeforeAll public static void beforeClass() throws Exception {
  localConnection = CalciteAssert.hr().connect();

  // Make sure we pick an ephemeral port for the server
  start = Main.start(new String[]{Factory.class.getName()}, 0,
      AvaticaJsonHandler::new);
}
 
Example #6
Source File: ChinookAvaticaServer.java    From calcite with Apache License 2.0 4 votes vote down vote up
public void startWithCalcite() throws Exception {
  final String[] args = {CalciteChinookMetaFactory.class.getName()};
  this.server = Main.start(args, 0, AvaticaProtobufHandler::new);
}
 
Example #7
Source File: ChinookAvaticaServer.java    From calcite with Apache License 2.0 4 votes vote down vote up
public void startWithRaw() throws Exception {
  final String[] args = {RawChinookMetaFactory.class.getName()};
  this.server = Main.start(args, 0, AvaticaProtobufHandler::new);
}