Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import java.nio.ByteBuffer;

/**
* Handles inbound messages by first deserializing a {@link TransportMessage} from an {@link InboundMessage} and then passing
* it to the appropriate handler.
* Handles inbound messages by first deserializing a {@link TransportRequest} or {@link TransportResponse} from an {@link InboundMessage}
* and then passing it to the appropriate handler.
*/
public class InboundHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.EsExecutors.TaskTrackingConfig;
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
import org.elasticsearch.core.RefCounted;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.lucene.grouping.TopFieldGroups;
import org.elasticsearch.search.DocValueFormat;
Expand Down Expand Up @@ -70,7 +71,6 @@
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportMessage;
import org.junit.After;
import org.junit.Before;

Expand Down Expand Up @@ -177,7 +177,7 @@ public void testSortDocs() {
ScoreDoc[] sortedDocs = SearchPhaseController.sortDocs(true, topDocsList, from, size, reducedCompletionSuggestions).scoreDocs();
assertThat(sortedDocs.length, equalTo(accumulatedLength));
} finally {
results.asList().forEach(TransportMessage::decRef);
results.asList().forEach(RefCounted::decRef);
}
}

Expand Down Expand Up @@ -211,7 +211,7 @@ public void testSortDocsIsIdempotent() throws Exception {
}
sortedDocs = SearchPhaseController.sortDocs(ignoreFrom, topDocsList, from, size, Collections.emptyList()).scoreDocs();
} finally {
results.asList().forEach(TransportMessage::decRef);
results.asList().forEach(RefCounted::decRef);
}
results = generateSeededQueryResults(randomSeed, nShards, Collections.emptyList(), queryResultSize, useConstantScore);
try {
Expand All @@ -231,7 +231,7 @@ public void testSortDocsIsIdempotent() throws Exception {
assertEquals(sortedDocs[i].score, sortedDocs2[i].score, 0.0f);
}
} finally {
results.asList().forEach(TransportMessage::decRef);
results.asList().forEach(RefCounted::decRef);
}
}

