/** * Gets the last known replication state of this db. This is * applicable only if it is the destination of a replication * and has had data replicated into it via imports previously. * Defaults to 0. */ public static long getLastReplicationId(HCatDatabase db){ Map<String, String> props = db.getProperties(); if (props != null){ if (props.containsKey(REPL_STATE_ID)){ return Long.parseLong(props.get(REPL_STATE_ID)); } } return 0l; // default is to return earliest possible state. }
@Override public HCatDatabase getDatabase(String dbName) throws HCatException { HCatDatabase db = null; try { Database hiveDB = hmsClient.getDatabase(checkDB(dbName)); if (hiveDB != null) { db = new HCatDatabase(hiveDB); } } catch (NoSuchObjectException exp) { throw new ObjectNotFoundException( "NoSuchObjectException while fetching database", exp); } catch (MetaException exp) { throw new HCatException("MetaException while fetching database", exp); } catch (TException exp) { throw new ConnectionFailureException( "TException while fetching database", exp); } return db; }
assertTrue(testDb.getComment() == null); assertTrue(testDb.getProperties().size() == 0); String warehouseDir = System .getProperty("test.warehouse.dir", "/user/hive/warehouse"); if (useExternalMS) { assertTrue(testDb.getLocation().matches(".*" + "/" + db + ".db")); } else { String expectedDir = warehouseDir.replaceFirst("pfile:///", "pfile:/") + "/" + msPort; assertEquals(expectedDir + "/" + db + ".db", testDb.getLocation());
@Test public void testDatabaseLocation() throws Exception { HCatClient client = HCatClient.create(new Configuration(hcatConf)); String dbName = "locationDB"; client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE); HCatCreateDBDesc dbDesc = HCatCreateDBDesc.create(dbName) .ifNotExists(true).location("/tmp/" + dbName).build(); client.createDatabase(dbDesc); HCatDatabase newDB = client.getDatabase(dbName); assertTrue(newDB.getLocation().matches(".*/tmp/" + dbName)); client.close(); }
/** * Gets the last known replication state of this db. This is * applicable only if it is the destination of a replication * and has had data replicated into it via imports previously. * Defaults to 0. */ public static long getLastReplicationId(HCatDatabase db){ Map<String, String> props = db.getProperties(); if (props != null){ if (props.containsKey(REPL_STATE_ID)){ return Long.parseLong(props.get(REPL_STATE_ID)); } } return 0l; // default is to return earliest possible state. }
@Override public HCatDatabase getDatabase(String dbName) throws HCatException { HCatDatabase db = null; try { Database hiveDB = hmsClient.getDatabase(checkDB(dbName)); if (hiveDB != null) { db = new HCatDatabase(hiveDB); } } catch (NoSuchObjectException exp) { throw new ObjectNotFoundException( "NoSuchObjectException while fetching database", exp); } catch (MetaException exp) { throw new HCatException("MetaException while fetching database", exp); } catch (TException exp) { throw new ConnectionFailureException( "TException while fetching database", exp); } return db; }
/** * Gets the last known replication state of this db. This is * applicable only if it is the destination of a replication * and has had data replicated into it via imports previously. * Defaults to 0. */ public static long getLastReplicationId(HCatDatabase db){ Map<String, String> props = db.getProperties(); if (props != null){ if (props.containsKey(REPL_STATE_ID)){ return Long.parseLong(props.get(REPL_STATE_ID)); } } return 0l; // default is to return earliest possible state. }
@Override public HCatDatabase getDatabase(String dbName) throws HCatException { HCatDatabase db = null; try { Database hiveDB = hmsClient.getDatabase(checkDB(dbName)); if (hiveDB != null) { db = new HCatDatabase(hiveDB); } } catch (NoSuchObjectException exp) { throw new ObjectNotFoundException( "NoSuchObjectException while fetching database", exp); } catch (MetaException exp) { throw new HCatException("MetaException while fetching database", exp); } catch (TException exp) { throw new ConnectionFailureException( "TException while fetching database", exp); } return db; }
/** * Gets the last known replication state of this db. This is * applicable only if it is the destination of a replication * and has had data replicated into it via imports previously. * Defaults to 0. */ public static long getLastReplicationId(HCatDatabase db){ Map<String, String> props = db.getProperties(); if (props != null){ if (props.containsKey(REPL_STATE_ID)){ return Long.parseLong(props.get(REPL_STATE_ID)); } } return 0l; // default is to return earliest possible state. }
@Override public HCatDatabase getDatabase(String dbName) throws HCatException { HCatDatabase db = null; try { Database hiveDB = hmsClient.getDatabase(checkDB(dbName)); if (hiveDB != null) { db = new HCatDatabase(hiveDB); } } catch (NoSuchObjectException exp) { throw new ObjectNotFoundException( "NoSuchObjectException while fetching database", exp); } catch (MetaException exp) { throw new HCatException("MetaException while fetching database", exp); } catch (TException exp) { throw new ConnectionFailureException( "TException while fetching database", exp); } return db; }