public ClientSession build() { return new ClientSession( server, user, source, traceToken, clientTags, clientInfo, catalog, schema, path, timeZone, locale, resourceEstimates, properties, preparedStatements, roles, transactionId, clientRequestTimeout); } }
private Builder(ClientSession clientSession) { requireNonNull(clientSession, "clientSession is null"); server = clientSession.getServer(); user = clientSession.getUser(); source = clientSession.getSource(); traceToken = clientSession.getTraceToken(); clientTags = clientSession.getClientTags(); clientInfo = clientSession.getClientInfo(); catalog = clientSession.getCatalog(); schema = clientSession.getSchema(); path = clientSession.getPath(); timeZone = clientSession.getTimeZone(); locale = clientSession.getLocale(); resourceEstimates = clientSession.getResourceEstimates(); properties = clientSession.getProperties(); preparedStatements = clientSession.getPreparedStatements(); roles = clientSession.getRoles(); transactionId = clientSession.getTransactionId(); clientRequestTimeout = clientSession.getClientRequestTimeout(); }
public static ClientSession stripTransactionId(ClientSession session) { return ClientSession.builder(session) .withoutTransactionId() .build(); }
try { finalSql = preprocessQuery( Optional.ofNullable(queryRunner.getSession().getCatalog()), Optional.ofNullable(queryRunner.getSession().getSchema()), sql); session = ClientSession.builder(session) .withCatalog(query.getSetCatalog().orElse(session.getCatalog())) .withSchema(query.getSetSchema().orElse(session.getSchema())) .build(); schemaChanged.run(); session = stripTransactionId(session); ClientSession.Builder builder = ClientSession.builder(session); Map<String, String> sessionProperties = new HashMap<>(session.getProperties()); sessionProperties.putAll(query.getSetSessionProperties()); sessionProperties.keySet().removeAll(query.getResetSessionProperties()); Map<String, ClientSelectedRole> roles = new HashMap<>(session.getRoles()); roles.putAll(query.getSetRoles()); builder = builder.withRoles(roles); Map<String, String> preparedStatements = new HashMap<>(session.getPreparedStatements()); preparedStatements.putAll(query.getAddedPreparedStatements()); preparedStatements.keySet().removeAll(query.getDeallocatedPreparedStatements());
private static void setupBasicAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> user, Optional<String> password) { if (user.isPresent() && password.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using username/password requires HTTPS to be enabled"); clientBuilder.addInterceptor(basicAuth(user.get(), password.get())); } }
properties.putAll(clientSession.getProperties()); properties.putAll(suite.getSessionProperties()); ClientSession session = ClientSession.builder(clientSession) .withProperties(properties) .build(); benchmarkSchemas = ImmutableList.of(new BenchmarkSchema(session.getSchema())); session = ClientSession.builder(session) .withCatalog(session.getCatalog()) .withSchema(benchmarkSchema.getName()) .build();
public void populateCache() { String schemaName = queryRunner.getSession().getSchema(); if (schemaName != null) { executor.execute(() -> { functionCache.refresh(schemaName); tableCache.refresh(schemaName); }); } }
try { finalSql = preprocessQuery( Optional.ofNullable(queryRunner.getSession().getCatalog()), Optional.ofNullable(queryRunner.getSession().getSchema()), sql); session = ClientSession.builder(session) .withCatalog(query.getSetCatalog().orElse(session.getCatalog())) .withSchema(query.getSetSchema().orElse(session.getSchema())) .build(); schemaChanged.run(); session = stripTransactionId(session); ClientSession.Builder builder = ClientSession.builder(session); Map<String, String> sessionProperties = new HashMap<>(session.getProperties()); sessionProperties.putAll(query.getSetSessionProperties()); sessionProperties.keySet().removeAll(query.getResetSessionProperties()); Map<String, ClientSelectedRole> roles = new HashMap<>(session.getRoles()); roles.putAll(query.getSetRoles()); builder = builder.withRoles(roles); Map<String, String> preparedStatements = new HashMap<>(session.getPreparedStatements()); preparedStatements.putAll(query.getAddedPreparedStatements()); preparedStatements.keySet().removeAll(query.getDeallocatedPreparedStatements());
private static void setupTokenAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> accessToken) { if (accessToken.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using an access token requires HTTPS to be enabled"); clientBuilder.addInterceptor(tokenAuth(accessToken.get())); } } }
public void populateCache() { String schemaName = queryRunner.getSession().getSchema(); if (schemaName != null) { executor.execute(() -> { functionCache.refresh(schemaName); tableCache.refresh(schemaName); }); } }
HttpUrl url = HttpUrl.get(session.getServer()); if (url == null) { throw new ClientException("Invalid server URL: " + session.getServer()); if (session.getSource() != null) { builder.addHeader(PRESTO_SOURCE, session.getSource()); session.getTraceToken().ifPresent(token -> builder.addHeader(PRESTO_TRACE_TOKEN, token)); if (session.getClientTags() != null && !session.getClientTags().isEmpty()) { builder.addHeader(PRESTO_CLIENT_TAGS, Joiner.on(",").join(session.getClientTags())); if (session.getClientInfo() != null) { builder.addHeader(PRESTO_CLIENT_INFO, session.getClientInfo()); if (session.getCatalog() != null) { builder.addHeader(PRESTO_CATALOG, session.getCatalog()); if (session.getSchema() != null) { builder.addHeader(PRESTO_SCHEMA, session.getSchema()); if (session.getPath() != null) { builder.addHeader(PRESTO_PATH, session.getPath()); builder.addHeader(PRESTO_TIME_ZONE, session.getTimeZone().getId()); if (session.getLocale() != null) { builder.addHeader(PRESTO_LANGUAGE, session.getLocale().toLanguageTag()); Map<String, String> property = session.getProperties();
public ClientSession getClientSession() { return new ClientSession( parseServer(server), user, "presto-benchmark", Optional.empty(), ImmutableSet.of(), null, catalog, schema, null, ZoneId.systemDefault(), Locale.getDefault(), ImmutableMap.of(), toProperties(this.sessionProperties), ImmutableMap.of(), ImmutableMap.of(), null, clientRequestTimeout); }
private static void setupTokenAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> accessToken) { if (accessToken.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using an access token requires HTTPS to be enabled"); clientBuilder.addInterceptor(tokenAuth(accessToken.get())); } } }
@Override public int complete(String buffer, int cursor, List<CharSequence> candidates) { if (cursor <= 0) { return cursor; } int blankPos = findLastBlank(buffer.substring(0, cursor)); String prefix = buffer.substring(blankPos + 1, cursor); String schemaName = queryRunner.getSession().getSchema(); if (schemaName != null) { List<String> functionNames = functionCache.getIfPresent(schemaName); List<String> tableNames = tableCache.getIfPresent(schemaName); SortedSet<String> sortedCandidates = new TreeSet<>(); if (functionNames != null) { sortedCandidates.addAll(filterResults(functionNames, prefix)); } if (tableNames != null) { sortedCandidates.addAll(filterResults(tableNames, prefix)); } candidates.addAll(sortedCandidates); } return blankPos + 1; }
public ClientSession toClientSession() { return new ClientSession( parseServer(server), user, source, Optional.empty(), parseClientTags(clientTags), clientInfo, catalog, schema, null, ZoneId.systemDefault(), Locale.getDefault(), toResourceEstimates(resourceEstimates), toProperties(sessionProperties), emptyMap(), emptyMap(), null, clientRequestTimeout); }
private static void setupBasicAuth( OkHttpClient.Builder clientBuilder, ClientSession session, Optional<String> user, Optional<String> password) { if (user.isPresent() && password.isPresent()) { checkArgument(session.getServer().getScheme().equalsIgnoreCase("https"), "Authentication using username/password requires HTTPS to be enabled"); clientBuilder.addInterceptor(basicAuth(user.get(), password.get())); } }
@Override public int complete(String buffer, int cursor, List<CharSequence> candidates) { if (cursor <= 0) { return cursor; } int blankPos = findLastBlank(buffer.substring(0, cursor)); String prefix = buffer.substring(blankPos + 1, cursor); String schemaName = queryRunner.getSession().getSchema(); if (schemaName != null) { List<String> functionNames = functionCache.getIfPresent(schemaName); List<String> tableNames = tableCache.getIfPresent(schemaName); SortedSet<String> sortedCandidates = new TreeSet<>(); if (functionNames != null) { sortedCandidates.addAll(filterResults(functionNames, prefix)); } if (tableNames != null) { sortedCandidates.addAll(filterResults(tableNames, prefix)); } candidates.addAll(sortedCandidates); } return blankPos + 1; }
public ClientSession toClientSession() { return new ClientSession( parseServer(server), user, source, Optional.ofNullable(traceToken), parseClientTags(clientTags), clientInfo, catalog, schema, null, ZoneId.systemDefault(), Locale.getDefault(), toResourceEstimates(resourceEstimates), toProperties(sessionProperties), emptyMap(), emptyMap(), toExtraCredentials(extraCredentials), null, clientRequestTimeout); }