Skip to content

Commit

Permalink
YARN-10885. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Aug 9, 2022
1 parent ce5ca51 commit fb42275
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,9 @@ public SubClusterId getApplicationHomeSubCluster(ApplicationId appId)
throws YarnException {
try {
if (isCachingEnabled()) {
Object value =
cache.get(buildGetApplicationHomeSubClusterRequest(appId));
if (value instanceof SubClusterId) {
return (SubClusterId) value;
} else {
throw new YarnException("Cannot be converted to SubClusterId.");
}
SubClusterId value = SubClusterId.class.cast(
cache.get(buildGetApplicationHomeSubClusterRequest(appId)));
return value;
} else {
GetApplicationHomeSubClusterResponse response = stateStore.getApplicationHomeSubCluster(
GetApplicationHomeSubClusterRequest.newInstance(appId));
Expand Down Expand Up @@ -531,20 +527,19 @@ public Map<String, SubClusterPolicyConfiguration> invoke(
private Object buildGetApplicationHomeSubClusterRequest(ApplicationId applicationId) {
final String cacheKey = buildCacheKey(getClass().getSimpleName(),
GET_APPLICATION_HOME_SUBCLUSTER_CACHEID, applicationId.toString());
CacheRequest<String, SubClusterId> cacheRequest =
new CacheRequest<>(
cacheKey,
input -> {
GetApplicationHomeSubClusterResponse response =
stateStore.getApplicationHomeSubCluster(
GetApplicationHomeSubClusterRequest.newInstance(applicationId));

ApplicationHomeSubCluster applicationHomeSubCluster =
response.getApplicationHomeSubCluster();
SubClusterId subClusterId = applicationHomeSubCluster.getHomeSubCluster();

return subClusterId;
});
CacheRequest<String, SubClusterId> cacheRequest = new CacheRequest<>(
cacheKey,
input -> {
GetApplicationHomeSubClusterResponse response =
stateStore.getApplicationHomeSubCluster(
GetApplicationHomeSubClusterRequest.newInstance(applicationId));

ApplicationHomeSubCluster applicationHomeSubCluster =
response.getApplicationHomeSubCluster();
SubClusterId subClusterId = applicationHomeSubCluster.getHomeSubCluster();

return subClusterId;
});
return cacheRequest;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ public void testGetApplicationHomeSubClusterCache() throws YarnException {

ApplicationHomeSubCluster appHomeSubCluster =
ApplicationHomeSubCluster.newInstance(appId, subClusterId1);
SubClusterId subClusterIdAdd =
facade.addApplicationHomeSubCluster(appHomeSubCluster);
SubClusterId subClusterIdAdd = facade.addApplicationHomeSubCluster(appHomeSubCluster);

SubClusterId subClusterIdByFacade = facade.getApplicationHomeSubCluster(appId);
Assert.assertEquals(subClusterIdByFacade, subClusterIdAdd);
Expand Down

0 comments on commit fb42275

Please sign in to comment.