use of org.apache.hadoop.hive.metastore.api.Database in project hive by apache.
the class ObjectStore method getJDODatabase.
public Database getJDODatabase(String name) throws NoSuchObjectException {
MDatabase mdb = null;
boolean commited = false;
try {
openTransaction();
mdb = getMDatabase(name);
commited = commitTransaction();
} finally {
if (!commited) {
rollbackTransaction();
}
}
Database db = new Database();
db.setName(mdb.getName());
db.setDescription(mdb.getDescription());
db.setLocationUri(mdb.getLocationUri());
db.setParameters(convertMap(mdb.getParameters()));
db.setOwnerName(mdb.getOwnerName());
String type = mdb.getOwnerType();
db.setOwnerType((null == type || type.trim().isEmpty()) ? null : PrincipalType.valueOf(type));
return db;
}
use of org.apache.hadoop.hive.metastore.api.Database in project hive by apache.
the class HBaseImport method copyIndexes.
private void copyIndexes() throws MetaException, InvalidObjectException, InterruptedException {
screen("Copying indexes");
// Start the parallel threads that will copy the indexes
Thread[] copiers = new Thread[parallel];
writingToQueue = true;
for (int i = 0; i < parallel; i++) {
copiers[i] = new IndexCopier();
copiers[i].start();
}
// Put indexes from the databases we copied into the queue
for (Database db : dbs) {
screen("Coyping indexes in database " + db.getName());
for (String tableName : rdbmsStore.get().getAllTables(db.getName())) {
for (Index index : rdbmsStore.get().getIndexes(db.getName(), tableName, -1)) {
indexNameQueue.put(new String[] { db.getName(), tableName, index.getIndexName() });
}
}
}
// Now put any specifically requested tables into the queue
if (tablesToImport != null) {
for (String compoundTableName : tablesToImport) {
String[] tn = compoundTableName.split("\\.");
if (tn.length != 2) {
error(compoundTableName + " not in proper form. Must be in form dbname.tablename. " + "Ignoring this table and continuing.");
} else {
for (Index index : rdbmsStore.get().getIndexes(tn[0], tn[1], -1)) {
indexNameQueue.put(new String[] { tn[0], tn[1], index.getIndexName() });
}
}
}
}
writingToQueue = false;
// Wait until we've finished adding all the tables
for (Thread copier : copiers) copier.join();
}
use of org.apache.hadoop.hive.metastore.api.Database in project hive by apache.
the class HBaseImport method copyDbs.
private void copyDbs() throws MetaException, NoSuchObjectException, InvalidObjectException {
screen("Copying databases");
List<String> toCopy = doAll ? rdbmsStore.get().getAllDatabases() : dbsToImport;
for (String dbName : toCopy) {
Database db = rdbmsStore.get().getDatabase(dbName);
dbs.add(db);
screen("Copying database " + dbName);
hbaseStore.get().createDatabase(db);
}
}
use of org.apache.hadoop.hive.metastore.api.Database in project brisk by riptano.
the class MetaStorePersisterTest method testBasicLoadMetaStoreEntity.
@Test
public void testBasicLoadMetaStoreEntity() throws Exception {
setupClient();
Database database = new Database();
database.setName("name");
database.setDescription("description");
database.setLocationUri("uri");
database.setParameters(new HashMap<String, String>());
metaStorePersister.save(database.metaDataMap, database, database.getName());
Database foundDb = new Database();
foundDb.setName("name");
metaStorePersister.load(foundDb, "name");
assertEquals(database, foundDb);
}
use of org.apache.hadoop.hive.metastore.api.Database in project brisk by riptano.
the class MetaStorePersisterTest method testFindMetaStoreEntities.
@Test
public void testFindMetaStoreEntities() throws Exception {
setupClient();
Database database = new Database();
database.setName("dbname");
database.setDescription("description");
database.setLocationUri("uri");
database.setParameters(new HashMap<String, String>());
metaStorePersister.save(database.metaDataMap, database, database.getName());
Table table = new Table();
table.setDbName("dbname");
table.setTableName("table_one");
metaStorePersister.save(table.metaDataMap, table, table.getDbName());
table.setTableName("table_two");
metaStorePersister.save(table.metaDataMap, table, table.getDbName());
table.setTableName("table_three");
metaStorePersister.save(table.metaDataMap, table, table.getDbName());
table.setTableName("other_table");
metaStorePersister.save(table.metaDataMap, table, table.getDbName());
List tables = metaStorePersister.find(table, "dbname");
assertEquals(4, tables.size());
tables = metaStorePersister.find(table, "dbname", "table", 100);
assertEquals(3, tables.size());
}
Aggregations