Skip to content

Commit

Permalink
spotless fix
Browse files Browse the repository at this point in the history
Signed-off-by: Sandeep Kumawat <[email protected]>
  • Loading branch information
skumawat2025 committed Apr 21, 2024
1 parent 23f4a64 commit b64d2d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ public long getContentLength() throws IOException {
return fileChannel == null ? content.length : fileChannel.size();
}

public FileChannel getFileChannel() {
return fileChannel;
}

public InputStream inputStream() throws IOException {
return fileChannel != null
? new BufferedInputStream(Channels.newInputStream(fileChannel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -252,23 +248,11 @@ private Map<String, String> createCheckpointDataAsObjectMetadata(TransferFileSna
metadata.put(CHECKPOINT_FILE_CHECKSUM_KEY, checksumBase64);

Check warning on line 248 in server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java#L246-L248

Added lines #L246 - L248 were not covered by tests

// Set the file data value
FileChannel fileChannel = checkpointFileSnapshot.getFileChannel();
long fileSize = fileChannel.size();
ByteBuffer buffer = ByteBuffer.allocate((int) fileSize);
try {
int bytesRead = 0;
while (buffer.hasRemaining()) {
bytesRead = fileChannel.read(buffer);
if (bytesRead == -1) {
break; // End of stream
}
}
} catch (IOException e) {
logger.error("Error reading translog.ckp file");
throw e;
}
buffer.flip();
String fileDataBase64 = Base64.getEncoder().encodeToString(buffer.array());
Path checkpointFilePath = checkpointFileSnapshot.getPath();
long fileSize = Files.size(checkpointFilePath);

Check warning on line 252 in server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java#L251-L252

Added lines #L251 - L252 were not covered by tests
assert fileSize < 1500 : "checkpoint file size is more than 1.5KB size, can't be stored as metadata";
byte[] fileBytes = Files.readAllBytes(checkpointFilePath);
String fileDataBase64 = Base64.getEncoder().encodeToString(fileBytes);
metadata.put(CHECKPOINT_FILE_DATA_KEY, fileDataBase64);

Check warning on line 256 in server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java#L254-L256

Added lines #L254 - L256 were not covered by tests

return metadata;

Check warning on line 258 in server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java#L258

Added line #L258 was not covered by tests
Expand Down

0 comments on commit b64d2d9

Please sign in to comment.