private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObjectException { try { ms.getDatabase(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME); } catch (NoSuchObjectException e) { Database db = new Database(DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_COMMENT, wh.getDefaultDatabasePath(DEFAULT_DATABASE_NAME).toString(), null); db.setOwnerName(PUBLIC); db.setOwnerType(PrincipalType.ROLE); db.setCatalogName(DEFAULT_CATALOG_NAME); long time = System.currentTimeMillis() / 1000; db.setCreateTime((int) time); ms.createDatabase(db); } }
private Database createTestDb(String dbName, String dbOwner) { String dbDescription = dbName; String dbLocation = "file:/tmp"; Map<String, String> dbParams = new HashMap<>(); Database db = new Database(dbName, dbDescription, dbLocation, dbParams); db.setOwnerName(dbOwner); db.setOwnerType(PrincipalType.USER); db.setCatalogName(DEFAULT_CATALOG_NAME); db.setCreateTime((int) (System.currentTimeMillis() / 1000)); return db; }
(null == type || type.trim().isEmpty()) ? null : PrincipalType.valueOf(type)); db.setCatalogName(MetastoreDirectSqlUtils.extractSqlString(dbline[6])); db.setCreateTime(MetastoreDirectSqlUtils.extractSqlInt(dbline[7])); db.setParameters(MetaStoreServerUtils.trimMapNulls(dbParams,convertMapNullsToEmptyStrings)); if (LOG.isDebugEnabled()){
public Database build(Configuration conf) throws MetaException { if (name == null) throw new MetaException("You must name the database"); if (catalogName == null) catalogName = MetaStoreUtils.getDefaultCatalog(conf); Database db = new Database(name, description, location, params); db.setCatalogName(catalogName); db.setCreateTime(createTime); try { if (ownerName == null) ownerName = SecurityUtils.getUser(); db.setOwnerName(ownerName); if (ownerType == null) ownerType = PrincipalType.USER; db.setOwnerType(ownerType); return db; } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } }
db.setLocationUri(dbPath.toString()); long time = System.currentTimeMillis()/1000; db.setCreateTime((int) time); boolean success = false; boolean madeDir = false;
/** * This test creates and queries a database and then drops it. Good for testing the happy path. */ @Test public void testCreateGetDeleteDatabase() throws Exception { Database database = getDatabaseWithAllParametersSet(); client.createDatabase(database); Database createdDatabase = client.getDatabase(database.getName()); // The createTime will be set on the server side, so the comparison should skip it database.setCreateTime(createdDatabase.getCreateTime()); Assert.assertEquals("Comparing databases", database, createdDatabase); Assert.assertTrue("The directory should be created", metaStore.isPathExists( new Path(database.getLocationUri()))); client.dropDatabase(database.getName()); Assert.assertFalse("The directory should be removed", metaStore.isPathExists(new Path(database.getLocationUri()))); try { client.getDatabase(database.getName()); Assert.fail("Expected a NoSuchObjectException to be thrown"); } catch (NoSuchObjectException exception) { // Expected exception } }
public Database getJDODatabase(String catName, String name) throws NoSuchObjectException { MDatabase mdb = null; boolean commited = false; try { openTransaction(); mdb = getMDatabase(catName, 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 = org.apache.commons.lang.StringUtils.defaultIfBlank(mdb.getOwnerType(), null); PrincipalType principalType = (type == null) ? null : PrincipalType.valueOf(type); db.setOwnerType(principalType); db.setCatalogName(catName); db.setCreateTime(mdb.getCreateTime()); return db; }
unsetCreateTime(); } else { setCreateTime((Integer)value);