com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration Java Examples

The following examples show how to use com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HBaseKeyColumnValueStoreTest.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = PermanentLockingException.class)
public void shouldThrowExceptionAfterConfiguredRetriesIfLockMediationFails() throws BackendException {
    when(storeManager.getMetaDataSchema("hbase")).thenReturn(new EntryMetaData[] {EntryMetaData.TIMESTAMP});
    when(storeManager.getStorageConfig()).thenReturn(storageConfig);
    when(storageConfig.get(GraphDatabaseConfiguration.LOCK_EXPIRE)).thenReturn(
            new StandardDuration(300L, TimeUnit.MILLISECONDS));
    when(storageConfig.get(GraphDatabaseConfiguration.LOCK_WAIT)).thenReturn(
            new StandardDuration(10L, TimeUnit.MILLISECONDS));
    when(storageConfig.get(GraphDatabaseConfiguration.LOCK_RETRY)).thenReturn(3);
    KeyColumn lockID = new KeyColumn(key, column);
    when(localLockMediator.lock(eq(lockID), eq(transaction), any(Timepoint.class))).
            thenReturn(false).thenReturn(false).thenReturn(false);

    HBaseKeyColumnValueStore hBaseKeyColumnValueStore =
            new HBaseKeyColumnValueStore(storeManager, connectionMask, "titan", "e", "hbase", localLockMediator);
    hBaseKeyColumnValueStore.acquireLock(key, column, expectedValue, transaction);

    fail("Should fail as lock could not be acquired after 3 retries.");
}
 
Example #2
Source File: StandardTransactionBuilder.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
public StandardTransactionBuilder(GraphDatabaseConfiguration graphConfig, StandardTitanGraph graph, Configuration customOptions) {
    Preconditions.checkNotNull(graphConfig);
    Preconditions.checkNotNull(graph);
    if (graphConfig.isReadOnly()) readOnly();
    if (graphConfig.isBatchLoading()) enableBatchLoading();
    this.graph = graph;
    this.defaultSchemaMaker = graphConfig.getDefaultSchemaMaker();
    this.assignIDsImmediately = graphConfig.hasFlushIDs();
    this.forceIndexUsage = graphConfig.hasForceIndexUsage();
    this.groupName = graphConfig.getMetricsPrefix();
    this.propertyPrefetching = graphConfig.hasPropertyPrefetching();
    this.writableCustomOptions = null;
    this.customOptions = customOptions;
    vertexCacheSize(graphConfig.getTxVertexCacheSize());
    dirtyVertexSize(graphConfig.getTxDirtyVertexSize());


    // KAFKA PRODUCER
    this.logIdentifier = null;
    boolean logAll = graphConfig.getLogAllTransactions();

    if (logAll) {
        this.logIdentifier = graphConfig.getAllLogTransactionName();

    }
}
 
Example #3
Source File: StandardTransactionBuilder.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new TitanTransaction configuration with default configuration parameters.
 */
public StandardTransactionBuilder(GraphDatabaseConfiguration graphConfig, StandardTitanGraph graph) {
    Preconditions.checkNotNull(graphConfig);
    Preconditions.checkNotNull(graph);
    if (graphConfig.isReadOnly()) readOnly();
    if (graphConfig.isBatchLoading()) enableBatchLoading();
    this.graph = graph;
    this.defaultSchemaMaker = graphConfig.getDefaultSchemaMaker();
    this.assignIDsImmediately = graphConfig.hasFlushIDs();
    this.forceIndexUsage = graphConfig.hasForceIndexUsage();
    this.groupName = graphConfig.getMetricsPrefix();
    this.propertyPrefetching = graphConfig.hasPropertyPrefetching();
    this.writableCustomOptions = GraphDatabaseConfiguration.buildGraphConfiguration();
    this.customOptions = new MergedConfiguration(writableCustomOptions, graphConfig.getConfiguration());
    vertexCacheSize(graphConfig.getTxVertexCacheSize());
    dirtyVertexSize(graphConfig.getTxDirtyVertexSize());

    // KAFKA PRODUCER
    this.logIdentifier = null;
    boolean logAll = graphConfig.getLogAllTransactions();

    if (logAll) {
        this.logIdentifier = graphConfig.getAllLogTransactionName();
    }
}
 