Expand Down Expand Up @@ -342,10 +342,10 @@ public void testMerge() {
assertThat(mergedResponse.profile(), is(anEmptyMap()));
}
} finally {
fetchResults.asList().forEach(TransportMessage::decRef);
fetchResults.asList().forEach(RefCounted::decRef);
}
} finally {
queryResults.asList().forEach(TransportMessage::decRef);
queryResults.asList().forEach(RefCounted::decRef);
}
}
}
Expand Down Expand Up @@ -419,11 +419,11 @@ protected boolean lessThan(RankDoc a, RankDoc b) {
assertThat(mergedResponse.hits().getHits().length, equalTo(reducedQueryPhase.sortedTopDocs().scoreDocs().length));
assertThat(mergedResponse.profile(), is(anEmptyMap()));
} finally {
fetchResults.asList().forEach(TransportMessage::decRef);
fetchResults.asList().forEach(RefCounted::decRef);
}
} finally {

queryResults.asList().forEach(TransportMessage::decRef);
queryResults.asList().forEach(RefCounted::decRef);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
package org.elasticsearch.search.profile;

import org.elasticsearch.common.util.Maps;
import org.elasticsearch.core.RefCounted;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.SearchShardTarget;
import org.elasticsearch.search.fetch.FetchSearchResult;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.transport.TransportMessage;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -77,7 +77,7 @@ public void testQueryAndFetch() {
equalTo((long) searchPhase.size())
);
} finally {
fetchPhase.forEach(TransportMessage::decRef);
fetchPhase.forEach(RefCounted::decRef);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.common.bytes.ReleasableBytesReference;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.RecyclerBytesStreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.MockPageCacheRecycler;
import org.elasticsearch.common.util.concurrent.ThreadContext;
Expand Down Expand Up @@ -269,7 +270,7 @@ public void testCompressedDecode() throws IOException {
Compression.Scheme scheme = randomFrom(Compression.Scheme.DEFLATE, Compression.Scheme.LZ4);

try (RecyclerBytesStreamOutput os = new RecyclerBytesStreamOutput(recycler)) {
final TransportMessage transportMessage = isRequest
final Writeable transportMessage = isRequest
? new TestRequest(randomAlphaOfLength(100))
: new TestResponse(randomAlphaOfLength(100));
final BytesReference totalBytes = OutboundHandler.serialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void testSendMessage() throws InterruptedException {
TransportActionProxy.registerProxyAction(serviceC, "internal:test", cancellable, SimpleTestResponse::new);
// Node A -> Node B -> Node C: different versions - serialize the response
{
final List<TransportMessage> responses = Collections.synchronizedList(new ArrayList<>());
final List<TransportResponse> responses = Collections.synchronizedList(new ArrayList<>());
final CountDownLatch latch = new CountDownLatch(1);
serviceB.addRequestHandlingBehavior(
TransportActionProxy.getProxyAction("internal:test"),
Expand Down Expand Up @@ -212,7 +212,7 @@ public void handleException(TransportException exp) {
{
AbstractSimpleTransportTestCase.connectToNode(serviceD, nodeB);
final CountDownLatch latch = new CountDownLatch(1);
final List<TransportMessage> responses = Collections.synchronizedList(new ArrayList<>());
final List<TransportResponse> responses = Collections.synchronizedList(new ArrayList<>());
serviceB.addRequestHandlingBehavior(
TransportActionProxy.getProxyAction("internal:test"),
(handler, request, channel, task) -> handler.messageReceived(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.http.HttpPreRequest;
import org.elasticsearch.transport.TransportMessage;
import org.elasticsearch.transport.TransportRequest;

/**
* A AuthenticationFailureHandler is responsible for the handling of a request that has failed authentication. This must
Expand Down Expand Up @@ -51,7 +51,7 @@ public interface AuthenticationFailureHandler {
* @return ElasticsearchSecurityException with the appropriate headers and message
*/
ElasticsearchSecurityException failedAuthentication(
TransportMessage message,
TransportRequest message,
AuthenticationToken token,
String action,
ThreadContext context
Expand All @@ -78,7 +78,7 @@ ElasticsearchSecurityException failedAuthentication(
* @param context The context of the request that failed authentication that could not be authenticated
* @return ElasticsearchSecurityException with the appropriate headers and message
*/
ElasticsearchSecurityException exceptionProcessingRequest(TransportMessage message, String action, Exception e, ThreadContext context);
ElasticsearchSecurityException exceptionProcessingRequest(TransportRequest message, String action, Exception e, ThreadContext context);

/**
* This method is called when a REST request is received and no authentication token could be extracted AND anonymous
Expand All @@ -99,7 +99,7 @@ ElasticsearchSecurityException failedAuthentication(
* @param context The context of the request that failed authentication that could not be authenticated
* @return ElasticsearchSecurityException with the appropriate headers and message
*/
ElasticsearchSecurityException missingToken(TransportMessage message, String action, ThreadContext context);
ElasticsearchSecurityException missingToken(TransportRequest message, String action, ThreadContext context);

/**
* This method is called when anonymous access is enabled, a request does not pass authorization with the anonymous
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.http.HttpPreRequest;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.transport.TransportMessage;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.xpack.core.XPackField;

import java.util.ArrayList;
Expand Down Expand Up @@ -98,7 +98,7 @@ public ElasticsearchSecurityException failedAuthentication(HttpPreRequest reques

@Override
public ElasticsearchSecurityException failedAuthentication(
TransportMessage message,
TransportRequest message,
AuthenticationToken token,
String action,
ThreadContext context
Expand All @@ -118,7 +118,7 @@ public ElasticsearchSecurityException exceptionProcessingRequest(HttpPreRequest

@Override
public ElasticsearchSecurityException exceptionProcessingRequest(
TransportMessage message,
TransportRequest message,
String action,
Exception e,
ThreadContext context
Expand All @@ -137,7 +137,7 @@ public ElasticsearchSecurityException missingToken(HttpPreRequest request, Threa
}

@Override
public ElasticsearchSecurityException missingToken(TransportMessage message, String action, ThreadContext context) {
public ElasticsearchSecurityException missingToken(TransportRequest message, String action, ThreadContext context) {
return createAuthenticationError("missing authentication credentials for action [{}]", null, action);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.transport.TransportMessage;
import org.elasticsearch.transport.TransportRequest;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -37,9 +37,9 @@ public static String restRequestContent(RestRequest request) {
return "";
}

public static Set<String> indices(TransportMessage message) {
if (message instanceof IndicesRequest) {
return arrayToSetOrNull(((IndicesRequest) message).indices());
public static Set<String> indices(TransportRequest message) {
if (message instanceof IndicesRequest indicesRequest) {
return arrayToSetOrNull(indicesRequest.indices());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.http.HttpPreRequest;
import org.elasticsearch.transport.TransportMessage;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.xpack.core.security.authc.AuthenticationToken;
import org.elasticsearch.xpack.core.security.authc.DefaultAuthenticationFailureHandler;

Expand All @@ -31,7 +31,7 @@ public ElasticsearchSecurityException failedAuthentication(HttpPreRequest reques

@Override
public ElasticsearchSecurityException failedAuthentication(
TransportMessage message,
TransportRequest message,
AuthenticationToken token,
String action,
ThreadContext context
Expand All @@ -51,7 +51,7 @@ public ElasticsearchSecurityException missingToken(HttpPreRequest request, Threa
}

@Override
public ElasticsearchSecurityException missingToken(TransportMessage message, String action, ThreadContext context) {
public ElasticsearchSecurityException missingToken(TransportRequest message, String action, ThreadContext context) {
ElasticsearchSecurityException e = super.missingToken(message, action, context);
// set a custom header
e.addHeader("WWW-Authenticate", "custom-challenge");
Expand Down