Search in sources :

Example 1 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class ElasticSearchConfigTest method testTitanFactoryBuilder.

@Test
public void testTitanFactoryBuilder() {
    String baseDir = Joiner.on(File.separator).join("target", "es", "titanfactory_jvmlocal_ext");
    TitanFactory.Builder builder = TitanFactory.build();
    builder.set("storage.backend", "inmemory");
    builder.set("index." + INDEX_NAME + ".elasticsearch.interface", "NODE");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work");
    builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs");
    // Must not throw an exception
    TitanGraph graph = builder.open();
    assertTrue(graph.isOpen());
    graph.close();
}
Also used : TitanGraph(com.thinkaurelius.titan.core.TitanGraph) TitanFactory(com.thinkaurelius.titan.core.TitanFactory) Test(org.junit.Test)

Example 2 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class TitanGraphTest method setAndCheckGraphOption.

private <T> void setAndCheckGraphOption(ConfigOption<T> opt, ConfigOption.Type requiredType, T firstValue, T secondValue) {
    // Sanity check: make sure the Type of the configoption is what we expect
    Preconditions.checkState(opt.getType().equals(requiredType));
    final EnumSet<ConfigOption.Type> allowedTypes = EnumSet.of(ConfigOption.Type.GLOBAL, ConfigOption.Type.GLOBAL_OFFLINE, ConfigOption.Type.MASKABLE);
    Preconditions.checkState(allowedTypes.contains(opt.getType()));
    // Sanity check: it's kind of pointless for the first and second values to be identical
    Preconditions.checkArgument(!firstValue.equals(secondValue));
    // Get full string path of config option
    final String path = ConfigElement.getPath(opt);
    // Set and check initial value before and after database restart
    mgmt.set(path, firstValue);
    assertEquals(firstValue.toString(), mgmt.get(path));
    // Close open tx first.  This is specific to BDB + GLOBAL_OFFLINE.
    // Basically: the BDB store manager throws a fit if shutdown is called
    // with one or more transactions still open, and GLOBAL_OFFLINE calls
    // shutdown on our behalf when we commit this change.
    tx.rollback();
    mgmt.commit();
    clopen();
    // Close tx again following clopen
    tx.rollback();
    assertEquals(firstValue.toString(), mgmt.get(path));
    // Set and check updated value before and after database restart
    mgmt.set(path, secondValue);
    assertEquals(secondValue.toString(), mgmt.get(path));
    mgmt.commit();
    clopen();
    tx.rollback();
    assertEquals(secondValue.toString(), mgmt.get(path));
    // Open a separate graph "g2"
    TitanGraph g2 = TitanFactory.open(config);
    TitanManagement m2 = g2.openManagement();
    assertEquals(secondValue.toString(), m2.get(path));
    // GLOBAL_OFFLINE options should be unmodifiable with g2 open
    if (opt.getType().equals(ConfigOption.Type.GLOBAL_OFFLINE)) {
        try {
            mgmt.set(path, firstValue);
            mgmt.commit();
            fail("Option " + path + " with type " + ConfigOption.Type.GLOBAL_OFFLINE + " should not be modifiable with concurrent instances");
        } catch (RuntimeException e) {
            log.debug("Caught expected exception", e);
        }
        assertEquals(secondValue.toString(), mgmt.get(path));
    // GLOBAL and MASKABLE should be modifiable even with g2 open
    } else {
        mgmt.set(path, firstValue);
        assertEquals(firstValue.toString(), mgmt.get(path));
        mgmt.commit();
        clopen();
        assertEquals(firstValue.toString(), mgmt.get(path));
    }
    m2.rollback();
    g2.close();
}
Also used : StandardTitanGraph(com.thinkaurelius.titan.graphdb.database.StandardTitanGraph) TitanGraph(com.thinkaurelius.titan.core.TitanGraph) InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) TitanSchemaType(com.thinkaurelius.titan.core.schema.TitanSchemaType) RelationType(com.thinkaurelius.titan.core.RelationType) TitanManagement(com.thinkaurelius.titan.core.schema.TitanManagement)