Example #4
Source File: IDAuthorityTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
public void open() throws BackendException {
    manager = new KeyColumnValueStoreManager[CONCURRENCY];
    idAuthorities = new IDAuthority[CONCURRENCY];

    for (int i = 0; i < CONCURRENCY; i++) {

        ModifiableConfiguration sc = StorageSetup.getConfig(baseStoreConfiguration.copy());
        //sc.set(GraphDatabaseConfiguration.INSTANCE_RID_SHORT,(short)i);
        sc.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX, (short)i);
        if (!sc.has(UNIQUE_INSTANCE_ID)) {
            String uniqueGraphId = getOrGenerateUniqueInstanceId(sc);
            log.debug("Setting unique instance id: {}", uniqueGraphId);
            sc.set(UNIQUE_INSTANCE_ID, uniqueGraphId);
        }
        sc.set(GraphDatabaseConfiguration.CLUSTER_MAX_PARTITIONS,MAX_NUM_PARTITIONS);

        manager[i] = openStorageManager();
        StoreFeatures storeFeatures = manager[i].getFeatures();
        KeyColumnValueStore idStore = manager[i].openDatabase("ids");
        if (storeFeatures.isKeyConsistent())
            idAuthorities[i] = new ConsistentKeyIDAuthority(idStore, manager[i], sc);
        else throw new IllegalArgumentException("Cannot open id store");
    }
}
 
Example #5
Source File: CassandraTransactionTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadConsistencyLevel() {
    int levelsChecked = 0;

    // Test whether CassandraTransaction honors the write consistency level option
    for (CLevel writeLevel : CLevel.values()) {
        StandardBaseTransactionConfig.Builder b = new StandardBaseTransactionConfig.Builder();
        ModifiableConfiguration mc = GraphDatabaseConfiguration.buildGraphConfiguration();
        mc.set(CASSANDRA_READ_CONSISTENCY, writeLevel.name());
        b.timestampProvider(TimestampProviders.MICRO);
        b.customOptions(mc);
        CassandraTransaction ct = new CassandraTransaction(b.build());
        assertEquals(writeLevel, ct.getReadConsistencyLevel());
        levelsChecked++;
    }

    // Sanity check: if CLevel.values was empty, something is wrong with the test
    Preconditions.checkState(0 < levelsChecked);
}
 
Example #6
Source File: CassandraTransactionTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteConsistencyLevel() {
    int levelsChecked = 0;

    // Test whether CassandraTransaction honors the write consistency level option
    for (CLevel writeLevel : CLevel.values()) {
        StandardBaseTransactionConfig.Builder b = new StandardBaseTransactionConfig.Builder();
        ModifiableConfiguration mc = GraphDatabaseConfiguration.buildGraphConfiguration();
        mc.set(CASSANDRA_WRITE_CONSISTENCY, writeLevel.name());
        b.customOptions(mc);
        b.timestampProvider(TimestampProviders.MICRO);
        CassandraTransaction ct = new CassandraTransaction(b.build());
        assertEquals(writeLevel, ct.getWriteConsistencyLevel());
        levelsChecked++;
    }

    // Sanity check: if CLevel.values was empty, something is wrong with the test
    Preconditions.checkState(0 < levelsChecked);
}
 
Example #7
Source File: InMemoryStoreManager.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
public InMemoryStoreManager(final Configuration configuration) {

        stores = new ConcurrentHashMap<String, InMemoryKeyColumnValueStore>();

        features = new StandardStoreFeatures.Builder()
            .orderedScan(true)
            .unorderedScan(true)
            .keyOrdered(true)
            .persists(false)
            .keyConsistent(GraphDatabaseConfiguration.buildGraphConfiguration())
            .build();

//        features = new StoreFeatures();
//        features.supportsOrderedScan = true;
//        features.supportsUnorderedScan = true;
//        features.supportsBatchMutation = false;
//        features.supportsTxIsolation = false;
//        features.supportsConsistentKeyOperations = true;
//        features.supportsLocking = false;
//        features.isDistributed = false;
//        features.supportsMultiQuery = false;
//        features.isKeyOrdered = true;
//        features.hasLocalKeyPartition = false;
    }
 
