Search in sources :

Example 41 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class TestInsertIntoCassandraTable method testInsertIntoValuesToCassandraMaterizedView.

@Test(groups = CASSANDRA)
public void testInsertIntoValuesToCassandraMaterizedView() throws Exception {
    TableName table = mutableTablesState().get(CASSANDRA_INSERT_TABLE).getTableName();
    onCasssandra(format("DROP MATERIALIZED VIEW IF EXISTS %s.%s", KEY_SPACE, CASSANDRA_MATERIALIZED_VIEW));
    onCasssandra(format("CREATE MATERIALIZED VIEW %s.%s AS " + "SELECT * FROM %s " + "WHERE b IS NOT NULL " + "PRIMARY KEY (a, b) " + "WITH CLUSTERING ORDER BY (integer DESC)", KEY_SPACE, CASSANDRA_MATERIALIZED_VIEW, table.getNameInDatabase()));
    assertContainsEventually(() -> query(format("SHOW TABLES FROM %s.%s", CONNECTOR_NAME, KEY_SPACE)), query(format("SELECT lower('%s')", CASSANDRA_MATERIALIZED_VIEW)), new Duration(1, MINUTES));
    assertThat(() -> query(format("INSERT INTO %s.%s.%s (a) VALUES (null) ", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_MATERIALIZED_VIEW))).failsWithMessage("Inserting into materialized views not yet supported");
    assertThat(() -> query(format("DROP TABLE %s.%s.%s", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_MATERIALIZED_VIEW))).failsWithMessage("Dropping materialized views not yet supported");
    onCasssandra(format("DROP MATERIALIZED VIEW IF EXISTS %s.%s", KEY_SPACE, CASSANDRA_MATERIALIZED_VIEW));
}
Also used : TableName(io.prestodb.tempto.internal.fulfillment.table.TableName) Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 42 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class TestFileBasedAccessControlConfig method testExplicitPropertyMappings.

@Test
public void testExplicitPropertyMappings() {
    Map<String, String> properties = new ImmutableMap.Builder<String, String>().put(SECURITY_CONFIG_FILE, "/test.json").put(SECURITY_REFRESH_PERIOD, "1s").build();
    FileBasedAccessControlConfig expected = new FileBasedAccessControlConfig().setConfigFile("/test.json").setRefreshPeriod(new Duration(1, TimeUnit.SECONDS));
    assertFullMapping(properties, expected);
}
Also used : Duration(io.airlift.units.Duration) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.testng.annotations.Test)

Example 43 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class TestMetadataConfig method testExplicitPropertyMappings.

@Test
public void testExplicitPropertyMappings() {
    Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("raptor.startup-grace-period", "42m").put("raptor.reassignment-delay", "6m").put("raptor.reassignment-interval", "7m").put("raptor.minimum-node-count", "39").build();
    MetadataConfig expected = new MetadataConfig().setStartupGracePeriod(new Duration(42, MINUTES)).setReassignmentDelay(new Duration(6, MINUTES)).setReassignmentInterval(new Duration(7, MINUTES)).setMinimumNodeCount(39);
    assertFullMapping(properties, expected);
}
Also used : Duration(io.airlift.units.Duration) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.testng.annotations.Test)

Example 44 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class TestRaptorSplitManager method setup.

