From 24f7ecdaccfc8cfad66cbd4d0084f83197ea227d Mon Sep 17 00:00:00 2001 From: Mark Vollmary Date: Fri, 2 Nov 2018 08:14:09 +0100 Subject: [PATCH 1/2] Change `ArangoDB#timeout` to also set the request timeout when using VelocyStream (issue #230) --- ChangeLog.md | 4 + docs/Drivers/Java/Reference/Setup.md | 2 +- src/main/java/com/arangodb/ArangoDB.java | 161 +++++++++--------- .../velocystream/internal/VstConnection.java | 2 +- .../internal/VstConnectionSync.java | 11 +- 5 files changed, 85 insertions(+), 95 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4afd3d9c4..77252bc09 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +### Changed + +- changed `ArangoDB#timeout` to also set the request timeout when using VelocyStream (issue #230) + ### Fixed - fixed compatibility of `ArangoCursor#filter` with Java 6 diff --git a/docs/Drivers/Java/Reference/Setup.md b/docs/Drivers/Java/Reference/Setup.md index 97cf08a5f..8dc314439 100644 --- a/docs/Drivers/Java/Reference/Setup.md +++ b/docs/Drivers/Java/Reference/Setup.md @@ -12,7 +12,7 @@ The driver is configured with some default values: - + diff --git a/src/main/java/com/arangodb/ArangoDB.java b/src/main/java/com/arangodb/ArangoDB.java index 683b25bbe..1a7b4a73c 100644 --- a/src/main/java/com/arangodb/ArangoDB.java +++ b/src/main/java/com/arangodb/ArangoDB.java @@ -75,23 +75,23 @@ /** * Central access point for applications to communicate with an ArangoDB server. - * + * *

* Will be instantiated through {@link ArangoDB.Builder} *

- * + * *
  * ArangoDB arango = new ArangoDB.Builder().build();
  * ArangoDB arango = new ArangoDB.Builder().host("127.0.0.1", 8529).build();
  * 
- * + * * @author Mark Vollmary */ public interface ArangoDB extends ArangoSerializationAccessor { /** * Builder class to build an instance of {@link ArangoDB}. - * + * * @author Mark Vollmary */ public static class Builder extends InternalArangoDBBuilder { @@ -129,7 +129,7 @@ public Builder loadProperties(final InputStream in) throws ArangoDBException { /** * Adds a host to connect to. Multiple hosts can be added to provide fallbacks. - * + * * @param host * address of the host * @param port @@ -142,19 +142,10 @@ public Builder host(final String host, final int port) { } /** - * Sets the timeout in milliseconds. - * - *

- * For network protocol {@link Protocol#VST} it is used as socket timeout when opening a VecloyStream - * connection. - *

- *

- * For network protocol {@link Protocol#HTTP_JSON} and {@link Protocol#HTTP_VPACK} it is used as timeout for a - * single request. - *

- * + * Sets the connection and request timeout in milliseconds. + * * @param timeout - * timeout in milliseconds + * timeout in milliseconds * @return {@link ArangoDB.Builder} */ public Builder timeout(final Integer timeout) { @@ -164,7 +155,7 @@ public Builder timeout(final Integer timeout) { /** * Sets the username to use for authentication. - * + * * @param user * the user in the database (default: {@code root}) * @return {@link ArangoDB.Builder} @@ -176,7 +167,7 @@ public Builder user(final String user) { /** * Sets the password for the user for authentication. - * + * * @param password * the password of the user in the database (default: {@code null}) * @return {@link ArangoDB.Builder} @@ -188,7 +179,7 @@ public Builder password(final String password) { /** * If set to {@code true} SSL will be used when connecting to an ArangoDB server. - * + * * @param useSsl * whether or not use SSL (default: {@code false}) * @return {@link ArangoDB.Builder} @@ -200,7 +191,7 @@ public Builder useSsl(final Boolean useSsl) { /** * Sets the SSL context to be used when {@code true} is passed through {@link #useSsl(Boolean)}. - * + * * @param sslContext * SSL context to be used * @return {@link ArangoDB.Builder} @@ -212,7 +203,7 @@ public Builder sslContext(final SSLContext sslContext) { /** * Sets the chunk size when {@link Protocol#VST} is used. - * + * * @param chunksize * size of a chunk in bytes * @return {@link ArangoDB.Builder} @@ -224,17 +215,17 @@ public Builder chunksize(final Integer chunksize) { /** * Sets the maximum number of connections the built in connection pool will open per host. - * + * *

* Defaults: *

- * + * *
 		 * {@link Protocol#VST} == 1
 		 * {@link Protocol#HTTP_JSON} == 20
 		 * {@link Protocol#HTTP_VPACK} == 20
 		 * 
- * + * * @param maxConnections * max number of connections * @return {@link ArangoDB.Builder} @@ -246,7 +237,7 @@ public Builder maxConnections(final Integer maxConnections) { /** * Set the maximum time to life of a connection. After this time the connection will be closed automatically. - * + * * @param connectionTtl * the maximum time to life of a connection. * @return {@link ArangoDB.Builder} @@ -259,11 +250,11 @@ public Builder connectionTtl(final Long connectionTtl) { /** * Whether or not the driver should acquire a list of available coordinators in an ArangoDB cluster or a single * server with active failover. - * + * *

* The host list will be used for failover and load balancing. *

- * + * * @param acquireHostList * whether or not automatically acquire a list of available hosts (default: false) * @return {@link ArangoDB.Builder} @@ -275,7 +266,7 @@ public Builder acquireHostList(final Boolean acquireHostList) { /** * Sets the load balancing strategy to be used in an ArangoDB cluster setup. - * + * * @param loadBalancingStrategy * the load balancing strategy to be used (default: {@link LoadBalancingStrategy#NONE} * @return {@link ArangoDB.Builder} @@ -288,11 +279,11 @@ public Builder loadBalancingStrategy(final LoadBalancingStrategy loadBalancingSt /** * Register a custom {@link VPackSerializer} for a specific type to be used within the internal serialization * process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param clazz * the type the serializer should be registered for * @param serializer @@ -306,11 +297,11 @@ public Builder registerSerializer(final Class clazz, final VPackSerialize /** * Register a special serializer for a member class which can only be identified by its enclosing class. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param clazz * the type of the enclosing class * @param serializer @@ -325,11 +316,11 @@ public Builder registerEnclosingSerializer(final Class clazz, final VPack /** * Register a custom {@link VPackDeserializer} for a specific type to be used within the internal serialization * process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param clazz * the type the serializer should be registered for * @param deserializer @@ -343,11 +334,11 @@ public Builder registerDeserializer(final Class clazz, final VPackDeseria /** * Register a custom {@link VPackInstanceCreator} for a specific type to be used within the internal * serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param clazz * the type the instance creator should be registered for * @param creator @@ -361,11 +352,11 @@ public Builder registerInstanceCreator(final Class clazz, final VPackInst /** * Register a custom {@link VPackJsonDeserializer} for a specific type to be used within the internal * serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param type * the type the serializer should be registered for * @param deserializer @@ -379,11 +370,11 @@ public Builder registerJsonDeserializer(final ValueType type, final VPackJsonDes /** * Register a custom {@link VPackJsonDeserializer} for a specific type and attribute name to be used within the * internal serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param attribute * @param type * the type the serializer should be registered for @@ -401,11 +392,11 @@ public Builder registerJsonDeserializer( /** * Register a custom {@link VPackJsonSerializer} for a specific type to be used within the internal * serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param clazz * the type the serializer should be registered for * @param serializer @@ -419,11 +410,11 @@ public Builder registerJsonSerializer(final Class clazz, final VPackJsonS /** * Register a custom {@link VPackJsonSerializer} for a specific type and attribute name to be used within the * internal serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param attribute * @param clazz * the type the serializer should be registered for @@ -441,11 +432,11 @@ public Builder registerJsonSerializer( /** * Register a custom {@link VPackAnnotationFieldFilter} for a specific type to be used within the internal * serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param type * the type the serializer should be registered for * @param fieldFilter @@ -461,11 +452,11 @@ public Builder annotationFieldFilter( /** * Register a custom {@link VPackAnnotationFieldNaming} for a specific type to be used within the internal * serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param type * the type the serializer should be registered for * @param fieldNaming @@ -480,11 +471,11 @@ public
Builder annotationFieldNaming( /** * Register a {@link VPackModule} to be used within the internal serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

- * + * * @param module * module to register * @return {@link ArangoDB.Builder} @@ -496,7 +487,7 @@ public Builder registerModule(final VPackModule module) { /** * Register a list of {@link VPackModule} to be used within the internal serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

@@ -512,7 +503,7 @@ public Builder registerModules(final VPackModule... modules) { /** * Register a {@link VPackParserModule} to be used within the internal serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

@@ -528,7 +519,7 @@ public Builder registerJsonModule(final VPackParserModule module) { /** * Register a list of {@link VPackParserModule} to be used within the internal serialization process. - * + * *

* Attention:can not be used together with {@link #serializer(ArangoSerialization)} *

@@ -544,10 +535,10 @@ public Builder registerJsonModules(final VPackParserModule... modules) { /** * Replace the built-in serializer with the given serializer. - * + * *
* ATTENTION!: Use at your own risk - * + * * @param serializer * custom serializer * @deprecated use {@link #serializer(ArangoSerialization)} instead @@ -561,10 +552,10 @@ public Builder setSerializer(final ArangoSerializer serializer) { /** * Replace the built-in deserializer with the given deserializer. - * + * *
* ATTENTION!: Use at your own risk - * + * * @param deserializer * custom deserializer * @deprecated use {@link #serializer(ArangoSerialization)} instead @@ -578,10 +569,10 @@ public Builder setDeserializer(final ArangoDeserializer deserializer) { /** * Replace the built-in serializer/deserializer with the given one. - * + * *
* ATTENTION!: Any registered custom serializer/deserializer or module will be ignored. - * + * * @param serialization * custom serializer/deserializer * @return {@link ArangoDB.Builder} @@ -593,7 +584,7 @@ public Builder serializer(final ArangoSerialization serialization) { /** * Returns an instance of {@link ArangoDB}. - * + * * @return {@link ArangoDB} */ public synchronized ArangoDB build() { @@ -635,21 +626,21 @@ public synchronized ArangoDB build() { /** * Releases all connections to the server and clear the connection pool. - * + * * @throws ArangoDBException */ void shutdown() throws ArangoDBException; /** * Returns a {@code ArangoDatabase} instance for the {@code _system} database. - * + * * @return database handler */ ArangoDatabase db(); /** * Returns a {@code ArangoDatabase} instance for the given database name. - * + * * @param name * Name of the database * @return database handler @@ -658,7 +649,7 @@ public synchronized ArangoDB build() { /** * Creates a new database with the given name. - * + * * @see
API * Documentation * @param name @@ -670,7 +661,7 @@ public synchronized ArangoDB build() { /** * Retrieves a list of all existing databases - * + * * @see API * Documentation * @return a list of all existing databases @@ -680,7 +671,7 @@ public synchronized ArangoDB build() { /** * Retrieves a list of all databases the current user can access - * + * * @see API * Documentation @@ -691,7 +682,7 @@ public synchronized ArangoDB build() { /** * List available database to the specified user - * + * * @see API * Documentation @@ -704,7 +695,7 @@ public synchronized ArangoDB build() { /** * Returns the server name and version number. - * + * * @see API * Documentation * @return the server version, number @@ -714,7 +705,7 @@ public synchronized ArangoDB build() { /** * Returns the server role. - * + * * @return the server role * @throws ArangoDBException */ @@ -723,7 +714,7 @@ public synchronized ArangoDB build() { /** * Create a new user. This user will not have access to any database. You need permission to the _system database in * order to execute this call. - * + * * @see API Documentation * @param user * The name of the user @@ -737,7 +728,7 @@ public synchronized ArangoDB build() { /** * Create a new user. This user will not have access to any database. You need permission to the _system database in * order to execute this call. - * + * * @see API Documentation * @param user * The name of the user @@ -752,7 +743,7 @@ public synchronized ArangoDB build() { /** * Removes an existing user, identified by user. You need access to the _system database. - * + * * @see API Documentation * @param user * The name of the user @@ -763,7 +754,7 @@ public synchronized ArangoDB build() { /** * Fetches data about the specified user. You can fetch information about yourself or you need permission to the * _system database in order to execute this call. - * + * * @see API Documentation * @param user * The name of the user @@ -774,7 +765,7 @@ public synchronized ArangoDB build() { /** * Fetches data about all users. You can only execute this call if you have access to the _system database. - * + * * @see API * Documentation * @return informations about all users @@ -785,7 +776,7 @@ public synchronized ArangoDB build() { /** * Partially updates the data of an existing user. The name of an existing user must be specified in user. You can * only change the password of your self. You need access to the _system database to change the active flag. - * + * * @see API Documentation * @param user * The name of the user @@ -799,7 +790,7 @@ public synchronized ArangoDB build() { /** * Replaces the data of an existing user. The name of an existing user must be specified in user. You can only * change the password of your self. You need access to the _system database to change the active flag. - * + * * @see API * Documentation * @param user @@ -814,7 +805,7 @@ public synchronized ArangoDB build() { /** * Sets the default access level for databases for the user {@code user}. You need permission to the _system * database in order to execute this call. - * + * * @param user * The name of the user * @param permissions @@ -827,7 +818,7 @@ public synchronized ArangoDB build() { /** * Sets the default access level for collections for the user {@code user}. You need permission to the _system * database in order to execute this call. - * + * * @param user * The name of the user * @param permissions @@ -839,7 +830,7 @@ public synchronized ArangoDB build() { /** * Generic Execute. Use this method to execute custom FOXX services. - * + * * @param request * VelocyStream request * @return VelocyStream response @@ -849,7 +840,7 @@ public synchronized ArangoDB build() { /** * Generic Execute. Use this method to execute custom FOXX services. - * + * * @param request * VelocyStream request * @param hostHandle @@ -861,7 +852,7 @@ public synchronized ArangoDB build() { /** * Returns fatal, error, warning or info log messages from the server's global log. - * + * * @see API * Documentation @@ -874,7 +865,7 @@ public synchronized ArangoDB build() { /** * Returns the server's current loglevel settings. - * + * * @return the server's current loglevel settings * @since ArangoDB 3.1.0 * @throws ArangoDBException @@ -883,7 +874,7 @@ public synchronized ArangoDB build() { /** * Modifies and returns the server's current loglevel settings. - * + * * @param entity * loglevel settings * @return the server's current loglevel settings @@ -894,7 +885,7 @@ public synchronized ArangoDB build() { /** * Attention: Please do not use! - * + * * @param cursorInitializer * @return ArangoDB */ diff --git a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java index 33f627fec..2d9cb1d93 100644 --- a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java +++ b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java @@ -60,7 +60,7 @@ public abstract class VstConnection implements Connection { private ExecutorService executor; protected final MessageStore messageStore; - private final Integer timeout; + protected final Integer timeout; private final Long ttl; private final Boolean useSsl; private final SSLContext sslContext; diff --git a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java index 35fdf6827..2e8a8b96b 100644 --- a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java +++ b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java @@ -22,9 +22,8 @@ import java.util.Collection; import java.util.concurrent.Callable; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; @@ -96,12 +95,8 @@ public Message call() throws Exception { messageStore.storeMessage(message.getId(), task); super.writeIntern(message, chunks); try { - return task.get(); - } catch (final InterruptedException e) { - throw new ArangoDBException(e); - } catch (final ExecutionException e) { - throw new ArangoDBException(e); - } catch (final CancellationException e) { + return timeout == null || timeout == 0L ? task.get() : task.get(timeout, TimeUnit.MILLISECONDS); + } catch (final Exception e) { throw new ArangoDBException(e); } } From 24d62ed9682a48b87a0d641917bcb7849247820c Mon Sep 17 00:00:00 2001 From: Mark Vollmary Date: Wed, 7 Nov 2018 20:33:35 +0100 Subject: [PATCH 2/2] Add ArangoGraph#drop(boolean dropCollections) --- ChangeLog.md | 4 ++ docs/Drivers/Java/Reference/Graph/README.md | 8 +++- src/main/java/com/arangodb/ArangoGraph.java | 45 ++++++++++++------- .../arangodb/internal/ArangoGraphImpl.java | 5 +++ .../internal/InternalArangoGraph.java | 10 ++++- .../java/com/arangodb/ArangoGraphTest.java | 28 ++++++++++++ 6 files changed, 82 insertions(+), 18 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 77252bc09..762e52319 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +### Added + +- added `ArangoGraph#drop(boolean dropCollections)` + ### Changed - changed `ArangoDB#timeout` to also set the request timeout when using VelocyStream (issue #230) diff --git a/docs/Drivers/Java/Reference/Graph/README.md b/docs/Drivers/Java/Reference/Graph/README.md index 466893971..d2c9199b3 100644 --- a/docs/Drivers/Java/Reference/Graph/README.md +++ b/docs/Drivers/Java/Reference/Graph/README.md @@ -149,11 +149,17 @@ GraphEntity info = graph.getInfo(); ## ArangoGraph.drop ``` -ArangoGraph.drop() : void +ArangoGraph.drop(boolean dropCollections) : void ``` Deletes the graph from the database. +**Arguments** + +- **dropCollections**: `boolean` + + Drop collections of this graph as well. Collections will only be dropped if they are not used in other graphs. + **Examples** ```Java diff --git a/src/main/java/com/arangodb/ArangoGraph.java b/src/main/java/com/arangodb/ArangoGraph.java index 6d3a4b94e..6679dc153 100644 --- a/src/main/java/com/arangodb/ArangoGraph.java +++ b/src/main/java/com/arangodb/ArangoGraph.java @@ -28,7 +28,7 @@ /** * Interface for operations on ArangoDB graph level. - * + * * @see API Documentation * @author Mark Vollmary */ @@ -36,21 +36,21 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * The the handler of the database the named graph is within - * + * * @return database handler */ public ArangoDatabase db(); /** * The name of the collection - * + * * @return collection name */ public String name(); /** * Checks whether the graph exists - * + * * @return true if the graph exists, otherwise false */ boolean exists() throws ArangoDBException; @@ -58,7 +58,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Creates the graph in the graph module. The creation of a graph requires the name of the graph and a definition of * its edges. - * + * * @see API * Documentation * @param edgeDefinitions @@ -71,7 +71,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Creates the graph in the graph module. The creation of a graph requires the name of the graph and a definition of * its edges. - * + * * @see API * Documentation * @param edgeDefinitions @@ -85,15 +85,28 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Deletes the graph from the database. - * + * * @see API Documentation * @throws ArangoDBException */ void drop() throws ArangoDBException; + /** + * Deletes the graph from the database. + * + * @see API + * Documentation + * @param dropCollections + * Drop collections of this graph as well. Collections will only be + * dropped if they are not used in other graphs. + * @throws ArangoDBException + */ + void drop(boolean dropCollections) throws ArangoDBException; + /** * Retrieves general information about the graph. - * + * * @see API Documentation * @return the definition content of this graph * @throws ArangoDBException @@ -102,7 +115,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Fetches all vertex collections from the graph and returns a list of collection names. - * + * * @see API * Documentation * @return all vertex collections within this graph @@ -113,7 +126,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Adds a vertex collection to the set of collections of the graph. If the collection does not exist, it will be * created. - * + * * @see API * Documentation * @param name @@ -125,7 +138,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Returns a {@code ArangoVertexCollection} instance for the given vertex collection name. - * + * * @param name * Name of the vertex collection * @return collection handler @@ -134,7 +147,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Returns a {@code ArangoEdgeCollection} instance for the given edge collection name. - * + * * @param name * Name of the edge collection * @return collection handler @@ -143,7 +156,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Fetches all edge collections from the graph and returns a list of collection names. - * + * * @see API * Documentation * @return all edge collections within this graph @@ -153,7 +166,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Adds the given edge definition to the graph. - * + * * @see API * Documentation * @param definition @@ -166,7 +179,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Change one specific edge definition. This will modify all occurrences of this definition in all graphs known to * your database - * + * * @see API * Documentation * @param definition @@ -179,7 +192,7 @@ public interface ArangoGraph extends ArangoSerializationAccessor { /** * Remove one edge definition from the graph. This will only remove the edge collection, the vertex collections * remain untouched and can still be used in your queries - * + * * @see API * Documentation diff --git a/src/main/java/com/arangodb/internal/ArangoGraphImpl.java b/src/main/java/com/arangodb/internal/ArangoGraphImpl.java index c06eeabf1..7af6e3efc 100644 --- a/src/main/java/com/arangodb/internal/ArangoGraphImpl.java +++ b/src/main/java/com/arangodb/internal/ArangoGraphImpl.java @@ -70,6 +70,11 @@ public void drop() throws ArangoDBException { executor.execute(dropRequest(), Void.class); } + @Override + public void drop(final boolean dropCollections) throws ArangoDBException { + executor.execute(dropRequest(dropCollections), Void.class); + } + @Override public GraphEntity getInfo() throws ArangoDBException { return executor.execute(getInfoRequest(), getInfoResponseDeserializer()); diff --git a/src/main/java/com/arangodb/internal/InternalArangoGraph.java b/src/main/java/com/arangodb/internal/InternalArangoGraph.java index 6f9f0050a..21748fb15 100644 --- a/src/main/java/com/arangodb/internal/InternalArangoGraph.java +++ b/src/main/java/com/arangodb/internal/InternalArangoGraph.java @@ -63,7 +63,15 @@ public String name() { } protected Request dropRequest() { - return request(db.name(), RequestType.DELETE, PATH_API_GHARIAL, name); + return dropRequest(false); + } + + protected Request dropRequest(final boolean dropCollections) { + final Request request = request(db.name(), RequestType.DELETE, PATH_API_GHARIAL, name); + if (dropCollections) { + request.putQueryParam("dropCollections", dropCollections); + } + return request; } protected Request getInfoRequest() { diff --git a/src/test/java/com/arangodb/ArangoGraphTest.java b/src/test/java/com/arangodb/ArangoGraphTest.java index 4cb59756c..d480f8f37 100644 --- a/src/test/java/com/arangodb/ArangoGraphTest.java +++ b/src/test/java/com/arangodb/ArangoGraphTest.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import org.junit.After; @@ -255,4 +256,31 @@ public void smartGraph() { assertThat(graph.getNumberOfShards(), is(2)); } } + + @Test + public void drop() { + final String edgeCollection = "edge_drop"; + final String vertexCollection = "vertex_drop"; + final String graph = GRAPH_NAME + "_drop"; + final GraphEntity result = db.graph(graph).create(Collections + .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))); + assertThat(result, is(notNullValue())); + db.graph(graph).drop(); + assertThat(db.collection(edgeCollection).exists(), is(true)); + assertThat(db.collection(vertexCollection).exists(), is(true)); + } + + @Test + public void dropPlusDropCollections() { + final String edgeCollection = "edge_dropC"; + final String vertexCollection = "vertex_dropC"; + final String graph = GRAPH_NAME + "_dropC"; + final GraphEntity result = db.graph(graph).create(Collections + .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))); + assertThat(result, is(notNullValue())); + db.graph(graph).drop(true); + assertThat(db.collection(edgeCollection).exists(), is(false)); + assertThat(db.collection(vertexCollection).exists(), is(false)); + } + }
property-keydescriptiondefault value
arangodb.hostsArangoDB hosts127.0.0.1:8529
arangodb.timeoutsocket connect timeout(millisecond)0
arangodb.timeoutconnect & request timeout(millisecond)0
arangodb.userBasic Authentication User
arangodb.passwordBasic Authentication Password
arangodb.useSsluse SSL connectionfalse