GithubHelp home page GithubHelp logo

arangodb / arangodb-java-driver-async Goto Github PK

View Code? Open in Web Editor NEW
42.0 51.0 9.0 1.26 MB

ArangoDB Asynchronous Java driver

License: Apache License 2.0

Java 99.76% Shell 0.24%
database nosql arangodb java driver vpack

arangodb-java-driver-async's Introduction

[DEPRECATED]: arangodb-java-driver-async has been merged into arangodb-java-driver

ArangoDB-Logo

arangodb-java-driver-async

Maven Central

The asynchronous variant of the official ArangoDB Java Driver.

The following documentation links to the documentation of the synchronous variant, because this driver provides a nearly identical API with some exceptions:

  • The main access point is the class ArangoDBAsync instead of ArangoDB
  • Each method, which performs a database operation, returns a CompletableFuture instead of the normal result.
  • Only the transport protocol VST is supported (no HTTP).

Documentation

Learn more

arangodb-java-driver-async's People

Contributors

bcaxelbecker avatar dependabot[bot] avatar dothebart avatar hkernbach avatar mpv1989 avatar rashtao avatar simran-b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arangodb-java-driver-async's Issues

Why my arangodb exit when i use async java driver to do CRUD test? I use docker 3.1.7 image

My test enviroment is only one instance of docker 3.1.7 image. There is no error log in server's log.

image

Server log

image

Client log

