Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
heesung-sn committed Sep 20, 2024
1 parent 44c3604 commit bee4bd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ private CompletableFuture<Void> syncToMetadataStore(String key, ServiceUnitState
return metadataStoreTableView.put(key, data);
}

private CompletableFuture<Void> dummy(String key, ServiceUnitStateData data) {
return CompletableFuture.completedFuture(null);
private void dummy(String key, ServiceUnitStateData data) {
}

private void syncExistingItems()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,15 @@ private CompletableFuture<Void> handleExisting(String path) {
}

private void fill() throws MetadataStoreException {
long started = System.currentTimeMillis();
final var deadline = System.currentTimeMillis() + FILL_TIMEOUT_IN_MILLIS;
log.info("{} start filling existing items under the pathPrefix:{}", name, pathPrefix);
ConcurrentLinkedDeque<String> q = new ConcurrentLinkedDeque<>();
List<CompletableFuture<Void>> futures = new ArrayList<>();
q.add(pathPrefix);
LongAdder count = new LongAdder();
while (!q.isEmpty()) {
if (System.currentTimeMillis() - started > FILL_TIMEOUT_IN_MILLIS) {
var now = System.currentTimeMillis();
if (now >= deadline) {
String err = name + " failed to fill existing items in "
+ TimeUnit.MILLISECONDS.toSeconds(FILL_TIMEOUT_IN_MILLIS) + " secs. Filled count:"
+ count.sum();
Expand All @@ -266,7 +267,9 @@ private void fill() throws MetadataStoreException {
}));
}
try {
FutureUtil.waitForAll(futures).get(timeoutInMillis, TimeUnit.MILLISECONDS);
FutureUtil.waitForAll(futures).get(
Math.min(timeoutInMillis, deadline - now),
TimeUnit.MILLISECONDS);
} catch (Throwable e) {
Throwable c = FutureUtil.unwrapCompletionException(e);
log.error("{} failed to fill existing items", name, c);
Expand Down

0 comments on commit bee4bd5

Please sign in to comment.