package com.infor.titan.pizza;
import com.thinkaurelius.titan.core.PropertyKey;
import com.thinkaurelius.titan.core.TitanFactory;
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.VertexLabel;
import com.thinkaurelius.titan.core.schema.SchemaAction;
import com.thinkaurelius.titan.core.schema.TitanManagement.IndexBuilder;
import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem;
import org.apache.tinkerpop.gremlin.structure.Vertex;
public class SimpleGraph {
public static final String PROPS_PATH = "config/titan-cassandra.properties";
public static void main(String[] args) {
ManagementSystem mgmt;
TitanGraph graph = TitanFactory.build().set("storage.backend", "cassandra")
.set("storage.hostname", "127.0.0.1")
.open();
graph.addVertex("name", "stephen");
graph.tx().commit();
//
graph.tx().rollback();
mgmt = (ManagementSystem) graph.openManagement();
PropertyKey name = mgmt.getPropertyKey("name");
VertexLabel restaurant = mgmt.getVertexLabel("restaurant");
IndexBuilder nameAndLabel = mgmt.buildIndex("byNameAndLabel", Vertex.class).addKey(name).indexOnly(restaurant);
mgmt.commit();
try {
ManagementSystem.awaitGraphIndexStatus(graph, "byNameAndLabel" ).call();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mgmt = (ManagementSystem) graph.openManagement();
mgmt.updateIndex(mgmt.getGraphIndex("byNameAndLabel"), SchemaAction.REINDEX);
mgmt.commit();
}
}
16:18:37,903 INFO ConnectionPoolMBeanManager:53 - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=ClusterTitanConnectionPool,ServiceType=connectionpool
16:18:37,919 INFO CountingConnectionPoolMonitor:194 - AddHost: 127.0.0.1
16:18:38,035 INFO ConnectionPoolMBeanManager:53 - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=KeyspaceTitanConnectionPool,ServiceType=connectionpool
16:18:38,035 INFO CountingConnectionPoolMonitor:194 - AddHost: 127.0.0.1
16:18:38,216 INFO GraphDatabaseConfiguration:1518 - Generated unique-instance-id=0a27c83664433-usalnmdebarr04-infor-com1
16:18:38,228 INFO ConnectionPoolMBeanManager:53 - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=ClusterTitanConnectionPool,ServiceType=connectionpool
16:18:38,229 INFO CountingConnectionPoolMonitor:194 - AddHost: 127.0.0.1
16:18:38,232 INFO ConnectionPoolMBeanManager:53 - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=KeyspaceTitanConnectionPool,ServiceType=connectionpool
16:18:38,232 INFO CountingConnectionPoolMonitor:194 - AddHost: 127.0.0.1
16:18:38,246 INFO Backend:176 - Initiated backend operations thread pool of size 8
16:18:38,279 INFO Backend:254 - Configuring total store cache size: 1886412760
16:18:38,363 INFO KCVSLog:730 - Loaded unidentified ReadMarker start time 2017-01-20T21:18:38.350Z into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller@6fa34d52
Exception in thread "main" java.lang.NullPointerException
at com.thinkaurelius.titan.graphdb.database.management.GraphIndexStatusWatcher.call(GraphIndexStatusWatcher.java:52)
at com.infor.titan.pizza.SimpleGraph.main(SimpleGraph.java:48)
IndexBuilder nameAndLabel = mgmt.buildIndex("byNameAndLabel", Vertex.class).addKey(name).indexOnly(restaurant);
TitanGraphIndex byNameAndLabel = nameAndLabel.buildCompositeIndex();
09:52:13,096 INFO Backend:176 - Initiated backend operations thread pool of size 8
09:52:13,260 INFO KCVSLog:730 - Loaded unidentified ReadMarker start time 2017-01-23T14:52:13.237Z into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller@5495333e
Exception in thread "main" java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)
at com.thinkaurelius.titan.graphdb.database.management.ManagementSystem$IndexBuilder.indexOnly(ManagementSystem.java:613)
at com.infor.titan.pizza.SimpleGraph.main(SimpleGraph.java:41)