Skip to content

Commit

Permalink
Incorporate PR review feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <ssashish@amazon.com>
  • Loading branch information
ashking94 committed Jul 18, 2024
1 parent 78493c5 commit 32702e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@

import java.io.IOException;
import java.util.Objects;
import java.util.Set;

import static org.opensearch.repositories.blobstore.BlobStoreRepository.PREFIX_MODE_VERIFICATION_SETTING;

/**
* Metadata about registered repository
Expand All @@ -53,7 +50,6 @@
@PublicApi(since = "1.0.0")
public class RepositoryMetadata implements Writeable {

private final static Set<String> IGNORED_SETTINGS = Set.of(PREFIX_MODE_VERIFICATION_SETTING.getKey());
private final String name;
private final String type;
private final Settings settings;
Expand Down Expand Up @@ -212,7 +208,7 @@ public void writeTo(StreamOutput out) throws IOException {
public boolean equalsIgnoreGenerations(RepositoryMetadata other) {
return name.equals(other.name)
&& type.equals(other.type())
&& settings.equalsIgnores(other.settings(), IGNORED_SETTINGS)
&& settings.equals(other.settings())
&& Objects.equals(cryptoMetadata, other.cryptoMetadata());
}

Expand Down
19 changes: 0 additions & 19 deletions server/src/main/java/org/opensearch/common/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -557,25 +557,6 @@ public boolean equals(Object o) {
return Objects.equals(settings, that.settings);
}

public boolean equalsIgnores(Settings that, Set<String> ignoredSettings) {
if (settings == null || that.settings == null) {
return settings == that.settings;
}

// Filter out settings to ignore and collect to new maps
Map<String, Object> filteredSettings1 = settings.entrySet()
.stream()
.filter(entry -> ignoredSettings.contains(entry.getKey()) == false)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

Map<String, Object> filteredSettings2 = that.settings.entrySet()
.stream()
.filter(entry -> ignoredSettings.contains(entry.getKey()) == false)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

return Objects.deepEquals(filteredSettings1, filteredSettings2);
}

@Override
public int hashCode() {
return settings != null ? settings.hashCode() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ public abstract class OpenSearchIntegTestCase extends OpenSearchTestCase {

protected static final String REMOTE_BACKED_STORAGE_REPOSITORY_NAME = "test-remote-store-repo";

private static Boolean prefixModeVerificationEnable;

private Path remoteStoreRepositoryPath;

private ReplicationType randomReplicationType;
Expand All @@ -395,6 +397,7 @@ public abstract class OpenSearchIntegTestCase extends OpenSearchTestCase {

@BeforeClass
public static void beforeClass() throws Exception {
prefixModeVerificationEnable = randomBoolean();
testClusterRule.beforeClass();
}

Expand Down Expand Up @@ -2652,15 +2655,15 @@ private static Settings buildRemoteStoreNodeAttributes(
.put("node.attr." + REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
.put(segmentRepoTypeAttributeKey, segmentRepoType)
.put(segmentRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath)
.put(segmentRepoSettingsAttributeKeyPrefix + prefixModeVerificationSuffix, randomBoolean())
.put(segmentRepoSettingsAttributeKeyPrefix + prefixModeVerificationSuffix, prefixModeVerificationEnable)
.put("node.attr." + REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY, translogRepoName)
.put(translogRepoTypeAttributeKey, translogRepoType)
.put(translogRepoSettingsAttributeKeyPrefix + "location", translogRepoPath)
.put(translogRepoSettingsAttributeKeyPrefix + prefixModeVerificationSuffix, randomBoolean())
.put(translogRepoSettingsAttributeKeyPrefix + prefixModeVerificationSuffix, prefixModeVerificationEnable)
.put("node.attr." + REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
.put(stateRepoTypeAttributeKey, segmentRepoType)
.put(stateRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath)
.put(stateRepoSettingsAttributeKeyPrefix + prefixModeVerificationSuffix, randomBoolean());
.put(stateRepoSettingsAttributeKeyPrefix + prefixModeVerificationSuffix, prefixModeVerificationEnable);

if (withRateLimiterAttributes) {
settings.put(segmentRepoSettingsAttributeKeyPrefix + "compress", randomBoolean())
Expand Down

0 comments on commit 32702e8

Please sign in to comment.