TitanManagement mgmt = null; try { mgmt = g.openManagement(); idx = mgmt.getGraphIndex(graphIndexName); for (PropertyKey pk : idx.getFieldKeys()) {
public Consumer<ScanMetrics> getIndexJobFinisher(final TitanGraph graph, final SchemaAction action) { Preconditions.checkArgument((graph != null && action != null) || (graph == null && action == null)); return metrics -> { try { if (metrics.get(ScanMetrics.Metric.FAILURE) == 0) { if (action != null) { ManagementSystem mgmt = (ManagementSystem) graph.openManagement(); try { TitanIndex index = retrieve(mgmt); mgmt.updateIndex(index, action); } finally { mgmt.commit(); } } LOGGER.info("Index update job successful for [{}]", IndexIdentifier.this.toString()); } else { LOGGER.error("Index update job unsuccessful for [{}]. Check logs", IndexIdentifier.this.toString()); } } catch (Throwable e) { LOGGER.error("Error encountered when updating index after job finished [" + IndexIdentifier.this.toString() + "]: ", e); } }; } }
public SchemaContainer(TitanGraph graph) { vertexLabels = Maps.newHashMap(); relationTypes = Maps.newHashMap(); TitanManagement mgmt = graph.openManagement(); try { for (VertexLabel vl : mgmt.getVertexLabels()) { VertexLabelDefinition vld = new VertexLabelDefinition(vl); vertexLabels.put(vld.getName(),vld); } for (EdgeLabel el : mgmt.getRelationTypes(EdgeLabel.class)) { EdgeLabelDefinition eld = new EdgeLabelDefinition(el); relationTypes.put(eld.getName(),eld); } for (PropertyKey pk : mgmt.getRelationTypes(PropertyKey.class)) { PropertyKeyDefinition pkd = new PropertyKeyDefinition(pk); relationTypes.put(pkd.getName(), pkd); } } finally { mgmt.rollback(); } }
TitanManagement mgmt = null; try { mgmt = g.openManagement(); idx = mgmt.getRelationIndex(mgmt.getRelationType(relationTypeName), relationIndexName); actualStatus = idx.getIndexStatus();
this.mgmt = (ManagementSystem)graph.openManagement();
@Override public void loadGraphData(final Graph g, final LoadGraphWith loadGraphWith, final Class testClass, final String testName) { if (loadGraphWith != null) { this.createIndices((TitanGraph) g, loadGraphWith.value()); } else { if (TransactionTest.class.equals(testClass) && testName.equalsIgnoreCase("shouldExecuteWithCompetingThreads")) { TitanManagement mgmt = ((TitanGraph) g).openManagement(); mgmt.makePropertyKey("blah").dataType(Double.class).make(); mgmt.makePropertyKey("bloop").dataType(Integer.class).make(); mgmt.makePropertyKey("test").dataType(Object.class).make(); mgmt.makeEdgeLabel("friend").make(); mgmt.commit(); } } super.loadGraphData(g, loadGraphWith, testClass, testName); }
TitanManagement m2 = g2.openManagement(); assertEquals(secondValue.toString(), m2.get(path));
private void createIndices(final TitanGraph g, final LoadGraphWith.GraphData graphData) { TitanManagement mgmt = g.openManagement(); if (graphData.equals(LoadGraphWith.GraphData.GRATEFUL)) { VertexLabel artist = mgmt.makeVertexLabel("artist").make();
public static void load(final TitanGraph graph, String mixedIndexName, boolean uniqueNameCompositeIndex) { TitanManagement mgmt = graph.openManagement(); final PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make(); TitanManagement.IndexBuilder nameIndexBuilder = mgmt.buildIndex("name", Vertex.class).addKey(name);
static void validateIndexBackend(Configuration config) { String configuredIndexBackend = config.getString(INDEX_BACKEND_CONF); TitanManagement managementSystem = getGraphInstance().openManagement(); String currentIndexBackend = managementSystem.get(INDEX_BACKEND_CONF); managementSystem.commit(); if (!configuredIndexBackend.equals(currentIndexBackend)) { throw new RuntimeException("Configured Index Backend " + configuredIndexBackend + " differs from earlier configured Index Backend " + currentIndexBackend + ". Aborting!"); } }
@Override public AtlasGraphManagement getManagementSystem() { return new Titan1GraphManagement(this, getGraph().openManagement()); }
private Set<String> getIndexKeys(Class<? extends Element> titanElementClass) { TitanManagement mgmt = getGraph().openManagement(); Iterable<TitanGraphIndex> indices = mgmt.getGraphIndexes(titanElementClass); Set<String> result = new HashSet<String>(); for (TitanGraphIndex index : indices) { result.add(index.name()); } mgmt.commit(); return result; }
public class GraphManagerFactory(){ TitanGraph instance; public static GraphManager getGraphManager(){ if(instance = null){ instance = TitanFactory.open("conf/titan-cassandra.properties"); TitanManagement management = instance.openManagement(); //Check if the labels exist before creating explicitly. //If they don't exist do the following: management.makeEdgeLabel("EdgeLabel").make(); management.makePropertyKey("property").dataType(String.class).make(); management.commit(); } return new GraphManager(instance.newTransaction()); } }
public Titan1Graph() { //determine multi-properties once at startup TitanManagement mgmt = null; try { mgmt = Titan1GraphDatabase.getGraphInstance().openManagement(); Iterable<PropertyKey> keys = mgmt.getRelationTypes(PropertyKey.class); multiProperties = new HashSet<>(); for (PropertyKey key : keys) { if (key.cardinality() != Cardinality.SINGLE) { multiProperties.add(key.name()); } } } finally { if (mgmt != null) { mgmt.rollback(); } } }
public SchemaContainer(TitanGraph graph) { vertexLabels = Maps.newHashMap(); relationTypes = Maps.newHashMap(); TitanManagement mgmt = graph.openManagement(); try { for (VertexLabel vl : mgmt.getVertexLabels()) { VertexLabelDefinition vld = new VertexLabelDefinition(vl); vertexLabels.put(vld.getName(),vld); } for (EdgeLabel el : mgmt.getRelationTypes(EdgeLabel.class)) { EdgeLabelDefinition eld = new EdgeLabelDefinition(el); relationTypes.put(eld.getName(),eld); } for (PropertyKey pk : mgmt.getRelationTypes(PropertyKey.class)) { PropertyKeyDefinition pkd = new PropertyKeyDefinition(pk); relationTypes.put(pkd.getName(), pkd); } } finally { mgmt.rollback(); } }
private static void buildTitanIndexes(TitanGraph graph) { TitanManagement management = graph.openManagement(); makeVertexLabels(management); makeEdgeLabels(management); makePropertyKeys(management); makeIndicesVertexCentric(management); makeIndicesComposite(management); management.commit(); }
private static void buildTitanIndexes(TitanGraph graph) { TitanManagement management = graph.openManagement(); makeVertexLabels(management); makeEdgeLabels(management); makePropertyKeys(management); makeIndicesVertexCentric(management); makeIndicesComposite(management); management.commit(); }
/** * Create in the db model a new property and the class it uses. * * @param propertyName Entry name in the model. * @param c Class for the entry. */ private void makeIfNotExistProperty(String propertyName, Class<?> c) { ManagementSystem manager = (ManagementSystem) getTitanGraph().openManagement(); if (!manager.containsPropertyKey(propertyName)) { manager.makePropertyKey(propertyName).dataType(c).cardinality(Cardinality.SINGLE).make(); System.out.println("adding key " + propertyName); manager.commit(); } else { manager.rollback(); } }
private static Graph openTuplGraph() { final Configuration conf = new BaseConfiguration(); conf.addProperty("storage.backend", "jp.classmethod.titan.diskstorage.tupl.TuplStoreManager"); final TitanGraph g = TitanFactory.open(conf); final TitanManagement mgmt = g.openManagement(); final PropertyKey nameKey = mgmt.makePropertyKey(NAME).cardinality(Cardinality.SINGLE).dataType(String.class).make(); mgmt.buildIndex("nameKeyIndex", Vertex.class).addKey(nameKey).unique().buildCompositeIndex(); mgmt.commit(); g.tx().commit(); return g; }
public static Graph createTheCrew() { final Configuration conf = new BaseConfiguration(); conf.addProperty("storage.backend", "jp.classmethod.titan.diskstorage.tupl.TuplStoreManager"); final TitanGraph g = TitanFactory.open(conf); final TitanManagement mgmt = g.openManagement(); mgmt.makePropertyKey(LOCATION).cardinality(Cardinality.LIST).dataType(String.class).make(); mgmt.makePropertyKey(START_TIME).cardinality(Cardinality.LIST).dataType(Integer.class).make(); mgmt.makePropertyKey(END_TIME).cardinality(Cardinality.LIST).dataType(Integer.class).make(); mgmt.commit(); g.tx().commit(); generateTheCrew(g); return g; }