From 7535e3ea1bf5af68338cab89614e99bde12db66d Mon Sep 17 00:00:00 2001
From: ribeaudc <ribeaudc>
Date: Mon, 26 May 2008 07:23:54 +0000
Subject: [PATCH] [SE-47] minor: - Field renaming. - Improve log output.

SVN: 6304
---
 .../highwatermark/FileWithHighwaterMark.java  | 20 ++++++++++---------
 .../highwatermark/HighwaterMarkWatcher.java   |  6 ++++++
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/common/source/java/ch/systemsx/cisd/common/highwatermark/FileWithHighwaterMark.java b/common/source/java/ch/systemsx/cisd/common/highwatermark/FileWithHighwaterMark.java
index 408635aacbf..92fe45ab73e 100644
--- a/common/source/java/ch/systemsx/cisd/common/highwatermark/FileWithHighwaterMark.java
+++ b/common/source/java/ch/systemsx/cisd/common/highwatermark/FileWithHighwaterMark.java
@@ -35,6 +35,8 @@ import ch.systemsx.cisd.common.utilities.PropertyUtils;
 public final class FileWithHighwaterMark extends AbstractHashable implements Serializable
 {
 
+    public static final int DEFAULT_HIGHWATER_MARK = -1;
+
     private static final long serialVersionUID = 1L;
 
     /**
@@ -45,17 +47,17 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
 
     private final File path;
 
-    private final long highwaterMark;
+    private final long highwaterMarkInKb;
 
     /**
      * @param file the file path.
-     * @param highwaterMark the high water mark. <code>-1</code> means that the system will not be
-     *            watching.
+     * @param highwaterMarkInKb the high water mark in <i>kilobytes</i>. <code>-1</code> means
+     *            that the system will not be watching.
      */
-    public FileWithHighwaterMark(final File file, final long highwaterMark)
+    public FileWithHighwaterMark(final File file, final long highwaterMarkInKb)
     {
         this.path = file;
-        this.highwaterMark = highwaterMark;
+        this.highwaterMarkInKb = highwaterMarkInKb;
     }
 
     /**
@@ -63,7 +65,7 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
      */
     public FileWithHighwaterMark(final File path)
     {
-        this(path, -1);
+        this(path, DEFAULT_HIGHWATER_MARK);
     }
 
     /**
@@ -79,10 +81,10 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
         assert properties != null : "Unspecified properties";
         assert StringUtils.isNotBlank(filePropertyKey) : "File property key is blank";
         final String filePath = PropertyUtils.getMandatoryProperty(properties, filePropertyKey);
-        final long highwaterMark =
+        final long highwaterMarkInKb =
                 PropertyUtils.getLong(properties, filePropertyKey.concat(".").concat(
                         HIGHWATER_MARK_PROPERTY_KEY), -1L);
-        return new FileWithHighwaterMark(new File(filePath), highwaterMark);
+        return new FileWithHighwaterMark(new File(filePath), highwaterMarkInKb);
     }
 
     /**
@@ -104,6 +106,6 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
      */
     public final long getHighwaterMark()
     {
-        return highwaterMark;
+        return highwaterMarkInKb;
     }
 }
diff --git a/common/source/java/ch/systemsx/cisd/common/highwatermark/HighwaterMarkWatcher.java b/common/source/java/ch/systemsx/cisd/common/highwatermark/HighwaterMarkWatcher.java
index 3dc7b938a67..9cadcc4664e 100644
--- a/common/source/java/ch/systemsx/cisd/common/highwatermark/HighwaterMarkWatcher.java
+++ b/common/source/java/ch/systemsx/cisd/common/highwatermark/HighwaterMarkWatcher.java
@@ -45,6 +45,8 @@ import ch.systemsx.cisd.common.utilities.FileUtilities;
 public final class HighwaterMarkWatcher implements Runnable
 {
 
+    private static final String UNSPECIFIED = "unspecified";
+
     private final static IFreeSpaceProvider DEFAULT_FREE_SPACE_PROVIDER =
             new DefaultFreeSpaceProvider();
 
@@ -95,6 +97,10 @@ public final class HighwaterMarkWatcher implements Runnable
 
     public final static String displayKilobyteValue(final long value)
     {
+        if (value < 0)
+        {
+            return UNSPECIFIED;
+        }
         return FileUtilities.byteCountToDisplaySize(value * FileUtils.ONE_KB);
     }
 
-- 
GitLab