Example 3 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class AbstractTitanGraphProvider method clear.

//    @Override
//    public <ID> ID reconstituteGraphSONIdentifier(final Class<? extends Element> clazz, final Object id) {
//        if (Edge.class.isAssignableFrom(clazz)) {
//            // TitanGraphSONModule toStrings the edgeid - expect a String value for the id
//            if (!(id instanceof String)) throw new RuntimeException("Expected a String value for the RelationIdentifier");
//            return (ID) RelationIdentifier.parse((String) id);
//        } else {
//            return (ID) id;
//        }
//    }
@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
    if (null != g) {
        while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
        TitanGraph graph = (TitanGraph) g;
        if (graph.isOpen()) {
            if (g.tx().isOpen())
                g.tx().rollback();
            g.close();
        }
    }
    WriteConfiguration config = new CommonsConfiguration(configuration);
    BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
    if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
        TitanGraphBaseTest.clearGraph(config);
    }
}
Also used : StandardTitanGraph(com.thinkaurelius.titan.graphdb.database.StandardTitanGraph) TitanGraph(com.thinkaurelius.titan.core.TitanGraph) Graph(org.apache.tinkerpop.gremlin.structure.Graph) StandardTitanGraph(com.thinkaurelius.titan.graphdb.database.StandardTitanGraph) TitanGraph(com.thinkaurelius.titan.core.TitanGraph) WrappedGraph(org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph) CommonsConfiguration(com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration) WriteConfiguration(com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration) BasicConfiguration(com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration) WrappedGraph(org.apache.tinkerpop.gremlin.structure.util.wrapped.WrappedGraph)

Example 4 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class AbstractTitanGraphProvider method loadGraphData.

@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);
}
Also used : StandardTitanGraph(com.thinkaurelius.titan.graphdb.database.StandardTitanGraph) TitanGraph(com.thinkaurelius.titan.core.TitanGraph) TransactionTest(org.apache.tinkerpop.gremlin.structure.TransactionTest) TitanManagement(com.thinkaurelius.titan.core.schema.TitanManagement)

Example 5 with TitanGraph

use of com.thinkaurelius.titan.core.TitanGraph in project titan by thinkaurelius.

the class TitanFactoryShorthandTest method testTitanFactoryShorthand.

@Test
public void testTitanFactoryShorthand() {
    TitanGraph g = TitanFactory.open("inmemory");
    g.close();
}
Also used : TitanGraph(com.thinkaurelius.titan.core.TitanGraph) Test(org.junit.Test)

Aggregations

TitanGraph (com.thinkaurelius.titan.core.TitanGraph)13 Test (org.junit.Test)5 StandardTitanGraph (com.thinkaurelius.titan.graphdb.database.StandardTitanGraph)3 TitanFactory (com.thinkaurelius.titan.core.TitanFactory)2 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)2 TitanManagement (com.thinkaurelius.titan.core.schema.TitanManagement)2 LongHashSet (com.carrotsearch.hppc.LongHashSet)1 LongSet (com.carrotsearch.hppc.LongSet)1 RelationType (com.thinkaurelius.titan.core.RelationType)1 TitanSchemaType (com.thinkaurelius.titan.core.schema.TitanSchemaType)1 BasicConfiguration (com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration)1 ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)1 WriteConfiguration (com.thinkaurelius.titan.diskstorage.configuration.WriteConfiguration)1 CommonsConfiguration (com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration)1 TitanIndexTest (com.thinkaurelius.titan.graphdb.TitanIndexTest)1 IDPoolExhaustedException (com.thinkaurelius.titan.graphdb.database.idassigner.IDPoolExhaustedException)1 InternalRelation (com.thinkaurelius.titan.graphdb.internal.InternalRelation)1 InternalRelationType (com.thinkaurelius.titan.graphdb.internal.InternalRelationType)1 VertexScanJob (com.thinkaurelius.titan.graphdb.olap.VertexScanJob)1 VertexArrayList (com.thinkaurelius.titan.graphdb.query.vertex.VertexArrayList)1