use of io.hetu.core.common.filesystem.TempFolder in project hetu-core by openlookeng.
the class TestIndexRecordManager method testIndexRecordAddLookUpHelper.
private void testIndexRecordAddLookUpHelper(String name, String user, String table, String[] columns, String indexType, List<String> indexProperties, List<String> partitions) throws IOException {
try (TempFolder folder = new TempFolder()) {
folder.create();
HetuMetastore testMetaStore = new HetuFsMetastore(new HetuFsMetastoreConfig().setHetuFileSystemMetastorePath(folder.getRoot().getPath()), FILE_SYSTEM_CLIENT);
IndexRecordManager indexRecordManager = new IndexRecordManager(testMetaStore);
IndexRecord expected = new IndexRecord(name, user, table, columns, indexType, 0L, indexProperties, partitions);
indexRecordManager.addIndexRecord(name, user, table, columns, indexType, 0L, indexProperties, partitions);
IndexRecord actual1 = indexRecordManager.lookUpIndexRecord(name);
assertNotNull(actual1);
assertEquals(actual1, expected);
IndexRecord actual2 = indexRecordManager.lookUpIndexRecord(table, columns, indexType);
assertNotNull(actual2);
assertEquals(actual2, expected);
}
}
use of io.hetu.core.common.filesystem.TempFolder in project hetu-core by openlookeng.
the class MemoryQueryRunner method createQueryRunner.
public static DistributedQueryRunner createQueryRunner(int nodes, Map<String, String> extraProperties, Map<String, String> memoryProperties, Boolean createTpchTables) throws Exception {
Session session = testSessionBuilder().setCatalog(CATALOG).setSchema("default").build();
DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, nodes, extraProperties);
Runtime.getRuntime().addShutdownHook(new Thread(queryRunner::close));
try {
queryRunner.installPlugin(new HetuFileSystemClientPlugin());
queryRunner.installPlugin(new HetuMetastorePlugin());
TempFolder metastoreFolder = new TempFolder().create();
Runtime.getRuntime().addShutdownHook(new Thread(metastoreFolder::close));
Map<String, String> metastoreConfig = new HashMap<>();
metastoreConfig.put("hetu.metastore.type", "hetufilesystem");
metastoreConfig.put("hetu.metastore.hetufilesystem.profile-name", "default");
metastoreConfig.put("hetu.metastore.hetufilesystem.path", metastoreFolder.newFolder("metastore").getAbsolutePath());
queryRunner.getServers().forEach(server -> {
try {
server.loadMetastore(new HashMap<>(metastoreConfig));
} catch (Exception e) {
throw new RuntimeException(e);
}
});
queryRunner.installPlugin(new MemoryPlugin());
queryRunner.getServers().forEach(server -> {
try {
TempFolder folder = new TempFolder();
folder.create();
Runtime.getRuntime().addShutdownHook(new Thread(folder::close));
// create memory catalog with custom memory properties
server.createCatalog(CATALOG, "memory", createConfig(folder, memoryProperties));
} catch (Exception e) {
throw new RuntimeException(e);
}
});
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of());
queryRunner.installPlugin(new TpcdsPlugin());
queryRunner.createCatalog("tpcds", "tpcds", ImmutableMap.of());
if (createTpchTables) {
copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, session, TpchTable.getTables());
}
return queryRunner;
} catch (Exception e) {
closeAllSuppress(e, queryRunner);
throw e;
}
}
use of io.hetu.core.common.filesystem.TempFolder in project hetu-core by openlookeng.
the class TestMemoryMetadata method setUp.
@BeforeMethod
public void setUp() throws IOException {
TempFolder tmp = new TempFolder().create();
Runtime.getRuntime().addShutdownHook(new Thread(tmp::close));
metadata = new MemoryMetadata(new TestingTypeManager(), new TestingNodeManager(), new HetuFsMetastore(new HetuFsMetastoreConfig().setHetuFileSystemMetastorePath(tmp.getRoot().getCanonicalPath()), new HetuLocalFileSystemClient(new LocalConfig(null), Paths.get(tmp.getRoot().getCanonicalPath()))), null, new MemoryConfig());
}
Aggregations