/** * Check the permissions on a file. * @param fs Filesystem the file is contained in * @param stat Stat info for the file * @param action action to be performed * @throws IOException If thrown by Hadoop * @throws AccessControlException if the file cannot be accessed */ public static void checkFileAccess(FileSystem fs, FileStatus stat, FsAction action) throws IOException, LoginException { checkFileAccess(fs, stat, action, SecurityUtils.getUGI()); }
/** * Returns the buildVersion which includes version, * revision, user and date. */ public static String getBuildVersion(){ return MetastoreVersionInfo.getVersion() + " from " + MetastoreVersionInfo.getRevision() + " by " + MetastoreVersionInfo.getUser() + " source checksum " + MetastoreVersionInfo.getSrcChecksum(); }
private final String getNsOrDefault(String ns) { // This is only needed for old clients not setting NS in requests. // Not clear how to handle this... this is properly a HS2 config but metastore needs its default // value for backward compat, and we don't want it configurable separately because it's also // used in upgrade scripts, were it cannot be configured. return normalizeIdentifier(ns == null ? "default" : ns); }
public boolean mkdirs(Path f) throws MetaException { FileSystem fs; try { fs = getFs(f); return FileUtils.mkdir(fs, f); } catch (IOException e) { MetaStoreUtils.logAndThrowMetaException(e); } return false; }
@Override public List<String> getAllDatabases(String catName) throws TException { List<String> databases = client.get_databases(prependCatalogToDbName(catName, null, conf)); return FilterUtils.filterDbNamesIfEnabled(isClientFilterEnabled, filterHook, databases); }
/** * Creates a pair. Constructor doesn't infer template args but * the method does, so the code becomes less ugly. */ public static <T1, T2> ObjectPair<T1, T2> create(T1 f, T2 s) { return new ObjectPair<>(f, s); }
@Override public List<String> getTables(String catName, String dbName, String tablePattern) throws TException { List<String> tables = client.get_tables(prependCatalogToDbName(catName, dbName, conf), tablePattern); return FilterUtils.filterTableNamesIfEnabled(isClientFilterEnabled, filterHook, catName, dbName, tables); }
@Override public List<TableMeta> getTableMeta(String catName, String dbPatterns, String tablePatterns, List<String> tableTypes) throws TException { List<TableMeta> tableMetas = client.get_table_meta(prependCatalogToDbName( catName, dbPatterns, conf), tablePatterns, tableTypes); return FilterUtils.filterTableMetasIfEnabled(isClientFilterEnabled, filterHook, catName,dbPatterns, tableMetas); }
/** * Given a catalog name and database name, cram them together into one string. These can be * parsed apart again via {@link #parseDbName(String, Configuration)}. * @param catalogName catalog name. This cannot be null. If this might be null use * {@link #prependCatalogToDbName(String, String, Configuration)} instead. * @param dbName database name. * @return one string that contains both. */ public static String prependNotNullCatToDbName(String catalogName, String dbName) { assert catalogName != null; return prependCatalogToDbName(catalogName, dbName, null); }
public static int startMetaStore(final HadoopThriftAuthBridge bridge, Configuration conf) throws Exception { int port = findFreePort(); startMetaStore(port, bridge, conf); return port; }
public static boolean isValidSchedulingPolicy(String str) { try { parseSchedulingPolicy(str); return true; } catch (IllegalArgumentException ex) { } return false; }
/** * Initialize log4j. * * @return an message suitable for display to the user * @throws LogInitializationException if log4j fails to initialize correctly */ public static String initHiveLog4j(Configuration conf) throws LogInitializationException { return initHiveLog4jCommon(conf, MetastoreConf.ConfVars.LOG4J_FILE); }
@Override public boolean equals(Object that) { if (that == null) { return false; } if (that instanceof ObjectPair) { return this.equals((ObjectPair<F, S>)that); } return false; }
@Override public Boolean run() throws Exception { return runDistCp(srcPaths, dst, conf); } });
public RemoteIteratorWithFilter(RemoteIterator<LocatedFileStatus> iter, PathFilter filter) throws IOException { this.iter = iter; this.filter = filter; findNext(); }
@Override public List<String> getDatabases(String catName, String databasePattern) throws TException { List<String> databases = client.get_databases(prependCatalogToDbName( catName, databasePattern, conf)); return FilterUtils.filterDbNamesIfEnabled(isClientFilterEnabled, filterHook, databases); }
/** * Prepend the default 'hive' catalog onto the database name. * @param dbName database name * @param conf configuration object, used to determine default catalog * @return one string with the 'hive' catalog name prepended. */ public static String prependCatalogToDbName(String dbName, Configuration conf) { return prependCatalogToDbName(null, dbName, conf); }
public SerDeInfo( String name, String serializationLib, Map<String,String> parameters) { this(); this.name = org.apache.hadoop.hive.metastore.utils.StringUtils.intern(name); this.serializationLib = org.apache.hadoop.hive.metastore.utils.StringUtils.intern(serializationLib); this.parameters = org.apache.hadoop.hive.metastore.utils.StringUtils.intern(parameters); }
public FieldSchema( String name, String type, String comment) { this(); this.name = org.apache.hadoop.hive.metastore.utils.StringUtils.intern(name); this.type = org.apache.hadoop.hive.metastore.utils.StringUtils.intern(type); this.comment = org.apache.hadoop.hive.metastore.utils.StringUtils.intern(comment); }