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

Remove hppc from task manager #85889

Merged
merged 1 commit into from
Apr 18, 2022
Merged
Changes from all commits
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
17 changes: 5 additions & 12 deletions server/src/main/java/org/elasticsearch/tasks/TaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

package org.elasticsearch.tasks;

import com.carrotsearch.hppc.ObjectIntHashMap;
import com.carrotsearch.hppc.ObjectIntMap;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
Expand Down Expand Up @@ -60,8 +57,6 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static org.elasticsearch.core.TimeValue.timeValueMillis;
import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_HEADER_SIZE;
Expand Down Expand Up @@ -506,7 +501,7 @@ private static class CancellableTaskHolder {
private final CancellableTask task;
private boolean finished = false;
private List<Runnable> cancellationListeners = null;
private ObjectIntMap<Transport.Connection> childTasksPerConnection = null;
private Map<Transport.Connection, Integer> childTasksPerConnection = null;
private String banChildrenReason;
private List<Runnable> childTaskCompletedListeners = null;

Expand Down Expand Up @@ -587,15 +582,15 @@ synchronized void registerChildConnection(Transport.Connection connection) {
throw new TaskCancelledException("parent task was cancelled [" + banChildrenReason + ']');
}
if (childTasksPerConnection == null) {
childTasksPerConnection = new ObjectIntHashMap<>();
childTasksPerConnection = new HashMap<>();
}
childTasksPerConnection.addTo(connection, 1);
childTasksPerConnection.merge(connection, 1, Integer::sum);
}

void unregisterChildConnection(Transport.Connection node) {
final List<Runnable> listeners;
synchronized (this) {
if (childTasksPerConnection.addTo(node, -1) == 0) {
if (childTasksPerConnection.merge(node, -1, Integer::sum) == 0) {
childTasksPerConnection.remove(node);
}
if (childTasksPerConnection.isEmpty() == false || this.childTaskCompletedListeners == null) {
Expand All @@ -617,9 +612,7 @@ Set<Transport.Connection> startBan(String reason, Runnable onChildTasksCompleted
if (childTasksPerConnection == null) {
pendingChildConnections = Collections.emptySet();
} else {
pendingChildConnections = StreamSupport.stream(childTasksPerConnection.spliterator(), false)
.map(e -> e.key)
.collect(Collectors.toUnmodifiableSet());
pendingChildConnections = Set.copyOf(childTasksPerConnection.keySet());
}
if (pendingChildConnections.isEmpty()) {
assert childTaskCompletedListeners == null;
Expand Down