Skip to content

Commit 6422955

Browse files
author
mpv1989
committed
Add CollectionCreateOptions.distributeShardsLike(String) (Issue #170)
1 parent 44d8a07 commit 6422955

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
v4.3.3 (2018-xx-xx)
22
---------------------------
3+
* added CollectionCreateOptions.distributeShardsLike(String) (Issue #170)
34
* fixed inconsistency of getDocument() variants (Issue #168)
45
* added AqlQueryOptions.memoryLimit(Long)
56
* added AqlQueryOptions.failOnWarning(Boolean)

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class CollectionCreateOptions {
4444
private Boolean isSystem;
4545
private CollectionType type;
4646
private Integer indexBuckets;
47+
private String distributeShardsLike;
4748

4849
public CollectionCreateOptions() {
4950
super();
@@ -257,4 +258,22 @@ public CollectionCreateOptions indexBuckets(final Integer indexBuckets) {
257258
return this;
258259
}
259260

261+
public String getDistributeShardsLike() {
262+
return distributeShardsLike;
263+
}
264+
265+
/**
266+
* @param distributeShardsLike
267+
* (The default is ""): in an enterprise cluster, this attribute binds the specifics of sharding for the
268+
* newly created collection to follow that of a specified existing collection. Note: Using this parameter
269+
* has consequences for the prototype collection. It can no longer be dropped, before sharding imitating
270+
* collections are dropped. Equally, backups and restores of imitating collections alone will generate
271+
* warnings, which can be overridden, about missing sharding prototype.
272+
* @return options
273+
*/
274+
public CollectionCreateOptions distributeShardsLike(final String distributeShardsLike) {
275+
this.distributeShardsLike = distributeShardsLike;
276+
return this;
277+
}
278+
260279
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.arangodb.entity.AqlParseEntity;
5353
import com.arangodb.entity.AqlParseEntity.AstNode;
5454
import com.arangodb.entity.ArangoDBVersion;
55+
import com.arangodb.entity.ArangoDBVersion.License;
5556
import com.arangodb.entity.BaseDocument;
5657
import com.arangodb.entity.BaseEdgeDocument;
5758
import com.arangodb.entity.CollectionEntity;
@@ -197,6 +198,18 @@ public void createCollectionWithNumberOfShardsAndShardKeys() {
197198
}
198199
}
199200

201+
@Test
202+
public void createCollectionWithDistributeShardsLike() {
203+
if (arangoDB.getVersion().getLicense() == License.ENTERPRISE && arangoDB.getRole() != ServerRole.SINGLE) {
204+
final Integer numberOfShards = 3;
205+
db.createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(numberOfShards));
206+
db.createCollection(COLLECTION_NAME + "2",
207+
new CollectionCreateOptions().distributeShardsLike(COLLECTION_NAME));
208+
assertThat(db.collection(COLLECTION_NAME).getProperties().getNumberOfShards(), is(numberOfShards));
209+
assertThat(db.collection(COLLECTION_NAME + "2").getProperties().getNumberOfShards(), is(numberOfShards));
210+
}
211+
}
212+
200213
@Test
201214
public void deleteCollection() {
202215
db.createCollection(COLLECTION_NAME, null);

0 commit comments

Comments
 (0)