Skip to content

Commit 9f95607

Browse files
authored
[DE-60] Deprecate usage of deprecated server API (#440)
* request next cursor batch using POST method instead of PUT * deprecated collection id * deprecated load/unload collection * deprecated DocumentCreateOptions.overwrite() * deprecated minReplicationFactor in favor of writeConcern * deprecated traversal API
1 parent 7a5c01f commit 9f95607

16 files changed

+124
-14
lines changed

src/main/java/com/arangodb/ArangoCollection.java

+4
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
661661
* @throws ArangoDBException
662662
* @see <a href="https://www.arangodb.com/docs/stable/http/collection-modifying.html#load-collection">API
663663
* Documentation</a>
664+
* @deprecated MMFiles only
664665
*/
666+
@Deprecated
665667
CollectionEntity load() throws ArangoDBException;
666668

667669
/**
@@ -672,7 +674,9 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
672674
* @throws ArangoDBException
673675
* @see <a href="https://www.arangodb.com/docs/stable/http/collection-modifying.html#unload-collection">API
674676
* Documentation</a>
677+
* @deprecated MMFiles only
675678
*/
679+
@Deprecated
676680
CollectionEntity unload() throws ArangoDBException;
677681

678682
/**

src/main/java/com/arangodb/async/ArangoCollectionAsync.java

+4
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,9 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
615615
* @return information about the collection
616616
* @see <a href="https://www.arangodb.com/docs/stable/http/collection-modifying.html#load-collection">API
617617
* Documentation</a>
618+
* @deprecated MMFiles only
618619
*/
620+
@Deprecated
619621
CompletableFuture<CollectionEntity> load();
620622

621623
/**
@@ -625,7 +627,9 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
625627
* @return information about the collection
626628
* @see <a href="https://www.arangodb.com/docs/stable/http/collection-modifying.html#unload-collection">API
627629
* Documentation</a>
630+
* @deprecated MMFiles only
628631
*/
632+
@Deprecated
629633
CompletableFuture<CollectionEntity> unload();
630634

631635
/**

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

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public CollectionEntity() {
4141
super();
4242
}
4343

44+
/**
45+
* @deprecated Accessing collections by their internal ID instead of accessing them by name is deprecated and highly
46+
* discouraged. This functionality may be removed in future versions of ArangoDB.
47+
*/
48+
@Deprecated
4449
public String getId() {
4550
return id;
4651
}

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CollectionPropertiesEntity extends CollectionEntity {
3838
private Collection<String> shardKeys;
3939
private final ReplicationFactor replicationFactor;
4040
private final MinReplicationFactor minReplicationFactor;
41-
41+
private Integer writeConcern;
4242
private String shardingStrategy; // cluster option
4343
private String smartJoinAttribute; // enterprise option
4444

@@ -119,14 +119,30 @@ public void setReplicationFactor(final Integer replicationFactor) {
119119
this.replicationFactor.setReplicationFactor(replicationFactor);
120120
}
121121

122+
/**
123+
* @deprecated use {@link #getWriteConcern()} instead
124+
*/
125+
@Deprecated
122126
public Integer getMinReplicationFactor() {
123127
return minReplicationFactor.getMinReplicationFactor();
124128
}
125129

130+
/**
131+
* @deprecated use {@link #setWriteConcern(Integer)} instead
132+
*/
133+
@Deprecated
126134
public void setMinReplicationFactor(final Integer minReplicationFactor) {
127135
this.minReplicationFactor.setMinReplicationFactor(minReplicationFactor);
128136
}
129137

138+
public Integer getWriteConcern() {
139+
return writeConcern;
140+
}
141+
142+
public void setWriteConcern(final Integer writeConcern) {
143+
this.writeConcern = writeConcern;
144+
}
145+
130146
/**
131147
* @return whether the collection is a satellite collection. Only in an enterprise cluster setup (else returning null).
132148
*/

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

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class GraphEntity implements Entity {
4141
private String smartGraphAttribute;
4242
private ReplicationFactor replicationFactor;
4343
private Integer minReplicationFactor;
44+
private Integer writeConcern;
4445

4546
public String getName() {
4647
return name != null ? name : _key;
@@ -74,10 +75,18 @@ public Boolean getSatellite() {
7475
return this.replicationFactor.getSatellite();
7576
}
7677

78+
/**
79+
* @deprecated use {@link #getWriteConcern()} instead
80+
*/
81+
@Deprecated
7782
public Integer getMinReplicationFactor() {
7883
return minReplicationFactor;
7984
}
8085

86+
public Integer getWriteConcern() {
87+
return writeConcern;
88+
}
89+
8190
public String getSmartGraphAttribute() {
8291
return smartGraphAttribute;
8392
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@
2020

2121
package com.arangodb.entity;
2222

23+
import com.arangodb.model.CollectionCreateOptions;
24+
2325
/**
2426
* @author Heiko Kernbach
27+
* @deprecated use {@link CollectionCreateOptions#writeConcern(Integer)} instead
2528
*/
29+
@Deprecated
2630
public class MinReplicationFactor {
2731

2832
private Integer minReplicationFactor;

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

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @see <a href= "https://www.arangodb.com/docs/stable/http/traversal.html#executes-a-traversal">API
2828
* Documentation</a>
2929
*/
30+
@Deprecated
3031
public class PathEntity<V, E> implements Entity {
3132

3233
private Collection<E> edges;

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

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @see <a href= "https://www.arangodb.com/docs/stable/http/traversal.html#executes-a-traversal">API
2828
* Documentation</a>
2929
*/
30+
@Deprecated
3031
public class TraversalEntity<V, E> implements Entity {
3132

3233
private Collection<V> vertices;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ protected Request queryRequest(
186186

187187
protected Request queryNextRequest(final String id, final AqlQueryOptions options, Map<String, String> meta) {
188188

189-
final Request request = request(dbName, RequestType.PUT, PATH_API_CURSOR, id);
189+
final Request request = request(dbName, RequestType.POST, PATH_API_CURSOR, id);
190190

191191
if (meta != null) {
192192
request.getHeaderParam().putAll(meta);

src/main/java/com/arangodb/model/CollectionCreateOptions.java

+24
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class CollectionCreateOptions {
3737
private Long journalSize;
3838
private final ReplicationFactor replicationFactor;
3939
private final MinReplicationFactor minReplicationFactor;
40+
private Integer writeConcern;
4041
private KeyOptions keyOptions;
4142
private Boolean waitForSync;
4243
private Boolean doCompact;
@@ -89,6 +90,10 @@ public Integer getReplicationFactor() {
8990
return replicationFactor.getReplicationFactor();
9091
}
9192

93+
/**
94+
* @deprecated use {@link #getWriteConcern()} instead
95+
*/
96+
@Deprecated
9297
public Integer getMinReplicationFactor() {
9398
return minReplicationFactor.getMinReplicationFactor();
9499
}
@@ -118,12 +123,31 @@ public CollectionCreateOptions replicationFactor(final Integer replicationFactor
118123
* are allowed. Having `minReplicationFactor > 1` requires additional insync copies on follower servers
119124
* to allow writes.
120125
* @return options
126+
* @deprecated use {@link #writeConcern(Integer)} instead
121127
*/
128+
@Deprecated
122129
public CollectionCreateOptions minReplicationFactor(final Integer minReplicationFactor) {
123130
this.minReplicationFactor.setMinReplicationFactor(minReplicationFactor);
124131
return this;
125132
}
126133

134+
public Integer getWriteConcern() {
135+
return writeConcern;
136+
}
137+
138+
/**
139+
* @param writeConcern write concern for this collection (default: 1).
140+
* It determines how many copies of each shard are required to be in sync on the different
141+
* DB-Servers. If there are less then these many copies in the cluster a shard will refuse to
142+
* write. Writes to shards with enough up-to-date copies will succeed at the same time however.
143+
* The value of writeConcern can not be larger than replicationFactor. (cluster only)
144+
* @return options
145+
*/
146+
public CollectionCreateOptions writeConcern(final Integer writeConcern) {
147+
this.writeConcern = writeConcern;
148+
return this;
149+
}
150+
127151
public Boolean getSatellite() {
128152
return replicationFactor.getSatellite();
129153
}

src/main/java/com/arangodb/model/DocumentCreateOptions.java

+2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public Boolean getOverwrite() {
9393
* the old document.
9494
* @return options
9595
* @since ArangoDB 3.4
96+
* @deprecated use {@link #overwriteMode(OverwriteMode)} instead
9697
*/
98+
@Deprecated
9799
public DocumentCreateOptions overwrite(final Boolean overwrite) {
98100
this.overwrite = overwrite;
99101
return this;

src/main/java/com/arangodb/model/GraphCreateOptions.java

+40
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ public GraphCreateOptions satellite(final Boolean satellite) {
143143
return this;
144144
}
145145

146+
/**
147+
* @deprecated use {@link #getWriteConcern()} instead
148+
*/
149+
@Deprecated
146150
public Integer getMinReplicationFactor() {
147151
return getOptions().getMinReplicationFactor();
148152
}
@@ -157,12 +161,31 @@ public Integer getMinReplicationFactor() {
157161
* are allowed. Having `minReplicationFactor > 1` requires additional insync copies on follower servers
158162
* to allow writes.
159163
* @return options
164+
* @deprecated use {@link #writeConcern(Integer)} instead
160165
*/
166+
@Deprecated
161167
public GraphCreateOptions minReplicationFactor(final Integer minReplicationFactor) {
162168
getOptions().setMinReplicationFactor(minReplicationFactor);
163169
return this;
164170
}
165171

172+
public Integer getWriteConcern() {
173+
return getOptions().getWriteConcern();
174+
}
175+
176+
/**
177+
* @param writeConcern Write concern for new collections in the graph.
178+
* It determines how many copies of each shard are required to be in sync on the different
179+
* DB-Servers. If there are less then these many copies in the cluster a shard will refuse to
180+
* write. Writes to shards with enough up-to-date copies will succeed at the same time however.
181+
* The value of writeConcern can not be larger than replicationFactor. (cluster only)
182+
* @return options
183+
*/
184+
public GraphCreateOptions writeConcern(final Integer writeConcern) {
185+
getOptions().setWriteConcern(writeConcern);
186+
return this;
187+
}
188+
166189
public Integer getNumberOfShards() {
167190
return getOptions().getNumberOfShards();
168191
}
@@ -216,6 +239,7 @@ private SmartOptions getOptions() {
216239
public static class SmartOptions {
217240
private ReplicationFactor replicationFactor;
218241
private Integer minReplicationFactor;
242+
private Integer writeConcern;
219243
private Integer numberOfShards;
220244
private String smartGraphAttribute;
221245
private Boolean isDisjoint;
@@ -242,14 +266,30 @@ public void setSatellite(final Boolean satellite) {
242266
replicationFactor.setSatellite(satellite);
243267
}
244268

269+
/**
270+
* @deprecated use {{@link #getWriteConcern()}} instead
271+
*/
272+
@Deprecated
245273
public Integer getMinReplicationFactor() {
246274
return minReplicationFactor;
247275
}
248276

277+
/**
278+
* @deprecated use {{@link #setWriteConcern(Integer)}} instead
279+
*/
280+
@Deprecated
249281
public void setMinReplicationFactor(final Integer minReplicationFactor) {
250282
this.minReplicationFactor = minReplicationFactor;
251283
}
252284

285+
public Integer getWriteConcern() {
286+
return writeConcern;
287+
}
288+
289+
public void setWriteConcern(final Integer writeConcern) {
290+
this.writeConcern = writeConcern;
291+
}
292+
253293
public Integer getNumberOfShards() {
254294
return numberOfShards;
255295
}

src/test/java/com/arangodb/ArangoDatabaseTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,18 @@ void createCollectionWithReplicationFactor(ArangoDatabase db) {
122122

123123
@ParameterizedTest(name = "{index}")
124124
@MethodSource("dbs")
125-
void createCollectionWithMinReplicationFactor(ArangoDatabase db) {
125+
void createCollectionWithWriteConcern(ArangoDatabase db) {
126126
assumeTrue(isAtLeastVersion(3, 5));
127127
assumeTrue(isCluster());
128128

129129
String name = "collection-" + rnd();
130130
final CollectionEntity result = db.createCollection(name,
131-
new CollectionCreateOptions().replicationFactor(2).minReplicationFactor(2));
131+
new CollectionCreateOptions().replicationFactor(2).writeConcern(2));
132132
assertThat(result).isNotNull();
133133
assertThat(result.getId()).isNotNull();
134134
CollectionPropertiesEntity props = db.collection(name).getProperties();
135135
assertThat(props.getReplicationFactor()).isEqualTo(2);
136-
assertThat(props.getMinReplicationFactor()).isEqualTo(2);
136+
assertThat(props.getWriteConcern()).isEqualTo(2);
137137
assertThat(props.getSatellite()).isNull();
138138
}
139139

src/test/java/com/arangodb/ArangoGraphTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ void exists(ArangoGraph graph) {
8787

8888
@ParameterizedTest(name = "{index}")
8989
@MethodSource("dbs")
90-
void createWithReplicationAndMinReplicationFactor(ArangoDatabase db) {
90+
void createWithReplicationAndWriteConcern(ArangoDatabase db) {
9191
assumeTrue(isAtLeastVersion(3, 5));
9292
assumeTrue(isCluster());
9393

9494
final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>();
95-
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2));
95+
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).writeConcern(2));
9696
assertThat(graph).isNotNull();
9797
assertThat(graph.getName()).isEqualTo(GRAPH_NAME + "_1");
98-
assertThat(graph.getMinReplicationFactor()).isEqualTo(2);
98+
assertThat(graph.getWriteConcern()).isEqualTo(2);
9999
assertThat(graph.getReplicationFactor()).isEqualTo(2);
100100
db.graph(GRAPH_NAME + "_1").drop();
101101
}

src/test/java/com/arangodb/async/ArangoDatabaseTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,16 @@ void createCollectionWithReplicationFactor() throws InterruptedException, Execut
123123
}
124124

125125
@Test
126-
void createCollectionWithMinReplicationFactor() throws ExecutionException, InterruptedException {
126+
void createCollectionWithWriteConcern() throws ExecutionException, InterruptedException {
127127
assumeTrue(isAtLeastVersion(3, 5));
128128
assumeTrue(isCluster());
129129

130130
final CollectionEntity result = db.createCollection(COLLECTION_NAME,
131-
new CollectionCreateOptions().replicationFactor(2).minReplicationFactor(2)).get();
131+
new CollectionCreateOptions().replicationFactor(2).writeConcern(2)).get();
132132
assertThat(result).isNotNull();
133133
assertThat(result.getId()).isNotNull();
134134
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getReplicationFactor()).isEqualTo(2);
135-
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getMinReplicationFactor()).isEqualTo(2);
135+
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getWriteConcern()).isEqualTo(2);
136136
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getSatellite()).isNull();
137137
db.collection(COLLECTION_NAME).drop();
138138
}

src/test/java/com/arangodb/async/ArangoGraphTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ void create() throws InterruptedException, ExecutionException {
9494
}
9595

9696
@Test
97-
void createWithReplicationAndMinReplicationFactor() throws ExecutionException, InterruptedException {
97+
void createWithReplicationAndWriteConcern() throws ExecutionException, InterruptedException {
9898
assumeTrue(isAtLeastVersion(3, 5));
9999
assumeTrue(isCluster());
100100
final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>();
101-
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2)).get();
101+
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).writeConcern(2)).get();
102102
assertThat(graph).isNotNull();
103103
assertThat(graph.getName()).isEqualTo(GRAPH_NAME + "_1");
104-
assertThat(graph.getMinReplicationFactor()).isEqualTo(2);
104+
assertThat(graph.getWriteConcern()).isEqualTo(2);
105105
assertThat(graph.getReplicationFactor()).isEqualTo(2);
106106
db.graph(GRAPH_NAME + "_1").drop();
107107
}

0 commit comments

Comments
 (0)