INIT succNum:1, failNum:0, exceptNum:0
Insert testing...
INSERT qps:37330.844, consumeTime:2143ms, succTotal:80000, failTotal:0, exceptTotal:0
Update testing...
UPDATE qps:34349.508, consumeTime:2329ms, succTotal:80000, failTotal:0, exceptTotal:0
Select testing...
2017-01-03 19:31:12,253 ERROR [com.arangodb.internal.CollectionCache] - java.io.IOException: Reached the end of the stream.
com.arangodb.ArangoDBException: java.io.IOException: Reached the end of the stream.
at com.arangodb.internal.velocystream.ConnectionSync.write(ConnectionSync.java:111)
at com.arangodb.internal.velocystream.CommunicationSync.send(CommunicationSync.java:137)
at com.arangodb.internal.velocystream.CommunicationSync.execute(CommunicationSync.java:119)
at com.arangodb.internal.velocystream.CommunicationSync.execute(CommunicationSync.java:42)
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:47)
at com.arangodb.ArangoCollection.getInfo(ArangoCollection.java:642)
at com.arangodb.internal.CollectionCache.execute(CollectionCache.java:100)
at com.arangodb.internal.CollectionCache.getInfo(CollectionCache.java:89)
at com.arangodb.internal.CollectionCache.getCollectionName(CollectionCache.java:76)
at com.arangodb.internal.velocypack.VPackConfigure$2.deserialize(VPackConfigure.java:84)
at com.arangodb.internal.velocypack.VPackConfigure$2.deserialize(VPackConfigure.java:74)
at com.arangodb.velocypack.VPack.getValue(VPack.java:352)
at com.arangodb.velocypack.VPack.deserializeObject(VPack.java:271)
at com.arangodb.velocypack.VPack.getValue(VPack.java:373)
at com.arangodb.velocypack.VPack.deserializeMap(VPack.java:422)
at com.arangodb.velocypack.VPack.getValue(VPack.java:367)
at com.arangodb.velocypack.VPack.deserialize(VPack.java:241)
at com.arangodb.velocypack.VPack$2.deserialize(VPack.java:219)
at com.arangodb.internal.velocypack.VPackDeserializers$4.deserialize(VPackDeserializers.java:92)
at com.arangodb.internal.velocypack.VPackDeserializers$4.deserialize(VPackDeserializers.java:86)
at com.arangodb.velocypack.VPack.getValue(VPack.java:352)
at com.arangodb.velocypack.VPack.deserialize(VPack.java:241)
at com.arangodb.util.ArangoUtil.deserialize(ArangoUtil.java:67)
at com.arangodb.internal.ArangoExecutor.deserialize(ArangoExecutor.java:112)
at com.arangodb.internal.ArangoExecutor.createResult(ArangoExecutor.java:108)
at com.arangodb.internal.ArangoExecutorAsync.lambda$execute$0(ArangoExecutorAsync.java:48)
at com.arangodb.internal.ArangoExecutorAsync.lambda$execute$1(ArangoExecutorAsync.java:56)
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
at com.arangodb.internal.velocystream.CommunicationAsync.lambda$execute$0(CommunicationAsync.java:143)
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
at com.arangodb.internal.velocystream.MessageStore.consume(MessageStore.java:56)
at com.arangodb.internal.velocystream.ChunkStore.checkCompleteness(ChunkStore.java:66)
at com.arangodb.internal.velocystream.ChunkStore.checkCompleteness(ChunkStore.java:60)
at com.arangodb.internal.velocystream.ConnectionAsync.lambda$open$0(ConnectionAsync.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Reached the end of the stream.
at com.arangodb.internal.velocystream.Connection.readBytesIntoBuffer(Connection.java:212)
at com.arangodb.internal.velocystream.Connection.readBytes(Connection.java:204)
at com.arangodb.internal.velocystream.Connection.readChunk(Connection.java:181)
at com.arangodb.internal.velocystream.ConnectionSync.write(ConnectionSync.java:98)
... 45 more
2017-01-03 19:31:12,341 ERROR [com.arangodb.internal.velocystream.MessageStore] - Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.arangodb.internal.velocystream.Connection.readBytesIntoBuffer(Connection.java:210)
at com.arangodb.internal.velocystream.ConnectionAsync.lambda$open$0(ConnectionAsync.java:111)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-01-03 19:31:12,341 ERROR [com.arangodb.internal.velocystream.MessageStore] - Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.arangodb.internal.velocystream.Connection.readBytesIntoBuffer(Connection.java:210)
at com.arangodb.internal.velocystream.ConnectionAsync.lambda$open$0(ConnectionAsync.java:111)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-01-03 19:31:12,340 ERROR [com.arangodb.internal.velocystream.MessageStore] - Reached the end of the stream.
java.io.IOException: Reached the end of the stream.
at com.arangodb.internal.velocystream.Connection.readBytesIntoBuffer(Connection.java:212)
at com.arangodb.internal.velocystream.ConnectionAsync.lambda$open$0(ConnectionAsync.java:111)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-01-03 19:31:12,253 ERROR [com.arangodb.internal.velocystream.MessageStore] - Reached the end of the stream.
java.io.IOException: Reached the end of the stream.
at com.arangodb.internal.velocystream.Connection.readBytesIntoBuffer(Connection.java:212)
at com.arangodb.internal.velocystream.ConnectionAsync.lambda$open$0(ConnectionAsync.java:111)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-01-03 19:31:12,345 ERROR [com.arangodb.internal.velocystream.MessageStore] - Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.arangodb.internal.velocystream.Connection.readBytesIntoBuffer(Connection.java:210)
at com.arangodb.internal.velocystream.ConnectionAsync.lambda$open$0(ConnectionAsync.java:111)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-01-03 19:31:12,346 ERROR [com.arangodb.internal.velocystream.MessageStore] - Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.arangodb.internal.velocystream.Connection.readBytesIntoBuffer(Connection.java:210)
at com.arangodb.internal.velocystream.ConnectionAsync.lambda$open$0(ConnectionAsync.java:111)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

My test code is very simple

private TestTaskResult initArangoDB() {
    TestTaskResult result = new TestTaskResult();
    try {
        String testDBName = configManager.getString(ConfigKey.TEST_DB_NAME);
        database = arangoDB.db(testDBName);
        result.addSuccessNum(1);
    } catch (ArangoDBException e) {
        e.printStackTrace();
        result.addExceptNum(1);
        result.addFailNum(1);
    }
    return result;
}

private TestTaskResult testArangoInsert() {
    TestTaskResult result = new TestTaskResult();
    ArrayList<CompletableFuture<DocumentCreateEntity<BaseDocument>>> list = new ArrayList(threadTestCnt);
    ArangoCollectionAsync entityCollection = database.collection(ENTITY_COLLECTION);

    try {
        String nanoTime = String.valueOf(System.nanoTime());
        StringBuilder randomValue = createRandomCharData(propertyBytes);

        for (int i = 0; i < threadTestCnt; i++) {
            final BaseDocument doc = new BaseDocument();
            doc.setKey(namePrefix + String.valueOf(i + 1 + nameIdOffset));
            for (int j = 0; j < propertyNum; j++) {
                String appendProp = "__" + nanoTime + "__" + String.valueOf(i + 1) + "__" + String.valueOf(j + 1);
                randomValue.append(appendProp);
                doc.addAttribute("property" + String.valueOf(j), randomValue.toString());
                int len = randomValue.length();
                randomValue.delete(len - appendProp.length(), len);
            }

            final CompletableFuture<DocumentCreateEntity<BaseDocument>> f = entityCollection.insertDocument(doc);
            list.add(f);
        }
    } catch (ArangoDBException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < threadTestCnt; i++) {
        try {
            DocumentCreateEntity<BaseDocument> createEntity = list.get(i).get();
            if (createEntity.getKey() != null) {
                result.addSuccessNum(1);
            } else {
                result.addFailNum(1);
            }
        } catch (InterruptedException | ExecutionException e) {
            result.addFailNum(1);
        }
    }

    return result;
}

private TestTaskResult testArangoUpdate() {
    TestTaskResult result = new TestTaskResult();
    int updatePropNum = propertyNum;
    if (propertyNum >= 10) {
        updatePropNum = propertyNum / 3;
    }

    ArrayList<CompletableFuture<DocumentUpdateEntity<BaseDocument>>> list = new ArrayList(threadTestCnt);
    ArangoCollectionAsync entityCollection = database.collection(ENTITY_COLLECTION);
    try {
        String nanoTime = String.valueOf(System.nanoTime());
        StringBuilder randomValue = createRandomCharData(propertyBytes);
        randomValue.append("_Update");

        for (int i = 0; i < threadTestCnt; i++) {
            final BaseDocument doc = new BaseDocument();
            doc.setKey(namePrefix + String.valueOf(i + 1 + nameIdOffset));

            for (int j = 0; j < updatePropNum; j++) {
                String appendProp = "__" + nanoTime + "__" + String.valueOf(i + 1) + "__" + String.valueOf(j + 1);
                randomValue.append(appendProp);
                doc.addAttribute("property" + String.valueOf(j), randomValue.toString());
                int len = randomValue.length();
                randomValue.delete(len - appendProp.length(), len);
            }

            final CompletableFuture<DocumentUpdateEntity<BaseDocument>> f = entityCollection.updateDocument(doc.getKey(), doc);
            list.add(f);
        }
    } catch (ArangoDBException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < threadTestCnt; i++) {
        try {
            DocumentUpdateEntity<BaseDocument> updateEntity = list.get(i).get();
            if (updateEntity.getKey() != null) {
                result.addSuccessNum(1);
            } else {
                result.addFailNum(1);
            }
        } catch (InterruptedException | ExecutionException e) {
            result.addFailNum(1);
        }
    }

    return result;
}

private TestTaskResult testArangoSelect() {
    TestTaskResult result = new TestTaskResult();
    ArrayList<CompletableFuture<BaseDocument>> list = new ArrayList(threadTestCnt);
    ArangoCollectionAsync entityCollection = database.collection(ENTITY_COLLECTION);
    try {
        for (int i = 0; i < threadTestCnt; i++) {
            final CompletableFuture<BaseDocument> f = entityCollection.getDocument(namePrefix + String.valueOf(i + 1 + nameIdOffset), BaseDocument.class);
            list.add(f);
        }
    } catch (ArangoDBException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < threadTestCnt; i++) {
        try {
            BaseDocument document = list.get(i).get();
            if (document.getKey() != null) {
                result.addSuccessNum(1);
            } else {
                result.addFailNum(1);
            }
        } catch (InterruptedException | ExecutionException e) {
            result.addFailNum(1);
        }
    }

    return result;
}

private TestTaskResult testArangoDelete() {
    TestTaskResult result = new TestTaskResult();
    ArrayList<CompletableFuture<DocumentDeleteEntity<Void>>> list = new ArrayList(threadTestCnt);
    ArangoCollectionAsync entityCollection = database.collection(ENTITY_COLLECTION);
    try {
        for (int i = 0; i < threadTestCnt; i++) {
            final CompletableFuture<DocumentDeleteEntity<Void>> f = entityCollection.deleteDocument(namePrefix + String.valueOf(i + 1 + nameIdOffset));
            list.add(f);
        }
    } catch (ArangoDBException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < threadTestCnt; i++) {
        try {
            DocumentDeleteEntity<Void> deleteEntity = list.get(i).get();
            if (deleteEntity.getKey() != null) {
                result.addSuccessNum(1);
            } else {
                result.addFailNum(1);
            }
        } catch (InterruptedException | ExecutionException e) {
            result.addFailNum(1);
        }
    }

    return result;
}

Key not decoded on server side

My Environment

  • ArangoDB Version: 3.4.0
  • Java Driver Version: 5.0.4

Steps to reproduce

This issue happens when trying to get a vertex using the Java Driver

  1. Create a document which key contains a +

arangoDbGraphDriver.collection("mycollection").insertVertex("+123")

  1. Fetch the document using the same key

arangoDbGraphDriver.collection("mycollection").getVertex("+123", VertexEntity.class)

Problem:
The document is not found

Expected result:
I should be able to get the vertex back using the same key.

Explanation

The issue seems to be related to the fact that the driver encodes the url to make the request to Arango server but the server does not decode it in order to make the search.

When inserting a vertex using the graph driver the:

arangoDbGraphDriver.collection("mycollection").insertVertex("+123")

The request generated is similar to the following curl:

curl --basic --user "root:" -X POST http://localhost:8529/_db/mydb/_api/gharial/mygraph/vertex/mycollection -d '{"_key":"+123"}'

However when the vertex is fetched using the driver:

arangoDbGraphDriver.collection("mycollection").getVertex("+123", VertexEntity.class)

The request generated encodes the url which looks like:

curl --basic --user "root:" -X GET http://localhost:8529/_db/mydb/_api/gharial/mygraph/vertex/mycollection/%2B123

{"error":true,"errorMessage":"document not found","code":404,"errorNum":1202}

Furthermore, and just for my own testing purposes, when I directly made a curl to arango server without the encoding key I was able to get it.

curl --basic --user "root:" -X GET
http://localhost:8529/_db/mydb/_api/gharial/mygraph/vertex/mycollection/+123

{"error":false,"code":200,"vertex":{"_key":"+123","_id":"mycollection/+123","_rev":"_Y8cR9tu--B"}}

If the driver encodes the url, the server should decode it. Otherwise there is no way I can get back keys that contain certain characters.

README.md outdated

In section "Maven", the readme.md still points to version 4.3.0 instead of 4.3.2.

As I blindly copied the maven code I ran into the Long value deserialization bug (arangodb/arangodb-java-driver#151) until I noticed 4.3.2 is the current version - which fixes the issue. I guess I won't be the only one to copy the code unchecked, please fix. Thanks!

Usage from multiple threads

I am planning on moving from driver v3 to async v4.1 and was wondering how to achieve good performance. Since async driver uses VelocyStream which uses binary socket protocol under the hood, it means only 1 thread can read/write from/to ArangoDB at a time. This is what I have also observed. Even if I create as many drivers as I have number of threads, still performance is below par. Infact, with more drivers, deadlock occurs and the application does not respond.
Can you please share some code samples for usage guidelines in a multi-threaded environment?
Thanks,
GK

ClassCastException when arangodb.acquireHostList=true

When arangodb.acquireHostList=true is set com.arangodb.ArangoDBTest fails with the following error:


java.lang.ClassCastException: class com.arangodb.internal.velocystream.VstConnectionAsync cannot be cast to class com.arangodb.internal.velocystream.internal.VstConnectionSync (com.arangodb.internal.velocystream.VstConnectionAsync and com.arangodb.internal.velocystream.internal.VstConnectionSync are in unnamed module of loader 'app')

	at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:42)
	at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:132)
	at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:47)
	at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:79)
	at com.arangodb.internal.net.ExtendedHostResolver.resolveFromServer(ExtendedHostResolver.java:139)
	at com.arangodb.internal.net.ExtendedHostResolver.resolve(ExtendedHostResolver.java:91)
	at com.arangodb.internal.net.FallbackHostHandler.confirm(FallbackHostHandler.java:75)
	at com.arangodb.internal.net.DirtyReadHostHandler.confirm(DirtyReadHostHandler.java:73)
	at com.arangodb.internal.velocystream.VstCommunication.connect(VstCommunication.java:100)
	at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:131)
	at com.arangodb.internal.ArangoExecutorAsync.execute(ArangoExecutorAsync.java:65)
	at com.arangodb.internal.ArangoExecutorAsync.execute(ArangoExecutorAsync.java:57)
	at com.arangodb.internal.ArangoDBAsyncImpl.createDatabase(ArangoDBAsyncImpl.java:100)
	at com.arangodb.ArangoDBTest.createDatabase(ArangoDBTest.java:84)
	...


