use of org.janusgraph.diskstorage.BaseTransactionConfig in project janusgraph by JanusGraph.
the class CassandraTransactionTest method testTimestampProvider.
@Test
public void testTimestampProvider() {
BaseTransactionConfig baseTransactionConfig = StandardBaseTransactionConfig.of(TimestampProviders.NANO);
CassandraTransaction ct = new CassandraTransaction(baseTransactionConfig);
assertEquals(TimestampProviders.NANO, ct.getConfiguration().getTimestampProvider());
baseTransactionConfig = StandardBaseTransactionConfig.of(TimestampProviders.MICRO);
ct = new CassandraTransaction(baseTransactionConfig);
assertEquals(TimestampProviders.MICRO, ct.getConfiguration().getTimestampProvider());
baseTransactionConfig = StandardBaseTransactionConfig.of(TimestampProviders.MILLI);
ct = new CassandraTransaction(baseTransactionConfig);
assertEquals(TimestampProviders.MILLI, ct.getConfiguration().getTimestampProvider());
}
use of org.janusgraph.diskstorage.BaseTransactionConfig in project janusgraph by JanusGraph.
the class ElasticSearchConfigTest method testExternalDynamic.
@Test
public void testExternalDynamic() 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, "/dynamic_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 OK because dynamic mapping
idx.register(storeName, "weight", IndexProviderTest.getMapping(idx.getFeatures(), ANALYZER_ENGLISH, ANALYZER_KEYWORD).get("weight"), itx);
itx.rollback();
idx.close();
}
use of org.janusgraph.diskstorage.BaseTransactionConfig in project janusgraph by JanusGraph.
the class ElasticSearchConfigTest method testExternalMappingsViaTemplate.
@Test
public void testExternalMappingsViaTemplate() 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();
final HttpPut newTemplate = new HttpPut("_template/template_1");
final Map<String, Object> content = ImmutableMap.of("template", "janusgraph_test_mapping*", "mappings", readMapping(version, "/strict_mapping.json").getMappings());
newTemplate.setEntity(new StringEntity(objectMapper.writeValueAsString(content), Charset.forName("UTF-8")));
executeRequest(newTemplate);
final HttpPut newMapping = new HttpPut("janusgraph_" + storeName);
executeRequest(newMapping);
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);
// 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();
}
use of org.janusgraph.diskstorage.BaseTransactionConfig in project janusgraph by JanusGraph.
the class ExpectedValueCheckingStoreManager method beginTransaction.
@Override
public ExpectedValueCheckingTransaction beginTransaction(BaseTransactionConfig configuration) throws BackendException {
// Get a transaction without any guarantees about strong consistency
StoreTransaction inconsistentTx = manager.beginTransaction(configuration);
// Get a transaction that provides global strong consistency
Configuration customOptions = new MergedConfiguration(storeFeatures.getKeyConsistentTxConfig(), configuration.getCustomOptions());
BaseTransactionConfig consistentTxCfg = new StandardBaseTransactionConfig.Builder(configuration).customOptions(customOptions).build();
StoreTransaction strongConsistentTx = manager.beginTransaction(consistentTxCfg);
// Return a wrapper around both the inconsistent and consistent store transactions
return new ExpectedValueCheckingTransaction(inconsistentTx, strongConsistentTx, maxReadTime);
}
use of org.janusgraph.diskstorage.BaseTransactionConfig 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();
}
Aggregations