@Test public void testTemporaryTablespace() { Optional<Tablespace> ts = TablespaceManager.removeTablespaceForTest("pgsql_cluster"); assertTrue(ts.isPresent()); Tablespace tempTs = TablespaceManager.get(jdbcUrl); assertNotNull(tempTs); TablespaceManager.addTableSpaceForTest(ts.get()); }
private Tablespace getTablespaceHandler(@Nullable String tableSpaceName, @Nullable URI tableUri) { if (tableSpaceName != null) { return TablespaceManager.getByName(tableSpaceName); } else if (tableUri != null) { return TablespaceManager.get(tableUri); } else { return TablespaceManager.getDefault(); } } }
/** * Get tablespace for the given URI. If uri is null, the default tablespace will be returned * * @param uri Table or Table Fragment URI. * @param <T> Tablespace class type * @return Tablespace. If uri is null, the default tablespace will be returned. */ public static <T extends Tablespace> T get(@Nullable URI uri) { if (uri == null) { return getDefault(); } else { return (T) get(uri.toString()); } }
@Override public URI getTableURI(@Nullable String spaceName, String databaseName, String tableName) { Tablespace space = spaceName == null ? getDefault() : getByName(spaceName); return space.getTableUri(databaseName, tableName); }
@Test(timeout = 120000) public void testGetFileTablespace() throws Exception { final Configuration hdfsConf = getTestHdfsConfiguration(); final MiniDFSCluster cluster = new MiniDFSCluster.Builder(hdfsConf) .numDataNodes(1).format(true).build(); URI uri = URI.create(cluster.getFileSystem().getUri() + "/tajo"); try { /* Local FileSystem */ FileTablespace space = TablespaceManager.getLocalFs(); assertEquals(localFs.getUri(), space.getFileSystem().getUri()); FileTablespace distTablespace = new FileTablespace("testGetFileTablespace", uri, null); distTablespace.init(conf); TablespaceManager.addTableSpaceForTest(distTablespace); /* Distributed FileSystem */ space = TablespaceManager.get(uri); assertEquals(cluster.getFileSystem().getUri(), space.getFileSystem().getUri()); space = TablespaceManager.getByName("testGetFileTablespace"); assertEquals(cluster.getFileSystem().getUri(), space.getFileSystem().getUri()); } finally { cluster.shutdown(); } } }
@Override public long getTableVolumn(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException { return get(table.getUri()).getTableVolume(table, filter); }
@Test public void testCreateNotExistsExternalHBaseTable() throws Exception { Optional<Tablespace> existing = TablespaceManager.removeTablespaceForTest("cluster1"); assertTrue(existing.isPresent()); try { String sql = String.format( "CREATE EXTERNAL TABLE external_hbase_mapped_table1 (col1 text, col2 text, col3 text, col4 text) " + "USING hbase WITH ('table'='external_hbase_table', 'columns'=':key,col2:a,col3:,col2:b') " + "LOCATION '%s/external_hbase_table'", tableSpaceUri); try { executeString(sql).close(); fail("External table should be a existed table."); } catch (Throwable e) { assertTrue(e instanceof UnavailableTableLocationException); } } finally { TablespaceManager.addTableSpaceForTest(existing.get()); } }
@SimpleTest @Test @Option(sort = true) public void testQueryWithConnProperties() throws Exception { Map<String, String> connProperties = new HashMap<>(); connProperties.put("user", "postgres"); connProperties.put("password", ""); Optional<Tablespace> old = Optional.empty(); try { old = PgSQLTestServer.resetAllParamsAndSetConnProperties(connProperties); runSimpleTests(); } finally { if (old.isPresent()) { TablespaceManager.addTableSpaceForTest(old.get()); } } } }
/** * It returns the default tablespace. This method ensures that it always return the tablespace. * * @return */ public static <T extends Tablespace> T getDefault() { return (T) getByName(DEFAULT_TABLESPACE_NAME); }
private Scanner getNextScanner() throws IOException { if (iterator.hasNext()) { currentFragment = iterator.next(); currentScanner = TablespaceManager.getLocalFs().getScanner(meta, schema, currentFragment, target); currentScanner.init(); return currentScanner; } else { return null; } }
@Override public URI getStagingUri(OverridableConf context, String queryId, TableMeta meta) throws IOException { if (meta.getOptions().isTrue(HBaseStorageConstants.INSERT_PUT_MODE)) { throw new IOException("Staging phase is not supported in this storage."); } else { return TablespaceManager.getDefault().getStagingUri(context, queryId, meta); } }
/** * Get tablespace for the given URI. If uri is null, the default tablespace will be returned * * @param uri Table or Table Fragment URI. * @param <T> Tablespace class type * @return Tablespace. If uri is null, the default tablespace will be returned. */ public static <T extends Tablespace> T get(@Nullable String uri) { if (uri == null || uri.isEmpty()) { return getDefault(); } Tablespace lastOne = null; // Find the longest matched one. For example, assume that the caller tries to find /x/y/z, and // there are /x and /x/y. In this case, /x/y will be chosen because it is more specific. for (Map.Entry<URI, Tablespace> entry : TABLE_SPACES.headMap(URI.create(uri), true).entrySet()) { if (uri.startsWith(entry.getKey().toString())) { lastOne = entry.getValue(); } } if (lastOne == null) { lastOne = initializeTableSpace(UUID.randomUUID().toString(), URI.create(uri), new JSONObject()); try { lastOne.init(systemConf); } catch (IOException e) { throw new RuntimeException(e); } } return (T) lastOne; }
catalog = util.getMaster().getCatalog(); workDir = CommonTestingUtil.getTestDir(TEST_PATH); sm = TablespaceManager.getLocalFs(); sm.getFileSystem().mkdirs(tablePath.getParent()); Appender appender = ((FileTablespace) TablespaceManager.getLocalFs()) .getAppender(employeeMeta, schema, tablePath); appender.init(); planner = new LogicalPlanner(catalog, TablespaceManager.getInstance()); optimizer = new LogicalOptimizer(conf, catalog, TablespaceManager.getInstance());
public void start() { try { analyzer = new SQLAnalyzer(); preVerifier = new PreLogicalPlanVerifier(context.getCatalog()); planner = new LogicalPlanner(context.getCatalog(), TablespaceManager.getInstance()); // Access path rewriter is enabled only in QueryMasterTask optimizer = new LogicalOptimizer(context.getConf(), context.getCatalog(), TablespaceManager.getInstance()); annotatedPlanVerifier = new LogicalPlanVerifier(); postLogicalPlanVerifier = new PostLogicalPlanVerifier(); } catch (Throwable t) { LOG.error(t.getMessage(), t); throw new RuntimeException(t); } super.start(); }
@AfterClass public static void tearDown() throws IOException { TablespaceManager.removeTablespaceForTest(S3_SPACENAME); TablespaceManager.removeTablespaceForTest(S3N_SPACENAME); TablespaceManager.removeTablespaceForTest(S3A_SPACENAME); }
public void openAppender(int suffixId) throws IOException { Path actualFilePath = lastFileName; if (suffixId > 0) { actualFilePath = new Path(lastFileName + "_" + suffixId); } appender = ((FileTablespace) TablespaceManager.get(lastFileName.toUri())) .getAppender(meta, outSchema, actualFilePath); appender.enableStats(); appender.init(); }
@Test public void testRowFieldSelectQuery() throws Exception { Optional<Tablespace> existing = TablespaceManager.removeTablespaceForTest("cluster1"); assertTrue(existing.isPresent()); TablespaceManager.addTableSpaceForTest(existing.get());
@BeforeClass public static void setUp() throws IOException { String tableSpaceUri = "hbase:zk://host1:2171"; HBaseTablespace hBaseTablespace = new HBaseTablespace("cluster1", URI.create(tableSpaceUri), null); hBaseTablespace.init(new TajoConf()); TablespaceManager.addTableSpaceForTest(hBaseTablespace); }
/** * It returns the default tablespace. This method ensures that it always return the tablespace. * * @return */ public static <T extends Tablespace> T getDefault() { return (T) getByName(DEFAULT_TABLESPACE_NAME); }