Skip to content
Snippets Groups Projects
Commit 7535e3ea authored by ribeaudc's avatar ribeaudc
Browse files

[SE-47]

minor: - Field renaming.
- Improve log output.

SVN: 6304
parent 77c5fde4
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,8 @@ import ch.systemsx.cisd.common.utilities.PropertyUtils; ...@@ -35,6 +35,8 @@ import ch.systemsx.cisd.common.utilities.PropertyUtils;
public final class FileWithHighwaterMark extends AbstractHashable implements Serializable public final class FileWithHighwaterMark extends AbstractHashable implements Serializable
{ {
public static final int DEFAULT_HIGHWATER_MARK = -1;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
...@@ -45,17 +47,17 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser ...@@ -45,17 +47,17 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
private final File path; private final File path;
private final long highwaterMark; private final long highwaterMarkInKb;
/** /**
* @param file the file path. * @param file the file path.
* @param highwaterMark the high water mark. <code>-1</code> means that the system will not be * @param highwaterMarkInKb the high water mark in <i>kilobytes</i>. <code>-1</code> means
* watching. * 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.path = file;
this.highwaterMark = highwaterMark; this.highwaterMarkInKb = highwaterMarkInKb;
} }
/** /**
...@@ -63,7 +65,7 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser ...@@ -63,7 +65,7 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
*/ */
public FileWithHighwaterMark(final File path) 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 ...@@ -79,10 +81,10 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
assert properties != null : "Unspecified properties"; assert properties != null : "Unspecified properties";
assert StringUtils.isNotBlank(filePropertyKey) : "File property key is blank"; assert StringUtils.isNotBlank(filePropertyKey) : "File property key is blank";
final String filePath = PropertyUtils.getMandatoryProperty(properties, filePropertyKey); final String filePath = PropertyUtils.getMandatoryProperty(properties, filePropertyKey);
final long highwaterMark = final long highwaterMarkInKb =
PropertyUtils.getLong(properties, filePropertyKey.concat(".").concat( PropertyUtils.getLong(properties, filePropertyKey.concat(".").concat(
HIGHWATER_MARK_PROPERTY_KEY), -1L); 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 ...@@ -104,6 +106,6 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
*/ */
public final long getHighwaterMark() public final long getHighwaterMark()
{ {
return highwaterMark; return highwaterMarkInKb;
} }
} }
...@@ -45,6 +45,8 @@ import ch.systemsx.cisd.common.utilities.FileUtilities; ...@@ -45,6 +45,8 @@ import ch.systemsx.cisd.common.utilities.FileUtilities;
public final class HighwaterMarkWatcher implements Runnable public final class HighwaterMarkWatcher implements Runnable
{ {
private static final String UNSPECIFIED = "unspecified";
private final static IFreeSpaceProvider DEFAULT_FREE_SPACE_PROVIDER = private final static IFreeSpaceProvider DEFAULT_FREE_SPACE_PROVIDER =
new DefaultFreeSpaceProvider(); new DefaultFreeSpaceProvider();
...@@ -95,6 +97,10 @@ public final class HighwaterMarkWatcher implements Runnable ...@@ -95,6 +97,10 @@ public final class HighwaterMarkWatcher implements Runnable
public final static String displayKilobyteValue(final long value) public final static String displayKilobyteValue(final long value)
{ {
if (value < 0)
{
return UNSPECIFIED;
}
return FileUtilities.byteCountToDisplaySize(value * FileUtils.ONE_KB); return FileUtilities.byteCountToDisplaySize(value * FileUtils.ONE_KB);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment