Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9feb4be

Browse files
committedJun 10, 2024·
Remove duplicate methods
Signed-off-by: Sooraj Sinha <soosinha@amazon.com>
1 parent f480d24 commit 9feb4be

File tree

5 files changed

+16
-34
lines changed

5 files changed

+16
-34
lines changed
 

‎server/src/main/java/org/opensearch/cluster/coordination/CoordinationState.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
import org.opensearch.cluster.metadata.Metadata;
4040
import org.opensearch.cluster.node.DiscoveryNode;
4141
import org.opensearch.common.settings.Settings;
42+
import org.opensearch.common.util.FeatureFlags;
4243
import org.opensearch.common.util.io.IOUtils;
43-
import org.opensearch.node.remotestore.RemoteStoreNodeAttribute;
4444

4545
import java.io.Closeable;
4646
import java.io.IOException;
@@ -53,6 +53,7 @@
5353
import java.util.Set;
5454

5555
import static org.opensearch.cluster.coordination.Coordinator.ZEN1_BWC_TERM;
56+
import static org.opensearch.common.util.FeatureFlags.REMOTE_PUBLICATION_EXPERIMENTAL;
5657
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.isRemoteStoreClusterStateEnabled;
5758

5859
/**
@@ -104,7 +105,8 @@ public CoordinationState(
104105
.getLastAcceptedConfiguration();
105106
this.publishVotes = new VoteCollection();
106107
this.isRemoteStateEnabled = isRemoteStoreClusterStateEnabled(settings);
107-
this.isRemotePublicationEnabled = RemoteStoreNodeAttribute.isRemotePublicationEnabled(settings);
108+
this.isRemotePublicationEnabled = FeatureFlags.isEnabled(REMOTE_PUBLICATION_EXPERIMENTAL)
109+
&& localNode.isRemoteStatePublicationEnabled();
108110
}
109111

110112
public boolean isRemotePublicationEnabled() {

‎server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ public void onFailure(Exception e) {
469469
} else {
470470
responseActionListener = listener;
471471
}
472+
// TODO Decide to send remote state before starting publication by checking remote publication on all nodes
472473
if (sendRemoteState && destination.isRemoteStatePublicationEnabled()) {
473474
logger.trace("sending remote cluster state version [{}] to [{}]", newState.version(), destination);
474475
sendRemoteClusterState(destination, publishRequest.getAcceptedState(), responseActionListener);

‎server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java

+5-20
Original file line numberDiff line numberDiff line change
@@ -472,31 +472,16 @@ public boolean isRemoteStoreNode() {
472472
return this.getAttributes().keySet().stream().anyMatch(key -> key.startsWith(REMOTE_STORE_NODE_ATTRIBUTE_KEY_PREFIX));
473473
}
474474

475-
/**
476-
* Returns whether the node is a remote cluster state enabled node.
477-
* @return true if the node contains remote cluster state node attribute, false otherwise
478-
*/
479-
public boolean isRemoteClusterStateEnabled() {
480-
return this.getAttributes()
481-
.keySet()
482-
.stream()
483-
.anyMatch(key -> (key.equals(REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY)));
484-
}
485-
486-
/**
487-
* Returns whether remote routing table is enabled on the node
488-
* @return true if the node contains remote routing table node attributes, false otherwise
489-
*/
490-
public boolean isRemoteRoutingTableEnabled() {
491-
return this.getAttributes().keySet().stream().anyMatch(key -> key.equals(REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY));
492-
}
493-
494475
/**
495476
* Returns whether remote cluster state publication is enabled on this node
496477
* @return true if the node contains remote cluster state node attribute and remote routing table node attribute
497478
*/
498479
public boolean isRemoteStatePublicationEnabled() {
499-
return isRemoteClusterStateEnabled() && isRemoteRoutingTableEnabled();
480+
return this.getAttributes()
481+
.keySet()
482+
.stream()
483+
.anyMatch(key -> (key.equals(REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY)))
484+
&& this.getAttributes().keySet().stream().anyMatch(key -> key.equals(REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY));
500485
}
501486

