@Override protected Discoverable pick(ServiceDiscovered serviceDiscovered) { Discoverable lastPick = this.lastPick; if (lastPick == null || !isValid(lastPick, serviceDiscovered)) { this.lastPick = lastPick = picker.pick(); } return lastPick; }
@Override public Connection getQueryClient(NamespaceId namespace) throws Exception { // this makes sure the Explore JDBC driver is loaded Class.forName(ExploreDriver.class.getName()); Discoverable discoverable = new StickyEndpointStrategy(() -> discoveryClient.discover(Constants.Service.EXPLORE_HTTP_USER_SERVICE)).pick(); if (null == discoverable) { throw new IOException("Explore service could not be discovered."); } InetSocketAddress address = discoverable.getSocketAddress(); String host = address.getHostName(); int port = address.getPort(); String connectString = String.format("%s%s:%d?namespace=%s", Constants.Explore.Jdbc.URL_PREFIX, host, port, namespace.getNamespace()); return DriverManager.getConnection(connectString); }
@Override public Connection getQueryClient(NamespaceId namespace) throws Exception { // this makes sure the Explore JDBC driver is loaded Class.forName(ExploreDriver.class.getName()); Discoverable discoverable = new StickyEndpointStrategy( discoveryClient.discover(Constants.Service.EXPLORE_HTTP_USER_SERVICE)).pick(); if (null == discoverable) { throw new IOException("Explore service could not be discovered."); } InetSocketAddress address = discoverable.getSocketAddress(); String host = address.getHostName(); int port = address.getPort(); String connectString = String.format("%s%s:%d?namespace=%s", Constants.Explore.Jdbc.URL_PREFIX, host, port, namespace.getNamespace()); return DriverManager.getConnection(connectString); }
@Override public Discoverable pick() { Discoverable lastPick = this.lastPick; if (lastPick == null || !isValid(lastPick)) { this.lastPick = lastPick = picker.pick(); } return lastPick; }