Skip to content

Commit

Permalink
fix#582: Review comments implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
sband committed May 26, 2023
1 parent 22c6419 commit ee42844
Showing 1 changed file with 3 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,29 @@ public CombinedStorageWriter(Writer localWriter, Writer remoteWriter, Reader sto
@Override
public Writer write(PageReadOnlyTrx pageReadOnlyTrx, PageReference pageReference, Bytes<ByteBuffer> bufferedBytes) {
Writer writer = localStorageWriter.write(pageReadOnlyTrx, pageReference, bufferedBytes);
CompletableFuture<Writer> remoteWriterTask = CompletableFuture.supplyAsync(() -> remoteStorageWriter.write(pageReadOnlyTrx, pageReference, bufferedBytes));
if (writer == null) {
try {
writer = remoteWriterTask.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Could not complete remote write operation, please check the error details");
e.printStackTrace();
}
}
CompletableFuture.supplyAsync(() -> remoteStorageWriter.write(pageReadOnlyTrx, pageReference, bufferedBytes));
return writer;
}

@Override
public Writer writeUberPageReference(PageReadOnlyTrx pageReadOnlyTrx, PageReference pageReference,
Bytes<ByteBuffer> bufferedBytes) {
Writer writer = localStorageWriter.writeUberPageReference(pageReadOnlyTrx, pageReference, bufferedBytes);
CompletableFuture<Writer> remoteWriterTask = CompletableFuture.supplyAsync(() -> remoteStorageWriter.writeUberPageReference(pageReadOnlyTrx, pageReference, bufferedBytes));
if (writer == null) {
try {
writer = remoteWriterTask.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Could not complete remote write operation, please check the error details");
e.printStackTrace();
}
}
CompletableFuture.supplyAsync(() -> remoteStorageWriter.writeUberPageReference(pageReadOnlyTrx, pageReference, bufferedBytes));
return writer;
}

@Override
public Writer truncateTo(PageReadOnlyTrx pageReadOnlyTrx, int revision) {
Writer writer = localStorageWriter.truncateTo(pageReadOnlyTrx, revision);
CompletableFuture<Writer> remoteWriterTask = CompletableFuture.supplyAsync(() -> remoteStorageWriter.truncateTo(pageReadOnlyTrx, revision));
if (writer == null) {
try {
writer = remoteWriterTask.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Could not complete remote write operation, please check the error details");
e.printStackTrace();
}
}
CompletableFuture.supplyAsync(() -> remoteStorageWriter.truncateTo(pageReadOnlyTrx, revision));
return writer;
}

@Override
public Writer truncate() {
Writer writer = localStorageWriter.truncate();
CompletableFuture<Writer> remoteWriterTask = CompletableFuture.supplyAsync(() -> remoteStorageWriter.truncate());
if (writer == null) {
try {
writer = remoteWriterTask.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("Could not complete remote write operation, please check the error details");
e.printStackTrace();
}
}
return writer;
}

Expand Down

0 comments on commit ee42844

Please sign in to comment.