Skip to content

Commit

Permalink
[DE-60] Deprecate usage of deprecated server API (#440)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rashtao authored Jun 7, 2022
1 parent 7a5c01f commit 9f95607
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/arangodb/ArangoCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,9 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
* @throws ArangoDBException
* @see <a href="https://www.arangodb.com/docs/stable/http/collection-modifying.html#load-collection">API
* Documentation</a>
* @deprecated MMFiles only
*/
@Deprecated
CollectionEntity load() throws ArangoDBException;

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

/**
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/arangodb/async/ArangoCollectionAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
* @return information about the collection
* @see <a href="https://www.arangodb.com/docs/stable/http/collection-modifying.html#load-collection">API
* Documentation</a>
* @deprecated MMFiles only
*/
@Deprecated
CompletableFuture<CollectionEntity> load();

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

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/arangodb/entity/CollectionEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public CollectionEntity() {
super();
}

/**
* @deprecated Accessing collections by their internal ID instead of accessing them by name is deprecated and highly
* discouraged. This functionality may be removed in future versions of ArangoDB.
*/
@Deprecated
public String getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CollectionPropertiesEntity extends CollectionEntity {
private Collection<String> shardKeys;
private final ReplicationFactor replicationFactor;
private final MinReplicationFactor minReplicationFactor;

private Integer writeConcern;
private String shardingStrategy; // cluster option
private String smartJoinAttribute; // enterprise option

Expand Down Expand Up @@ -119,14 +119,30 @@ public void setReplicationFactor(final Integer replicationFactor) {
this.replicationFactor.setReplicationFactor(replicationFactor);
}

/**
* @deprecated use {@link #getWriteConcern()} instead
*/
@Deprecated
public Integer getMinReplicationFactor() {
return minReplicationFactor.getMinReplicationFactor();
}

/**
* @deprecated use {@link #setWriteConcern(Integer)} instead
*/
@Deprecated
public void setMinReplicationFactor(final Integer minReplicationFactor) {
this.minReplicationFactor.setMinReplicationFactor(minReplicationFactor);
}

public Integer getWriteConcern() {
return writeConcern;
}

public void setWriteConcern(final Integer writeConcern) {
this.writeConcern = writeConcern;
}

/**
* @return whether the collection is a satellite collection. Only in an enterprise cluster setup (else returning null).
*/
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/arangodb/entity/GraphEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class GraphEntity implements Entity {
private String smartGraphAttribute;
private ReplicationFactor replicationFactor;
private Integer minReplicationFactor;
private Integer writeConcern;

public String getName() {
return name != null ? name : _key;
Expand Down Expand Up @@ -74,10 +75,18 @@ public Boolean getSatellite() {
return this.replicationFactor.getSatellite();
}

/**
* @deprecated use {@link #getWriteConcern()} instead
*/
@Deprecated
public Integer getMinReplicationFactor() {
return minReplicationFactor;
}

public Integer getWriteConcern() {
return writeConcern;
}

public String getSmartGraphAttribute() {
return smartGraphAttribute;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/arangodb/entity/MinReplicationFactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@

package com.arangodb.entity;

import com.arangodb.model.CollectionCreateOptions;

/**
* @author Heiko Kernbach
* @deprecated use {@link CollectionCreateOptions#writeConcern(Integer)} instead
*/
@Deprecated
public class MinReplicationFactor {

private Integer minReplicationFactor;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/arangodb/entity/PathEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @see <a href= "https://www.arangodb.com/docs/stable/http/traversal.html#executes-a-traversal">API
* Documentation</a>
*/
@Deprecated
public class PathEntity<V, E> implements Entity {

private Collection<E> edges;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/arangodb/entity/TraversalEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @see <a href= "https://www.arangodb.com/docs/stable/http/traversal.html#executes-a-traversal">API
* Documentation</a>
*/
@Deprecated
public class TraversalEntity<V, E> implements Entity {

private Collection<V> vertices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected Request queryRequest(

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

final Request request = request(dbName, RequestType.PUT, PATH_API_CURSOR, id);
final Request request = request(dbName, RequestType.POST, PATH_API_CURSOR, id);

if (meta != null) {
request.getHeaderParam().putAll(meta);
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/arangodb/model/CollectionCreateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class CollectionCreateOptions {
private Long journalSize;
private final ReplicationFactor replicationFactor;
private final MinReplicationFactor minReplicationFactor;
private Integer writeConcern;
private KeyOptions keyOptions;
private Boolean waitForSync;
private Boolean doCompact;
Expand Down Expand Up @@ -89,6 +90,10 @@ public Integer getReplicationFactor() {
return replicationFactor.getReplicationFactor();
}

/**
* @deprecated use {@link #getWriteConcern()} instead
*/
@Deprecated
public Integer getMinReplicationFactor() {
return minReplicationFactor.getMinReplicationFactor();
}
Expand Down Expand Up @@ -118,12 +123,31 @@ public CollectionCreateOptions replicationFactor(final Integer replicationFactor
* are allowed. Having `minReplicationFactor > 1` requires additional insync copies on follower servers
* to allow writes.
* @return options
* @deprecated use {@link #writeConcern(Integer)} instead
*/
@Deprecated
public CollectionCreateOptions minReplicationFactor(final Integer minReplicationFactor) {
this.minReplicationFactor.setMinReplicationFactor(minReplicationFactor);
return this;
}

public Integer getWriteConcern() {
return writeConcern;
}

/**
* @param writeConcern write concern for this collection (default: 1).
* It determines how many copies of each shard are required to be in sync on the different
* DB-Servers. If there are less then these many copies in the cluster a shard will refuse to
* write. Writes to shards with enough up-to-date copies will succeed at the same time however.
* The value of writeConcern can not be larger than replicationFactor. (cluster only)
* @return options
*/
public CollectionCreateOptions writeConcern(final Integer writeConcern) {
this.writeConcern = writeConcern;
return this;
}

public Boolean getSatellite() {
return replicationFactor.getSatellite();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/arangodb/model/DocumentCreateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public Boolean getOverwrite() {
* the old document.
* @return options
* @since ArangoDB 3.4
* @deprecated use {@link #overwriteMode(OverwriteMode)} instead
*/
@Deprecated
public DocumentCreateOptions overwrite(final Boolean overwrite) {
this.overwrite = overwrite;
return this;
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/arangodb/model/GraphCreateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public GraphCreateOptions satellite(final Boolean satellite) {
return this;
}

/**
* @deprecated use {@link #getWriteConcern()} instead
*/
@Deprecated
public Integer getMinReplicationFactor() {
return getOptions().getMinReplicationFactor();
}
Expand All @@ -157,12 +161,31 @@ public Integer getMinReplicationFactor() {
* are allowed. Having `minReplicationFactor > 1` requires additional insync copies on follower servers
* to allow writes.
* @return options
* @deprecated use {@link #writeConcern(Integer)} instead
*/
@Deprecated
public GraphCreateOptions minReplicationFactor(final Integer minReplicationFactor) {
getOptions().setMinReplicationFactor(minReplicationFactor);
return this;
}

public Integer getWriteConcern() {
return getOptions().getWriteConcern();
}

/**
* @param writeConcern Write concern for new collections in the graph.
* It determines how many copies of each shard are required to be in sync on the different
* DB-Servers. If there are less then these many copies in the cluster a shard will refuse to
* write. Writes to shards with enough up-to-date copies will succeed at the same time however.
* The value of writeConcern can not be larger than replicationFactor. (cluster only)
* @return options
*/
public GraphCreateOptions writeConcern(final Integer writeConcern) {
getOptions().setWriteConcern(writeConcern);
return this;
}

public Integer getNumberOfShards() {
return getOptions().getNumberOfShards();
}
Expand Down Expand Up @@ -216,6 +239,7 @@ private SmartOptions getOptions() {
public static class SmartOptions {
private ReplicationFactor replicationFactor;
private Integer minReplicationFactor;
private Integer writeConcern;
private Integer numberOfShards;
private String smartGraphAttribute;
private Boolean isDisjoint;
Expand All @@ -242,14 +266,30 @@ public void setSatellite(final Boolean satellite) {
replicationFactor.setSatellite(satellite);
}

/**
* @deprecated use {{@link #getWriteConcern()}} instead
*/
@Deprecated
public Integer getMinReplicationFactor() {
return minReplicationFactor;
}

/**
* @deprecated use {{@link #setWriteConcern(Integer)}} instead
*/
@Deprecated
public void setMinReplicationFactor(final Integer minReplicationFactor) {
this.minReplicationFactor = minReplicationFactor;
}

public Integer getWriteConcern() {
return writeConcern;
}

public void setWriteConcern(final Integer writeConcern) {
this.writeConcern = writeConcern;
}

public Integer getNumberOfShards() {
return numberOfShards;
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/arangodb/ArangoDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ void createCollectionWithReplicationFactor(ArangoDatabase db) {

@ParameterizedTest(name = "{index}")
@MethodSource("dbs")
void createCollectionWithMinReplicationFactor(ArangoDatabase db) {
void createCollectionWithWriteConcern(ArangoDatabase db) {
assumeTrue(isAtLeastVersion(3, 5));
assumeTrue(isCluster());

String name = "collection-" + rnd();
final CollectionEntity result = db.createCollection(name,
new CollectionCreateOptions().replicationFactor(2).minReplicationFactor(2));
new CollectionCreateOptions().replicationFactor(2).writeConcern(2));
assertThat(result).isNotNull();
assertThat(result.getId()).isNotNull();
CollectionPropertiesEntity props = db.collection(name).getProperties();
assertThat(props.getReplicationFactor()).isEqualTo(2);
assertThat(props.getMinReplicationFactor()).isEqualTo(2);
assertThat(props.getWriteConcern()).isEqualTo(2);
assertThat(props.getSatellite()).isNull();
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/arangodb/ArangoGraphTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ void exists(ArangoGraph graph) {

@ParameterizedTest(name = "{index}")
@MethodSource("dbs")
void createWithReplicationAndMinReplicationFactor(ArangoDatabase db) {
void createWithReplicationAndWriteConcern(ArangoDatabase db) {
assumeTrue(isAtLeastVersion(3, 5));
assumeTrue(isCluster());

final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>();
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2));
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).writeConcern(2));
assertThat(graph).isNotNull();
assertThat(graph.getName()).isEqualTo(GRAPH_NAME + "_1");
assertThat(graph.getMinReplicationFactor()).isEqualTo(2);
assertThat(graph.getWriteConcern()).isEqualTo(2);
assertThat(graph.getReplicationFactor()).isEqualTo(2);
db.graph(GRAPH_NAME + "_1").drop();
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/arangodb/async/ArangoDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ void createCollectionWithReplicationFactor() throws InterruptedException, Execut
}

@Test
void createCollectionWithMinReplicationFactor() throws ExecutionException, InterruptedException {
void createCollectionWithWriteConcern() throws ExecutionException, InterruptedException {
assumeTrue(isAtLeastVersion(3, 5));
assumeTrue(isCluster());

final CollectionEntity result = db.createCollection(COLLECTION_NAME,
new CollectionCreateOptions().replicationFactor(2).minReplicationFactor(2)).get();
new CollectionCreateOptions().replicationFactor(2).writeConcern(2)).get();
assertThat(result).isNotNull();
assertThat(result.getId()).isNotNull();
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getReplicationFactor()).isEqualTo(2);
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getMinReplicationFactor()).isEqualTo(2);
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getWriteConcern()).isEqualTo(2);
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getSatellite()).isNull();
db.collection(COLLECTION_NAME).drop();
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/arangodb/async/ArangoGraphTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ void create() throws InterruptedException, ExecutionException {
}

@Test
void createWithReplicationAndMinReplicationFactor() throws ExecutionException, InterruptedException {
void createWithReplicationAndWriteConcern() throws ExecutionException, InterruptedException {
assumeTrue(isAtLeastVersion(3, 5));
assumeTrue(isCluster());
final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>();
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2)).get();
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).writeConcern(2)).get();
assertThat(graph).isNotNull();
assertThat(graph.getName()).isEqualTo(GRAPH_NAME + "_1");
assertThat(graph.getMinReplicationFactor()).isEqualTo(2);
assertThat(graph.getWriteConcern()).isEqualTo(2);
assertThat(graph.getReplicationFactor()).isEqualTo(2);
db.graph(GRAPH_NAME + "_1").drop();
}
Expand Down

0 comments on commit 9f95607

Please sign in to comment.