Example #8
Source File: ExpectedValueCheckingTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@After
public void verifyMocks() {
    ctrl.verify();
    ctrl.reset();

    // Check capture created in the @Before method
    assertTrue(txConfigCapture.hasCaptured());
    List<BaseTransactionConfig> txCfgs = txConfigCapture.getValues();
    assertEquals(2, txCfgs.size());
    // First backing store transaction should use default tx config
    assertEquals("default", txCfgs.get(0).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
    // Second backing store transaction should use global strong consistency config
    assertEquals("global",  txCfgs.get(1).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
    // The order in which these transactions are opened isn't really significant;
    // testing them in order is kind of overspecifying the impl's behavior.
    // Could probably relax the ordering selectively here with some thought, but
    // I want to keep order checking on in general for the EasyMock control.
}
 
Example #9
Source File: TitanCleanup.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
/**
 * Clears out the entire graph. This will delete ALL of the data stored in this graph and the data will NOT be
 * recoverable. This method is intended only for development and testing use.
 *
 * @param graph
 * @throws IllegalArgumentException if the graph has not been shut down
 * @throws com.thinkaurelius.titan.core.TitanException if clearing the storage is unsuccessful
 */
public static final void clear(TitanGraph graph) {
    Preconditions.checkNotNull(graph);
    Preconditions.checkArgument(graph instanceof StandardTitanGraph,"Invalid graph instance detected: %s",graph.getClass());
    StandardTitanGraph g = (StandardTitanGraph)graph;
    Preconditions.checkArgument(!g.isOpen(),"Graph needs to be shut down before it can be cleared.");
    final GraphDatabaseConfiguration config = g.getConfiguration();
    BackendOperation.execute(new Callable<Boolean>(){
        @Override
        public Boolean call() throws Exception {
            config.getBackend().clearStorage();
            return true;
        }
        @Override
        public String toString() { return "ClearBackend"; }
    }, Duration.ofSeconds(20));
}
 
Example #10
Source File: AbstractTitanGraphProvider.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #11
Source File: ElasticSearchConfigTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalNodeUsingYaml() throws BackendException, InterruptedException {

    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_yml");

    assertFalse(new File(baseDir + File.separator + "data").exists());

    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    config.set(INDEX_CONF_FILE,
            Joiner.on(File.separator).join("target", "test-classes", "es_jvmlocal.yml"), INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    assertTrue(new File(baseDir + File.separator + "data").exists());
}
 
Example #12
Source File: ElasticSearchConfigTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalNodeUsingExtAndIndexDirectory() throws BackendException, InterruptedException {

    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_ext2");

    assertFalse(new File(baseDir + File.separator + "data").exists());

    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    config.set(INDEX_DIRECTORY, baseDir, INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    assertTrue(new File(baseDir + File.separator + "data").exists());
}
 
Example #13
Source File: CassandraBinaryInputFormat.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Override
public void setConf(final Configuration config) {
    super.setConf(config);

    // Copy some Titan configuration keys to the Hadoop Configuration keys used by Cassandra's ColumnFamilyInputFormat
    ConfigHelper.setInputInitialAddress(config, titanConf.get(GraphDatabaseConfiguration.STORAGE_HOSTS)[0]);
    if (titanConf.has(GraphDatabaseConfiguration.STORAGE_PORT))
        ConfigHelper.setInputRpcPort(config, String.valueOf(titanConf.get(GraphDatabaseConfiguration.STORAGE_PORT)));
    if (titanConf.has(GraphDatabaseConfiguration.AUTH_USERNAME))
        ConfigHelper.setInputKeyspaceUserName(config, titanConf.get(GraphDatabaseConfiguration.AUTH_USERNAME));
    if (titanConf.has(GraphDatabaseConfiguration.AUTH_PASSWORD))
        ConfigHelper.setInputKeyspacePassword(config, titanConf.get(GraphDatabaseConfiguration.AUTH_PASSWORD));

    // Copy keyspace, force the CF setting to edgestore, honor widerows when set
    final boolean wideRows = config.getBoolean(INPUT_WIDEROWS_CONFIG, false);
    // Use the setInputColumnFamily overload that includes a widerows argument; using the overload without this argument forces it false
    ConfigHelper.setInputColumnFamily(config, titanConf.get(AbstractCassandraStoreManager.CASSANDRA_KEYSPACE),
            mrConf.get(TitanHadoopConfiguration.COLUMN_FAMILY_NAME), wideRows);
    log.debug("Set keyspace: {}", titanConf.get(AbstractCassandraStoreManager.CASSANDRA_KEYSPACE));

    // Set the column slice bounds via Faunus's vertex query filter
    final SlicePredicate predicate = new SlicePredicate();
    final int rangeBatchSize = config.getInt(RANGE_BATCH_SIZE_CONFIG, Integer.MAX_VALUE);
    predicate.setSlice_range(getSliceRange(TitanHadoopSetupCommon.DEFAULT_SLICE_QUERY, rangeBatchSize)); // TODO stop slicing the whole row
    ConfigHelper.setInputSlicePredicate(config, predicate);
}
 
Example #14
Source File: HBaseKeyColumnValueStoreTest.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRetryRightNumberOfTimesIfLockMediationFails() throws BackendException {
    when(storeManager.getMetaDataSchema("hbase")).thenReturn(new EntryMetaData[] {EntryMetaData.TIMESTAMP});
    when(storeManager.getStorageConfig()).thenReturn(storageConfig);
    when(storageConfig.get(GraphDatabaseConfiguration.LOCK_EXPIRE)).thenReturn(
            new StandardDuration(300L, TimeUnit.MILLISECONDS));
    when(storageConfig.get(GraphDatabaseConfiguration.LOCK_WAIT)).thenReturn(
            new StandardDuration(10L, TimeUnit.MILLISECONDS));
    when(storageConfig.get(GraphDatabaseConfiguration.LOCK_RETRY)).thenReturn(3);
    KeyColumn lockID = new KeyColumn(key, column);
    when(localLockMediator.lock(eq(lockID), eq(transaction), any(Timepoint.class))).
            thenReturn(false).thenReturn(false).thenReturn(true);

    HBaseKeyColumnValueStore hBaseKeyColumnValueStore =
            new HBaseKeyColumnValueStore(storeManager, connectionMask, "titan", "e", "hbase", localLockMediator);
    hBaseKeyColumnValueStore.acquireLock(key, column, expectedValue, transaction);

    verify(transaction).updateLocks(lockID, expectedValue);
    verify(localLockMediator, times(3)).lock(eq(lockID), eq(transaction), any(Timepoint.class));
}
 
Example #15
Source File: ElasticSearchConfigTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalNodeUsingExt() throws BackendException, InterruptedException {

    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_ext");

    assertFalse(new File(baseDir + File.separator + "data").exists());

    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs");
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    assertTrue(new File(baseDir + File.separator + "data").exists());
}
 
Example #16
Source File: KCVSConfigTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Override
public WriteConfiguration getConfig() {
    final KeyColumnValueStoreManager manager = new InMemoryStoreManager(Configuration.EMPTY);
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(GraphDatabaseConfiguration.TIMESTAMP_PROVIDER, TimestampProviders.MICRO);
    try {
        return new KCVSConfiguration(new BackendOperation.TransactionalProvider() {
            @Override
            public StoreTransaction openTx() throws BackendException {
                return manager.beginTransaction(StandardBaseTransactionConfig.of(TimestampProviders.MICRO, manager.getFeatures().getKeyConsistentTxConfig()));
            }

            @Override
            public void close() throws BackendException {
                manager.close();
            }
        }, config, manager.openDatabase("titan"),"general");
    } catch (BackendException e) {
        throw new RuntimeException(e);
    }
}
 
Example #17
Source File: HBaseStoreManager.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Override
public StoreFeatures getFeatures() {

    Configuration c = GraphDatabaseConfiguration.buildGraphConfiguration();

    StandardStoreFeatures.Builder fb = new StandardStoreFeatures.Builder()
            .orderedScan(true).unorderedScan(true).batchMutation(true)
            .multiQuery(true).distributed(true).keyOrdered(true).storeTTL(true)
            .timestamps(true).preferredTimestamps(PREFERRED_TIMESTAMPS)
            .keyConsistent(c);

    try {
        fb.localKeyPartition(getDeployment() == Deployment.LOCAL);
    } catch (Exception e) {
        logger.warn("Unexpected exception during getDeployment()", e);
    }

    return fb.build();
}
 
Example #18
Source File: InMemoryGraphTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
@Override
public void clopen(Object... settings) {
    if (settings!=null && settings.length>0) {
        if (graph!=null && graph.isOpen()) {
            Preconditions.checkArgument(!graph.vertices().hasNext() &&
                !graph.edges().hasNext(),"Graph cannot be re-initialized for InMemory since that would delete all data");
            graph.close();
        }
        Map<TestConfigOption,Object> options = validateConfigOptions(settings);
        ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
        config.set(GraphDatabaseConfiguration.STORAGE_BACKEND,"inmemory");
        for (Map.Entry<TestConfigOption,Object> option : options.entrySet()) {
            config.set(option.getKey().option, option.getValue(), option.getKey().umbrella);
        }
        open(config.getConfiguration());
    }
    newTx();
}
 
Example #19
Source File: HBaseStoreManager.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Override
public StoreFeatures getFeatures() {

    Configuration c = GraphDatabaseConfiguration.buildConfiguration();

    StandardStoreFeatures.Builder fb = new StandardStoreFeatures.Builder()
            .orderedScan(true).unorderedScan(true).batchMutation(true)
            .multiQuery(true).distributed(true).keyOrdered(true).storeTTL(true)
            .timestamps(true).preferredTimestamps(PREFERRED_TIMESTAMPS)
            .locking(true)
            .keyConsistent(c);

    try {
        fb.localKeyPartition(getDeployment() == Deployment.LOCAL);
    } catch (Exception e) {
        logger.warn("Unexpected exception during getDeployment()", e);
    }

    return fb.build();
}
 
Example #20
Source File: VertexIDAssignerTest.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param numPartitionsBits The number of partitions bits to use. This means there are exactly (1<<numPartitionBits) partitions.
 * @param partitionMax The maxium number of ids that can be allocated per partition. This is artifically constraint by the MockIDAuthority
 * @param localPartitionDef This array contains three integers: 1+2) lower and upper bounds for the local partition range, and
 *                          3) the bit width of the local bounds. The bounds will be bitshifted forward to consume the bit width
 */
public VertexIDAssignerTest(int numPartitionsBits, int partitionMax, int[] localPartitionDef) {
    MockIDAuthority idAuthority = new MockIDAuthority(11, partitionMax);

    StandardStoreFeatures.Builder fb = new StandardStoreFeatures.Builder();

    if (null != localPartitionDef) {
        fb.localKeyPartition(true);
        idAuthority.setLocalPartition(PartitionIDRangeTest.convert(localPartitionDef[0],localPartitionDef[1],localPartitionDef[2]));
    }
    StoreFeatures features = fb.build();

    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(GraphDatabaseConfiguration.CLUSTER_MAX_PARTITIONS,1<<numPartitionsBits);
    idAssigner = new VertexIDAssigner(config, idAuthority, features);
    System.out.println(String.format("Configuration [%s|%s|%s]",numPartitionsBits,partitionMax,Arrays.toString(localPartitionDef)));

    if (localPartitionDef!=null && localPartitionDef[0]<localPartitionDef[1] && localPartitionDef[2]<=numPartitionsBits) {
        this.maxIDAssignments = ((localPartitionDef[1]-localPartitionDef[0])<<(numPartitionsBits-localPartitionDef[2]))*((long)partitionMax);
    } else {
        this.maxIDAssignments = (1<<numPartitionsBits)*((long)partitionMax);
    }
}
 
Example #21
Source File: MapReduceIndexJobs.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
public static ScanMetrics cassandraRemove(Properties titanProperties, String indexName, String relationType,
                                          String partitionerName, Configuration hadoopBaseConf)
        throws InterruptedException, IOException, ClassNotFoundException {
    IndexRemoveJob job = new IndexRemoveJob();
    CassandraHadoopScanRunner cr = new CassandraHadoopScanRunner(job);
    ModifiableConfiguration mc = getIndexJobConf(indexName, relationType);
    copyPropertiesToInputAndOutputConf(hadoopBaseConf, titanProperties);
    cr.partitionerOverride(partitionerName);
    cr.scanJobConf(mc);
    cr.scanJobConfRoot(GraphDatabaseConfiguration.class.getName() + "#JOB_NS");
    cr.baseHadoopConf(hadoopBaseConf);
    return cr.run();
}
 
Example #22
Source File: SolrIndexTest.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
private Configuration getLocalSolrTestConfig() {
    final String index = "solr";
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();

    config.set(SolrIndex.ZOOKEEPER_URL, SolrRunner.getMiniCluster().getZkServer().getZkAddress(), index);
    config.set(SolrIndex.WAIT_SEARCHER, true, index);
    return config.restrictTo(index);
}
 
Example #23
Source File: MapReduceIndexJobs.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
public static ScanMetrics hbaseRepair(Properties titanProperties, String indexName, String relationType,
                                      Configuration hadoopBaseConf)
        throws InterruptedException, IOException, ClassNotFoundException {
    IndexRepairJob job = new IndexRepairJob();
    HBaseHadoopScanRunner cr = new HBaseHadoopScanRunner(job);
    ModifiableConfiguration mc = getIndexJobConf(indexName, relationType);
    copyPropertiesToInputAndOutputConf(hadoopBaseConf, titanProperties);
    cr.scanJobConf(mc);
    cr.scanJobConfRoot(GraphDatabaseConfiguration.class.getName() + "#JOB_NS");
    cr.baseHadoopConf(hadoopBaseConf);
    return cr.run();
}
 
Example #24
Source File: ElasticSearchIndexTest.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigurationFile() throws BackendException {
    final String index = "es";
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(LOCAL_MODE, true, index);
    config.set(CLIENT_ONLY, true, index);
    config.set(INDEX_CONF_FILE, Joiner.on(File.separator).join("target", "test-classes", "es_nodename_foo.yml"), index);
    config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index);
    Configuration indexConfig = config.restrictTo(index);

    ElasticSearchIndex idx = new ElasticSearchIndex(indexConfig); // Shouldn't throw exception
    idx.close();

    assertEquals("foo", idx.getNode().settings().get("node.name"));

    config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(LOCAL_MODE, true, index);
    config.set(CLIENT_ONLY, true, index);
    config.set(INDEX_CONF_FILE, Joiner.on(File.separator).join("target", "test-classes", "es_nodename_bar.yml"), index);
    config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index);
    indexConfig = config.restrictTo(index);

    idx = new ElasticSearchIndex(indexConfig); // Shouldn't throw exception
    idx.close();

    assertEquals("bar", idx.getNode().settings().get("node.name"));
}
 
