Skip to content

Commit 92a6749

Browse files
committed
Merge branch 'master' of github.com:arangodb/arangodb-java-driver
2 parents 0af2e3c + c05c3b7 commit 92a6749

File tree

10 files changed

+219
-8
lines changed

10 files changed

+219
-8
lines changed

docs/Drivers/Java/Reference/Database/StreamTransactions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ Gets information about a Stream Transaction.
2929
transaction id
3030

3131

32+
## ArangoDatabase.getStreamTransactions
33+
34+
`ArangoDatabase.getStreamTransactions() : Collection<TransactionEntity>`
35+
36+
Gets all the currently running Stream Transactions.
37+
38+
3239
## ArangoDatabase.commitStreamTransaction
3340

3441
`ArangoDatabase.commitStreamTransaction(String id) : StreamTransactionEntity`

docs/Drivers/Java/Reference/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [Queries](Database/Queries.md)
99
- [AQL User Functions](Database/AqlUserFunctions.md)
1010
- [Transactions](Database/Transactions.md)
11+
- [Stream Transactions](Database/StreamTransactions.md)
1112
- [Graph Access](Database/GraphAccess.md)
1213
- [HTTP Routes](Database/HttpRoutes.md)
1314
- [Collection](Collection/README.md)
@@ -18,6 +19,7 @@
1819
- [View](View/README.md)
1920
- [View Manipulation](View/ViewManipulation.md)
2021
- [ArangoSearch Views](View/ArangoSearch.md)
22+
- [Analyzers](View/Analyzers.md)
2123
- [Cursor](Cursor.md)
2224
- [Graph](Graph/README.md)
2325
- [Vertex Collection](Graph/VertexCollection.md)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Analyzers
2+
3+
[HTTP Interface for Analyzers](https://www.arangodb.com/docs/devel/http/analyzers.html).
4+
5+
6+
## Types
7+
8+
- **AnalyzerEntity**
9+
10+
- **name**: `String`
11+
12+
The analyzer name.
13+
14+
- **type**: `AnalyzerType`
15+
16+
The analyzer type. Can be one of: `identity`, `delimiter`, `stem`, `norm`, `ngram`, `text`
17+
18+
- **properties**: `Map<String, Object>`
19+
20+
The properties used to configure the specified type. Value may be a string, an object or null. The default value is null.
21+
22+
- **features**: `Set<AnalyzerFeature>`
23+
24+
The set of features to set on the analyzer generated fields. The default value is an empty array.
25+
Values can be: `frequency`, `norm`, `position`
26+
27+
28+
## ArangoDatabase.createArangoSearch
29+
30+
`ArangoDatabase.createAnalyzer(AnalyzerEntity options) : AnalyzerEntity`
31+
32+
Creates an Analyzer.
33+
34+
35+
## ArangoDatabase.getAnalyzer
36+
37+
`ArangoDatabase.getAnalyzer(String name) : AnalyzerEntity`
38+
39+
Gets information about an Analyzer
40+
41+
**Arguments**
42+
43+
- **name**: `String`
44+
45+
The name of the analyzer
46+
47+
48+
## ArangoDatabase.getAnalyzers
49+
50+
`ArangoDatabase.getAnalyzers() : Collection<AnalyzerEntity>`
51+
52+
Retrieves all analyzers definitions.
53+
54+
55+
## ArangoDatabase.deleteAnalyzer
56+
57+
`ArangoDatabase.deleteAnalyzer(String name) : void`
58+
59+
Deletes an Analyzer.
60+
61+
**Arguments**
62+
63+
- **name**: `String`
64+
65+
The name of the analyzer
66+
67+
68+
## ArangoDatabase.deleteAnalyzer
69+
70+
`ArangoDatabase.deleteAnalyzer(String name, AnalyzerDeleteOptions options) : void`
71+
72+
Deletes an Analyzer.
73+
74+
**Arguments**
75+
76+
- **name**: `String`
77+
78+
The name of the analyzer
79+
80+
- **options**: `AnalyzerDeleteOptions`
81+
82+
- **force**: `Boolean`
83+
84+
The analyzer configuration should be removed even if it is in-use. The default value is false.

src/main/java/com/arangodb/ArangoDatabase.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,17 @@ GraphEntity createGraph(String name, Collection<EdgeDefinition> edgeDefinitions,
577577
*/
578578
StreamTransactionEntity getStreamTransaction(String id) throws ArangoDBException;
579579

580+
/**
581+
* Gets all the currently running Stream Transactions.
582+
*
583+
* @return all the currently running Stream Transactions
584+
* @throws ArangoDBException
585+
* @see <a href="https://docs.arangodb.com/current/HTTP/transaction-stream-transaction.html#list-currently-ongoing-transactions">
586+
* API Documentation</a>
587+
* @since ArangoDB 3.5.0
588+
*/
589+
Collection<TransactionEntity> getStreamTransactions() throws ArangoDBException;
590+
580591
/**
581592
* Commits a Stream Transaction.
582593
*

src/main/java/com/arangodb/entity/StreamTransactionEntity.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ public class StreamTransactionEntity implements Entity {
3131
private String id;
3232
private StreamTransactionStatus status;
3333

34-
public enum StreamTransactionStatus {
35-
running, committed, aborted
36-
}
37-
3834
public String getId() {
3935
return id;
4036
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
/**
24+
* @author Michele Rastelli
25+
*/
26+
public enum StreamTransactionStatus {
27+
running, committed, aborted
28+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
/**
24+
* @author Michele Rastelli
25+
* @see <a href=
26+
* "https://docs.arangodb.com/current/HTTP/transaction-stream-transaction.html#list-currently-ongoing-transactions</a>
27+
* @since ArangoDB 3.5.0
28+
*/
29+
public class TransactionEntity implements Entity {
30+
31+
private String id;
32+
private StreamTransactionStatus state;
33+
34+
public String getId() {
35+
return id;
36+
}
37+
38+
public StreamTransactionStatus getStatus() {
39+
return state;
40+
}
41+
42+
}

src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ public StreamTransactionEntity getStreamTransaction(String id) throws ArangoDBEx
351351
return executor.execute(getStreamTransactionRequest(id), streamTransactionResponseDeserializer());
352352
}
353353

354+
@Override
355+
public Collection<TransactionEntity> getStreamTransactions() throws ArangoDBException {
356+
return executor.execute(getStreamTransactionsRequest(), transactionsResponseDeserializer());
357+
}
358+
354359
@Override
355360
public StreamTransactionEntity commitStreamTransaction(String id) throws ArangoDBException {
356361
return executor.execute(commitStreamTransactionRequest(id), streamTransactionResponseDeserializer());

src/main/java/com/arangodb/internal/InternalArangoDatabase.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,25 @@ protected Request abortStreamTransactionRequest(String id) {
387387
return request(name, RequestType.DELETE, PATH_API_TRANSACTION, id);
388388
}
389389

390+
protected Request getStreamTransactionsRequest() {
391+
return request(name, RequestType.GET, PATH_API_TRANSACTION);
392+
}
393+
390394
protected Request getStreamTransactionRequest(String id) {
391395
return request(name, RequestType.GET, PATH_API_TRANSACTION, id);
392396
}
393397

398+
protected ResponseDeserializer<Collection<TransactionEntity>> transactionsResponseDeserializer() {
399+
return new ResponseDeserializer<Collection<TransactionEntity>>() {
400+
@Override
401+
public Collection<TransactionEntity> deserialize(final Response response) throws VPackException {
402+
final VPackSlice result = response.getBody().get("transactions");
403+
return util().deserialize(result, new Type<Collection<TransactionEntity>>() {
404+
}.getType());
405+
}
406+
};
407+
}
408+
394409
protected Request commitStreamTransactionRequest(String id) {
395410
return request(name, RequestType.PUT, PATH_API_TRANSACTION, id);
396411
}

src/test/java/com/arangodb/StreamTransactionTest.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void beginStreamTransaction() {
7373

7474
StreamTransactionEntity tx = db.beginStreamTransaction(null);
7575
assertThat(tx.getId(), is(notNullValue()));
76-
assertThat(tx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.running));
76+
assertThat(tx.getStatus(), is(StreamTransactionStatus.running));
7777
db.abortStreamTransaction(tx.getId());
7878
}
7979

@@ -97,7 +97,7 @@ public void abortStreamTransaction() {
9797

9898
assertThat(abortedTx.getId(), is(notNullValue()));
9999
assertThat(abortedTx.getId(), is(begunTx.getId()));
100-
assertThat(abortedTx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.aborted));
100+
assertThat(abortedTx.getStatus(), is(StreamTransactionStatus.aborted));
101101
}
102102

103103
@Test
@@ -151,7 +151,7 @@ public void getStreamTransaction() {
151151

152152
assertThat(gotTx.getId(), is(notNullValue()));
153153
assertThat(gotTx.getId(), is(createdTx.getId()));
154-
assertThat(gotTx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.running));
154+
assertThat(gotTx.getStatus(), is(StreamTransactionStatus.running));
155155

156156
db.abortStreamTransaction(createdTx.getId());
157157
}
@@ -185,7 +185,7 @@ public void commitStreamTransaction() {
185185

186186
assertThat(committedTx.getId(), is(notNullValue()));
187187
assertThat(committedTx.getId(), is(createdTx.getId()));
188-
assertThat(committedTx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.committed));
188+
assertThat(committedTx.getStatus(), is(StreamTransactionStatus.committed));
189189
}
190190

191191
@Test
@@ -705,4 +705,25 @@ public void nextCursor() {
705705
db.abortStreamTransaction(tx.getId());
706706
}
707707

708+
@Test
709+
public void getStreamTransactions() {
710+
assumeTrue(requireSingleServer());
711+
assumeTrue(requireVersion(3, 5));
712+
assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb));
713+
714+
StreamTransactionEntity tx1 = db.beginStreamTransaction(null);
715+
StreamTransactionEntity tx2 = db.beginStreamTransaction(null);
716+
717+
List<String> createdIds = Arrays.asList(tx1.getId(), tx2.getId());
718+
Set<TransactionEntity> gotTxs = db.getStreamTransactions().stream().
719+
filter(it -> createdIds.contains(it.getId())).collect(Collectors.toSet());
720+
721+
assertThat(gotTxs.size(), is(createdIds.size()));
722+
assertThat(gotTxs.stream()
723+
.allMatch(it -> it.getStatus() == StreamTransactionStatus.running), is(true));
724+
725+
db.abortStreamTransaction(tx1.getId());
726+
db.abortStreamTransaction(tx2.getId());
727+
}
728+
708729
}

0 commit comments

Comments
 (0)