Example #1
0
 public static Path getTempTableSpace(Configuration conf) {
   SessionState ss = SessionState.get();
   if (ss == null) {
     String tempTablePathString = conf.get(TMP_TABLE_SPACE_KEY);
     Preconditions.checkNotNull(
         tempTablePathString, "Conf temp table path expected to be non-null");
     return new Path(tempTablePathString);
   }
   return ss.getTempTableSpace();
 }
Example #2
0
 public static Path getLocalSessionPath(Configuration conf) {
   SessionState ss = SessionState.get();
   if (ss == null) {
     String localPathString = conf.get(LOCAL_SESSION_PATH_KEY);
     Preconditions.checkNotNull(
         localPathString, "Conf local session path expected to be non-null");
     return new Path(localPathString);
   }
   Preconditions.checkNotNull(ss.localSessionPath, "Local session path expected to be non-null");
   return ss.localSessionPath;
 }
Example #3
0
 public static Path getHDFSSessionPath(Configuration conf) {
   SessionState ss = SessionState.get();
   if (ss == null) {
     String sessionPathString = conf.get(HDFS_SESSION_PATH_KEY);
     Preconditions.checkNotNull(
         sessionPathString, "Conf non-local session path expected to be non-null");
     return new Path(sessionPathString);
   }
   Preconditions.checkNotNull(
       ss.hdfsSessionPath, "Non-local session path expected to be non-null");
   return ss.hdfsSessionPath;
 }
Example #4
0
 static void registerJars(List<String> newJars) throws IllegalArgumentException {
   LogHelper console = getConsole();
   try {
     ClassLoader loader = Thread.currentThread().getContextClassLoader();
     ClassLoader newLoader = Utilities.addToClassPath(loader, newJars.toArray(new String[0]));
     Thread.currentThread().setContextClassLoader(newLoader);
     SessionState.get().getConf().setClassLoader(newLoader);
     console.printInfo("Added " + newJars + " to class path");
   } catch (Exception e) {
     String message = "Unable to register " + newJars;
     throw new IllegalArgumentException(message, e);
   }
 }
Example #5
0
  static void validateFiles(List<String> newFiles) throws IllegalArgumentException {
    SessionState ss = SessionState.get();
    Configuration conf = (ss == null) ? new Configuration() : ss.getConf();

    for (String newFile : newFiles) {
      try {
        if (Utilities.realFile(newFile, conf) == null) {
          String message = newFile + " does not exist";
          throw new IllegalArgumentException(message);
        }
      } catch (IOException e) {
        String message = "Unable to validate " + newFile;
        throw new IllegalArgumentException(message, e);
      }
    }
  }
Example #6
0
  // reloading the jars under the path specified in hive.reloadable.aux.jars.path property
  public void reloadAuxJars() throws IOException {
    final Set<String> reloadedAuxJars = new HashSet<String>();

    final String renewableJarPath = conf.getVar(ConfVars.HIVERELOADABLEJARS);
    // do nothing if this property is not specified or empty
    if (renewableJarPath == null || renewableJarPath.isEmpty()) {
      return;
    }

    Set<String> jarPaths = Utilities.getJarFilesByPath(renewableJarPath);

    // load jars under the hive.reloadable.aux.jars.path
    if (!jarPaths.isEmpty()) {
      reloadedAuxJars.addAll(jarPaths);
    }

    // remove the previous renewable jars
    try {
      if (preReloadableAuxJars != null && !preReloadableAuxJars.isEmpty()) {
        Utilities.removeFromClassPath(preReloadableAuxJars.toArray(new String[0]));
      }
    } catch (Exception e) {
      String msg = "Fail to remove the reloaded jars loaded last time: " + e;
      throw new IOException(msg, e);
    }

    try {
      if (reloadedAuxJars != null && !reloadedAuxJars.isEmpty()) {
        URLClassLoader currentCLoader =
            (URLClassLoader) SessionState.get().getConf().getClassLoader();
        currentCLoader =
            (URLClassLoader)
                Utilities.addToClassPath(currentCLoader, reloadedAuxJars.toArray(new String[0]));
        conf.setClassLoader(currentCLoader);
        Thread.currentThread().setContextClassLoader(currentCLoader);
      }
      preReloadableAuxJars.clear();
      preReloadableAuxJars.addAll(reloadedAuxJars);
    } catch (Exception e) {
      String msg =
          "Fail to add jars from the path specified in hive.reloadable.aux.jars.path property: "
              + e;
      throw new IOException(msg, e);
    }
  }
Example #7
0
 /**
  * @return username from current SessionState authenticator. username will be null if there is no
  *     current SessionState object or authenticator is null.
  */
 public static String getUserFromAuthenticator() {
   if (SessionState.get() != null && SessionState.get().getAuthenticator() != null) {
     return SessionState.get().getAuthenticator().getUserName();
   }
   return null;
 }
Example #8
0
 public boolean getIsSilent() {
   SessionState ss = SessionState.get();
   // use the session or the one supplied in constructor
   return (ss != null) ? ss.getIsSilent() : isSilent;
 }
Example #9
0
 public PrintStream getChildErrStream() {
   SessionState ss = SessionState.get();
   return ((ss != null) && (ss.childErr != null)) ? ss.childErr : System.err;
 }
Example #10
0
 public PrintStream getChildOutStream() {
   SessionState ss = SessionState.get();
   return ((ss != null) && (ss.childOut != null)) ? ss.childOut : System.out;
 }
Example #11
0
 public PrintStream getInfoStream() {
   SessionState ss = SessionState.get();
   return ((ss != null) && (ss.info != null)) ? ss.info : getErrStream();
 }