Example #25
Source File: ElasticSearchIndexTest.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
public static final Configuration getLocalESTestConfig() {
    final String index = "es";
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(LOCAL_MODE, true, index);
    config.set(CLIENT_ONLY, false, index);
    config.set(TTL_INTERVAL, "5s", index);
    config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index);
    return config.restrictTo(index);
}
 
Example #26
Source File: BerkeleyGraphComputerProvider.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
@Override
public ModifiableConfiguration getTitanConfiguration(String graphName, Class<?> test, String testMethodName) {
    ModifiableConfiguration config = BerkeleyStorageSetup.getBerkeleyJEConfiguration(StorageSetup.getHomeDir(graphName));
    config.set(GraphDatabaseConfiguration.IDAUTHORITY_WAIT, Duration.ofMillis(20));
    config.set(GraphDatabaseConfiguration.STORAGE_TRANSACTIONAL,false);
    return config;
}
 
Example #27
Source File: BerkeleyJEStoreManager.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
public BerkeleyJEStoreManager(Configuration configuration) throws BackendException {
        super(configuration);
        stores = new HashMap<String, BerkeleyJEKeyValueStore>();

        int cachePercentage = configuration.get(JVM_CACHE);
        initialize(cachePercentage);

        features = new StandardStoreFeatures.Builder()
                    .orderedScan(true)
                    .transactional(transactional)
                    .keyConsistent(GraphDatabaseConfiguration.buildGraphConfiguration())
                    .locking(true)
                    .keyOrdered(true)
                    .scanTxConfig(GraphDatabaseConfiguration.buildGraphConfiguration()
                            .set(ISOLATION_LEVEL, IsolationLevel.READ_UNCOMMITTED.toString()))
                    .supportsInterruption(false)
                    .build();

//        features = new StoreFeatures();
//        features.supportsOrderedScan = true;
//        features.supportsUnorderedScan = false;
//        features.supportsBatchMutation = false;
//        features.supportsTxIsolation = transactional;
//        features.supportsConsistentKeyOperations = true;
//        features.supportsLocking = true;
//        features.isKeyOrdered = true;
//        features.isDistributed = false;
//        features.hasLocalKeyPartition = false;
//        features.supportsMultiQuery = false;
    }
 
