Skip to content

Commit

Permalink
Moved initialisation of data node timing of request from NodeTermsEnu…
Browse files Browse the repository at this point in the history
…mRequest constructor to TransportTermsEnumAction#asyncNodeOperation
  • Loading branch information
markharwood committed May 6, 2021
1 parent 6d55f99 commit cf70053
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public class NodeTermsEnumRequest extends TransportRequest implements IndicesReq

public NodeTermsEnumRequest(StreamInput in) throws IOException {
super(in);
// Set the clock running as soon as we appear on a node.
nodeStartedTimeMillis = System.currentTimeMillis();

field = in.readString();
string = in.readString();
caseInsensitive = in.readBoolean();
Expand Down Expand Up @@ -85,15 +82,19 @@ public long taskStartedTimeMillis() {

/**
* The time this request was materialized on a node
* (defaults to "now" if serialization was not used e.g. a local request).
*/
public long nodeStartedTimeMillis() {
long nodeStartedTimeMillis() {
// In case startTimerOnDataNode has not been called (should never happen in normal circumstances?)
if (nodeStartedTimeMillis == 0) {
nodeStartedTimeMillis = System.currentTimeMillis();
}
return this.nodeStartedTimeMillis;
}

public void startTimerOnDataNode() {
nodeStartedTimeMillis = System.currentTimeMillis();
}

public Set<ShardId> shardIds() {
return Collections.unmodifiableSet(shardIds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,11 @@ public void messageReceived(NodeTermsEnumRequest request, TransportChannel chann

private void asyncNodeOperation(NodeTermsEnumRequest request, Task task, ActionListener<NodeTermsEnumResponse> listener)
throws IOException {
// Start the clock ticking on the data node using the data node's local current time.
request.startTimerOnDataNode();

// DLS/FLS check copied from ResizeRequestInterceptor - check permissions and
// any index_filter canMatch checks on network thread before allocating work
// any index_filter canMatch checks on network thread before allocating work
ThreadContext threadContext = transportService.getThreadPool().getThreadContext();
final XPackLicenseState frozenLicenseState = licenseState.copyCurrentLicenseState();
for (ShardId shardId : request.shardIds().toArray(new ShardId[0])) {
Expand Down

0 comments on commit cf70053

Please sign in to comment.