ArangoSerialization no longer accessible

After updating to the 4.6 async java driver from 4.4, the following code broke

   protected ArangoSerialization getSerializer() {
       //ArangoDatabaseAsync instance below
        return arangoDatabaseAsync.util();
    }

I have found a less than ideal workaround (below)

protected ArangoSerialization getSerializer() {
    return ((ArangoDBAsyncImpl) arangoDatabaseAsync.arango()).util();
}

Can you please expose ArangoSerialization at one of the the interface levels, or explain to me why not?

VelocyJack deserialization not always called

I have configured VelocyJack deserialization as per the docs. I note that in some cases, this deserializer is not called. Specifically, I am testing some code that simply does:

// 1
collection.insertDocument(doc)
...
// 2
collection.getDocument(key, MyDoc::class.java, DocumentReadOptions())

and the built-in default deserializer is being called at (2), not the VelocyJack deserializer. This was driving me nuts until I attached a debugger to the system to determine that the wrong deserializer was being called at ArangoExecutor.createResult.

ArangoExecutor upon initialization always requests the INTERNAL serializer, even if a custom one is defined.

Clearly the custom serialization is a work in progress. I'm gonna switch back to the default serialization for now.

Async collection methods do not complete exceptionally

The async collection getDocument methods never complete exceptionally, even if there is an exception thrown -- for example, if deserialization fails.

