Search in sources :

Example 16 with Configuration

use of org.janusgraph.diskstorage.configuration.Configuration in project janusgraph by JanusGraph.

the class ElasticSearchConfigTest method testExternalMappingsViaMapping.

@Test
public void testExternalMappingsViaMapping() throws Exception {
    final Duration maxWrite = Duration.ofMillis(2000L);
    final String storeName = "test_mapping";
    final Configuration indexConfig = GraphDatabaseConfiguration.buildGraphConfiguration().set(USE_EXTERNAL_MAPPINGS, true, INDEX_NAME).restrictTo(INDEX_NAME);
    final IndexProvider idx = open(indexConfig);
    final ElasticMajorVersion version = ((ElasticSearchIndex) idx).getVersion();
    // Test create index KO mapping is not push
    final KeyInformation.IndexRetriever indexRetriever = IndexProviderTest.getIndexRetriever(IndexProviderTest.getMapping(idx.getFeatures(), ANALYZER_ENGLISH, ANALYZER_KEYWORD));
    final BaseTransactionConfig txConfig = StandardBaseTransactionConfig.of(TimestampProviders.MILLI);
    final IndexTransaction itx = new IndexTransaction(idx, indexRetriever, txConfig, maxWrite);
    try {
        idx.register(storeName, "date", IndexProviderTest.getMapping(idx.getFeatures(), ANALYZER_ENGLISH, ANALYZER_KEYWORD).get("date"), itx);
        fail("should fail");
    } catch (final PermanentBackendException ignored) {
    }
    final HttpPut newMapping = new HttpPut("janusgraph_" + storeName);
    newMapping.setEntity(new StringEntity(objectMapper.writeValueAsString(readMapping(version, "/strict_mapping.json")), Charset.forName("UTF-8")));
    executeRequest(newMapping);
    // Test date property OK
    idx.register(storeName, "date", IndexProviderTest.getMapping(idx.getFeatures(), ANALYZER_ENGLISH, ANALYZER_KEYWORD).get("date"), itx);
    // Test weight property KO
    try {
        idx.register(storeName, "weight", IndexProviderTest.getMapping(idx.getFeatures(), ANALYZER_ENGLISH, ANALYZER_KEYWORD).get("weight"), itx);
        fail("should fail");
    } catch (final BackendException ignored) {
    }
    itx.rollback();
    idx.close();
}
Also used : BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) Configuration(org.janusgraph.diskstorage.configuration.Configuration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) Duration(java.time.Duration) StandardBaseTransactionConfig(org.janusgraph.diskstorage.util.StandardBaseTransactionConfig) BaseTransactionConfig(org.janusgraph.diskstorage.BaseTransactionConfig) HttpPut(org.apache.http.client.methods.HttpPut) BackendException(org.janusgraph.diskstorage.BackendException) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) StringEntity(org.apache.http.entity.StringEntity) ElasticSearchIndex(org.janusgraph.diskstorage.es.ElasticSearchIndex) Test(org.junit.Test)

Example 17 with Configuration

use of org.janusgraph.diskstorage.configuration.Configuration in project janusgraph by JanusGraph.

the class ElasticSearchConfigTest method testMultiTypeUpgrade.

@Test
public void testMultiTypeUpgrade() throws InterruptedException, BackendException, IOException {
    // create multi-type index
    final ModifiableConfiguration config = esr.setElasticsearchConfiguration(GraphDatabaseConfiguration.buildGraphConfiguration(), INDEX_NAME);
    config.set(USE_DEPRECATED_MULTITYPE_INDEX, true, INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = open(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();
    // should be able to open multi-type index if USE_DEPRECATED_MULTITYPE_INDEX is unset
    config.remove(USE_DEPRECATED_MULTITYPE_INDEX, INDEX_NAME);
    indexConfig = config.restrictTo(INDEX_NAME);
    idx = open(indexConfig);
    idx.close();
}
Also used : BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) Configuration(org.janusgraph.diskstorage.configuration.Configuration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) Test(org.junit.Test)

Example 18 with Configuration

use of org.janusgraph.diskstorage.configuration.Configuration in project janusgraph by JanusGraph.

the class HBaseStoreManager method getFeatures.

@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).cellTTL(true).timestamps(true).preferredTimestamps(PREFERRED_TIMESTAMPS).optimisticLocking(true).keyConsistent(c);
    try {
        fb.localKeyPartition(getDeployment() == Deployment.LOCAL);
    } catch (Exception e) {
        logger.warn("Unexpected exception during getDeployment()", e);
    }
    return fb.build();
}
Also used : StandardStoreFeatures(org.janusgraph.diskstorage.keycolumnvalue.StandardStoreFeatures) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) Configuration(org.janusgraph.diskstorage.configuration.Configuration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException) TemporaryBackendException(org.janusgraph.diskstorage.TemporaryBackendException) JanusGraphException(org.janusgraph.core.JanusGraphException) ZooKeeperConnectionException(org.apache.hadoop.hbase.ZooKeeperConnectionException) BackendException(org.janusgraph.diskstorage.BackendException) IOException(java.io.IOException) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException)

Aggregations

Configuration (org.janusgraph.diskstorage.configuration.Configuration)18 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)11 ModifiableConfiguration (org.janusgraph.diskstorage.configuration.ModifiableConfiguration)9 Test (org.junit.Test)9 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)8 BasicConfiguration (org.janusgraph.diskstorage.configuration.BasicConfiguration)8 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)8 BaseTransactionConfig (org.janusgraph.diskstorage.BaseTransactionConfig)5 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)5 ElasticSearchIndex (org.janusgraph.diskstorage.es.ElasticSearchIndex)5 BackendException (org.janusgraph.diskstorage.BackendException)4 IOException (java.io.IOException)3 StandardStoreFeatures (org.janusgraph.diskstorage.keycolumnvalue.StandardStoreFeatures)3 StandardBaseTransactionConfig (org.janusgraph.diskstorage.util.StandardBaseTransactionConfig)3 Session (com.datastax.driver.core.Session)2 Duration (java.time.Duration)2 List (java.util.List)2 HttpPut (org.apache.http.client.methods.HttpPut)2 StringEntity (org.apache.http.entity.StringEntity)2 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)2