Search in sources :

Example 61 with Duration

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);
}
Also used : Stopwatch(com.google.common.base.Stopwatch) Duration(io.airlift.units.Duration) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 62 with Duration

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);
}
Also used : Path(org.apache.hadoop.fs.Path) Duration(io.airlift.units.Duration) File(java.io.File) Files.createTempFile(java.nio.file.Files.createTempFile) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 63 with Duration

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));
    }
}
Also used : TimingInfo(com.amazonaws.util.TimingInfo) AWSRequestMetrics(com.amazonaws.util.AWSRequestMetrics) Duration(io.airlift.units.Duration)

Example 64 with Duration

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);
}
Also used : ClientSession(com.facebook.presto.client.ClientSession) Duration(io.airlift.units.Duration)

Example 65 with Duration

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);
}
Also used : Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Aggregations

Duration (io.airlift.units.Duration)124 Test (org.testng.annotations.Test)66 DataSize (io.airlift.units.DataSize)35 URI (java.net.URI)12 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)11 Session (com.facebook.presto.Session)9 DateTime (org.joda.time.DateTime)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 ImmutableSet (com.google.common.collect.ImmutableSet)8 TestingTicker (io.airlift.testing.TestingTicker)8 List (java.util.List)8 PrestoException (com.facebook.presto.spi.PrestoException)7 ImmutableList (com.google.common.collect.ImmutableList)7 File (java.io.File)6 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 CyclicBarrier (java.util.concurrent.CyclicBarrier)5 Produces (javax.ws.rs.Produces)5 Type (com.facebook.presto.spi.type.Type)4 IOException (java.io.IOException)4