@Override void initialize(Configuration conf) throws HCatException { this.config = conf; try { hiveConfig = HCatUtil.getHiveConf(config); hmsClient = HCatUtil.getHiveMetastoreClient(hiveConfig); } catch (MetaException exp) { throw new HCatException("MetaException while creating HMS client", exp); } catch (IOException exp) { throw new HCatException("IOException while creating HMS client", exp); } }
/** * Decrement the user count and piggyback this to set expiry flag as well, then teardown(), if conditions are met. * This *MUST* be called by anyone who uses this client. */ @Override public synchronized void close() { release(); tearDownIfUnused(); }
/** * Gets the error code. * @return the error code */ public int getErrorCode() { return errorType.getErrorCode(); }
@Override public String run() throws IOException, TException, InterruptedException { final IMetaStoreClient client = HCatUtil.getHiveMetastoreClient(c); return ugi.doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws IOException, TException, InterruptedException { String u = ugi.getUserName(); return client.getDelegationToken(c.getUser(),u); } }); } });
/** * Gets the HCatOuputJobInfo object by reading the Configuration and deserializing * the string. If InputJobInfo is not present in the configuration, throws an * exception since that means HCatOutputFormat.setOutput has not been called. * @param conf the job Configuration object * @return the OutputJobInfo object * @throws IOException the IO exception */ public static OutputJobInfo getJobInfo(Configuration conf) throws IOException { String jobString = conf.get(HCatConstants.HCAT_KEY_OUTPUT_INFO); if (jobString == null) { throw new HCatException(ErrorType.ERROR_NOT_INITIALIZED); } return (OutputJobInfo) HCatUtil.deserialize(jobString); }
@Test public void testCloseAllClients() throws IOException, MetaException, LoginException { final HiveClientCache cache = new HiveClientCache(1000); HiveClientCache.ICacheableMetaStoreClient client1 = (HiveClientCache.ICacheableMetaStoreClient) cache.get(hiveConf); hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, " "); // URIs are checked for string equivalence, even spaces make them different HiveClientCache.ICacheableMetaStoreClient client2 = (HiveClientCache.ICacheableMetaStoreClient) cache.get(hiveConf); cache.closeAllClientsQuietly(); assertTrue(client1.isClosed()); assertTrue(client2.isClosed()); }
private static void assertTypeInCategory(Type type, Category category, String fieldName) throws HCatException { Category typeCategory = Category.fromType(type); if (typeCategory != category) { throw new HCatException("Type category mismatch. Expected " + category + " but type " + type + " in category " + typeCategory + " (field " + fieldName + ")"); } }
@Override public String toString() { return getMessage(); }
public static LinkedList<InputJobInfo> getInputJobInfosFromConf(Configuration conf) throws IOException { LinkedList<InputJobInfo> inputJobInfos = (LinkedList<InputJobInfo>) HCatUtil.deserialize( conf.get(HCatConstants.HCAT_KEY_JOB_INFO)); return inputJobInfos; }
/** * Is this a retriable error. * @return is it retriable */ public boolean isRetriable() { return errorType.isRetriable(); }
/** * Instantiates a new hcat exception. * @param errorType the error type * @param extraMessage extra messages to add to the message string * @param cause the cause */ public HCatException(ErrorType errorType, String extraMessage, Throwable cause) { super(buildErrorMessage( errorType, extraMessage, cause), cause); this.errorType = errorType; }
public static HiveClientCacheKey fromHiveConf(HiveConf hiveConf, final int threadId) throws IOException, LoginException { return new HiveClientCacheKey(hiveConf, threadId); }
public static HiveStorageHandler getStorageHandler(Configuration conf, PartInfo partitionInfo) throws IOException { return HCatUtil.getStorageHandler( conf, partitionInfo.getStorageHandlerClassName(), partitionInfo.getSerdeClassName(), partitionInfo.getInputFormatClassName(), partitionInfo.getOutputFormatClassName()); }
public static InputJobInfo getLastInputJobInfosFromConf(Configuration conf) throws IOException { LinkedList<InputJobInfo> inputJobInfos = getInputJobInfosFromConf(conf); if (inputJobInfos == null || inputJobInfos.isEmpty()) { return null; } else { return getInputJobInfosFromConf(conf).getLast(); } }
static public Pair<String, String> getDBTableNames(String location) throws IOException { // the location string will be of the form: // <database name>.<table name> - parse it and // communicate the information to HCatInputFormat try { return HCatUtil.getDbAndTableName(location); } catch (IOException e) { String locationErrMsg = "The input location in load statement " + "should be of the form " + "<databasename>.<table name> or <table name>. Got " + location; throw new PigException(locationErrMsg, PIG_EXCEPTION_CODE); } }
private static Properties getHiveSiteOverrides(Configuration jobConf) { return getHiveSiteOverrides(getHiveSiteContentsFromClasspath(), jobConf); }
@Override public void run() { cleanup(); } };
@Test public void testValidateMorePermissive() { assertConsistentFsPermissionBehaviour(FsAction.ALL, true, true, true, true, true, true, true, true); assertConsistentFsPermissionBehaviour(FsAction.READ, false, true, false, true, false, false, false, false); assertConsistentFsPermissionBehaviour(FsAction.WRITE, false, true, false, false, true, false, false, false); assertConsistentFsPermissionBehaviour(FsAction.EXECUTE, false, true, true, false, false, false, false, false); assertConsistentFsPermissionBehaviour(FsAction.READ_EXECUTE, false, true, true, true, false, true, false, false); assertConsistentFsPermissionBehaviour(FsAction.READ_WRITE, false, true, false, true, true, false, true, false); assertConsistentFsPermissionBehaviour(FsAction.WRITE_EXECUTE, false, true, true, false, true, false, false, true); assertConsistentFsPermissionBehaviour(FsAction.NONE, false, true, false, false, false, false, false, false); }
private static void assertTypeNotInCategory(Type type, Category category) throws HCatException { Category typeCategory = Category.fromType(type); if (typeCategory == category) { throw new HCatException("Type category mismatch. Expected type " + type + " not in category " + category + " but was so."); } }
/** * Setter for the "root" location of the HCatPartitionSpec. * @param location The new "root" location of the HCatPartitionSpec. * @throws HCatException On failure to set a new location. */ public void setRootLocation(String location) throws HCatException { try { partitionSpecProxy.setRootLocation(location); } catch (MetaException metaException) { throw new HCatException("Unable to set root-path!", metaException); } }