public void refreshLogRetentionSettings() throws IOException {
    if (getServiceState() == STATE.STARTED) {
      Configuration conf = createConf();
      setConfig(conf);
      stopRMClient();
      stopTimer();
      scheduleLogDeletionTasks();
    } else {
      LOG.warn("Failed to execute refreshLogRetentionSettings : Aggregated Log Deletion Service is not started");
    }
  }
@Test
  void testRefreshLogRetentionSettings() throws Exception {
    long now = System.currentTimeMillis();
    long before2000Secs = now - (2000 * 1000);
    long before50Secs = now - (50 * 1000);
    int checkIntervalSeconds = 2;
    int checkIntervalMilliSeconds = checkIntervalSeconds * 1000;

    Configuration conf = setupConfiguration(1800, 1);

    LogAggregationTestcase testcase = LogAggregationTestcaseBuilder.create(conf)
        .withRootPath(ROOT)
        .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
        .withUserDir(USER_ME, before50Secs)
        .withSuffixDir(SUFFIX, before50Secs)
        .withBucketDir(before50Secs)
        .withApps(Lists.newArrayList(
            //Set time last modified of app1Dir directory and its files to before2000Secs
            new AppDescriptor(before2000Secs, Lists.newArrayList(
                Pair.of(DIR_HOST1, before2000Secs))),
            //Set time last modified of app1Dir directory and its files to before50Secs
            new AppDescriptor(before50Secs, Lists.newArrayList(
                Pair.of(DIR_HOST1, before50Secs))))
        )
        .withFinishedApps(1, 2)
        .withRunningApps()
        .build();

    testcase
        .startDeletionService()
        //app1Dir would be deleted since it is done above log retention period
        .verifyAppDirDeleted(1, 10000L)
        //app2Dir is not expected to be deleted since it is below the threshold
        .verifyAppDirNotDeleted(2, 3000L);

    //Now, let's change the log aggregation retention configs
    conf.setInt(YarnConfiguration.LOG_AGGREGATION_RETAIN_SECONDS, 50);
    conf.setInt(YarnConfiguration.LOG_AGGREGATION_RETAIN_CHECK_INTERVAL_SECONDS,
        checkIntervalSeconds);

    testcase
        //We have not called refreshLogSettings, hence don't expect to see
        // the changed conf values
        .verifyCheckIntervalMilliSecondsNotEqualTo(checkIntervalMilliSeconds)
        //refresh the log settings
        .refreshLogRetentionSettings()
        //Check interval time should reflect the new value
        .verifyCheckIntervalMilliSecondsEqualTo(checkIntervalMilliSeconds)
        //app2Dir should be deleted since it falls above the threshold
        .verifyAppDirDeleted(2, 10000L)
        //Close expected 2 times: once for refresh and once for stopping
        .teardown(2);
  }