Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
removed unncessary null
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal Jha committed Nov 1, 2018
1 parent 3161533 commit 8f5018e
Showing 1 changed file with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,32 +238,22 @@ protected <K, V> Map<K, V> loadDataAsync(final Collection<K> keys,
public final Collection<Session> listSessions()
throws SubscriptionNotInitializedException, NakadiRuntimeException, ServiceTemporarilyUnavailableException {
getLog().info("fetching sessions information");
final int numberOfCalls = 3;
for (int i = 0; i < numberOfCalls; i++) {
final List<String> zkSessions;
final Map <String,Session> result;
for (int i = 0; i < 5; i++) {
try {
zkSessions = getCurator().getChildren().forPath(getSubscriptionPath("/sessions"));
final List<String> sessions = getCurator().getChildren().forPath(getSubscriptionPath("/sessions"));
final Map <String,Session> result = loadDataAsync(sessions,
key -> getSubscriptionPath("/sessions/" + key),
this::deserializeSession);
if (result.size() == sessions.size()) {
return result.values();
}
} catch (final KeeperException.NoNodeException e) {
throw new SubscriptionNotInitializedException(getSubscriptionId());
} catch (Exception ex) {
throw new NakadiRuntimeException(ex);
}
result = loadDataAsync(zkSessions, key -> getSubscriptionPath("/sessions/" + key),
this::deserializeSession);
if (result.size() == zkSessions.size()) {
return result.values();
}
if (i == numberOfCalls-1) {
throw new ServiceTemporarilyUnavailableException("Failed to get all keys " +
zkSessions.stream()
.filter(v -> !result.containsKey(v))
.map(String::valueOf)
.collect(Collectors.joining(", "))
+ " from ZK", null);
}
}
return null;
throw new ServiceTemporarilyUnavailableException("Failed to get all keys from ZK", null);
}

@Override
Expand Down

0 comments on commit 8f5018e

Please sign in to comment.