use of io.airlift.units.Duration in project presto by prestodb.
the class TestHiveS3Config method testExplicitPropertyMappings.
@Test
public void testExplicitPropertyMappings() {
Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("hive.s3.aws-access-key", "abc123").put("hive.s3.aws-secret-key", "secret").put("hive.s3.endpoint", "endpoint.example.com").put("hive.s3.signer-type", "S3SignerType").put("hive.s3.use-instance-credentials", "false").put("hive.s3.ssl.enabled", "false").put("hive.s3.sse.enabled", "true").put("hive.s3.sse.type", "KMS").put("hive.s3.sse.kms-key-id", "KMS_KEY_ID").put("hive.s3.encryption-materials-provider", "EMP_CLASS").put("hive.s3.kms-key-id", "KEY_ID").put("hive.s3.max-client-retries", "9").put("hive.s3.max-error-retries", "8").put("hive.s3.max-backoff-time", "4m").put("hive.s3.max-retry-time", "20m").put("hive.s3.connect-timeout", "8s").put("hive.s3.socket-timeout", "4m").put("hive.s3.multipart.min-file-size", "32MB").put("hive.s3.multipart.min-part-size", "15MB").put("hive.s3.max-connections", "77").put("hive.s3.staging-directory", "/s3-staging").put("hive.s3.pin-client-to-current-region", "true").put("hive.s3.user-agent-prefix", "user-agent-prefix").build();
HiveS3Config expected = new HiveS3Config().setS3AwsAccessKey("abc123").setS3AwsSecretKey("secret").setS3Endpoint("endpoint.example.com").setS3SignerType(PrestoS3SignerType.S3SignerType).setS3UseInstanceCredentials(false).setS3SslEnabled(false).setS3SseEnabled(true).setS3SseType(PrestoS3SseType.KMS).setS3SseKmsKeyId("KMS_KEY_ID").setS3EncryptionMaterialsProvider("EMP_CLASS").setS3KmsKeyId("KEY_ID").setS3MaxClientRetries(9).setS3MaxErrorRetries(8).setS3MaxBackoffTime(new Duration(4, TimeUnit.MINUTES)).setS3MaxRetryTime(new Duration(20, TimeUnit.MINUTES)).setS3ConnectTimeout(new Duration(8, TimeUnit.SECONDS)).setS3SocketTimeout(new Duration(4, TimeUnit.MINUTES)).setS3MultipartMinFileSize(new DataSize(32, Unit.MEGABYTE)).setS3MultipartMinPartSize(new DataSize(15, Unit.MEGABYTE)).setS3MaxConnections(77).setS3StagingDirectory(new File("/s3-staging")).setPinS3ClientToCurrentRegion(true).setS3UserAgentPrefix("user-agent-prefix");
assertFullMapping(properties, expected);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestLdapConfig method testExplicitConfig.
@Test
public void testExplicitConfig() {
Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("authentication.ldap.url", "ldaps://localhost:636").put("authentication.ldap.user-bind-pattern", "uid=${USER},ou=org,dc=test,dc=com").put("authentication.ldap.user-base-dn", "dc=test,dc=com").put("authentication.ldap.group-auth-pattern", "&(objectClass=user)(memberOf=cn=group)(user=username)").put("authentication.ldap.cache-ttl", "2m").build();
LdapConfig expected = new LdapConfig().setLdapUrl("ldaps://localhost:636").setUserBindSearchPattern("uid=${USER},ou=org,dc=test,dc=com").setUserBaseDistinguishedName("dc=test,dc=com").setGroupAuthorizationSearchPattern("&(objectClass=user)(memberOf=cn=group)(user=username)").setLdapCacheTtl(new Duration(2, TimeUnit.MINUTES));
assertFullMapping(properties, expected);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TaskExecutorSimulator method printTaskCompletion.
private synchronized void printTaskCompletion(SimulationTask task) {
if (!PRINT_TASK_COMPLETION) {
return;
}
long taskStart = Long.MAX_VALUE;
long taskEnd = 0;
long taskQueuedTime = 0;
long totalCpuTime = 0;
for (SimulationSplit split : task.getSplits()) {
taskStart = Math.min(taskStart, split.getStartNanos());
taskEnd = Math.max(taskEnd, split.getDoneNanos());
taskQueuedTime += split.getQueuedNanos();
totalCpuTime += MILLISECONDS.toNanos(split.getRequiredProcessMillis());
}
System.out.printf("%-12s %8s %8s %.2f\n", task.getTaskId() + ":", new Duration(taskQueuedTime, NANOSECONDS).convertTo(MILLISECONDS), new Duration(taskEnd - taskStart, NANOSECONDS).convertTo(MILLISECONDS), 1.0 * totalCpuTime / (taskEnd - taskStart));
// print split info
if (PRINT_SPLIT_COMPLETION) {
for (SimulationSplit split : task.getSplits()) {
Duration totalQueueTime = new Duration(split.getQueuedNanos(), NANOSECONDS).convertTo(MILLISECONDS);
Duration executionWallTime = new Duration(split.getDoneNanos() - split.getStartNanos(), NANOSECONDS).convertTo(MILLISECONDS);
Duration totalWallTime = new Duration(split.getDoneNanos() - split.getCreatedNanos(), NANOSECONDS).convertTo(MILLISECONDS);
System.out.printf(" %8s %8s %8s\n", totalQueueTime, executionWallTime, totalWallTime);
}
System.out.println();
}
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestStageStats method assertExpectedStageStats.
public static void assertExpectedStageStats(StageStats actual) {
assertEquals(actual.getSchedulingComplete().getMillis(), 0);
assertEquals(actual.getGetSplitDistribution().getCount(), 1.0);
assertEquals(actual.getScheduleTaskDistribution().getCount(), 2.0);
assertEquals(actual.getAddSplitDistribution().getCount(), 3.0);
assertEquals(actual.getTotalTasks(), 4);
assertEquals(actual.getRunningTasks(), 5);
assertEquals(actual.getCompletedTasks(), 6);
assertEquals(actual.getTotalDrivers(), 7);
assertEquals(actual.getQueuedDrivers(), 8);
assertEquals(actual.getRunningDrivers(), 10);
assertEquals(actual.getCompletedDrivers(), 11);
assertEquals(actual.getCumulativeMemory(), 12.0);
assertEquals(actual.getTotalMemoryReservation(), new DataSize(13, BYTE));
assertEquals(actual.getPeakMemoryReservation(), new DataSize(14, BYTE));
assertEquals(actual.getTotalScheduledTime(), new Duration(15, NANOSECONDS));
assertEquals(actual.getTotalCpuTime(), new Duration(16, NANOSECONDS));
assertEquals(actual.getTotalUserTime(), new Duration(17, NANOSECONDS));
assertEquals(actual.getTotalBlockedTime(), new Duration(18, NANOSECONDS));
assertEquals(actual.getRawInputDataSize(), new DataSize(19, BYTE));
assertEquals(actual.getRawInputPositions(), 20);
assertEquals(actual.getProcessedInputDataSize(), new DataSize(21, BYTE));
assertEquals(actual.getProcessedInputPositions(), 22);
assertEquals(actual.getOutputDataSize(), new DataSize(23, BYTE));
assertEquals(actual.getOutputPositions(), 24);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestStateMachine method assertStateChange.
private void assertStateChange(StateMachine<State> stateMachine, StateChanger stateChange, State expectedState) throws Exception {
State initialState = stateMachine.get();
ListenableFuture<State> futureChange = stateMachine.getStateChange(initialState);
SettableFuture<State> listenerChange = SettableFuture.create();
stateMachine.addStateChangeListener(listenerChange::set);
Future<State> waitChange = executor.submit(() -> {
try {
stateMachine.waitForStateChange(initialState, new Duration(10, SECONDS));
return stateMachine.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw Throwables.propagate(e);
} catch (Exception e) {
throw Throwables.propagate(e);
}
});
stateChange.run();
assertEquals(stateMachine.get(), expectedState);
assertEquals(futureChange.get(1, SECONDS), expectedState);
assertEquals(listenerChange.get(1, SECONDS), expectedState);
assertEquals(waitChange.get(1, SECONDS), expectedState);
// listeners should not be retained if we are in a terminal state
boolean isTerminalState = stateMachine.isTerminalState(expectedState);
if (isTerminalState) {
assertEquals(stateMachine.getStateChangeListeners(), ImmutableSet.of());
}
}
Aggregations