summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-03-17 13:30:22 +0100
committerJon Marius Venstad <venstad@gmail.com>2021-03-17 13:30:22 +0100
commit1934f2c97b8fda95d55a2164699141bdbd35f694 (patch)
tree1217a44d5445671fb18a183cba916258fdc7fed0 /vespaclient-container-plugin
parent5e99305b424275df61fe16b59ceab28fd16b3b77 (diff)
Simplify lazy decoder and make raw data eligible for GC once parsed
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
index faf15d397c5..520e95d2792 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
@@ -555,9 +555,7 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
overload(request, "Rejecting execution due to overload: " + maxThrottled + " requests already enqueued", handler);
return;
}
- operations.offer(new Operation(request, handler) {
- @Override BooleanSupplier parse() { return operationParser.get(); }
- });
+ operations.offer(new Operation(request, handler, operationParser));
dispatchFirst();
}
@@ -764,16 +762,18 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
// -------------------------------------------- Document Operations ----------------------------------------
- private static abstract class Operation {
+ private static class Operation {
private final Lock lock = new ReentrantLock();
private final HttpRequest request;
private final ResponseHandler handler;
- private BooleanSupplier operation;
+ private BooleanSupplier operation; // The operation to attempt until it returns success.
+ private Supplier<BooleanSupplier> parser; // The unparsed operation—getting this will parse it.
- Operation(HttpRequest request, ResponseHandler handler) {
+ Operation(HttpRequest request, ResponseHandler handler, Supplier<BooleanSupplier> parser) {
this.request = request;
this.handler = handler;
+ this.parser = parser;
}
/**
@@ -789,8 +789,10 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
throw new IllegalStateException("Concurrent attempts at dispatch — this is a bug");
try {
- if (operation == null)
- operation = parse();
+ if (operation == null) {
+ operation = parser.get();
+ parser = null;
+ }
return operation.getAsBoolean();
}
@@ -806,8 +808,6 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
return true;
}
- abstract BooleanSupplier parse();
-
}
/** Attempts to send the given document operation, returning false if this needs to be retried. */