/** * Sets the pipe reader to a new value. The pipe reader will be informed about new records. * * @param pipeReader * The new pipe reader. */ public void setPipeReader(final IPipeReader pipeReader) { this.pipeReader = pipeReader; if (LOG.isDebugEnabled()) { LOG.debug("PipeReader initialized"); } }
@Override public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) { LOG.error("Exception caught by RejectedExecutionHandler for Runnable " + r + " and ThreadPoolExecutor " + executor); } }
/** * {@inheritDoc} */ @Override public void terminate(final boolean error) { this.log.info("Shutting down reader."); this.running = false; }
@Override public boolean insert(final E element) { final boolean offered = this.queue.offer(element); if (!offered) { final long tmpMissedRecords = this.numFailedInserts.incrementAndGet(); if (LOG.isWarnEnabled() && ((tmpMissedRecords % 1024) == 1)) { // warn upon the first failed element and upon all 1024th one LOG.warn("Queue is full, dropping records. Number of already dropped records: " + tmpMissedRecords); } } return true; }
@Override public void write(final int b) throws IOException { if (b == LINE_END) { if (LOG.isTraceEnabled()) { LOG.trace(this.baos.toString("UTF-8")); // Redirect previous log message from RSession as log message } this.baos.reset(); } else { this.baos.write(b); } } }
LOG.info("Directory '" + this.inputDir + "' contains no file '" + FSUtil.MAP_FILENAME + "'. Found '" + FSUtil.LEGACY_MAP_FILENAME + "' ... switching to legacy mode"); } else { if (LOG.isWarnEnabled()) { LOG.warn("No mapping file in directory '" + this.inputDir.getAbsolutePath() + "'"); if (LOG.isDebugEnabled()) { LOG.debug("Read line: " + line); LOG.error("Failed to parse line: {" + line + "} from file " + mappingFile.getAbsolutePath() + ". Each line must contain ID=VALUE pairs."); continue; // continue on errors id = Integer.valueOf((key.charAt(0) == '$') ? key.substring(1) : key); // NOCS } catch (final NumberFormatException ex) { LOG.error("Error reading mapping file, id must be integer", ex); continue; // continue on errors LOG.error("Found addional entry for id='" + id + "', old value was '" + prevVal + "' new value is '" + value + "'"); LOG.error("Error reading mapping file", ex); } finally { if (in != null) { in.close(); } catch (final IOException ex) { LOG.error("Exception while closing input stream for mapping file", ex);
/** * Registers the given reader with this analysis instance. <b>This method is for internal use only!</b> * * @param reader * The reader to register with this analysis. * * @throws IllegalStateException * If the analysis has already been started when this method is called. */ public final void registerReader(final AbstractReaderPlugin reader) throws IllegalStateException { if (this.state != STATE.READY) { throw new IllegalStateException("Unable to register filter after starting analysis."); } if (this.readers.contains(reader)) { LOG.warn("Reader " + reader.getName() + " already registered."); return; } this.readers.add(reader); if (LOG.isDebugEnabled()) { LOG.debug("Registered reader " + reader); } }
@SuppressWarnings("synthetic-access") @Override protected void onRecordReceived(final IMonitoringRecord record) { final boolean success = DualSocketTcpReader.this.deliver(OUTPUT_PORT_NAME_RECORDS, record); if (!success) { this.logger.warn("Failed to deliver record: " + record); } } };
private void addToPatternEntryList(final String pattern) { if (pattern.length() == 0) { // ignore empty lines return; } try { switch (pattern.charAt(0)) { case '+': this.patternList.add(new PatternEntry(pattern.substring(1).trim(), true)); break; case '-': this.patternList.add(new PatternEntry(pattern.substring(1).trim(), false)); break; case '#': // ignore comment break; default: if (LOG.isWarnEnabled()) { LOG.warn("Each line should either start with '+', '-', or '#'. Ignoring: " + pattern); } break; } } catch (final InvalidPatternException ex) { LOG.error("'" + pattern.substring(1) + "' is not a valid pattern.", ex); } }
@Override protected boolean performTask() { if (LOG.isDebugEnabled()) { if (this.realtimeMode) { LOG.debug("Replaying log data in real time"); } else { LOG.debug("Replaying log data in non-real time"); } } final FilesystemLogReplayer player = new FilesystemLogReplayer(this.monitoringConfigurationFile, this.realtimeMode, this.realtimeAccelerationFactor, this.keepOriginalLoggingTimestamps, this.numRealtimeWorkerThreads, this.ignoreRecordsBeforeTimestamp, this.ignoreRecordsAfterTimestamp, this.inputDirs); if (player.replay()) { return true; } else { LOG.error("An error occured"); return false; } }
/** * Creates the configuration for the singleton controller instance. Note that the {@link Properties} returned by * this method are not a singleton instance, i.e., each call returns an equal but not same set of * {@link Properties}. * * @return the configuration for the singleton controller */ public static final Configuration createSingletonConfiguration() { if (LOG.isDebugEnabled()) { LOG.debug("Searching for JVM argument '" + Keys.CUSTOM_PROPERTIES_LOCATION_JVM + "' ..."); } final Configuration defaultConfiguration = ConfigurationFactory.defaultConfiguration(); // ignore default default-name and set to KIEKER-SINGLETON defaultConfiguration.setProperty(Keys.CONTROLLER_NAME, "KIEKER-SINGLETON"); // Searching for configuration file location passed to JVM String configurationFile = System.getProperty(Keys.CUSTOM_PROPERTIES_LOCATION_JVM); final Configuration loadConfiguration; if (configurationFile != null) { LOG.info("Loading configuration from JVM-specified location: '" + configurationFile + "'"); loadConfiguration = ConfigurationFactory.loadConfigurationFromFile(configurationFile, defaultConfiguration); } else { // No JVM property; Trying to find configuration file in classpath configurationFile = Keys.CUSTOM_PROPERTIES_LOCATION_CLASSPATH; LOG.info("Loading properties from properties file in classpath: '" + configurationFile + "'"); loadConfiguration = ConfigurationFactory.loadConfigurationFromResource(configurationFile, defaultConfiguration); } // 1.JVM-params -> 2.properties file -> 3.default properties file return ConfigurationFactory.getSystemPropertiesStartingWith(Keys.PREFIX, loadConfiguration); }
private CommandLine parseCommandLineArguments(final Options options, final String[] arguments) { final BasicParser parser = new BasicParser(); try { return parser.parse(options, arguments); } catch (final ParseException ex) { // Note that we append ex.getMessage() to the log message on purpose to improve the // logging output on the console. LOG.error("An error occurred while parsing the command line arguments: " + ex.getMessage(), ex); LOG.info("Use the option `--" + CMD_OPT_NAME_HELP_LONG + "` for usage information"); return null; } }
@Override public void run() { if (!monitoringController.isMonitoringTerminated()) { // WONTFIX: We should not use a logger in shutdown hooks, logger may already be down! (#26) LOG.info("ShutdownHook notifies controller to initiate shutdown."); monitoringController.terminateMonitoring(); try { monitoringController.waitForTermination(SHUTDOWN_DELAY_MILLIS); } catch (final InterruptedException e) { // ignore since we cannot do anything at this point LOG.warn("Shutdown was interrupted while waiting"); } // LOG.info("ShutdownHook has finished."); // does not work anymore // System.out.println("ShutdownHook has finished."); // works! } } });
/** * Wraps the execution of an arbitrary R expression. Both errors and results are logged. * * @param input * The R expression to evaluate. * * @return The result or the error of the evaluation of the given R expression. The method tries to convert it into a string, if possible. */ public Object evalWithR(final String input) throws InvalidREvaluationResultException { Object out = null; try { out = this.rCon.eval(input); Object output = null; if (out instanceof REXPString) { output = ((REXPString) out).asString(); } else if (out instanceof REXPLogical) { output = ((REXPLogical) out).toDebugString(); } else if (out != null) { output = out; } else { throw new InvalidREvaluationResultException("Got a null result for evaluation input: \"" + input + "\""); } RBridgeControl.LOG.trace("> REXP: " + input + " return: " + output); } catch (final REXPMismatchException exc) { RBridgeControl.LOG.error("Error R expr.: " + input + " Cause: " + exc, exc); } return out; }
LOG.info("Directory '" + this.inputDir + "' contains no file '" + FSUtil.MAP_FILENAME + "'. Found '" + FSUtil.LEGACY_MAP_FILENAME + "' ... switching to legacy mode"); } else { if (LOG.isWarnEnabled()) { LOG.warn("No mapping file in directory '" + this.inputDir.getAbsolutePath() + "'"); if (LOG.isDebugEnabled()) { LOG.debug("Read line: " + line); LOG.error("Failed to parse line: {" + line + "} from file " + mappingFile.getAbsolutePath() + ". Each line must contain ID=VALUE pairs."); continue; // continue on errors id = Integer.valueOf((key.charAt(0) == '$') ? key.substring(1) : key); // NOCS } catch (final NumberFormatException ex) { LOG.error("Error reading mapping file, id must be integer", ex); continue; // continue on errors LOG.error("Found addional entry for id='" + id + "', old value was '" + prevVal + "' new value is '" + value + "'"); LOG.error("Error reading " + mappingFile, e); } finally { if (in != null) { in.close(); } catch (final IOException ex) { LOG.error("Exception while closing input stream for mapping file", ex);
/** * Registers the given filter with this analysis instance. <b>This method is for internal use only!</b> * * @param filter * The filter to register with this analysis. * * @throws IllegalStateException * If the analysis has already been started when this method is called. */ public final void registerFilter(final AbstractFilterPlugin filter) throws IllegalStateException { if (this.state != STATE.READY) { throw new IllegalStateException("Unable to register filter after starting analysis."); } if (this.filters.contains(filter)) { LOG.warn("Filter '" + filter.getName() + "' (" + filter.getPluginName() + ") already registered."); return; } this.filters.add(filter); if (LOG.isDebugEnabled()) { LOG.debug("Registered plugin " + filter); } }
/** * Causes the calling thread to wait until the analysis controller has been initialized. */ protected final void awaitInitialization() { try { this.initializationLatch.await(); } catch (final InterruptedException ex) { LOG.warn("Interrupted while waiting for initialization of analysis controller.", ex); } }
return; } catch (final IOException ex) { if (LOG.isWarnEnabled()) { LOG.warn("Error reading adaptive monitoring config file: " + this.configFilePathname, ex); reader.close(); } catch (final IOException ex) { LOG.error("Failed to close file: " + this.configFilePathname, ex); return; } catch (final IOException ex) { LOG.warn("Error reading adaptive monitoring config file: " + this.configFilePathname, ex); reader.close(); } catch (final IOException ex) { LOG.error("Failed to close file: " + this.configFilePathname, ex); if (LOG.isWarnEnabled()) { LOG.warn("Adaptive monitoring config file not found: " + this.configFilePathname);
public static void close(final Closeable closeable, final Log log) { try { closeable.close(); } catch (final IOException e) { if (log.isWarnEnabled()) { log.warn("Caught exception while closing '" + closeable.getClass() + "'.", e); } } } }
@Override protected final void cleanup() { if (LOG.isDebugEnabled()) { LOG.debug("Shutting down State Controller"); } }