public OperationLog(String name, File file, HiveConf hiveConf) { operationName = name; logFile = new LogFile(file); if (hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_ENABLED)) { String logLevel = hiveConf.getVar(HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LEVEL); opLoggingLevel = getLoggingLevel(logLevel); } else { opLoggingLevel = LoggingLevel.UNKNOWN; } // If in test mod create a test log file which will contain only logs which are supposed to // be written to the qtest output if (hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST)) { isRemoveLogs = hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_TESTING_REMOVE_LOGS); if (hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_TESTING_SHORT_LOGS)) { testLogFile = new LogFile(new File(file.getAbsolutePath() + ".test")); isShortLogs = true; } else { testLogFile = null; isShortLogs = false; } } else { testLogFile = null; isShortLogs = false; isRemoveLogs = true; } }
synchronized List<String> read(boolean isFetchFirst, long maxRows) throws SQLException{ // reset the BufferReader, if fetching from the beginning of the file if (isFetchFirst) { resetIn(); } if (maxRows >= (long) Integer.MAX_VALUE) { throw new SQLException("Cannot support loading this many rows: " + maxRows); } return readResults((int)maxRows); }
public OperationLog(String name, File file, HiveConf hiveConf) throws FileNotFoundException { operationName = name; logFile = new LogFile(file); if (hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_ENABLED)) { String logLevel = hiveConf.getVar(HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LEVEL); opLoggingLevel = getLoggingLevel(logLevel); } }
synchronized List<String> read(boolean isFetchFirst, long maxRows) throws SQLException{ // reset the BufferReader, if fetching from the beginning of the file if (isFetchFirst) { resetIn(); } return readResults(maxRows); }
/** * Read operation execution logs from log file * @param isFetchFirst true if the Enum FetchOrientation value is Fetch_First * @param maxRows the max number of fetched lines from log * @return * @throws java.sql.SQLException */ public List<String> readOperationLog(boolean isFetchFirst, long maxRows) throws SQLException{ return logFile.read(isFetchFirst, maxRows); }
/** * Write operation execution logs into log file * @param operationLogMessage one line of log emitted from log4j */ public void writeOperationLog(String operationLogMessage) { logFile.write(operationLogMessage); }
/** * Close this OperationLog when operation is closed. The log file will be removed. */ public void close() { logFile.remove(); }
public PrintStream getPrintStream() { return logFile.getPrintStream(); }
/** * Close the logs, and remove them if specified. * @param removeLog If true, remove the log file */ synchronized void close(boolean removeLog) { try { resetIn(); if (removeLog && !isRemoved) { if (file.exists()) { FileUtils.forceDelete(file); } isRemoved = true; } } catch (IOException e) { LOG.error("Failed to remove corresponding log file of operation: {}", operationName, e); } }
/** * Close this OperationLog when operation is closed. The log file will be removed. */ public void close() { logFile.remove(); }
/** * Read operation execution logs from log file * @param isFetchFirst true if the Enum FetchOrientation value is Fetch_First * @param maxRows the max number of fetched lines from log * @return * @throws java.sql.SQLException */ public List<String> readOperationLog(boolean isFetchFirst, long maxRows) throws SQLException{ return logFile.read(isFetchFirst, maxRows); }
/** * Write operation execution logs into log file * @param operationLogMessage one line of log emitted from log4j */ public void writeOperationLog(String operationLogMessage) { logFile.write(operationLogMessage); }
/** * Write operation execution logs into log file * @param operationLogMessage one line of log emitted from log4j */ public void writeOperationLog(LoggingLevel level, String operationLogMessage) { if (opLoggingLevel.compareTo(level) < 0) return; logFile.write(operationLogMessage); }
synchronized List<String> read(boolean isFetchFirst, long maxRows) throws SQLException{ // reset the BufferReader, if fetching from the beginning of the file if (isFetchFirst) { resetIn(); } return readResults(maxRows); }
public OperationLog(String name, File file, HiveConf hiveConf) throws FileNotFoundException { operationName = name; logFile = new LogFile(file); if (hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_ENABLED)) { String logLevel = hiveConf.getVar(HiveConf.ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LEVEL); opLoggingLevel = getLoggingLevel(logLevel); } }
/** * Read operation execution logs from log file * @param isFetchFirst true if the Enum FetchOrientation value is Fetch_First * @param maxRows the max number of fetched lines from log * @return * @throws java.sql.SQLException */ public List<String> readOperationLog(boolean isFetchFirst, long maxRows) throws SQLException { LogFile lf = (isShortLogs) ? testLogFile : logFile; return lf.read(isFetchFirst, maxRows); }