The problem is at https://github.com/arangodb/arangodb-java-driver-async/blob/master/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java#L132 and at https://github.com/arangodb/arangodb-java-driver-async/blob/master/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java#L144 -- these methods assume result.complete, even if response is null and ex has a value.

Instead, these methods should be calling result.completeExceptionally(ex) if ex has a value.

The observed behavior with the current code is that errors at deserialization are swallowed, and presumably other errors such as temporary database errors, and to the application it looks like there is no issue, and a null was simply returned from the method.

An easy way to replicate this is:

MyDoc doc = new MyDoc(...);
collection.insertDocument(doc).join();
// set a breakpoint here, and modify some data in the db in an incompatible way
MyDoc result = collection.getDocument(doc._key, MyDoc.class, DocumentReadOptions()).join();
// the line above should throw an Exception, but instead it just sets result to null and silently ignores the data corruption

This is confusing, but worse -- suppressing exceptions like this is a recipe for downstream failures. For example, a db query failures due to the primary shard being unavailable, which could normally be handled by a retry if the exception was bubbled up normally, would simply return a null value to the application and the application will not be aware of any issue until much later when that null causes a user error or data corruption.

ArangoCursorAsync close() is synchronous

Hi guys,

I am new to Arango, so please bear with me. I am looking at invoking Arango in asynchronous manner and getting ArangoCursorAsync containing the results. However I see there is only synchronous close() method for closing the cursor. This really defies the point of having the async implementation if some calls are still synchronous. Am I missing something? Is invoking ArangoCursorAsync.close() not required?

