|
@@ -42,6 +42,7 @@ import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_CONTROLLER_FMT;
|
|
import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_CONTROLLER_FMT;
|
|
|
|
+import static org.apache.hadoop.yarn.logaggregation.LogAggregationTestUtils.enableFileControllers;
|
|
import static org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.NO_TIMEOUT;
|
|
import static org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.NO_TIMEOUT;
|
|
import static org.mockito.Mockito.mock;
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
|
@@ -118,12 +119,12 @@ public class TestAggregatedLogDeletionService {
|
|
.withRunningApps(4)
|
|
.withRunningApps(4)
|
|
.injectExceptionForAppDirDeletion(3)
|
|
.injectExceptionForAppDirDeletion(3)
|
|
.build()
|
|
.build()
|
|
- .setupAndRunDeletionService()
|
|
|
|
|
|
+ .startDeletionService()
|
|
.verifyAppDirsDeleted(timeout, 1, 3)
|
|
.verifyAppDirsDeleted(timeout, 1, 3)
|
|
.verifyAppDirsNotDeleted(timeout, 2, 4)
|
|
.verifyAppDirsNotDeleted(timeout, 2, 4)
|
|
.verifyAppFileDeleted(4, 1, timeout)
|
|
.verifyAppFileDeleted(4, 1, timeout)
|
|
.verifyAppFileNotDeleted(4, 2, timeout)
|
|
.verifyAppFileNotDeleted(4, 2, timeout)
|
|
- .teardown();
|
|
|
|
|
|
+ .teardown(1);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -155,7 +156,7 @@ public class TestAggregatedLogDeletionService {
|
|
.build();
|
|
.build();
|
|
|
|
|
|
testcase
|
|
testcase
|
|
- .setupAndRunDeletionService()
|
|
|
|
|
|
+ .startDeletionService()
|
|
//app1Dir would be deleted since it is done above log retention period
|
|
//app1Dir would be deleted since it is done above log retention period
|
|
.verifyAppDirDeleted(1, 10000L)
|
|
.verifyAppDirDeleted(1, 10000L)
|
|
//app2Dir is not expected to be deleted since it is below the threshold
|
|
//app2Dir is not expected to be deleted since it is below the threshold
|
|
@@ -176,7 +177,8 @@ public class TestAggregatedLogDeletionService {
|
|
.verifyCheckIntervalMilliSecondsEqualTo(checkIntervalMilliSeconds)
|
|
.verifyCheckIntervalMilliSecondsEqualTo(checkIntervalMilliSeconds)
|
|
//app2Dir should be deleted since it falls above the threshold
|
|
//app2Dir should be deleted since it falls above the threshold
|
|
.verifyAppDirDeleted(2, 10000L)
|
|
.verifyAppDirDeleted(2, 10000L)
|
|
- .teardown();
|
|
|
|
|
|
+ //Close expected 2 times: once for refresh and once for stopping
|
|
|
|
+ .teardown(2);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -202,7 +204,7 @@ public class TestAggregatedLogDeletionService {
|
|
.withFinishedApps(1)
|
|
.withFinishedApps(1)
|
|
.withRunningApps()
|
|
.withRunningApps()
|
|
.build()
|
|
.build()
|
|
- .setupAndRunDeletionService()
|
|
|
|
|
|
+ .startDeletionService()
|
|
.verifyAnyPathListedAtLeast(4, 10000L)
|
|
.verifyAnyPathListedAtLeast(4, 10000L)
|
|
.verifyAppDirNotDeleted(1, NO_TIMEOUT)
|
|
.verifyAppDirNotDeleted(1, NO_TIMEOUT)
|
|
// modify the timestamp of the logs and verify if it is picked up quickly
|
|
// modify the timestamp of the logs and verify if it is picked up quickly
|
|
@@ -211,7 +213,7 @@ public class TestAggregatedLogDeletionService {
|
|
.changeModTimeOfBucketDir(toDeleteTime)
|
|
.changeModTimeOfBucketDir(toDeleteTime)
|
|
.reinitAllPaths()
|
|
.reinitAllPaths()
|
|
.verifyAppDirDeleted(1, 10000L)
|
|
.verifyAppDirDeleted(1, 10000L)
|
|
- .teardown();
|
|
|
|
|
|
+ .teardown(1);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -241,6 +243,59 @@ public class TestAggregatedLogDeletionService {
|
|
.verifyAppDirDeleted(3, NO_TIMEOUT);
|
|
.verifyAppDirDeleted(3, NO_TIMEOUT);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
+ public void testDeletionTwoControllers() throws IOException {
|
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
|
+ long toDeleteTime = now - (2000 * 1000);
|
|
|
|
+ long toKeepTime = now - (1500 * 1000);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Configuration conf = setupConfiguration(1800, -1);
|
|
|
|
+ enableFileControllers(conf, REMOTE_ROOT_LOG_DIR, ALL_FILE_CONTROLLERS,
|
|
|
|
+ ALL_FILE_CONTROLLER_NAMES);
|
|
|
|
+ long timeout = 2000L;
|
|
|
|
+ LogAggregationTestcaseBuilder.create(conf)
|
|
|
|
+ .withRootPath(ROOT)
|
|
|
|
+ .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
|
|
|
|
+ .withBothFileControllers()
|
|
|
|
+ .withUserDir(USER_ME, toKeepTime)
|
|
|
|
+ .withSuffixDir(SUFFIX, toDeleteTime)
|
|
|
|
+ .withBucketDir(toDeleteTime)
|
|
|
|
+ .withApps(//Apps for TFile
|
|
|
|
+ Lists.newArrayList(
|
|
|
|
+ new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList()),
|
|
|
|
+ new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
|
|
|
|
+ Pair.of(DIR_HOST1, toDeleteTime),
|
|
|
|
+ Pair.of(DIR_HOST2, toKeepTime))),
|
|
|
|
+ new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
|
|
|
|
+ Pair.of(DIR_HOST1, toDeleteTime),
|
|
|
|
+ Pair.of(DIR_HOST2, toDeleteTime))),
|
|
|
|
+ new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
|
|
|
|
+ Pair.of(DIR_HOST1, toDeleteTime),
|
|
|
|
+ Pair.of(DIR_HOST2, toKeepTime))),
|
|
|
|
+ //Apps for IFile
|
|
|
|
+ new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList()),
|
|
|
|
+ new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
|
|
|
|
+ Pair.of(DIR_HOST1, toDeleteTime),
|
|
|
|
+ Pair.of(DIR_HOST2, toKeepTime))),
|
|
|
|
+ new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
|
|
|
|
+ Pair.of(DIR_HOST1, toDeleteTime),
|
|
|
|
+ Pair.of(DIR_HOST2, toDeleteTime))),
|
|
|
|
+ new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
|
|
|
|
+ Pair.of(DIR_HOST1, toDeleteTime),
|
|
|
|
+ Pair.of(DIR_HOST2, toKeepTime)))))
|
|
|
|
+ .withFinishedApps(1, 2, 3, 5, 6, 7)
|
|
|
|
+ .withRunningApps(4, 8)
|
|
|
|
+ .injectExceptionForAppDirDeletion(3, 6)
|
|
|
|
+ .build()
|
|
|
|
+ .startDeletionService()
|
|
|
|
+ .verifyAppDirsDeleted(timeout, 1, 3, 5, 7)
|
|
|
|
+ .verifyAppDirsNotDeleted(timeout, 2, 4, 6, 8)
|
|
|
|
+ .verifyAppFilesDeleted(timeout, Lists.newArrayList(Pair.of(4, 1), Pair.of(8, 1)))
|
|
|
|
+ .verifyAppFilesNotDeleted(timeout, Lists.newArrayList(Pair.of(4, 2), Pair.of(8, 2)))
|
|
|
|
+ .teardown(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
static class MockFileSystem extends FilterFileSystem {
|
|
static class MockFileSystem extends FilterFileSystem {
|
|
MockFileSystem() {
|
|
MockFileSystem() {
|
|
super(mock(FileSystem.class));
|
|
super(mock(FileSystem.class));
|