|
@@ -24,6 +24,9 @@ import java.io.IOException;
|
|
import java.io.RandomAccessFile;
|
|
import java.io.RandomAccessFile;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
|
|
+import org.apache.hadoop.fs.CommonConfigurationKeys;
|
|
|
|
+
|
|
/** This test makes sure that "DU" does not get to run on each call to getUsed */
|
|
/** This test makes sure that "DU" does not get to run on each call to getUsed */
|
|
public class TestDU extends TestCase {
|
|
public class TestDU extends TestCase {
|
|
final static private File DU_DIR = new File(
|
|
final static private File DU_DIR = new File(
|
|
@@ -106,7 +109,9 @@ public class TestDU extends TestCase {
|
|
public void testDUGetUsedWillNotReturnNegative() throws IOException {
|
|
public void testDUGetUsedWillNotReturnNegative() throws IOException {
|
|
File file = new File(DU_DIR, "data");
|
|
File file = new File(DU_DIR, "data");
|
|
assertTrue(file.createNewFile());
|
|
assertTrue(file.createNewFile());
|
|
- DU du = new DU(file, 10000);
|
|
|
|
|
|
+ Configuration conf = new Configuration();
|
|
|
|
+ conf.setLong(CommonConfigurationKeys.FS_DU_INTERVAL_KEY, 10000L);
|
|
|
|
+ DU du = new DU(file, conf);
|
|
du.decDfsUsed(Long.MAX_VALUE);
|
|
du.decDfsUsed(Long.MAX_VALUE);
|
|
long duSize = du.getUsed();
|
|
long duSize = du.getUsed();
|
|
assertTrue(String.valueOf(duSize), duSize >= 0L);
|
|
assertTrue(String.valueOf(duSize), duSize >= 0L);
|