How to test whether ArangoDB is up or not?

I am writing an app where I need to find out whether the database is running or not. If the database is running, I will proceed. Otherwise, I need to quit.

I used recursion but its not working. And is there any other way than recursion?

Java driver does not comply with API?

Hi guys,

I was writing some integration test for my side project. As part of the test I am creating some documents and then creating a search view on top. I wanted to avoid Thread.sleep in the test so decided to specify 0 in the consolidationIntervalMsec option property hoping to effectively have instant commits.

I have discovered that if consolidationIntervalMsec is set to ANY value at all, then the search view setup fails with the following exception:

Caused by: com.arangodb.ArangoDBException: Response: 400, Error: 10 - expecting body to be of the form {name: <string>, type: <string>, properties: <object>}
	at com.arangodb.internal.velocystream.VstCommunicationAsync.lambda$execute$0(VstCommunicationAsync.java:132)
	at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
	at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
	at com.arangodb.internal.velocystream.VstConnectionAsync$1.call(VstConnectionAsync.java:101)
	at com.arangodb.internal.velocystream.VstConnectionAsync$1.call(VstConnectionAsync.java:97)
	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
	at com.arangodb.internal.velocystream.internal.MessageStore.consume(MessageStore.java:64)
	at com.arangodb.internal.velocystream.internal.ChunkStore.checkCompleteness(ChunkStore.java:66)
	at com.arangodb.internal.velocystream.internal.ChunkStore.checkCompleteness(ChunkStore.java:60)
	at com.arangodb.internal.velocystream.internal.VstConnection$1.call(VstConnection.java:147)
	at com.arangodb.internal.velocystream.internal.VstConnection$1.call(VstConnection.java:124)
	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

I suspect that the request object is not serialised to the format expected by the api if the consolidationIntervalMsec property is present:

