@Override public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { ImmutableList.Builder<SchemaTableName> tableNames = ImmutableList.builder(); for (String schemaName : listSchemas(session, schemaNameOrNull)) { try { for (String tableName : schemaProvider.getAllTables(schemaName)) { tableNames.add(new SchemaTableName(schemaName, tableName.toLowerCase(ENGLISH))); } } catch (SchemaNotFoundException e) { // schema disappeared during listing operation } } return tableNames.build(); }
public Set<String> getTableNames(String schemaName) throws InterruptedException, ExecutionException, IOException { log.info("checking... %s\n", schemaName); List<RiakObject> objects = getSchemaRiakObjects(schemaName); if (objects.size() == 0) { throw new SchemaNotFoundException(schemaName, "No siblings in " + SCHEMA_KEY_NAME); } for (RiakObject o : objects) { PRSchema schema = objectMapper.readValue(o.getValue().toStringUtf8(), PRSchema.class); checkNotNull(schema, "no schema key exists in Riak"); HashSet<String> set = new HashSet<>(); for (String t : schema.getTables()) { set.add(t); } return ImmutableSet.copyOf(set); } Set<String> s = new HashSet<String>(); return ImmutableSet.copyOf(s); }
public boolean addTableToSchema(String schemaName, PRTable table) throws InterruptedException, ExecutionException, IOException { List<RiakObject> objects = getSchemaRiakObjects(schemaName); if (objects.size() == 0) { throw new SchemaNotFoundException(schemaName, "No siblings in " + SCHEMA_KEY_NAME); } for (RiakObject o : objects) { PRSchema schema = objectMapper.readValue(o.getValue().toStringUtf8(), PRSchema.class); checkNotNull(schema, "no schema key exists in Riak"); return true; } return false; }
public List<String> getAllTables(String schema) throws SchemaNotFoundException { KeyspaceMetadata meta = getCheckedKeyspaceMetadata(schema); ImmutableList.Builder<String> builder = ImmutableList.builder(); for (TableMetadata tableMeta : meta.getTables()) { builder.add(tableMeta.getName()); } return builder.build(); }
private KeyspaceMetadata getCheckedKeyspaceMetadata(final String schema) throws SchemaNotFoundException { KeyspaceMetadata keyspaceMetadata = executeWithSession(schema, new SessionCallable<KeyspaceMetadata>() { @Override public KeyspaceMetadata executeWithSession(Session session) { return session.getCluster().getMetadata().getKeyspace(schema); } }); if (keyspaceMetadata == null) { throw new SchemaNotFoundException(schema); } return keyspaceMetadata; }
@Override public List<String> getAllTables(String schema) throws SchemaNotFoundException { accessCount.incrementAndGet(); if (throwException) { throw new IllegalStateException(); } if (schema.equals(TEST_SCHEMA)) { return ImmutableList.of(TEST_TABLE); } throw new SchemaNotFoundException(schema); }
@Override public void getSchema(String schema) throws SchemaNotFoundException { accessCount.incrementAndGet(); if (throwException) { throw new IllegalStateException(); } if (!schema.equals(TEST_SCHEMA)) { throw new SchemaNotFoundException(schema); } }
public List<RiakObject> getSchemaRiakObjects(String schemaName) throws InterruptedException, ExecutionException, IOException { // null returns if not found FetchOperation op = buildFetchOperation(schemaName, META_BUCKET_NAME, SCHEMA_KEY_NAME); cluster.execute(op); op.await(); if (!op.isSuccess()) { throw new SchemaNotFoundException(schemaName, SCHEMA_KEY_NAME + " was not found", op.cause()); } return op.get().getObjectList(); }
public List<String> getAllTables(String databaseName) throws SchemaNotFoundException { return ImmutableList.copyOf(getCacheValue(tableNamesCache, databaseName, SchemaNotFoundException.class).keySet()); }
public String getCaseSensitiveTableName(SchemaTableName schemaTableName) { String caseSensitiveTableName = getCacheValue(tableNamesCache, schemaTableName.getSchemaName(), SchemaNotFoundException.class).get(schemaTableName.getTableName().toLowerCase(ENGLISH)); return caseSensitiveTableName == null ? schemaTableName.getTableName() : caseSensitiveTableName; }
public void getSchema(String schema) throws SchemaNotFoundException { getCheckedKeyspaceMetadata(schema); }
@Test(expectedExceptions = SchemaNotFoundException.class) public void testInvalidDbGetAllTAbles() throws Exception { schemaProvider.getAllTables(BAD_SCHEMA); }
@Test(enabled = false, expectedExceptions = SchemaNotFoundException.class) public void testGetTableNamesException() throws Exception { metadata.listTables(SESSION, INVALID_DATABASE); }
private static Database getDatabase(HiveMetastore metastore, String database) { return metastore.getDatabase(database).orElseThrow(() -> new SchemaNotFoundException(database)); }