Java Code Examples for org.apache.arrow.flight.Location#forGrpcInsecure()
The following examples show how to use
org.apache.arrow.flight.Location#forGrpcInsecure() .
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: SslHelper.java From dremio-flight-connector with Apache License 2.0 | 7 votes |
public static Pair<Location, FlightServer.Builder> sslHelper(FlightServer.Builder serverBuilder, DremioConfig config, boolean useSsl, String hostname, int port, String sslHostname) { Location location; Location exLocation; try { if (!useSsl) { throw new UnsupportedOperationException("Don't use ssl"); } Pair<InputStream, InputStream> pair = ssl(config, sslHostname); location = Location.forGrpcTls(hostname, port); exLocation = Location.forGrpcTls(sslHostname, port); serverBuilder.useTls(pair.getRight(), pair.getLeft()).location(location); } catch (Exception e) { location = Location.forGrpcInsecure(hostname, port); exLocation = Location.forGrpcInsecure(sslHostname, port); serverBuilder.location(location); } return Pair.of(exLocation, serverBuilder); }
Example 2
Source File: TestFlightEndpoint.java From dremio-flight-connector with Apache License 2.0 | 6 votes |
@Test public void connect() throws Exception { InetAddress ip = InetAddress.getLocalHost(); Location location = Location.forGrpcInsecure(ip.getHostName(), 47470); try (FlightClient c = flightClient(getAllocator(), location)) { c.authenticate(new BasicClientAuthHandler(SystemUser.SYSTEM_USERNAME, null)); String sql = "select * from sys.options"; FlightInfo info = c.getInfo(FlightDescriptor.command(sql.getBytes())); long total = info.getEndpoints().stream() .map(this::submit) .map(TestFlightEndpoint::get) .mapToLong(Long::longValue) .sum(); Assert.assertTrue(total > 1); System.out.println(total); } }
Example 3
Source File: DefaultSource.java From flight-spark-source with Apache License 2.0 | 5 votes |
public DataSourceReader createReader(DataSourceOptions dataSourceOptions) { Location defaultLocation = Location.forGrpcInsecure( dataSourceOptions.get("host").orElse("localhost"), dataSourceOptions.getInt("port", 47470) ); String sql = dataSourceOptions.get("path").orElse(""); FlightDataSourceReader.FactoryOptions options = new FlightDataSourceReader.FactoryOptions( defaultLocation, sql, dataSourceOptions.get("username").orElse("anonymous"), dataSourceOptions.get("password").orElse(null), dataSourceOptions.getBoolean("parallel", false), null); Broadcast<FlightDataSourceReader.FactoryOptions> bOptions = lazySparkContext().broadcast(options); return new FlightDataSourceReader(bOptions); }
Example 4
Source File: Producer.java From dremio-flight-connector with Apache License 2.0 | 4 votes |
public void planParallelized(PlanningSet planningSet) { logger.debug("plan parallel called, collecting endpoints"); List<FlightEndpoint> endpoints = Lists.newArrayList(); FlightEndpoint screenEndpoint = null; for (Wrapper wrapper : planningSet.getFragmentWrapperMap().values()) { String majorId = String.valueOf(wrapper.getMajorFragmentId()); try { Boolean isWriter = wrapper.getNode().getRoot().accept(new WriterVisitor(), false); if (!isWriter) { continue; } } catch (Throwable throwable) { logger.warn("unable to complete visitor ", throwable); } CoreOperatorType op = CoreOperatorType.valueOf(wrapper.getNode().getRoot().getOperatorType()); boolean isScreen = CoreOperatorType.SCREEN.equals(op) && planningSet.getFragmentWrapperMap().size() > 1; logger.info("Creating tickets for {}. MajorId {}", wrapper.getNode().getRoot(), majorId); for (int i = 0; i < wrapper.getAssignedEndpoints().size(); i++) { CoordinationProtos.NodeEndpoint endpoint = wrapper.getAssignedEndpoint(i); logger.warn("Creating ticket for {} . MajorId {} and index {}", wrapper.getNode().getRoot(), majorId, i); Ticket ticket = new Ticket(JOINER.join( majorId, String.valueOf(i), endpoint.getAddress(), endpoint.getUserPort() ).getBytes()); int port = Integer.parseInt(PropertyHelper.getFromEnvProperty("dremio.formation.port", Integer.toString(FormationPlugin.FLIGHT_PORT))); String host = PropertyHelper.getFromEnvProperty("dremio.formation.host", endpoint.getAddress()); Location location = Location.forGrpcInsecure(host, port); if (isScreen) { screenEndpoint = new FlightEndpoint(ticket, location); } else { endpoints.add(new FlightEndpoint(ticket, location)); } } } if (screenEndpoint != null && endpoints.isEmpty()) { logger.info("Adding a screen endpoint as its the only possible endpoint!"); endpoints.add(screenEndpoint); } else { logger.warn("Skipping a screen as it lies above the writer."); } logger.debug("built {} parallel endpoints", endpoints.size()); future.complete(endpoints); }
Example 5
Source File: FlightDataSourceReader.java From flight-spark-source with Apache License 2.0 | 4 votes |
public Location getLocation() { return Location.forGrpcInsecure(host, port); }
Example 6
Source File: FlightDataReader.java From flight-spark-source with Apache License 2.0 | 4 votes |
public FlightDataReader(Broadcast<FlightDataSourceReader.FactoryOptions> options) { this.options = options; this.location = Location.forGrpcInsecure(options.value().getHost(), options.value().getPort()); this.ticket = new Ticket(options.value().getTicket()); }