Skip to content

Commit ff58789

Browse files
committed
YARN-9013. Fix CheckStyle.
1 parent cb66801 commit ff58789

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-globalpolicygenerator/src/main/java/org/apache/hadoop/yarn/server/globalpolicygenerator/applicationcleaner

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-globalpolicygenerator/src/main/java/org/apache/hadoop/yarn/server/globalpolicygenerator/applicationcleaner/DefaultApplicationCleaner.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.Set;
2525
import java.util.stream.Collectors;
2626

27-
import org.apache.hadoop.thirdparty.com.google.common.collect.Sets;
27+
import org.apache.hadoop.util.Sets;
2828
import org.apache.hadoop.yarn.api.records.ApplicationId;
2929
import org.apache.hadoop.yarn.server.federation.store.records.ApplicationHomeSubCluster;
3030
import org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
@@ -56,6 +56,10 @@ public void run() {
5656
}
5757
LOG.info("{} app entries in FederationStateStore", allStateStoreApps.size());
5858

59+
// Get the candidate list from Registry before calling router
60+
List<String> allRegistryApps = getRegistryClient().getAllApplications();
61+
LOG.info("{} app entries in FederationRegistry", allStateStoreApps.size());
62+
5963
// Get the list of known apps from Router
6064
Set<ApplicationId> routerApps = getRouterKnownApplications();
6165
LOG.info("{} known applications from Router", routerApps.size());
@@ -65,10 +69,9 @@ public void run() {
6569
Sets.difference(allStateStoreApps, routerApps);
6670

6771
LOG.info("Deleting {} applications from statestore", toDelete.size());
68-
if (LOG.isDebugEnabled()) {
69-
LOG.debug("Apps to delete: {}.", toDelete.stream().map(Object::toString)
70-
.collect(Collectors.joining(",")));
71-
}
72+
LOG.debug("Apps to delete: {}.",
73+
toDelete.stream().map(Object::toString).collect(Collectors.joining(",")));
74+
7275
for (ApplicationId appId : toDelete) {
7376
try {
7477
LOG.debug("Deleting {} from statestore ", appId);
@@ -77,8 +80,15 @@ public void run() {
7780
LOG.error("deleteApplicationHomeSubCluster failed at application {}.", appId, e);
7881
}
7982
}
80-
// Clean up registry entries
81-
cleanupAppRecordInRegistry(routerApps);
83+
84+
// Clean up Registry entries
85+
for (String app : allRegistryApps) {
86+
ApplicationId appId = ApplicationId.fromString(app);
87+
if (!routerApps.contains(appId)) {
88+
LOG.debug("removing finished application entry for {}", app);
89+
getRegistryClient().removeAppFromRegistry(appId, true);
90+
}
91+
}
8292
} catch (Throwable e) {
8393
LOG.error("Application cleaner started at time {} fails. ", now, e);
8494
}

0 commit comments

Comments
 (0)