From 7c11a2b73279046f31e5bb0a6e1e9ac0df9f3ef3 Mon Sep 17 00:00:00 2001 From: Areek Zillur Date: Fri, 21 Oct 2016 14:48:50 -0400 Subject: [PATCH] cleanup and improve documentation for TWA --- .../action/bulk/TransportShardBulkAction.java | 4 ++-- .../action/delete/TransportDeleteAction.java | 4 ++-- .../action/index/TransportIndexAction.java | 6 ++--- .../replication/TransportWriteAction.java | 22 ++++++++----------- .../TransportWriteActionTests.java | 14 ++++++------ 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index b765e19a200..d97fc47af25 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -101,7 +101,7 @@ public class TransportShardBulkAction extends TransportWriteAction, @@ -61,26 +62,21 @@ public abstract class TransportWriteAction< /** * Called on the primary with a reference to the primary {@linkplain IndexShard} to modify. + * + * @return the result of the operation on primary, including current translog location and operation response and failure + * async refresh is performed on the primary shard according to the Request refresh policy */ - protected abstract WritePrimaryResult onPrimaryShard(Request request, IndexShard primary) throws Exception; + @Override + protected abstract WritePrimaryResult shardOperationOnPrimary(Request request, IndexShard primary) throws Exception; /** * Called once per replica with a reference to the replica {@linkplain IndexShard} to modify. * - * @return the result of the replication operation containing either the translog location of the {@linkplain IndexShard} - * after the write was completed or a failure if the operation failed + * @return the result of the operation on replica, including current translog location and operation response and failure + * async refresh is performed on the replica shard according to the ReplicaRequest refresh policy */ - protected abstract WriteReplicaResult onReplicaShard(ReplicaRequest request, IndexShard replica) throws Exception; - @Override - protected final WritePrimaryResult shardOperationOnPrimary(Request request, IndexShard primary) throws Exception { - return onPrimaryShard(request, primary); - } - - @Override - protected final WriteReplicaResult shardOperationOnReplica(ReplicaRequest request, IndexShard replica) throws Exception { - return onReplicaShard(request, replica); - } + protected abstract WriteReplicaResult shardOperationOnReplica(ReplicaRequest request, IndexShard replica) throws Exception; /** * Result of taking the action on the primary. diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java index 15aed84e1f6..66251c92abf 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java @@ -136,19 +136,19 @@ public class TransportWriteActionTests extends ESTestCase { } @Override - protected WritePrimaryResult onPrimaryShard(TestRequest request, IndexShard primary) throws Exception { + protected TestResponse newResponseInstance() { + return new TestResponse(); + } + + @Override + protected WritePrimaryResult shardOperationOnPrimary(TestRequest request, IndexShard primary) throws Exception { return new WritePrimaryResult(request, new TestResponse(), location, null, primary); } @Override - protected WriteReplicaResult onReplicaShard(TestRequest request, IndexShard replica) { + protected WriteReplicaResult shardOperationOnReplica(TestRequest request, IndexShard replica) throws Exception { return new WriteReplicaResult(request, location, null, replica); } - - @Override - protected TestResponse newResponseInstance() { - return new TestResponse(); - } } private static class TestRequest extends ReplicatedWriteRequest {