use of io.airlift.units.Duration in project presto by prestodb.
the class TestBlackHoleSmoke method pageProcessingDelay.
@Test
public void pageProcessingDelay() throws Exception {
Session session = testSessionBuilder().setCatalog("blackhole").setSchema("default").build();
Duration pageProcessingDelay = new Duration(1, SECONDS);
assertThatQueryReturnsValue(format("CREATE TABLE nation WITH ( %s = 8, %s = 1, %s = 1, %s = 1, %s = '%s' ) AS " + "SELECT * FROM tpch.tiny.nation", FIELD_LENGTH_PROPERTY, ROWS_PER_PAGE_PROPERTY, PAGES_PER_SPLIT_PROPERTY, SPLIT_COUNT_PROPERTY, PAGE_PROCESSING_DELAY, pageProcessingDelay), 25L, session);
Stopwatch stopwatch = Stopwatch.createStarted();
assertEquals(queryRunner.execute(session, "SELECT * FROM nation").getRowCount(), 1);
queryRunner.execute(session, "INSERT INTO nation SELECT CAST(null AS BIGINT), CAST(null AS VARCHAR(25)), CAST(null AS BIGINT), CAST(null AS VARCHAR(152))");
stopwatch.stop();
assertGreaterThan(stopwatch.elapsed(MILLISECONDS), pageProcessingDelay.toMillis());
assertThatQueryReturnsValue("DROP TABLE nation", true);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class PrestoS3FileSystem method initialize.
@Override
public void initialize(URI uri, Configuration conf) throws IOException {
requireNonNull(uri, "uri is null");
requireNonNull(conf, "conf is null");
super.initialize(uri, conf);
setConf(conf);
this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority());
this.workingDirectory = new Path(PATH_SEPARATOR).makeQualified(this.uri, new Path(PATH_SEPARATOR));
HiveS3Config defaults = new HiveS3Config();
this.stagingDirectory = new File(conf.get(S3_STAGING_DIRECTORY, defaults.getS3StagingDirectory().toString()));
this.maxAttempts = conf.getInt(S3_MAX_CLIENT_RETRIES, defaults.getS3MaxClientRetries()) + 1;
this.maxBackoffTime = Duration.valueOf(conf.get(S3_MAX_BACKOFF_TIME, defaults.getS3MaxBackoffTime().toString()));
this.maxRetryTime = Duration.valueOf(conf.get(S3_MAX_RETRY_TIME, defaults.getS3MaxRetryTime().toString()));
int maxErrorRetries = conf.getInt(S3_MAX_ERROR_RETRIES, defaults.getS3MaxErrorRetries());
boolean sslEnabled = conf.getBoolean(S3_SSL_ENABLED, defaults.isS3SslEnabled());
Duration connectTimeout = Duration.valueOf(conf.get(S3_CONNECT_TIMEOUT, defaults.getS3ConnectTimeout().toString()));
Duration socketTimeout = Duration.valueOf(conf.get(S3_SOCKET_TIMEOUT, defaults.getS3SocketTimeout().toString()));
int maxConnections = conf.getInt(S3_MAX_CONNECTIONS, defaults.getS3MaxConnections());
long minFileSize = conf.getLong(S3_MULTIPART_MIN_FILE_SIZE, defaults.getS3MultipartMinFileSize().toBytes());
long minPartSize = conf.getLong(S3_MULTIPART_MIN_PART_SIZE, defaults.getS3MultipartMinPartSize().toBytes());
this.useInstanceCredentials = conf.getBoolean(S3_USE_INSTANCE_CREDENTIALS, defaults.isS3UseInstanceCredentials());
this.pinS3ClientToCurrentRegion = conf.getBoolean(S3_PIN_CLIENT_TO_CURRENT_REGION, defaults.isPinS3ClientToCurrentRegion());
this.sseEnabled = conf.getBoolean(S3_SSE_ENABLED, defaults.isS3SseEnabled());
this.sseType = PrestoS3SseType.valueOf(conf.get(S3_SSE_TYPE, defaults.getS3SseType().name()));
this.sseKmsKeyId = conf.get(S3_SSE_KMS_KEY_ID, defaults.getS3SseKmsKeyId());
String userAgentPrefix = conf.get(S3_USER_AGENT_PREFIX, defaults.getS3UserAgentPrefix());
ClientConfiguration configuration = new ClientConfiguration().withMaxErrorRetry(maxErrorRetries).withProtocol(sslEnabled ? Protocol.HTTPS : Protocol.HTTP).withConnectionTimeout(toIntExact(connectTimeout.toMillis())).withSocketTimeout(toIntExact(socketTimeout.toMillis())).withMaxConnections(maxConnections).withUserAgentPrefix(userAgentPrefix).withUserAgentSuffix(S3_USER_AGENT_SUFFIX);
this.s3 = createAmazonS3Client(uri, conf, configuration);
transferConfig.setMultipartUploadThreshold(minFileSize);
transferConfig.setMinimumUploadPartSize(minPartSize);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class PrestoS3FileSystemMetricCollector method collectMetrics.
@Override
public void collectMetrics(Request<?> request, Response<?> response) {
AWSRequestMetrics metrics = request.getAWSRequestMetrics();
TimingInfo timingInfo = metrics.getTimingInfo();
Number requestCounts = timingInfo.getCounter(RequestCount.name());
Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name());
Number throttleExceptions = timingInfo.getCounter(ThrottleException.name());
TimingInfo requestTime = timingInfo.getSubMeasurement(HttpRequestTime.name());
TimingInfo clientExecuteTime = timingInfo.getSubMeasurement(ClientExecuteTime.name());
if (requestCounts != null) {
stats.updateAwsRequestCount(requestCounts.longValue());
}
if (retryCounts != null) {
stats.updateAwsRetryCount(retryCounts.longValue());
}
if (throttleExceptions != null) {
stats.updateAwsThrottleExceptionsCount(throttleExceptions.longValue());
}
if (requestTime != null && requestTime.getTimeTakenMillisIfKnown() != null) {
stats.addAwsRequestTime(new Duration(requestTime.getTimeTakenMillisIfKnown(), MILLISECONDS));
}
if (clientExecuteTime != null && clientExecuteTime.getTimeTakenMillisIfKnown() != null) {
stats.addAwsClientExecuteTime(new Duration(clientExecuteTime.getTimeTakenMillisIfKnown(), MILLISECONDS));
}
}
use of io.airlift.units.Duration in project presto by prestodb.
the class PrestoConnection method startQuery.
StatementClient startQuery(String sql) {
String source = firstNonNull(clientInfo.get("ApplicationName"), "presto-jdbc");
ClientSession session = new ClientSession(httpUri, user, source, clientInfo.get("ClientInfo"), catalog.get(), schema.get(), timeZoneId.get(), locale.get(), ImmutableMap.copyOf(sessionProperties), transactionId.get(), false, new Duration(2, MINUTES));
return queryExecutor.startQuery(session, sql);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestTransactionManagerConfig method testExplicitPropertyMappings.
@Test
public void testExplicitPropertyMappings() {
Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("transaction.idle-check-interval", "1s").put("transaction.idle-timeout", "10s").put("transaction.max-finishing-concurrency", "100").build();
TransactionManagerConfig expected = new TransactionManagerConfig().setIdleCheckInterval(new Duration(1, TimeUnit.SECONDS)).setIdleTimeout(new Duration(10, TimeUnit.SECONDS)).setMaxFinishingConcurrency(100);
assertFullMapping(properties, expected);
}
Aggregations