Mercurial > stress-tester
changeset 1128:abd8ab4d6b80
minor
author | Devel 2 |
---|---|
date | Fri, 05 Jun 2020 14:37:26 +0200 |
parents | ae2d0e7c5f5b |
children | c34359011cf5 |
files | stress-tester/src/main/java/com/passus/st/client/mysql/MySqlFlowHandler.java stress-tester/src/main/java/com/passus/st/metric/FileMetricsCollectionAppender.java |
diffstat | 2 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/mysql/MySqlFlowHandler.java Fri Jun 05 14:36:09 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/mysql/MySqlFlowHandler.java Fri Jun 05 14:37:26 2020 +0200 @@ -10,8 +10,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.List; - import static com.passus.net.mysql.MySqlPacketTypes.ROW_RESPONSE; import static com.passus.st.Protocols.NETFLOW;
--- a/stress-tester/src/main/java/com/passus/st/metric/FileMetricsCollectionAppender.java Fri Jun 05 14:36:09 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/metric/FileMetricsCollectionAppender.java Fri Jun 05 14:37:26 2020 +0200 @@ -28,7 +28,7 @@ public static final String TYPE = "file"; - private static final Logger logger = LogManager.getLogger(FileMetricsCollectionAppender.class); + private static final Logger LOGGER = LogManager.getLogger(FileMetricsCollectionAppender.class); private int bufferSize = 512; @@ -134,7 +134,7 @@ createWriter(fileName); started = true; } catch (IOException ex) { - logger.error("Unable to open appender.", ex); + LOGGER.error("Unable to open appender.", ex); started = false; } } @@ -208,7 +208,7 @@ srcFile = new File(fileName + "." + i); if (srcFile.exists()) { dstFile = new File(fileName + '.' + (i + 1)); - logger.debug("Renaming file '" + srcFile + "' to '" + dstFile + "'."); + LOGGER.debug("Renaming file '" + srcFile + "' to '" + dstFile + "'."); renameSucceeded = srcFile.renameTo(dstFile); } } @@ -218,14 +218,14 @@ this.closeWriter(); srcFile = new File(fileName); - logger.debug("Renaming file '" + srcFile + "' to '" + dstFile + "'."); + LOGGER.debug("Renaming file '" + srcFile + "' to '" + dstFile + "'."); renameSucceeded = srcFile.renameTo(dstFile); if (!renameSucceeded) { try { this.createWriter(fileName); } catch (IOException e) { - logger.error(e.getMessage(), e); + LOGGER.error(e.getMessage(), e); } } } @@ -236,13 +236,17 @@ this.createWriter(fileName); nextRollOverSize = 0; } catch (IOException e) { - logger.error(e.getMessage(), e); + LOGGER.error(e.getMessage(), e); } } } @Override public void handle(MetricsCollection mc) { + if (!started) { + return; + } + try { if (checkFileExists && System.currentTimeMillis() > nextCheckFileExists) { if (!(new File(fileName).exists())) { @@ -259,8 +263,8 @@ writer.write(line); writer.write("\n"); } catch (IOException e) { - if (logger.isDebugEnabled()) { - logger.debug(e.getMessage(), e); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(e.getMessage(), e); } createWriter(fileName); @@ -275,7 +279,7 @@ writer.flush(); } catch (Exception ex) { - logger.error("Write to file \"" + fileName + "\" failed.", ex); + LOGGER.error("Write to file \"" + fileName + "\" failed.", ex); } }