Skip to content

Commit

Permalink
YARN-11011. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Oct 27, 2023
1 parent 14cfab9 commit 32aa13d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static void logAndThrowException(Throwable t, String errMsgFormat, Object
public static void logAndThrowException(String errMsg, Throwable t)
throws YarnException {
if (t != null) {
LOG.error(errMsg, t);
LOG.error(errMsg + "" + t.getMessage(), t);
throw new YarnException(errMsg, t);
} else {
LOG.error(errMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ public GetClusterMetricsResponse getClusterMetrics(
clusterMetrics = invokeConcurrent(remoteMethod, GetClusterMetricsResponse.class);
} catch (Exception ex) {
routerMetrics.incrGetClusterMetricsFailedRetrieved();
String msg = "Unable to get cluster metrics due to exception. ";
String msg = "Unable to get cluster metrics due to exception.";
RouterAuditLogger.logFailure(user.getShortUserName(), GET_CLUSTERMETRICS, UNKNOWN,
TARGET_CLIENT_RM_SERVICE, msg + ex.getMessage());
TARGET_CLIENT_RM_SERVICE, msg);
RouterServerUtil.logAndThrowException(msg, ex);
}
long stopTime = clock.getTime();
Expand All @@ -837,7 +837,7 @@ <R> Collection<R> invokeConcurrent(ClientMethod request, Class<R> clazz)

List<Callable<Pair<SubClusterId, Object>>> callables = new ArrayList<>();
List<Future<Pair<SubClusterId, Object>>> futures = new ArrayList<>();
List<String> exceptions = new ArrayList<>();
Map<SubClusterId, Exception> exceptions = new TreeMap<>();

// Generate parallel Callable tasks
for (SubClusterId subClusterId : subClusterIds) {
Expand All @@ -856,8 +856,9 @@ <R> Collection<R> invokeConcurrent(ClientMethod request, Class<R> clazz)
cause = cause.getCause();
}
String errMsg = (cause.getMessage() != null) ? cause.getMessage() : "UNKNOWN";
throw new YarnException(String.format("subClusterId %s exec %s error %s.",
subClusterId, request.getMethodName(), errMsg), e);
return Pair.of(subClusterId, new YarnException(
String.format("subClusterId %s exec %s error %s.", subClusterId,
request.getMethodName(), errMsg), e));
}
});
}
Expand All @@ -872,11 +873,15 @@ <R> Collection<R> invokeConcurrent(ClientMethod request, Class<R> clazz)
Pair<SubClusterId, Object> pair = future.get();
subClusterId = pair.getKey();
Object result = pair.getValue();
if(result instanceof YarnException) {
throw YarnException.class.cast(result);
}
results.put(subClusterId, clazz.cast(result));
} catch (InterruptedException | ExecutionException e) {
} catch (InterruptedException | ExecutionException | YarnException e) {
Throwable cause = e.getCause();
LOG.error(cause.getMessage(), e);
exceptions.add(cause.getMessage());
LOG.error("Cannot execute {} on {} : {}", request.getMethodName(),
subClusterId.getId(), cause.getMessage());
exceptions.put(subClusterId, e);
}
});
} catch (InterruptedException e) {
Expand All @@ -886,7 +891,8 @@ <R> Collection<R> invokeConcurrent(ClientMethod request, Class<R> clazz)
// All sub-clusters return results to be considered successful,
// otherwise an exception will be thrown.
if (exceptions != null && !exceptions.isEmpty()) {
throw new YarnException("invokeConcurrent Failed = " + StringUtils.join(exceptions, ","));
throw new YarnException("invokeConcurrent Failed = " +
StringUtils.join(exceptions.values(), ","));
}

// return result
Expand Down

0 comments on commit 32aa13d

Please sign in to comment.