private List<String> internalListTables(String prefix) { try { if (prefix.isEmpty()) { return client.getTablesList().getTablesList(); } else { return client.getTablesList(prefix).getTablesList(); } } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
private List<String> listSchemaNamesFromTablets(KuduClient client) throws KuduException { List<String> tables = client.getTablesList().getTablesList(); LinkedHashSet<String> schemas = new LinkedHashSet<>(); schemas.add(DEFAULT_SCHEMA); for (String table : tables) { SchemaTableName schemaTableName = fromRawName(table); if (schemaTableName != null) { schemas.add(schemaTableName.getSchemaName()); } } return ImmutableList.copyOf(schemas); }
private boolean checkForTable(String name) throws Exception { return !client.getTablesList(name).getTablesList().isEmpty(); }
@Override public Set<String> getTableNames() { try { ListTablesResponse tablesList = plugin.getClient().getTablesList(); return Sets.newHashSet(tablesList.getTablesList()); } catch (Exception e) { logger.warn("Failure reading kudu tables.", e); return Collections.emptySet(); } }
@Override public void dropSchema(KuduClient client, String schemaName) { if (DEFAULT_SCHEMA.equals(schemaName)) { throw new PrestoException(GENERIC_USER_ERROR, "Deleting default schema not allowed."); } else { try { String prefix = getPrefixForTablesOfSchema(schemaName); for (String name : client.getTablesList(prefix).getTablesList()) { client.deleteTable(name); } KuduTable schemasTable = getSchemasTable(client); KuduSession session = client.newSession(); try { Delete delete = schemasTable.newDelete(); delete.getRow().addString(0, schemaName); session.apply(delete); } finally { session.close(); } } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } } }
if (!tables.getTablesList().isEmpty()) { client.deleteTable(tableName);
private List<String> internalListTables(String prefix) { try { List<String> tables; if (prefix.isEmpty()) { tables = client.getTablesList().getTablesList(); } else { tables = client.getTablesList(prefix).getTablesList().stream(). filter(name -> name.startsWith(prefix)).collect(toImmutableList()); } return tables; } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
private List<String> internalListTables(String prefix) { try { if (prefix.isEmpty()) { return client.getTablesList().getTablesList(); } else { return client.getTablesList(prefix).getTablesList(); } } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
@Override public Deferred<Boolean> call(ListTablesResponse listTablesResponse) throws Exception { for (String tableName : listTablesResponse.getTablesList()) { if (name.equals(tableName)) { return Deferred.fromResult(true); } } return Deferred.fromResult(false); } });
private List<String> listSchemaNamesFromTablets(KuduClient client) throws KuduException { List<String> tables = client.getTablesList().getTablesList(); LinkedHashSet<String> schemas = new LinkedHashSet<>(); schemas.add(DEFAULT_SCHEMA); for (String table : tables) { SchemaTableName schemaTableName = fromRawName(table); if (schemaTableName != null) { schemas.add(schemaTableName.getSchemaName()); } } return ImmutableList.copyOf(schemas); }
@Override public void dropSchema(KuduClient client, String schemaName) { if (DEFAULT_SCHEMA.equals(schemaName)) { throw new PrestoException(GENERIC_USER_ERROR, "Deleting default schema not allowed."); } else { try { String prefix = getPrefixForTablesOfSchema(schemaName); for (String name : client.getTablesList(prefix).getTablesList()) { client.deleteTable(name); } KuduTable schemasTable = getSchemasTable(client); KuduSession session = client.newSession(); try { Delete delete = schemasTable.newDelete(); delete.getRow().addString(0, schemaName); session.apply(delete); } finally { session.close(); } } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } } }
/** * Test creating and deleting a table through a KuduClient. */ @Test(timeout = 100000) public void testCreateDeleteTable() throws Exception { // Check that we can create a table. client.createTable(TABLE_NAME, basicSchema, getBasicCreateTableOptions()); assertFalse(client.getTablesList().getTablesList().isEmpty()); assertTrue(client.getTablesList().getTablesList().contains(TABLE_NAME)); // Check that we can delete it. client.deleteTable(TABLE_NAME); assertFalse(client.getTablesList().getTablesList().contains(TABLE_NAME)); // Check that we can re-recreate it, with a different schema. List<ColumnSchema> columns = new ArrayList<>(basicSchema.getColumns()); columns.add(new ColumnSchema.ColumnSchemaBuilder("one more", Type.STRING).build()); Schema newSchema = new Schema(columns); client.createTable(TABLE_NAME, newSchema, getBasicCreateTableOptions()); // Check that we can open a table and see that it has the new schema. KuduTable table = client.openTable(TABLE_NAME); assertEquals(newSchema.getColumnCount(), table.getSchema().getColumnCount()); assertTrue(table.getPartitionSchema().isSimpleRangePartitioning()); // Check that the block size parameter we specified in the schema is respected. assertEquals(4096, newSchema.getColumn("column3_s").getDesiredBlockSize()); assertEquals(ColumnSchema.Encoding.DICT_ENCODING, newSchema.getColumn("column3_s").getEncoding()); assertEquals(ColumnSchema.CompressionAlgorithm.LZ4, newSchema.getColumn("column3_s").getCompressionAlgorithm()); }
@Override @SuppressWarnings("AssertionFailureIgnored") public void run() { final String tableName = "TestAuthnTokenReacquire-table-" + threadIdx; try { ListTabletServersResponse response = client.listTabletServers(); assertNotNull(response); dropConnectionsAndExpireToken(); ListTablesResponse tableList = client.getTablesList(tableName); assertNotNull(tableList); assertTrue(tableList.getTablesList().isEmpty()); dropConnectionsAndExpireToken(); client.createTable(tableName, basicSchema, getBasicCreateTableOptions()); dropConnectionsAndExpireToken(); KuduTable table = client.openTable(tableName); assertEquals(basicSchema.getColumnCount(), table.getSchema().getColumnCount()); dropConnectionsAndExpireToken(); client.deleteTable(tableName); assertFalse(client.tableExists(tableName)); } catch (Throwable e) { //noinspection ThrowableResultOfMethodCallIgnored exceptions.put(threadIdx, e); } } });
.build() ) { assertTrue(client.getTablesList().getTablesList().isEmpty());
@Test(timeout = 50000) public void testKerberos() throws Exception { FakeDNS.getInstance().install(); try (MiniKuduCluster cluster = new MiniKuduCluster.MiniKuduClusterBuilder() .numMasterServers(NUM_MASTERS) .numTabletServers(NUM_TABLET_SERVERS) .enableKerberos() .build()) { KuduClient client = new KuduClientBuilder(cluster.getMasterAddressesAsString()).build(); ListTablesResponse resp = client.getTablesList(); assertTrue(resp.getTablesList().isEmpty()); assertNull(client.getHiveMetastoreConfig()); } }
int initialTableCount = asyncClient.getTablesList().join(DEFAULT_SLEEP).getTablesList().size(); .join(DEFAULT_SLEEP).getTablesList().size()); assertEquals(1, asyncClient.getTablesList(tableWithDefault) .join(DEFAULT_SLEEP).getTablesList().size()); assertEquals(initialTableCount + 5, asyncClient.getTablesList().join(DEFAULT_SLEEP).getTablesList().size()); assertFalse(asyncClient.getTablesList(tableWithDefault). join(DEFAULT_SLEEP).getTablesList().isEmpty());
assertTrue(tableList.getTablesList().isEmpty());