Example #28
Source File: StandardTitanGraph.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
public StandardTitanGraph(GraphDatabaseConfiguration configuration) {

        this.config = configuration;
        this.backend = configuration.getBackend();

        this.idAssigner = config.getIDAssigner(backend);
        this.idManager = idAssigner.getIDManager();

        this.serializer = config.getSerializer();
        StoreFeatures storeFeatures = backend.getStoreFeatures();
        this.indexSerializer = new IndexSerializer(configuration.getConfiguration(), this.serializer,
                this.backend.getIndexInformation(), storeFeatures.isDistributed() && storeFeatures.isKeyOrdered());
        this.edgeSerializer = new EdgeSerializer(this.serializer);
        this.vertexExistenceQuery = edgeSerializer.getQuery(BaseKey.VertexExists, Direction.OUT, new EdgeSerializer.TypedInterval[0]).setLimit(1);
        this.queryCache = new RelationQueryCache(this.edgeSerializer);
        this.schemaCache = configuration.getTypeCache(typeCacheRetrieval);
        this.times = configuration.getTimestampProvider();

        isOpen = true;
        txCounter = new AtomicLong(0);
        openTransactions = Collections.newSetFromMap(new ConcurrentHashMap<StandardTitanTx, Boolean>(100, 0.75f, 1));

        //Register instance and ensure uniqueness
        String uniqueInstanceId = configuration.getUniqueGraphId();
        ModifiableConfiguration globalConfig = GraphDatabaseConfiguration.getGlobalSystemConfig(backend);
        if (globalConfig.has(REGISTRATION_TIME, uniqueInstanceId)) {
            throw new TitanException(String.format("A Titan graph with the same instance id [%s] is already open. Might required forced shutdown.", uniqueInstanceId));
        }
        globalConfig.set(REGISTRATION_TIME, times.getTime(), uniqueInstanceId);

        Log mgmtLog = backend.getSystemMgmtLog();
        mgmtLogger = new ManagementLogger(this, mgmtLog, schemaCache, this.times);
        mgmtLog.registerReader(ReadMarker.fromNow(), mgmtLogger);

        shutdownHook = new ShutdownThread(this);
        Runtime.getRuntime().addShutdownHook(shutdownHook);
        log.debug("Installed shutdown hook {}", shutdownHook, new Throwable("Hook creation trace"));
    }
 
Example #29
Source File: StandardTitanGraph.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
@Override
public Long retrieveSchemaByName(String typeName) {
    // Get a consistent tx
    Configuration customTxOptions = backend.getStoreFeatures().getKeyConsistentTxConfig();
    StandardTitanTx consistentTx = null;
    try {
        consistentTx = StandardTitanGraph.this.newTransaction(new StandardTransactionBuilder(getConfiguration(),
                StandardTitanGraph.this, customTxOptions).groupName(GraphDatabaseConfiguration.METRICS_SCHEMA_PREFIX_DEFAULT));
        consistentTx.getTxHandle().disableCache();
        TitanVertex v = Iterables.getOnlyElement(QueryUtil.getVertices(consistentTx, BaseKey.SchemaName, typeName), null);
        return v!=null?v.longId():null;
    } finally {
        TXUtils.rollbackQuietly(consistentTx);
    }
}
 
Example #30
Source File: InMemoryPartitionGraphTest.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
@Override
public WriteConfiguration getBaseConfiguration() {
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(GraphDatabaseConfiguration.STORAGE_BACKEND,"inmemory");
    config.set(GraphDatabaseConfiguration.IDS_FLUSH,false);
    return config.getConfiguration();
}