Make ConcreteShardRequest public and static

Request interceptors need to be able to work with it.
This commit is contained in:
Nik Everett 2016-09-06 15:40:28 -04:00
parent fd3392aef8
commit eb9d2b6659
2 changed files with 9 additions and 8 deletions

View File

@ -964,7 +964,7 @@ public abstract class TransportReplicationAction<
}
/** a wrapper class to encapsulate a request when being sent to a specific allocation id **/
final class ConcreteShardRequest<R extends TransportRequest> extends TransportRequest {
public static final class ConcreteShardRequest<R extends TransportRequest> extends TransportRequest {
/** {@link AllocationId#getId()} of the shard this request is sent to **/
private String targetAllocationID;

View File

@ -120,7 +120,7 @@ public class TransportReplicationActionTests extends ESTestCase {
*/
public static <R extends ReplicationRequest> R resolveRequest(TransportRequest requestOrWrappedRequest) {
if (requestOrWrappedRequest instanceof TransportReplicationAction.ConcreteShardRequest) {
requestOrWrappedRequest = ((TransportReplicationAction.ConcreteShardRequest)requestOrWrappedRequest).getRequest();
requestOrWrappedRequest = ((TransportReplicationAction.ConcreteShardRequest<?>)requestOrWrappedRequest).getRequest();
}
return (R) requestOrWrappedRequest;
}
@ -721,7 +721,8 @@ public class TransportReplicationActionTests extends ESTestCase {
final Action.ReplicaOperationTransportHandler replicaOperationTransportHandler = action.new ReplicaOperationTransportHandler();
try {
replicaOperationTransportHandler.messageReceived(
action.new ConcreteShardRequest(new Request().setShardId(shardId), replicaRouting.allocationId().getId()),
new TransportReplicationAction.ConcreteShardRequest<>(
new Request().setShardId(shardId), replicaRouting.allocationId().getId()),
createTransportChannel(new PlainActionFuture<>()), task);
} catch (ElasticsearchException e) {
assertThat(e.getMessage(), containsString("simulated"));
@ -771,7 +772,7 @@ public class TransportReplicationActionTests extends ESTestCase {
PlainActionFuture<Response> listener = new PlainActionFuture<>();
Request request = new Request(shardId).timeout("1ms");
action.new PrimaryOperationTransportHandler().messageReceived(
action.new ConcreteShardRequest(request, "_not_a_valid_aid_"),
new TransportReplicationAction.ConcreteShardRequest<>(request, "_not_a_valid_aid_"),
createTransportChannel(listener), maybeTask()
);
try {
@ -797,7 +798,7 @@ public class TransportReplicationActionTests extends ESTestCase {
PlainActionFuture<Response> listener = new PlainActionFuture<>();
Request request = new Request(shardId).timeout("1ms");
action.new ReplicaOperationTransportHandler().messageReceived(
action.new ConcreteShardRequest(request, "_not_a_valid_aid_"),
new TransportReplicationAction.ConcreteShardRequest<>(request, "_not_a_valid_aid_"),
createTransportChannel(listener), maybeTask()
);
try {
@ -840,7 +841,7 @@ public class TransportReplicationActionTests extends ESTestCase {
final Request request = new Request().setShardId(shardId);
request.primaryTerm(state.metaData().getIndexSafe(shardId.getIndex()).primaryTerm(shardId.id()));
replicaOperationTransportHandler.messageReceived(
action.new ConcreteShardRequest(request, replica.allocationId().getId()),
new TransportReplicationAction.ConcreteShardRequest<>(request, replica.allocationId().getId()),
createTransportChannel(listener), task);
if (listener.isDone()) {
listener.get(); // fail with the exception if there
@ -862,8 +863,8 @@ public class TransportReplicationActionTests extends ESTestCase {
final CapturingTransport.CapturedRequest capturedRequest = capturedRequests.get(0);
assertThat(capturedRequest.action, equalTo("testActionWithExceptions[r]"));
assertThat(capturedRequest.request, instanceOf(TransportReplicationAction.ConcreteShardRequest.class));
assertThat(((TransportReplicationAction.ConcreteShardRequest) capturedRequest.request).getRequest(), equalTo(request));
assertThat(((TransportReplicationAction.ConcreteShardRequest) capturedRequest.request).getTargetAllocationID(),
assertThat(((TransportReplicationAction.ConcreteShardRequest<?>) capturedRequest.request).getRequest(), equalTo(request));
assertThat(((TransportReplicationAction.ConcreteShardRequest<?>) capturedRequest.request).getTargetAllocationID(),
equalTo(replica.allocationId().getId()));
}