summaryrefslogtreecommitdiffstats
path: root/documentapi
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-09-25 17:23:46 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-09-25 17:23:46 +0200
commitb819f60b6bdc2d6e124c0dc54c718016009e603c (patch)
treef88ee1742d4827ba86067446d7b55652b831014f /documentapi
parentd0572215be00dd764281818c9f370b7f82adb8bf (diff)
Update abi spec and simplify synch i LocalAsyncSession
Diffstat (limited to 'documentapi')
-rw-r--r--documentapi/abi-spec.json15
-rw-r--r--documentapi/src/main/java/com/yahoo/documentapi/local/LocalAsyncSession.java3
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/local/LocalDocumentApiTestCase.java7
3 files changed, 15 insertions, 10 deletions
diff --git a/documentapi/abi-spec.json b/documentapi/abi-spec.json
index f5f2a7c1845..0b5d3cd5dce 100644
--- a/documentapi/abi-spec.json
+++ b/documentapi/abi-spec.json
@@ -979,7 +979,9 @@
"public com.yahoo.documentapi.Result update(com.yahoo.document.DocumentUpdate, com.yahoo.documentapi.messagebus.protocol.DocumentProtocol$Priority)",
"public com.yahoo.documentapi.Response getNext()",
"public com.yahoo.documentapi.Response getNext(int)",
- "public void destroy()"
+ "public void destroy()",
+ "public void setSynchronizer(java.lang.Runnable)",
+ "public void setResultType(com.yahoo.documentapi.Result$ResultType)"
],
"fields": []
},
@@ -991,12 +993,15 @@
],
"methods": [
"public void <init>(com.yahoo.documentapi.DocumentAccessParams)",
- "public com.yahoo.documentapi.SyncSession createSyncSession(com.yahoo.documentapi.SyncParameters)",
- "public com.yahoo.documentapi.AsyncSession createAsyncSession(com.yahoo.documentapi.AsyncParameters)",
- "public com.yahoo.documentapi.VisitorSession createVisitorSession(com.yahoo.documentapi.VisitorParameters)",
+ "public com.yahoo.documentapi.local.LocalSyncSession createSyncSession(com.yahoo.documentapi.SyncParameters)",
+ "public com.yahoo.documentapi.local.LocalAsyncSession createAsyncSession(com.yahoo.documentapi.AsyncParameters)",
+ "public com.yahoo.documentapi.local.LocalVisitorSession createVisitorSession(com.yahoo.documentapi.VisitorParameters)",
"public com.yahoo.documentapi.VisitorDestinationSession createVisitorDestinationSession(com.yahoo.documentapi.VisitorDestinationParameters)",
"public com.yahoo.documentapi.SubscriptionSession createSubscription(com.yahoo.documentapi.SubscriptionParameters)",
- "public com.yahoo.documentapi.SubscriptionSession openSubscription(com.yahoo.documentapi.SubscriptionParameters)"
+ "public com.yahoo.documentapi.SubscriptionSession openSubscription(com.yahoo.documentapi.SubscriptionParameters)",
+ "public bridge synthetic com.yahoo.documentapi.VisitorSession createVisitorSession(com.yahoo.documentapi.VisitorParameters)",
+ "public bridge synthetic com.yahoo.documentapi.AsyncSession createAsyncSession(com.yahoo.documentapi.AsyncParameters)",
+ "public bridge synthetic com.yahoo.documentapi.SyncSession createSyncSession(com.yahoo.documentapi.SyncParameters)"
],
"fields": []
},
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/local/LocalAsyncSession.java b/documentapi/src/main/java/com/yahoo/documentapi/local/LocalAsyncSession.java
index b0ecf1b23b0..565b14981e7 100644
--- a/documentapi/src/main/java/com/yahoo/documentapi/local/LocalAsyncSession.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/local/LocalAsyncSession.java
@@ -145,7 +145,7 @@ public class LocalAsyncSession implements AsyncSession {
}
/**
- * This is run in a separate thread before and after providing the response from each accepted request, for advanced testing.
+ * This is run in a separate thread before providing the response from each accepted request, for advanced testing.
*
* If this is not set, which is the default, the documents appear synchronously in the response queue or handler.
*/
@@ -179,7 +179,6 @@ public class LocalAsyncSession implements AsyncSession {
new Thread(() -> {
runnable.run();
addResponse(responses.apply(req));
- runnable.run();
}).start();
return runnable;
});
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/local/LocalDocumentApiTestCase.java b/documentapi/src/test/java/com/yahoo/documentapi/local/LocalDocumentApiTestCase.java
index ced7a0c352e..951d0405b40 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/local/LocalDocumentApiTestCase.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/local/LocalDocumentApiTestCase.java
@@ -100,7 +100,8 @@ public class LocalDocumentApiTestCase extends AbstractDocumentApiTestCase {
for (DocumentId id : ids)
session.put(new Document(access.getDocumentTypeManager().getDocumentType("music"), id));
- // Let all async operations wait for a signal from the test thread before and after each response.
+ // Let all async operations wait for a signal from the test thread before sending their responses.
+ // Phaser not strictly needed here, but it's reusable, dynamic, and doesn't throw InterruptedException. Love it!
Phaser phaser = new Phaser(1);
session.setSynchronizer(() -> {
phaser.register();
@@ -121,12 +122,12 @@ public class LocalDocumentApiTestCase extends AbstractDocumentApiTestCase {
Future<?> futureWithAssertions = Executors.newSingleThreadExecutor().submit(() -> {
try {
List<Document> documents = new ArrayList<>();
- while (!outstandingRequests.isEmpty()) {
+ while ( ! outstandingRequests.isEmpty()) {
int timeSinceStart = (int) (System.currentTimeMillis() - startTime);
Response response = session.getNext(timeoutMillis - timeSinceStart);
if (response == null)
throw new RuntimeException("Timed out waiting for documents"); // or return what you have
- if (!outstandingRequests.contains(response.getRequestId())) continue; // Stale: Ignore
+ if ( ! outstandingRequests.contains(response.getRequestId())) continue; // Stale: Ignore
if (response.isSuccess())
documents.add(((DocumentResponse) response).getDocument());