Refine search
private void dumpOption(String s) { SessionState ss = SessionState.get(); if (ss.getConf().isHiddenConfig(s)) { ss.out.println(s + " is a hidden config"); } else if (ss.getConf().get(s) != null) { ss.out.println(s + "=" + ss.getConf().get(s)); } else if (ss.getHiveVariables().containsKey(s)) { ss.out.println(s + "=" + ss.getHiveVariables().get(s)); } else { ss.out.println(s + " is undefined"); } }
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); } }
public static SparkSession getSparkSession(HiveConf conf, SparkSessionManager sparkSessionManager) throws HiveException { SessionState sessionState = SessionState.get(); synchronized (sessionState) { SparkSession sparkSession = sessionState.getSparkSession(); HiveConf sessionConf = sessionState.getConf(); // Spark configurations are updated close the existing session // In case of async queries or confOverlay is not empty, // sessionConf and conf are different objects if (sessionConf.getSparkConfigUpdated() || conf.getSparkConfigUpdated()) { sparkSessionManager.closeSession(sparkSession); sparkSession = null; conf.setSparkConfigUpdated(false); sessionConf.setSparkConfigUpdated(false); } sparkSession = sparkSessionManager.getSession(sparkSession, conf, true); sessionState.setSparkSession(sparkSession); return sparkSession; } }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 0) { throw new UDFArgumentLengthException( "The function CURRENT_DATE does not take any arguments, but found " + arguments.length); } if (currentDate == null) { SessionState ss = SessionState.get(); ZonedDateTime dateTime = ss.getQueryCurrentTimestamp().atZone( ss.getConf().getLocalTimeZone()); Date dateVal = Date.valueOf( dateTime.toString().substring(0, 10)); currentDate = new DateWritableV2(dateVal); } return PrimitiveObjectInspectorFactory.writableDateObjectInspector; }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution(() -> SessionState.get().getHiveVariables()).substitute(ss.getConf(), command); String[] tokens = command.split("\\s+"); if (tokens.length < 1) { return returnErrorResponse("Command arguments are empty."); } String params[] = Arrays.copyOfRange(tokens, 1, tokens.length); try { return llapClusterCommandHandler(ss, params); } catch (Exception e) { return returnErrorResponse(e.getMessage()); } }
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); } }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 0) { throw new UDFArgumentLengthException( "The function CURRENT_TIMESTAMP does not take any arguments, but found " + arguments.length); } if (currentTimestamp == null) { SessionState ss = SessionState.get(); ZonedDateTime dateTime = ss.getQueryCurrentTimestamp().atZone( ss.getConf().getLocalTimeZone()); currentTimestamp = new TimestampWritableV2( Timestamp.valueOf(dateTime.toLocalDateTime().toString())); } return PrimitiveObjectInspectorFactory.writableTimestampObjectInspector; }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution(() -> SessionState.get().getHiveVariables()).substitute(ss.getConf(), command); String[] tokens = command.split("\\s+"); if (tokens.length < 1) { return returnErrorResponse("Command arguments are empty."); } String params[] = Arrays.copyOfRange(tokens, 1, tokens.length); try { return llapCacheCommandHandler(ss, params); } catch (Exception e) { return returnErrorResponse(e.getMessage()); } }
public CliDriver() { SessionState ss = SessionState.get(); conf = (ss != null) ? ss.getConf() : new Configuration(); Logger LOG = LoggerFactory.getLogger("CliDriver"); if (LOG.isDebugEnabled()) { LOG.debug("CliDriver inited with classpath {}", System.getProperty("java.class.path")); } console = new LogHelper(LOG); }
private void dumpOption(String s) { SessionState ss = SessionState.get(); if (ss.getConf().isHiddenConfig(s)) { ss.out.println(s + " is a hidden config"); } else if (ss.getConf().get(s) != null) { if (ss.getConf().isEncodedPar(s)) { ss.out.println(s + "=" + HiveConf.EncoderDecoderFactory.URL_ENCODER_DECODER .decode(ss.getConf().get(s))); } else { ss.out.println(s + "=" + ss.getConf().get(s)); } } else if (ss.getHiveVariables().containsKey(s)) { ss.out.println(s + "=" + ss.getHiveVariables().get(s)); } else { ss.out.println(s + " is undefined"); } }
public static void restoreSessionSpecifiedClassLoader(ClassLoader prev) { SessionState state = SessionState.get(); if (state != null && state.getConf() != null) { ClassLoader current = state.getConf().getClassLoader(); if (current != prev && JavaUtils.closeClassLoadersTo(current, prev)) { Thread.currentThread().setContextClassLoader(prev); state.getConf().setClassLoader(prev); } } }
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); } } }
public static void restoreSessionSpecifiedClassLoader(ClassLoader prev) { SessionState state = SessionState.get(); if (state != null && state.getConf() != null) { ClassLoader current = state.getConf().getClassLoader(); if (current != prev && JavaUtils.closeClassLoadersTo(current, prev)) { Thread.currentThread().setContextClassLoader(prev); state.getConf().setClassLoader(prev); } } }
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); } } }