Skip to content

Commit

Permalink
spotless changes
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
shiv0408 committed Oct 22, 2023
1 parent fef26e5 commit 1311929
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> listener,
final ToXContent.Params params
final T obj,
final BlobContainer blobContainer,
final String name,
final Compressor compressor,
ActionListener<Void> listener,
final ToXContent.Params params
) throws IOException {
// use NORMAL priority by default
this.writeAsyncWithPriority(obj, blobContainer, name, compressor, WritePriority.NORMAL, listener, params);
Expand All @@ -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<Void> listener,
final ToXContent.Params params
final T obj,
final BlobContainer blobContainer,
final String name,
final Compressor compressor,
ActionListener<Void> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -58,22 +55,24 @@
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;
import java.nio.file.Path;
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 {

Expand Down Expand Up @@ -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(
Expand All @@ -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<BlobObj> checksumSMILE = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent);
Expand All @@ -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();

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1311929

Please sign in to comment.