Java 类com.facebook.presto.spi.SchemaNotFoundException 实例源码

项目:presto    文件:CassandraMetadata.java   
@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();
}
项目:presto-riak    文件:RiakClient.java   
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);
}
项目:presto-riak    文件:RiakClient.java   
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;
}
项目:presto    文件:CassandraSession.java   
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();
}
项目:presto    文件:CassandraSession.java   
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;
}
项目:presto    文件:MockCassandraSession.java   
@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);
}
项目:presto    文件:MockCassandraSession.java   
@Override
public void getSchema(String schema)
        throws SchemaNotFoundException
{
    accessCount.incrementAndGet();
    if (throwException) {
        throw new IllegalStateException();
    }

    if (!schema.equals(TEST_SCHEMA)) {
        throw new SchemaNotFoundException(schema);
    }
}
项目:presto-riak    文件:RiakClient.java   
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();
}
项目:presto    文件:CachingCassandraSchemaProvider.java   
public List<String> getAllTables(String databaseName)
        throws SchemaNotFoundException
{
    return ImmutableList.copyOf(getCacheValue(tableNamesCache, databaseName, SchemaNotFoundException.class).keySet());
}
项目:presto    文件:CachingCassandraSchemaProvider.java   
public String getCaseSensitiveTableName(SchemaTableName schemaTableName)
{
    String caseSensitiveTableName = getCacheValue(tableNamesCache, schemaTableName.getSchemaName(), SchemaNotFoundException.class).get(schemaTableName.getTableName().toLowerCase(ENGLISH));
    return caseSensitiveTableName == null ? schemaTableName.getTableName() : caseSensitiveTableName;
}
项目:presto    文件:CassandraSession.java   
public void getSchema(String schema)
        throws SchemaNotFoundException
{
    getCheckedKeyspaceMetadata(schema);
}
项目:presto    文件:TestCachingCassandraSchemaProvider.java   
@Test(expectedExceptions = SchemaNotFoundException.class)
public void testInvalidDbGetAllTAbles()
        throws Exception
{
    schemaProvider.getAllTables(BAD_SCHEMA);
}
项目:presto    文件:TestCassandraConnector.java   
@Test(enabled = false, expectedExceptions = SchemaNotFoundException.class)
public void testGetTableNamesException()
        throws Exception
{
    metadata.listTables(SESSION, INVALID_DATABASE);
}
项目:presto    文件:HiveWriteUtils.java   
private static Database getDatabase(HiveMetastore metastore, String database)
{
    return metastore.getDatabase(database).orElseThrow(() -> new SchemaNotFoundException(database));
}