Skip to content

Commit

Permalink
apply spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
  • Loading branch information
shiv0408 committed Jun 11, 2024
1 parent a1f1729 commit a11a5af
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class RemoteClusterStateCleanupManager implements Closeable {
private long lastCleanupAttemptStateVersion;
private final ThreadPool threadpool;
private final ClusterApplierService clusterApplierService;
private final RemoteManifestManager remoteManifestManager;

public RemoteClusterStateCleanupManager(RemoteClusterStateService remoteClusterStateService, ClusterService clusterService) {
this.remoteClusterStateService = remoteClusterStateService;
Expand All @@ -82,6 +83,7 @@ public RemoteClusterStateCleanupManager(RemoteClusterStateService remoteClusterS
// initialize with 0, a cleanup will be done when this node is elected master node and version is incremented more than threshold
this.lastCleanupAttemptStateVersion = 0;
clusterSettings.addSettingsUpdateConsumer(REMOTE_CLUSTER_STATE_CLEANUP_INTERVAL_SETTING, this::updateCleanupInterval);
remoteManifestManager = remoteClusterStateService.getRemoteManifestManager();
}

void start() {
Expand Down Expand Up @@ -169,8 +171,11 @@ void deleteClusterMetadata(
Set<String> staleIndexMetadataPaths = new HashSet<>();
Set<String> staleGlobalMetadataPaths = new HashSet<>();
activeManifestBlobMetadata.forEach(blobMetadata -> {
ClusterMetadataManifest clusterMetadataManifest = remoteClusterStateService.getRemoteManifestManager()
.fetchRemoteClusterMetadataManifest(clusterName, clusterUUID, blobMetadata.name());
ClusterMetadataManifest clusterMetadataManifest = remoteManifestManager.fetchRemoteClusterMetadataManifest(
clusterName,
clusterUUID,
blobMetadata.name()
);
clusterMetadataManifest.getIndices()
.forEach(
uploadedIndexMetadata -> filesToKeep.add(
Expand All @@ -189,11 +194,13 @@ void deleteClusterMetadata(
}
});
staleManifestBlobMetadata.forEach(blobMetadata -> {
ClusterMetadataManifest clusterMetadataManifest = remoteClusterStateService.getRemoteManifestManager()
.fetchRemoteClusterMetadataManifest(clusterName, clusterUUID, blobMetadata.name());
ClusterMetadataManifest clusterMetadataManifest = remoteManifestManager.fetchRemoteClusterMetadataManifest(
clusterName,
clusterUUID,
blobMetadata.name()
);
staleManifestPaths.add(
remoteClusterStateService.getRemoteManifestManager().getManifestFolderPath(clusterName, clusterUUID).buildAsString()
+ blobMetadata.name()
remoteManifestManager.getManifestFolderPath(clusterName, clusterUUID).buildAsString() + blobMetadata.name()
);
if (clusterMetadataManifest.getCodecVersion() == ClusterMetadataManifest.CODEC_V1) {
addStaleGlobalMetadataPath(clusterMetadataManifest.getGlobalMetadataFileName(), filesToKeep, staleGlobalMetadataPaths);
Expand Down Expand Up @@ -258,7 +265,7 @@ void deleteStaleClusterMetadata(String clusterName, String clusterUUID, int mani
try {
getBlobStoreTransferService().listAllInSortedOrderAsync(
ThreadPool.Names.REMOTE_PURGE,
remoteClusterStateService.getRemoteManifestManager().getManifestFolderPath(clusterName, clusterUUID),
remoteManifestManager.getManifestFolderPath(clusterName, clusterUUID),
MANIFEST,
Integer.MAX_VALUE,
new ActionListener<>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,9 @@ public void start() {
remoteGlobalMetadataManager = new RemoteGlobalMetadataManager(
clusterSettings,
clusterName,
blobStoreRepository, blobStoreTransferService, threadpool
blobStoreRepository,
blobStoreTransferService,
threadpool
);
remoteIndexMetadataManager = new RemoteIndexMetadataManager(
clusterSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ Metadata getGlobalMetadata(String clusterUUID, ClusterMetadataManifest clusterMe
);
return globalMetadataBlobStore.read(remoteGlobalMetadata);
} else if (clusterMetadataManifest.hasMetadataAttributesFiles()) {
// from CODEC_V2, we have started uploading all the metadata in granular files instead of a single entity
Metadata.Builder builder = new Metadata.Builder();
if (clusterMetadataManifest.getCoordinationMetadata().getUploadedFilename() != null) {
RemoteCoordinationMetadata remoteCoordinationMetadata = new RemoteCoordinationMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public RemoteIndexMetadataManager(
clusterName,
threadpool,
ThreadPool.Names.REMOTE_STATE_READ
);;
);
;
this.namedXContentRegistry = blobStoreRepository.getNamedXContentRegistry();
this.compressor = blobStoreRepository.getCompressor();
this.indexMetadataUploadTimeout = clusterSettings.get(INDEX_METADATA_UPLOAD_TIMEOUT_SETTING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ public class RemoteManifestManager {
this.metadataManifestUploadTimeout = clusterSettings.get(METADATA_MANIFEST_UPLOAD_TIMEOUT_SETTING);
this.nodeId = nodeId;
this.manifestBlobStore = new RemoteClusterStateBlobStore<>(
blobStoreTransferService,
blobStoreRepository,
clusterName,
threadpool,
ThreadPool.Names.REMOTE_STATE_READ
);;
blobStoreTransferService,
blobStoreRepository,
clusterName,
threadpool,
ThreadPool.Names.REMOTE_STATE_READ
);
;
clusterSettings.addSettingsUpdateConsumer(METADATA_MANIFEST_UPLOAD_TIMEOUT_SETTING, this::setMetadataManifestUploadTimeout);
this.compressor = blobStoreRepository.getCompressor();
this.namedXContentRegistry = blobStoreRepository.getNamedXContentRegistry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1632,11 +1632,33 @@ private void mockObjectsForGettingPreviousClusterUUID(

if (differGlobalMetadata) {
mockBlobContainerOrderedList.addAll(
List.of(blobContainer3, blobContainer1, blobContainer3, blobContainer1, blobContainer1, blobContainer1, blobContainer1, blobContainer3, blobContainer3, blobContainer3)
List.of(
blobContainer3,
blobContainer1,
blobContainer3,
blobContainer1,
blobContainer1,
blobContainer1,
blobContainer1,
blobContainer3,
blobContainer3,
blobContainer3
)
);
}
mockBlobContainerOrderedList.addAll(
List.of(blobContainer2, blobContainer1, blobContainer2, blobContainer1, blobContainer1, blobContainer1, blobContainer1, blobContainer2, blobContainer2, blobContainer2)
List.of(
blobContainer2,
blobContainer1,
blobContainer2,
blobContainer1,
blobContainer1,
blobContainer1,
blobContainer1,
blobContainer2,
blobContainer2,
blobContainer2
)
);
BlobContainer[] mockBlobContainerOrderedArray = new BlobContainer[mockBlobContainerOrderedList.size()];
mockBlobContainerOrderedList.toArray(mockBlobContainerOrderedArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@
package org.opensearch.gateway.remote;

import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.coordination.CoordinationMetadata;
import org.opensearch.cluster.metadata.Metadata;
import org.opensearch.cluster.metadata.TemplatesMetadata;
import org.opensearch.common.network.NetworkModule;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.compress.Compressor;
import org.opensearch.core.compress.NoneCompressor;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.model.RemoteClusterStateBlobStore;
import org.opensearch.gateway.remote.model.RemoteCoordinationMetadata;
import org.opensearch.gateway.remote.model.RemoteCustomMetadata;
import org.opensearch.gateway.remote.model.RemoteGlobalMetadata;
import org.opensearch.gateway.remote.model.RemotePersistentSettingsMetadata;
import org.opensearch.gateway.remote.model.RemoteTemplatesMetadata;
import org.opensearch.index.translog.transfer.BlobStoreTransferService;
import org.opensearch.indices.IndicesModule;
import org.opensearch.repositories.blobstore.BlobStoreRepository;
Expand All @@ -37,10 +28,8 @@
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;
import static org.mockito.Mockito.when;
import static org.opensearch.threadpool.ThreadPool.Names.GENERIC;
import static org.opensearch.threadpool.ThreadPool.Names.REMOTE_STATE_READ;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class RemoteGlobalMetadataManagerTests extends OpenSearchTestCase {
private RemoteGlobalMetadataManager remoteGlobalMetadataManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
package org.opensearch.gateway.remote;

import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.network.NetworkModule;
import org.opensearch.common.remote.RemoteWritableEntityStore;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.compress.Compressor;
import org.opensearch.core.compress.NoneCompressor;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.model.RemoteClusterStateBlobStore;
import org.opensearch.gateway.remote.model.RemoteIndexMetadata;
import org.opensearch.index.translog.transfer.BlobStoreTransferService;
import org.opensearch.indices.IndicesModule;
import org.opensearch.repositories.blobstore.BlobStoreRepository;
Expand All @@ -32,9 +28,8 @@
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;
import static org.mockito.Mockito.when;
import static org.opensearch.threadpool.ThreadPool.Names.REMOTE_STATE_READ;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class RemoteIndexMetadataManagerTests extends OpenSearchTestCase {
private RemoteIndexMetadataManager remoteIndexMetadataManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.opensearch.core.compress.Compressor;
import org.opensearch.core.compress.NoneCompressor;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.model.RemoteClusterMetadataManifest;
import org.opensearch.gateway.remote.model.RemoteClusterStateBlobStore;
import org.opensearch.index.translog.transfer.BlobStoreTransferService;
import org.opensearch.indices.IndicesModule;
import org.opensearch.repositories.blobstore.BlobStoreRepository;
Expand Down

0 comments on commit a11a5af

Please sign in to comment.