Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track cancellable tasks by parent ID #76186

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Iterable -> Collection
DaveCTurner committed Aug 9, 2021

Verified

This commit was signed with the committer’s verified signature.
kashifest Kashif Khan
commit 0d98b3e499c871b310f471416a8436ce14b88a16
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -98,7 +99,7 @@ public T remove(Task task) {
* Return a collection of all the tracked items. May be large. In the presence of concurrent calls to {@link #put} and {@link #remove}
* it behaves similarly to {@link ConcurrentHashMap#values()}.
*/
public Iterable<T> values() {
public Collection<T> values() {
return byTaskId.values();
}

Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@
import org.elasticsearch.test.ESTestCase;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasItem;
@@ -80,7 +80,7 @@ private static class TestTask {
final int stateBefore = state.get();
final String getResult = tracker.get(task.getId());
final Set<String> getByParentResult = tracker.getByParent(task.getParentTaskId()).collect(Collectors.toSet());
final Set<String> values = StreamSupport.stream(tracker.values().spliterator(), false).collect(Collectors.toSet());
final Set<String> values = new HashSet<>(tracker.values());
final int stateAfter = state.get();

assertThat(stateBefore, lessThanOrEqualTo(stateAfter));