@BeforeMethod
public void setup() throws Exception {
    FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
    DBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime() + "_" + ThreadLocalRandom.current().nextInt());
    dbi.registerMapper(new TableColumn.Mapper(functionAndTypeManager));
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    temporary = createTempDir();
    AssignmentLimiter assignmentLimiter = new AssignmentLimiter(ImmutableSet::of, systemTicker(), new MetadataConfig());
    shardManager = new DatabaseShardManager(dbi, new DaoSupplier<>(dbi, ShardDao.class), ImmutableSet::of, assignmentLimiter, systemTicker(), new Duration(0, MINUTES));
    TestingNodeManager nodeManager = new TestingNodeManager();
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    String nodeName = UUID.randomUUID().toString();
    nodeManager.addNode(new InternalNode(nodeName, new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN, false));
    RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
    metadata = new RaptorMetadata(connectorId.toString(), dbi, shardManager, createTestFunctionAndTypeManager());
    metadata.createTable(SESSION, TEST_TABLE, false);
    tableHandle = metadata.getTableHandle(SESSION, TEST_TABLE.getTable());
    List<ShardInfo> shards = ImmutableList.<ShardInfo>builder().add(shardInfo(UUID.randomUUID(), nodeName)).add(shardInfo(UUID.randomUUID(), nodeName)).add(shardInfo(UUID.randomUUID(), nodeName)).add(shardInfo(UUID.randomUUID(), nodeName)).build();
    tableId = ((RaptorTableHandle) tableHandle).getTableId();
    List<ColumnInfo> columns = metadata.getColumnHandles(SESSION, tableHandle).values().stream().map(RaptorColumnHandle.class::cast).map(ColumnInfo::fromHandle).collect(toList());
    long transactionId = shardManager.beginTransaction();
    shardManager.commitShards(transactionId, tableId, columns, shards, Optional.empty(), 0);
    raptorSplitManager = new RaptorSplitManager(connectorId, nodeSupplier, shardManager, false);
}
Also used : RaptorColumnHandle(com.facebook.presto.raptor.RaptorColumnHandle) RaptorMetadata(com.facebook.presto.raptor.RaptorMetadata) DBI(org.skife.jdbi.v2.DBI) Duration(io.airlift.units.Duration) DaoSupplier(com.facebook.presto.raptor.util.DaoSupplier) URI(java.net.URI) FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) FunctionAndTypeManager.createTestFunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager) ImmutableSet(com.google.common.collect.ImmutableSet) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) InternalNode(com.facebook.presto.metadata.InternalNode) RaptorConnectorId(com.facebook.presto.raptor.RaptorConnectorId) NodeSupplier(com.facebook.presto.raptor.NodeSupplier) RaptorSplitManager(com.facebook.presto.raptor.RaptorSplitManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 45 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class TestShardCleanerConfig method testExplicitPropertyMappings.

@Test
public void testExplicitPropertyMappings() {
    Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("raptor.max-transaction-age", "42m").put("raptor.transaction-cleaner-interval", "43m").put("raptor.local-cleaner-interval", "31m").put("raptor.local-clean-time", "32m").put("raptor.backup-cleaner-interval", "34m").put("raptor.backup-clean-time", "35m").put("raptor.backup-deletion-threads", "37").put("raptor.max-completed-transaction-age", "39m").build();
    ShardCleanerConfig expected = new ShardCleanerConfig().setMaxTransactionAge(new Duration(42, MINUTES)).setTransactionCleanerInterval(new Duration(43, MINUTES)).setLocalCleanerInterval(new Duration(31, MINUTES)).setLocalCleanTime(new Duration(32, MINUTES)).setBackupCleanerInterval(new Duration(34, MINUTES)).setBackupCleanTime(new Duration(35, MINUTES)).setBackupDeletionThreads(37).setMaxCompletedTransactionAge(new Duration(39, MINUTES));
    assertFullMapping(properties, expected);
}
Also used : Duration(io.airlift.units.Duration) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.testng.annotations.Test)

Aggregations

Duration (io.airlift.units.Duration)323 Test (org.testng.annotations.Test)203 DataSize (io.airlift.units.DataSize)66 ImmutableMap (com.google.common.collect.ImmutableMap)42 URI (java.net.URI)40 Map (java.util.Map)22 List (java.util.List)21 ImmutableList (com.google.common.collect.ImmutableList)18 TestingTicker (com.facebook.airlift.testing.TestingTicker)17 Optional (java.util.Optional)17 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)16 Assert.assertEquals (org.testng.Assert.assertEquals)16 Session (com.facebook.presto.Session)15 PrestoException (com.facebook.presto.spi.PrestoException)15 File (java.io.File)15 TaskId (com.facebook.presto.execution.TaskId)14 ImmutableSet (com.google.common.collect.ImmutableSet)14 SECONDS (java.util.concurrent.TimeUnit.SECONDS)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)12