{
    "name": "ThingsSearchView",
    "consolidationIntervalMsec": 60000,
    "links": {
        "Thing": {
            "fields": {
                "name": {
                    "analyzers": ["identity"]
                }
            }
        }
    },
    "type": "arangosearch"
}

Dependency used:

<dependency>
    <groupId>com.arangodb</groupId>
    <artifactId>arangodb-java-driver-async</artifactId>
    <version>5.0.4</version>
</dependency>

Arangodb version: 3.4.3

Unit Test to reproduce:


    @Test
    public void experiment() {
        ArangoDBAsync arango = new ArangoDBAsync.Builder()
                .user("root")
                .password("developer")
                .build();


        ArangoDatabaseAsync db = arango.db("database_of_things");
        if (db.exists().join()) {
            db.drop().join();
        }

        db.create().join();

        db.collection("Thing").create().join();

        db.createArangoSearch("ThingsSearchView", new ArangoSearchCreateOptions()
                .consolidationIntervalMsec(60000L) //<== This line breaks it
                .link(CollectionLink.on("Thing")
                        .fields(FieldLink.on("name")
                                .analyzers("identity"))))
                .join();

    }

P.S.
sorry about .join() everywhere, tried to keep it callback-free for ease of understanding

More type options for passing JSON from Jackson

I'm trying out ArangoDB in a Dropwizard application and I already have annotations on my POJOs for validation and serialization/deserialization of them using Jackson's ObjectMapper. I'd like to have more options around creating a VPackSlice for sending to ArangoDB than just a String. byte[] and or ByteBuffer would be better (the latter's useful in situations where you're pooling buffers). Better yet, I'd rather have a Module implementation that I could register in Jackson that would let me natively convert my POJOs to VPackSlices by using mapper.convertValue(pojo, VPackSlice.class).

Name your threads

The async driver creates a thread pool, but uses the default naming. In stack traces, this causes all the threads to show up with the default name pool-x-thread-y. For ease of use when reviewing thread dumps, please name your pool threads. Example thread:

"pool-9-thread-1" - Thread t@47
   java.lang.Thread.State: RUNNABLE
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
	at java.net.SocketInputStream.read(SocketInputStream.java:168)
	at java.net.SocketInputStream.read(SocketInputStream.java:140)
	at com.arangodb.internal.velocystream.internal.VstConnection.readBytesIntoBuffer(VstConnection.java:260)
	at com.arangodb.internal.velocystream.internal.VstConnection.readBytes(VstConnection.java:254)
	at com.arangodb.internal.velocystream.internal.VstConnection.readChunk(VstConnection.java:231)
	at com.arangodb.internal.velocystream.internal.VstConnection$1.call(VstConnection.java:141)
	at com.arangodb.internal.velocystream.internal.VstConnection$1.call(VstConnection.java:124)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(Thread.java:834)

Issues (potentially with) 'waitForSync: true'

I'm running arangodb 3.3.3 via docker container. There is a single instance (no clustering).

I'm doing essentially the following:

  • Statement 1: UPSERT...INSERT....REPLACE....OPTIONS { waitForSync: true }
  • Statement 2: // Use object inserted in Statement 1

Initially, I wasn't using the waitForSync: true option and was getting errors stating the object didn't exist when Statement 2 executed. I thought I had solved it by adding waitForSync: true, but the error seemed to reappear. I patched it with a very hackish and arbitrary delay between the two statements. So far, "it's working on my machine"โ„ข but this is obviously something that concerns me.

  • Are you aware of any issues with waitForSync and this java async driver?
  • How does waitForSync work with the driver?
  • How can I test to ensure that this issue will not appear once I remove the delay?

If I could introduce an artificial delay in the INSERT statement, I would be able to test that the waitForSync option is observed. For example, imagine executing something like INSERT...OPTIONS { delay: 5000, waitForSync: false }. This would return immediately (the waitForSync option is not true), but would delay execution of the statement. Since the call returns immediately, we can assert that the object does not yet exist via a second query that executes before the delay expires. We can also run INSERT...OPTIONS { delay: 5000, waitForSync: true }. Since we enabled waitForSync the call doesn't return until the record is inserted. We can assert that the object does exist via a subsequent query.

If I can test and get positive results that waitForSync is behaving and I still experience the same issue, then at least we know it's not the waitForSync setting, and perhaps we can explore other options together.

Appreciate any guidance you can offer!

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.