Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/com/arangodb/entity/GraphEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class GraphEntity implements Entity {
private Boolean isSmart;
private Integer numberOfShards;
private String smartGraphAttribute;
private Integer replicationFactor;
private ReplicationFactor replicationFactor;
private Integer minReplicationFactor;

public String getName() {
Expand All @@ -62,7 +62,11 @@ public Integer getNumberOfShards() {
}

public Integer getReplicationFactor() {
return replicationFactor;
return replicationFactor.getReplicationFactor();
}

public Boolean getSatellite() {
return this.replicationFactor.getSatellite();
}

public Integer getMinReplicationFactor() {
Expand Down
35 changes: 30 additions & 5 deletions src/main/java/com/arangodb/model/GraphCreateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.arangodb.model;

import com.arangodb.entity.EdgeDefinition;
import com.arangodb.entity.ReplicationFactor;

import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -94,7 +95,7 @@ public GraphCreateOptions isSmart(final Boolean isSmart) {
}

public Integer getReplicationFactor() {
return getOptions().getReplicationFactor();
return getOptions().replicationFactor.getReplicationFactor();
}

/**
Expand All @@ -108,7 +109,22 @@ public Integer getReplicationFactor() {
* @return options
*/
public GraphCreateOptions replicationFactor(final Integer replicationFactor) {
getOptions().setReplicationFactor(replicationFactor);
getOptions().replicationFactor.setReplicationFactor(replicationFactor);
return this;
}

public Boolean getSatellite() {
return getOptions().replicationFactor.getSatellite();
}

/**
* @param satellite If the true the graph is created as a satellite graph. In this case
* {@link #replicationFactor(Integer)} is ignored.
* @return options
* @since ArangoDB 3.7
*/
public GraphCreateOptions satellite(final Boolean satellite) {
getOptions().replicationFactor.setSatellite(satellite);
return this;
}

Expand Down Expand Up @@ -167,21 +183,30 @@ private SmartOptions getOptions() {
}

public static class SmartOptions {
private Integer replicationFactor;
private ReplicationFactor replicationFactor;
private Integer minReplicationFactor;
private Integer numberOfShards;
private String smartGraphAttribute;

public SmartOptions() {
super();
replicationFactor = new ReplicationFactor();
}

public Integer getReplicationFactor() {
return replicationFactor;
return replicationFactor.getReplicationFactor();
}

public void setReplicationFactor(final Integer replicationFactor) {
this.replicationFactor = replicationFactor;
this.replicationFactor.setReplicationFactor(replicationFactor);
}

public Boolean getSatellite() {
return replicationFactor.getSatellite();
}

public void setSatellite(final Boolean satellite) {
replicationFactor.setSatellite(satellite);
}

public Integer getMinReplicationFactor() {
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/arangodb/ArangoDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,23 @@ public void createGraph() {
assertThat(result.getName(), is(name));
}

@Test
public void createGraphSatellite() {
assumeTrue(isAtLeastVersion(3, 7));
assumeTrue(isCluster());
assumeTrue(isEnterprise());

String name = "graph-" + rnd();
final GraphEntity result = db.createGraph(name, null, new GraphCreateOptions().satellite(true));
assertThat(result.getSatellite(), is(true));

GraphEntity info = db.graph(name).getInfo();
assertThat(info.getSatellite(), is(true));

GraphEntity graph = db.getGraphs().stream().filter(g -> name.equals(g.getName())).findFirst().get();
assertThat(graph.getSatellite(), is(true));
}

@Test
public void createGraphReplicationFaktor() {
assumeTrue(isCluster());
Expand Down