diff --git a/docs/Drivers/Java/Reference/Database/StreamTransactions.md b/docs/Drivers/Java/Reference/Database/StreamTransactions.md index 244bd6ae6..dfd6f2e18 100644 --- a/docs/Drivers/Java/Reference/Database/StreamTransactions.md +++ b/docs/Drivers/Java/Reference/Database/StreamTransactions.md @@ -29,6 +29,13 @@ Gets information about a Stream Transaction. transaction id +## ArangoDatabase.getStreamTransactions + +`ArangoDatabase.getStreamTransactions() : Collection` + +Gets all the currently running Stream Transactions. + + ## ArangoDatabase.commitStreamTransaction `ArangoDatabase.commitStreamTransaction(String id) : StreamTransactionEntity` diff --git a/docs/Drivers/Java/Reference/README.md b/docs/Drivers/Java/Reference/README.md index c35bf9b2a..ea6307f54 100644 --- a/docs/Drivers/Java/Reference/README.md +++ b/docs/Drivers/Java/Reference/README.md @@ -8,6 +8,7 @@ - [Queries](Database/Queries.md) - [AQL User Functions](Database/AqlUserFunctions.md) - [Transactions](Database/Transactions.md) + - [Stream Transactions](Database/StreamTransactions.md) - [Graph Access](Database/GraphAccess.md) - [HTTP Routes](Database/HttpRoutes.md) - [Collection](Collection/README.md) @@ -18,6 +19,7 @@ - [View](View/README.md) - [View Manipulation](View/ViewManipulation.md) - [ArangoSearch Views](View/ArangoSearch.md) + - [Analyzers](View/Analyzers.md) - [Cursor](Cursor.md) - [Graph](Graph/README.md) - [Vertex Collection](Graph/VertexCollection.md) diff --git a/docs/Drivers/Java/Reference/View/Analyzers.md b/docs/Drivers/Java/Reference/View/Analyzers.md new file mode 100644 index 000000000..543a9bd48 --- /dev/null +++ b/docs/Drivers/Java/Reference/View/Analyzers.md @@ -0,0 +1,84 @@ +# Analyzers + +[HTTP Interface for Analyzers](https://www.arangodb.com/docs/devel/http/analyzers.html). + + +## Types + +- **AnalyzerEntity** + + - **name**: `String` + + The analyzer name. + + - **type**: `AnalyzerType` + + The analyzer type. Can be one of: `identity`, `delimiter`, `stem`, `norm`, `ngram`, `text` + + - **properties**: `Map` + + The properties used to configure the specified type. Value may be a string, an object or null. The default value is null. + + - **features**: `Set` + + The set of features to set on the analyzer generated fields. The default value is an empty array. + Values can be: `frequency`, `norm`, `position` + + +## ArangoDatabase.createArangoSearch + +`ArangoDatabase.createAnalyzer(AnalyzerEntity options) : AnalyzerEntity` + +Creates an Analyzer. + + +## ArangoDatabase.getAnalyzer + +`ArangoDatabase.getAnalyzer(String name) : AnalyzerEntity` + +Gets information about an Analyzer + +**Arguments** + +- **name**: `String` + + The name of the analyzer + + +## ArangoDatabase.getAnalyzers + +`ArangoDatabase.getAnalyzers() : Collection` + +Retrieves all analyzers definitions. + + +## ArangoDatabase.deleteAnalyzer + +`ArangoDatabase.deleteAnalyzer(String name) : void` + +Deletes an Analyzer. + +**Arguments** + +- **name**: `String` + + The name of the analyzer + + +## ArangoDatabase.deleteAnalyzer + +`ArangoDatabase.deleteAnalyzer(String name, AnalyzerDeleteOptions options) : void` + +Deletes an Analyzer. + +**Arguments** + +- **name**: `String` + + The name of the analyzer + +- **options**: `AnalyzerDeleteOptions` + + - **force**: `Boolean` + + The analyzer configuration should be removed even if it is in-use. The default value is false. diff --git a/src/main/java/com/arangodb/ArangoDatabase.java b/src/main/java/com/arangodb/ArangoDatabase.java index 0df415007..a1e43f6d2 100644 --- a/src/main/java/com/arangodb/ArangoDatabase.java +++ b/src/main/java/com/arangodb/ArangoDatabase.java @@ -577,6 +577,17 @@ GraphEntity createGraph(String name, Collection edgeDefinitions, */ StreamTransactionEntity getStreamTransaction(String id) throws ArangoDBException; + /** + * Gets all the currently running Stream Transactions. + * + * @return all the currently running Stream Transactions + * @throws ArangoDBException + * @see + * API Documentation + * @since ArangoDB 3.5.0 + */ + Collection getStreamTransactions() throws ArangoDBException; + /** * Commits a Stream Transaction. * diff --git a/src/main/java/com/arangodb/entity/StreamTransactionEntity.java b/src/main/java/com/arangodb/entity/StreamTransactionEntity.java index 948a7b15c..0a7a808dc 100644 --- a/src/main/java/com/arangodb/entity/StreamTransactionEntity.java +++ b/src/main/java/com/arangodb/entity/StreamTransactionEntity.java @@ -31,10 +31,6 @@ public class StreamTransactionEntity implements Entity { private String id; private StreamTransactionStatus status; - public enum StreamTransactionStatus { - running, committed, aborted - } - public String getId() { return id; } diff --git a/src/main/java/com/arangodb/entity/StreamTransactionStatus.java b/src/main/java/com/arangodb/entity/StreamTransactionStatus.java new file mode 100644 index 000000000..fc8ce7b0b --- /dev/null +++ b/src/main/java/com/arangodb/entity/StreamTransactionStatus.java @@ -0,0 +1,28 @@ +/* + * DISCLAIMER + * + * Copyright 2016 ArangoDB GmbH, Cologne, Germany + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright holder is ArangoDB GmbH, Cologne, Germany + */ + +package com.arangodb.entity; + +/** + * @author Michele Rastelli + */ +public enum StreamTransactionStatus { + running, committed, aborted +} diff --git a/src/main/java/com/arangodb/entity/TransactionEntity.java b/src/main/java/com/arangodb/entity/TransactionEntity.java new file mode 100644 index 000000000..d2b85189b --- /dev/null +++ b/src/main/java/com/arangodb/entity/TransactionEntity.java @@ -0,0 +1,42 @@ +/* + * DISCLAIMER + * + * Copyright 2016 ArangoDB GmbH, Cologne, Germany + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright holder is ArangoDB GmbH, Cologne, Germany + */ + +package com.arangodb.entity; + +/** + * @author Michele Rastelli + * @see + * @since ArangoDB 3.5.0 + */ +public class TransactionEntity implements Entity { + + private String id; + private StreamTransactionStatus state; + + public String getId() { + return id; + } + + public StreamTransactionStatus getStatus() { + return state; + } + +} diff --git a/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java b/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java index 047127ca0..cc5880d82 100644 --- a/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java +++ b/src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java @@ -351,6 +351,11 @@ public StreamTransactionEntity getStreamTransaction(String id) throws ArangoDBEx return executor.execute(getStreamTransactionRequest(id), streamTransactionResponseDeserializer()); } + @Override + public Collection getStreamTransactions() throws ArangoDBException { + return executor.execute(getStreamTransactionsRequest(), transactionsResponseDeserializer()); + } + @Override public StreamTransactionEntity commitStreamTransaction(String id) throws ArangoDBException { return executor.execute(commitStreamTransactionRequest(id), streamTransactionResponseDeserializer()); diff --git a/src/main/java/com/arangodb/internal/InternalArangoDatabase.java b/src/main/java/com/arangodb/internal/InternalArangoDatabase.java index e8e7c7ab3..5afa31189 100644 --- a/src/main/java/com/arangodb/internal/InternalArangoDatabase.java +++ b/src/main/java/com/arangodb/internal/InternalArangoDatabase.java @@ -387,10 +387,25 @@ protected Request abortStreamTransactionRequest(String id) { return request(name, RequestType.DELETE, PATH_API_TRANSACTION, id); } + protected Request getStreamTransactionsRequest() { + return request(name, RequestType.GET, PATH_API_TRANSACTION); + } + protected Request getStreamTransactionRequest(String id) { return request(name, RequestType.GET, PATH_API_TRANSACTION, id); } + protected ResponseDeserializer> transactionsResponseDeserializer() { + return new ResponseDeserializer>() { + @Override + public Collection deserialize(final Response response) throws VPackException { + final VPackSlice result = response.getBody().get("transactions"); + return util().deserialize(result, new Type>() { + }.getType()); + } + }; + } + protected Request commitStreamTransactionRequest(String id) { return request(name, RequestType.PUT, PATH_API_TRANSACTION, id); } diff --git a/src/test/java/com/arangodb/StreamTransactionTest.java b/src/test/java/com/arangodb/StreamTransactionTest.java index 71f498ecd..55e326cde 100644 --- a/src/test/java/com/arangodb/StreamTransactionTest.java +++ b/src/test/java/com/arangodb/StreamTransactionTest.java @@ -73,7 +73,7 @@ public void beginStreamTransaction() { StreamTransactionEntity tx = db.beginStreamTransaction(null); assertThat(tx.getId(), is(notNullValue())); - assertThat(tx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.running)); + assertThat(tx.getStatus(), is(StreamTransactionStatus.running)); db.abortStreamTransaction(tx.getId()); } @@ -97,7 +97,7 @@ public void abortStreamTransaction() { assertThat(abortedTx.getId(), is(notNullValue())); assertThat(abortedTx.getId(), is(begunTx.getId())); - assertThat(abortedTx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.aborted)); + assertThat(abortedTx.getStatus(), is(StreamTransactionStatus.aborted)); } @Test @@ -151,7 +151,7 @@ public void getStreamTransaction() { assertThat(gotTx.getId(), is(notNullValue())); assertThat(gotTx.getId(), is(createdTx.getId())); - assertThat(gotTx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.running)); + assertThat(gotTx.getStatus(), is(StreamTransactionStatus.running)); db.abortStreamTransaction(createdTx.getId()); } @@ -185,7 +185,7 @@ public void commitStreamTransaction() { assertThat(committedTx.getId(), is(notNullValue())); assertThat(committedTx.getId(), is(createdTx.getId())); - assertThat(committedTx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.committed)); + assertThat(committedTx.getStatus(), is(StreamTransactionStatus.committed)); } @Test @@ -705,4 +705,25 @@ public void nextCursor() { db.abortStreamTransaction(tx.getId()); } + @Test + public void getStreamTransactions() { + assumeTrue(requireSingleServer()); + assumeTrue(requireVersion(3, 5)); + assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + + StreamTransactionEntity tx1 = db.beginStreamTransaction(null); + StreamTransactionEntity tx2 = db.beginStreamTransaction(null); + + List createdIds = Arrays.asList(tx1.getId(), tx2.getId()); + Set gotTxs = db.getStreamTransactions().stream(). + filter(it -> createdIds.contains(it.getId())).collect(Collectors.toSet()); + + assertThat(gotTxs.size(), is(createdIds.size())); + assertThat(gotTxs.stream() + .allMatch(it -> it.getStatus() == StreamTransactionStatus.running), is(true)); + + db.abortStreamTransaction(tx1.getId()); + db.abortStreamTransaction(tx2.getId()); + } + }