【发布时间】:2016-08-28 12:15:27
【问题描述】:
我在使用 PartitionStrategy 以及 titanDb 和 DynamoDb 作为后端时遇到了问题。我使用 dynamodb-titan-storage-backend 插件将 dynamoDb 用作本地后端。下面是我用java写的一个简单的测试用例:
import com.thinkaurelius.titan.core.TitanEdge;
import com.thinkaurelius.titan.core.TitanFactory;
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanGraphQuery;
import com.thinkaurelius.titan.core.TitanTransaction;
import com.thinkaurelius.titan.core.TitanVertex;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Iterator;
public class TitanTest {
TitanGraph titanGraph;
@Before
public void setUp() {
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("storage.backend", "com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager");
conf.setProperty("storage.dynamodb.client.endpoint", "http://localhost:4567");
titanGraph = TitanFactory.open(conf);
}
@Test
public void testAddVertexToTitanGraph(){
titanGraph.addVertex( "name", "Bob", "age", "4.6x10^9");
titanGraph.traversal().V().forEachRemaining(it -> {
System.out.println("Found " + it.value("name"));
});
}
@Test
public void addVertexViaPartitionStrategy() {
PartitionStrategy partitionStrategy = PartitionStrategy.build().partitionKey("_partition").writePartition("a").addReadPartition("a").create();
GraphTraversalSource graphTraversalSource = GraphTraversalSource.build().with(partitionStrategy).create(titanGraph);
GraphTraversal<Vertex, Vertex> marko = graphTraversalSource.addV("name", "marko", "age", 29);
graphTraversalSource.V().forEachRemaining(it -> {
System.out.println("name:" + it.value("name").toString());
});
}
}
但是,当我运行 addVertexViaPartitionStrategy 测试用例时,我似乎没有打印出任何内容。我在这里遵循了这个例子: http://tinkerpop.apache.org/docs/3.0.1-incubating/#_partitionstrategy
我能够读取和写入数据库,请参阅测试 testAddVertexToTitanGraph,只是在使用分区策略时无法创建顶点。
【问题讨论】:
标签: java amazon-dynamodb titan