org.apache.calcite.avatica.server.AvaticaJsonHandler Java Examples
The following examples show how to use
org.apache.calcite.avatica.server.AvaticaJsonHandler.
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: DynamicAvaticaJsonHandler.java From kareldb with Apache License 2.0 | 6 votes |
public DynamicAvaticaJsonHandler(KarelDbConfig config, AvaticaHandler localHandler, UrlProvider urlProvider, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.config = config; this.localHandler = Objects.requireNonNull(localHandler); this.urlProvider = Objects.requireNonNull(urlProvider); this.metrics = Objects.requireNonNull(metrics); // Metrics this.requestTimer = this.metrics.getTimer( concat(AvaticaJsonHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.threadLocalBuffer = ThreadLocal.withInitial(UnsynchronizedBuffer::new); this.serverConfig = serverConfig; }
Example #2
Source File: JdbcServer.java From Quicksql with MIT License | 6 votes |
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 #3
Source File: AlternatingRemoteMetaTest.java From calcite-avatica with Apache License 2.0 | 6 votes |
@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 #4
Source File: KarelDbMain.java From kareldb with Apache License 2.0 | 5 votes |
public static HttpServer start(KarelDbConfig config, KarelDbLeaderElector elector) throws SQLException { Meta meta = create(config); Service service = new LocalService(meta); AvaticaHandler localHandler = new AvaticaJsonHandler(service); AvaticaHandler handler = new DynamicAvaticaJsonHandler(config, localHandler, elector); HttpServer server = new HttpServerExtension(elector.getIdentity(), handler, config); server.start(); return server; }
Example #5
Source File: CalciteRemoteDriverTest.java From Quicksql with MIT License | 5 votes |
@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 #6
Source File: JdbcRemoteTest.java From Quicksql with MIT License | 5 votes |
@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 #7
Source File: CalciteRemoteDriverTest.java From calcite with Apache License 2.0 | 5 votes |
@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); }