502487
/**

‎server/src/main/java/org/opensearch/node/remotestore/RemoteStoreNodeAttribute.java

-6
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@ private static boolean isRemoteRoutingTableAttributePresent(Settings settings) {
201201
.isEmpty() == false;
202202
}
203203

204-
public static boolean isRemotePublicationEnabled(Settings settings) {
205-
return FeatureFlags.isEnabled(REMOTE_PUBLICATION_EXPERIMENTAL)
206-
&& isRemoteRoutingTableAttributePresent(settings)
207-
&& isRemoteStoreClusterStateEnabled(settings);
208-
}
209-
210204
public static boolean isRemoteRoutingTableEnabled(Settings settings) {
211205
return FeatureFlags.isEnabled(REMOTE_PUBLICATION_EXPERIMENTAL) && isRemoteRoutingTableAttributePresent(settings);
212206
}

‎server/src/test/java/org/opensearch/cluster/coordination/PublicationTransportHandlerTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void writeTo(StreamOutput out) throws IOException {
140140
assertThat(e.getCause().getMessage(), containsString("Simulated failure of diff serialization"));
141141
}
142142

143-
public void testHandleRemoteIncomingPublishRequestWhenNoCurrentPublishRequest() {
143+
public void testHandleIncomingRemotePublishRequestWhenNoCurrentPublishRequest() {
144144
RemoteClusterStateService remoteClusterStateService = mock(RemoteClusterStateService.class);
145145

146146
PublishWithJoinResponse expectedPublishResponse = new PublishWithJoinResponse(new PublishResponse(TERM, VERSION), Optional.empty());
@@ -163,7 +163,7 @@ public void testHandleRemoteIncomingPublishRequestWhenNoCurrentPublishRequest()
163163
Mockito.verifyNoInteractions(remoteClusterStateService);
164164
}
165165

166-
public void testHandleRemoteIncomingPublishRequestWhenTermMismatch() {
166+
public void testHandleIncomingRemotePublishRequestWhenTermMismatch() {
167167
RemoteClusterStateService remoteClusterStateService = mock(RemoteClusterStateService.class);
168168

169169
PublishWithJoinResponse expectedPublishResponse = new PublishWithJoinResponse(new PublishResponse(TERM, VERSION), Optional.empty());
@@ -188,7 +188,7 @@ public void testHandleRemoteIncomingPublishRequestWhenTermMismatch() {
188188
Mockito.verifyNoInteractions(remoteClusterStateService);
189189
}
190190

191-
public void testHandleRemoteIncomingPublishRequestWhenVersionMismatch() {
191+
public void testHandleIncomingRemotePublishRequestWhenVersionMismatch() {
192192
RemoteClusterStateService remoteClusterStateService = mock(RemoteClusterStateService.class);
193193

194194
PublishWithJoinResponse expectedPublishResponse = new PublishWithJoinResponse(new PublishResponse(TERM, VERSION), Optional.empty());
@@ -213,7 +213,7 @@ public void testHandleRemoteIncomingPublishRequestWhenVersionMismatch() {
213213
Mockito.verifyNoInteractions(remoteClusterStateService);
214214
}
215215

216-
public void testHandleRemoteIncomingPublishRequestForLocalNode() throws IOException {
216+
public void testHandleIncomingRemotePublishRequestForLocalNode() throws IOException {
217217
RemoteClusterStateService remoteClusterStateService = mock(RemoteClusterStateService.class);
218218

219219
PublishWithJoinResponse expectedPublishResponse = new PublishWithJoinResponse(new PublishResponse(TERM, VERSION), Optional.empty());
@@ -235,7 +235,7 @@ public void testHandleRemoteIncomingPublishRequestForLocalNode() throws IOExcept
235235
Mockito.verifyNoInteractions(remoteClusterStateService);
236236
}
237237

238-
public void testHandleRemoteIncomingPublishRequestWhenManifestNotFound() throws IOException {
238+
public void testHandleIncomingRemotePublishRequestWhenManifestNotFound() throws IOException {
239239
RemoteClusterStateService remoteClusterStateService = mock(RemoteClusterStateService.class);
240240

241241
PublishWithJoinResponse expectedPublishResponse = new PublishWithJoinResponse(new PublishResponse(TERM, VERSION), Optional.empty());
@@ -261,7 +261,7 @@ public void testHandleRemoteIncomingPublishRequestWhenManifestNotFound() throws
261261
Mockito.verify(remoteClusterStateService, times(1)).getClusterMetadataManifestByFileName(Mockito.any(), Mockito.any());
262262
}
263263

264-
public void testHandleRemoteIncomingPublishRequestWhenNoLastSeenState() throws IOException {
264+
public void testHandleIncomingRemotePublishRequestWhenNoLastSeenState() throws IOException {
265265
RemoteClusterStateService remoteClusterStateService = mock(RemoteClusterStateService.class);
266266

267267
PublishWithJoinResponse expectedPublishResponse = new PublishWithJoinResponse(new PublishResponse(TERM, VERSION), Optional.empty());

0 commit comments

Comments
 (0)
Please sign in to comment.