Skip to content

Commit

Permalink
Remove duplicate methods from RemoteStoreBaseIntegTestCase (opensearc…
Browse files Browse the repository at this point in the history
…h-project#13044)

Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
sachinpkale authored Apr 4, 2024
1 parent e8c5daf commit 17641f6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.UUIDs;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.common.unit.ByteSizeUnit;
import org.opensearch.core.index.Index;
import org.opensearch.index.IndexModule;
import org.opensearch.index.IndexService;
Expand Down Expand Up @@ -57,11 +56,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.opensearch.repositories.fs.ReloadableFsRepository.REPOSITORIES_FAILRATE_SETTING;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;

Expand Down Expand Up @@ -191,121 +187,6 @@ protected BulkResponse indexBulk(String indexName, int numDocs) {
return client().bulk(bulkRequest).actionGet();
}

public static Settings remoteStoreClusterSettings(String name, Path path) {
return remoteStoreClusterSettings(name, path, name, path);
}

public static Settings remoteStoreClusterSettings(
String segmentRepoName,
Path segmentRepoPath,
String segmentRepoType,
String translogRepoName,
Path translogRepoPath,
String translogRepoType
) {
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(
buildRemoteStoreNodeAttributes(
segmentRepoName,
segmentRepoPath,
segmentRepoType,
translogRepoName,
translogRepoPath,
translogRepoType,
false
)
);
return settingsBuilder.build();
}

public static Settings remoteStoreClusterSettings(
String segmentRepoName,
Path segmentRepoPath,
String translogRepoName,
Path translogRepoPath
) {
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(buildRemoteStoreNodeAttributes(segmentRepoName, segmentRepoPath, translogRepoName, translogRepoPath, false));
return settingsBuilder.build();
}

public static Settings buildRemoteStoreNodeAttributes(
String segmentRepoName,
Path segmentRepoPath,
String translogRepoName,
Path translogRepoPath,
boolean withRateLimiterAttributes
) {
return buildRemoteStoreNodeAttributes(
segmentRepoName,
segmentRepoPath,
ReloadableFsRepository.TYPE,
translogRepoName,
translogRepoPath,
ReloadableFsRepository.TYPE,
withRateLimiterAttributes
);
}

public static Settings buildRemoteStoreNodeAttributes(
String segmentRepoName,
Path segmentRepoPath,
String segmentRepoType,
String translogRepoName,
Path translogRepoPath,
String translogRepoType,
boolean withRateLimiterAttributes
) {
String segmentRepoTypeAttributeKey = String.format(
Locale.getDefault(),
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
segmentRepoName
);
String segmentRepoSettingsAttributeKeyPrefix = String.format(
Locale.getDefault(),
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
segmentRepoName
);
String translogRepoTypeAttributeKey = String.format(
Locale.getDefault(),
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
translogRepoName
);
String translogRepoSettingsAttributeKeyPrefix = String.format(
Locale.getDefault(),
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
translogRepoName
);
String stateRepoTypeAttributeKey = String.format(
Locale.getDefault(),
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
segmentRepoName
);
String stateRepoSettingsAttributeKeyPrefix = String.format(
Locale.getDefault(),
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
segmentRepoName
);

Settings.Builder settings = Settings.builder()
.put("node.attr." + REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
.put(segmentRepoTypeAttributeKey, segmentRepoType)
.put(segmentRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath)
.put("node.attr." + REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY, translogRepoName)
.put(translogRepoTypeAttributeKey, translogRepoType)
.put(translogRepoSettingsAttributeKeyPrefix + "location", translogRepoPath)
.put("node.attr." + REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
.put(stateRepoTypeAttributeKey, segmentRepoType)
.put(stateRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath);

if (withRateLimiterAttributes) {
settings.put(segmentRepoSettingsAttributeKeyPrefix + "compress", randomBoolean())
.put(segmentRepoSettingsAttributeKeyPrefix + "chunk_size", 200, ByteSizeUnit.BYTES);
}

return settings.build();
}

Settings defaultIndexSettings() {
return Settings.builder()
.put(super.indexSettings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2538,7 +2538,7 @@ public static Settings buildRemoteStoreNodeAttributes(
);
}

public static Settings buildRemoteStoreNodeAttributes(
private static Settings buildRemoteStoreNodeAttributes(
String segmentRepoName,
Path segmentRepoPath,
String segmentRepoType,
Expand Down

0 comments on commit 17641f6

Please sign in to comment.