diff --git a/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java b/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java index ae0527e4813af..ff9265728d0f7 100644 --- a/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java +++ b/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java @@ -20,7 +20,6 @@ import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.common.blobstore.BlobPath; -import org.opensearch.common.blobstore.stream.write.WritePriority; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; diff --git a/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java b/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java index a9e80affe7fb1..d80d67d757706 100644 --- a/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java +++ b/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java @@ -200,12 +200,12 @@ public void write( * Internally calls {@link #writeAsyncWithPriority} with {@link WritePriority#NORMAL} */ public void writeAsync( - final T obj, - final BlobContainer blobContainer, - final String name, - final Compressor compressor, - ActionListener listener, - final ToXContent.Params params + final T obj, + final BlobContainer blobContainer, + final String name, + final Compressor compressor, + ActionListener listener, + final ToXContent.Params params ) throws IOException { // use NORMAL priority by default this.writeAsyncWithPriority(obj, blobContainer, name, compressor, WritePriority.NORMAL, listener, params); @@ -219,17 +219,16 @@ public void writeAsync( * other use cases. */ public void urgentWriteAsync( - final T obj, - final BlobContainer blobContainer, - final String name, - final Compressor compressor, - ActionListener listener, - final ToXContent.Params params + final T obj, + final BlobContainer blobContainer, + final String name, + final Compressor compressor, + ActionListener listener, + final ToXContent.Params params ) throws IOException { this.writeAsyncWithPriority(obj, blobContainer, name, compressor, WritePriority.URGENT, listener, params); } - /** * Method to writes blob with resolving the blob name using {@link #blobName} method with specified * {@link WritePriority}. Leverages the multipart upload if supported by the blobContainer. diff --git a/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java b/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java index ce6f3cb8c0a3a..510e5eb1f22d7 100644 --- a/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java +++ b/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java @@ -32,8 +32,6 @@ package org.opensearch.snapshots; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; import org.opensearch.OpenSearchCorruptionException; import org.opensearch.OpenSearchParseException; import org.opensearch.common.blobstore.AsyncMultiStreamBlobContainer; @@ -46,7 +44,6 @@ import org.opensearch.common.blobstore.stream.read.ReadContext; import org.opensearch.common.blobstore.stream.write.WriteContext; import org.opensearch.common.blobstore.stream.write.WritePriority; -import org.opensearch.common.blobstore.transfer.RemoteTransferContainer; import org.opensearch.common.compress.DeflateCompressor; import org.opensearch.common.io.Streams; import org.opensearch.common.io.stream.BytesStreamOutput; @@ -58,12 +55,10 @@ import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.gateway.remote.RemoteClusterStateService; import org.opensearch.index.translog.BufferedChecksumStreamOutput; import org.opensearch.repositories.blobstore.ChecksumBlobStoreFormat; import org.opensearch.test.OpenSearchTestCase; -import javax.swing.*; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; @@ -71,9 +66,13 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; +import org.mockito.ArgumentCaptor; + import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.greaterThan; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; public class BlobStoreFormatTests extends OpenSearchTestCase { @@ -163,9 +162,8 @@ public void testBlobStoreAsyncOperations() throws IOException, InterruptedExcept verify(spyContainer, times(2)).asyncBlobUpload(writeContextArgumentCaptor.capture(), actionListenerArgumentCaptor.capture()); assertEquals(2, writeContextArgumentCaptor.getAllValues().size()); - writeContextArgumentCaptor.getAllValues().forEach( - writeContext -> assertEquals(WritePriority.NORMAL, writeContext.getWritePriority()) - ); + writeContextArgumentCaptor.getAllValues() + .forEach(writeContext -> assertEquals(WritePriority.NORMAL, writeContext.getWritePriority())); // Assert that all checksum blobs can be read assertEquals(checksumSMILE.read(mockBlobContainer.getDelegate(), "check-smile", xContentRegistry()).getText(), "checksum smile"); assertEquals( @@ -177,9 +175,9 @@ public void testBlobStoreAsyncOperations() throws IOException, InterruptedExcept public void testBlobStorePriorityAsyncOperation() throws IOException, InterruptedException { BlobStore blobStore = createTestBlobStore(); MockFsVerifyingBlobContainer mockBlobContainer = new MockFsVerifyingBlobContainer( - (FsBlobStore) blobStore, - BlobPath.cleanPath(), - null + (FsBlobStore) blobStore, + BlobPath.cleanPath(), + null ); MockFsVerifyingBlobContainer spyContainer = spy(mockBlobContainer); ChecksumBlobStoreFormat checksumSMILE = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent); @@ -190,12 +188,12 @@ public void testBlobStorePriorityAsyncOperation() throws IOException, Interrupte // Write blobs in different formats checksumSMILE.urgentWriteAsync( - new BlobObj("cluster state diff"), - spyContainer, - "cluster-state-diff", - CompressorRegistry.none(), - getVoidActionListener(latch), - ChecksumBlobStoreFormat.SNAPSHOT_ONLY_FORMAT_PARAMS + new BlobObj("cluster state diff"), + spyContainer, + "cluster-state-diff", + CompressorRegistry.none(), + getVoidActionListener(latch), + ChecksumBlobStoreFormat.SNAPSHOT_ONLY_FORMAT_PARAMS ); latch.await(); @@ -278,6 +276,7 @@ public void onFailure(Exception e) { return actionListener; } + protected BlobStore createTestBlobStore() throws IOException { return new FsBlobStore(randomIntBetween(1, 8) * 1024, createTempDir(), false); }