Skip to content

Commit de56665

Browse files
committed
Review fixes
1 parent 62e421e commit de56665

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

server/src/main/java/org/elasticsearch/node/Node.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ public Node start() throws NodeValidationException {
357357
clusterService.start();
358358
assert clusterService.localNode().equals(localNodeFactory.getNode())
359359
: "clusterService has a different local node than the factory provided";
360-
transportService.getTaskManager().setLocalNodeId(clusterService.localNode().getId());
361360
transportService.acceptIncomingRequests();
362361
/*
363362
* CoordinationDiagnosticsService expects to be able to send transport requests and use the cluster state, so it is important to

server/src/main/java/org/elasticsearch/tasks/TaskAwareRequest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.tasks;
1111

12+
import org.elasticsearch.core.Nullable;
13+
1214
import java.util.Map;
1315

1416
/**
@@ -56,7 +58,14 @@ default Task createTask(long id, String type, String action, TaskId parentTaskId
5658
* Returns the task object that should be used to keep track of the processing of the request, with an extra local node ID.
5759
*/
5860
// TODO remove the above overload, use only this one.
59-
default Task createTask(String localNodeId, long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
61+
default Task createTask(
62+
@Nullable String localNodeId,
63+
long id,
64+
String type,
65+
String action,
66+
TaskId parentTaskId,
67+
Map<String, String> headers
68+
) {
6069
return createTask(id, type, action, parentTaskId, headers);
6170
}
6271

server/src/main/java/org/elasticsearch/tasks/TaskManager.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public class TaskManager implements ClusterStateApplier {
8787
private final ByteSizeValue maxHeaderSize;
8888
private final Map<TcpChannel, ChannelPendingTaskTracker> channelPendingTaskTrackers = ConcurrentCollections.newConcurrentMap();
8989
private final SetOnce<TaskCancellationService> cancellationService = new SetOnce<>();
90-
private final SetOnce<String> localNodeId = new SetOnce<>();
9190

9291
private final List<RemovedTaskListener> removedTaskListeners = new CopyOnWriteArrayList<>();
9392

@@ -112,10 +111,6 @@ public void setTaskCancellationService(TaskCancellationService taskCancellationS
112111
this.cancellationService.set(taskCancellationService);
113112
}
114113

115-
public void setLocalNodeId(String localNodeId) {
116-
this.localNodeId.set(localNodeId);
117-
}
118-
119114
/**
120115
* Registers a task without parent task
121116
*/
@@ -146,10 +141,14 @@ public Task register(String type, String action, TaskAwareRequest request, boole
146141
headers.put(key, httpHeader);
147142
}
148143
}
149-
var localNodeId = this.localNodeId.get();
150-
Task task = localNodeId != null
151-
? request.createTask(localNodeId, taskIdGenerator.incrementAndGet(), type, action, request.getParentTask(), headers)
152-
: request.createTask(taskIdGenerator.incrementAndGet(), type, action, request.getParentTask(), headers);
144+
Task task = request.createTask(
145+
lastDiscoveryNodes.getLocalNodeId(),
146+
taskIdGenerator.incrementAndGet(),
147+
type,
148+
action,
149+
request.getParentTask(),
150+
headers
151+
);
153152
Objects.requireNonNull(task);
154153
assert task.getParentTaskId().equals(request.getParentTask()) : "Request [ " + request + "] didn't preserve it parentTaskId";
155154
if (logger.isTraceEnabled()) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlQueryStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private EsqlQueryStatus(StreamInput stream) throws IOException {
3434

3535
@Override
3636
public void writeTo(StreamOutput out) throws IOException {
37-
out.writeWriteable(id);
37+
id.writeTo(out);
3838
}
3939

4040
@Override

0 commit comments

Comments
 (0)