Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit Kala <ankikala@amazon.com>
  • Loading branch information
ankitkala committed May 24, 2023
1 parent e4cb6fc commit dce4030
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ public void testReplicaHasDiffFilesThanPrimary() throws Exception {

public void testPressureServiceStats() throws Exception {
if (segmentReplicationWithRemoteEnabled()) {
logger.info("Skipping testPressureServiceStats as segment replication with remote store is enabled.");
logger.info("Skipping the test as pressure service is not compatible with SegRep and Remote store yet.");
return;
}
final String primaryNode = internalCluster().startNode();
Expand Down Expand Up @@ -880,7 +880,8 @@ public void testPressureServiceStats() throws Exception {
*/
public void testScrollCreatedOnReplica() throws Exception {
if (segmentReplicationWithRemoteEnabled()) {
logger.info("Skipping testScrollCreatedOnReplica as segment replication with remote store is enabled.");
// Skipping the test due to a bug while uploading Segments to remote store.
logger.info("Skipping the test for segment replication with remote store enabled.");
return;
}
// create the cluster with one primary node containing primary shard and replica node containing replica shard
Expand Down Expand Up @@ -973,7 +974,7 @@ public void testScrollCreatedOnReplica() throws Exception {
*/
public void testScrollWithOngoingSegmentReplication() throws Exception {
if (segmentReplicationWithRemoteEnabled()) {
logger.info("Skipping testScrollWithOngoingSegmentReplication as segment replication with remote store is enabled.");
logger.info("Skipping the test as its not compatible with segment replication with remote store yet.");
return;
}
// create the cluster with one primary node containing primary shard and replica node containing replica shard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.Lock;
import org.apache.lucene.util.IOUtils;
import org.opensearch.common.blobstore.BlobContainer;
import org.opensearch.common.blobstore.BlobMetadata;

Expand Down Expand Up @@ -201,4 +202,25 @@ public void rename(String source, String dest) throws IOException {
public Lock obtainLock(String name) throws IOException {
throw new UnsupportedOperationException();
}

/**
* Overriding the copyFrom as the parent method doesn't close the input/output streams resulting in file handle leaks.
*/
@Override
public void copyFrom(Directory from, String src, String dest, IOContext context) throws IOException {
boolean success = false;
IndexInput is = null;
IndexOutput os = null;
try {
is = from.openInput(src, context);
os = createOutput(dest, context);
os.copyBytes(is, is.length());
success = true;
} finally {
if (!success) {
IOUtils.deleteFilesIgnoringExceptions(this, dest);
}
IOUtils.close(is, os);
}
}
}

0 comments on commit dce4030

Please sign in to comment.