Add a number of auxiliary methods to persistent tasks classes.
Original commit: elastic/x-pack@7f44b41b7a
This commit is contained in:
parent
f136bfa6e0
commit
777b21f2ef
|
@ -30,8 +30,11 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A cluster state record that contains a list of all running persistent tasks
|
||||
|
@ -53,6 +56,19 @@ public final class PersistentTasksInProgress extends AbstractNamedDiffable<Clust
|
|||
return this.entries;
|
||||
}
|
||||
|
||||
public Collection<PersistentTaskInProgress<?>> findEntries(String actionName, Predicate<PersistentTaskInProgress<?>> predicate) {
|
||||
return this.entries().stream()
|
||||
.filter(p -> actionName.equals(p.getAction()))
|
||||
.filter(predicate)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public boolean entriesExist(String actionName, Predicate<PersistentTaskInProgress<?>> predicate) {
|
||||
return this.entries().stream()
|
||||
.filter(p -> actionName.equals(p.getAction()))
|
||||
.anyMatch(predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
|
@ -112,7 +112,7 @@ public class RemovePersistentTaskAction extends Action<RemovePersistentTaskActio
|
|||
}
|
||||
|
||||
public static class Response extends AcknowledgedResponse {
|
||||
protected Response() {
|
||||
public Response() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue