@Test
  public void testTransportClient() throws BackendException, InterruptedException {
    ElasticsearchRunner esr = new ElasticsearchRunner(".", "transportClient.yml");
    esr.start();
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(INTERFACE, ElasticSearchSetup.TRANSPORT_CLIENT.toString(), INDEX_NAME);
    config.set(INDEX_HOSTS, new String[] {"127.0.0.1"}, INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(INTERFACE, ElasticSearchSetup.TRANSPORT_CLIENT.toString(), INDEX_NAME);
    config.set(INDEX_HOSTS, new String[] {"10.11.12.13"}, INDEX_NAME);
    indexConfig = config.restrictTo(INDEX_NAME);
    Throwable failure = null;
    try {
      idx = new ElasticSearchIndex(indexConfig);
    } catch (Throwable t) {
      failure = t;
    }
    // idx.close();
    Assert.assertNotNull("ES client failed to throw exception on connection failure", failure);

    esr.stop();
  }
Beispiel #2
0
 @Override
 public Features getFeatures() {
   Features features = TitanFeatures.getBaselineTitanFeatures();
   GraphDatabaseConfiguration config = ((StandardTitanGraph) this).getConfiguration();
   features.supportsSerializableObjectProperty = config.hasSerializeAll();
   return features;
 }
  @Test
  public void testNetworkNodeUsingYaml() throws BackendException, InterruptedException {
    ElasticsearchRunner esr = new ElasticsearchRunner(".", "networkNodeUsingYaml.yml");
    esr.start();
    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_cfg_nodeclient.yml"),
        INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    config.set(HEALTH_REQUEST_TIMEOUT, "5s", INDEX_NAME);
    config.set(
        INDEX_CONF_FILE,
        Joiner.on(File.separator).join("target", "test-classes", "es_cfg_bogus_nodeclient.yml"),
        INDEX_NAME);
    indexConfig = config.restrictTo(INDEX_NAME);

    Throwable failure = null;
    try {
      idx = new ElasticSearchIndex(indexConfig);
    } catch (Throwable t) {
      failure = t;
    }
    // idx.close();
    Assert.assertNotNull("ES client failed to throw exception on connection failure", failure);
    esr.stop();
  }
Beispiel #4
0
 @Override
 public String toString() {
   GraphDatabaseConfiguration config = ((StandardTitanGraph) this).getConfiguration();
   return "titangraph"
       + StringFactory.L_BRACKET
       + config.getStorageManagerDescription()
       + StringFactory.R_BRACKET;
   //        return StringFactory.graphString(this,config.getStorageManagerDescription());
 }
Beispiel #5
0
 /** Constructs a new TitanTransaction configuration with default configuration parameters. */
 public TransactionConfig(GraphDatabaseConfiguration graphConfig, boolean threadBound) {
   this.isReadOnly = graphConfig.isReadOnly();
   this.assignIDsImmediately = graphConfig.hasFlushIDs();
   this.defaultTypeMaker = graphConfig.getDefaultTypeMaker();
   if (graphConfig.isBatchLoading()) {
     verifyUniqueness = false;
     verifyVertexExistence = false;
     acquireLocks = false;
   } else {
     verifyUniqueness = true;
     verifyVertexExistence = true;
     acquireLocks = true;
   }
   this.threadBound = threadBound;
   singleThreaded = threadBound;
 }
  public StandardTitanGraph(GraphDatabaseConfiguration configuration) {
    this.config = configuration;
    this.storage = configuration.getStorageManager();
    this.edgeStore = configuration.getEdgeStore(this.storage);
    this.propertyIndex = configuration.getPropertyIndex(this.storage);
    this.bufferMutations = configuration.hasBufferMutations();
    this.bufferSize = configuration.getBufferSize();
    Preconditions.checkArgument(bufferSize > 0);
    this.maxWriteRetryAttempts = config.getWriteAttempts();
    this.maxReadRetryAttempts = config.getReadAttempts();
    this.retryStorageWaitTime = config.getStorageWaittime();

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

    this.serializer = config.getSerializer();
    this.etManager = new SimpleTypeManager(this);
    isOpen = true;
  }
Beispiel #7
0
 private static final Map<String, IndexProvider> getIndexes(Configuration storageConfig) {
   Configuration indexConfig = storageConfig.subset(GraphDatabaseConfiguration.INDEX_NAMESPACE);
   Set<String> indexes = GraphDatabaseConfiguration.getUnqiuePrefixes(indexConfig);
   ImmutableMap.Builder<String, IndexProvider> builder = ImmutableMap.builder();
   for (String index : indexes) {
     Preconditions.checkArgument(StringUtils.isNotBlank(index), "Invalid index name [%s]", index);
     Configuration config = indexConfig.subset(index);
     log.info(
         "Configuring index [{}] based on: \n {}",
         index,
         GraphDatabaseConfiguration.toString(config));
     IndexProvider provider =
         getImplementationClass(
             config,
             GraphDatabaseConfiguration.INDEX_BACKEND_KEY,
             GraphDatabaseConfiguration.INDEX_BACKEND_DEFAULT,
             REGISTERED_INDEX_PROVIDERS);
     Preconditions.checkNotNull(provider);
     builder.put(index, provider);
   }
   return builder.build();
 }
 @Override
 public LogManager openLogManager(String senderId, boolean requiresOrderPreserving)
     throws BackendException {
   storeManager = openStorageManager();
   ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
   config.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, senderId);
   config.set(GraphDatabaseConfiguration.LOG_READ_INTERVAL, Duration.ofMillis(500L), LOG_NAME);
   // To ensure that the write order is preserved in reading, we need to ensure that all writes go
   // to the same partition
   // otherwise readers will independently read from the partitions out-of-order by design to avoid
   // having to synchronize
   config.set(KCVSLogManager.LOG_FIXED_PARTITION, requiresOrderPreserving, LOG_NAME);
   return new KCVSLogManager(storeManager, config.restrictTo(LOG_NAME));
 }
  @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());
  }
 private final StoreMutator getStoreMutator(TransactionHandle txh) {
   if (edgeStore instanceof MultiWriteKeyColumnValueStore
       && propertyIndex instanceof MultiWriteKeyColumnValueStore) {
     if (config.isBatchLoading()) {
       //                return new BatchStoreMutator(txh,
       // (MultiWriteKeyColumnValueStore)edgeStore, (MultiWriteKeyColumnValueStore)propertyIndex,
       // bufferSize, 8);
       return new BufferStoreMutator(
           txh,
           (MultiWriteKeyColumnValueStore) edgeStore,
           (MultiWriteKeyColumnValueStore) propertyIndex,
           bufferSize);
     } else if (bufferMutations) {
       return new BufferStoreMutator(
           txh,
           (MultiWriteKeyColumnValueStore) edgeStore,
           (MultiWriteKeyColumnValueStore) propertyIndex,
           bufferSize);
     }
   }
   return new DirectStoreMutator(txh, edgeStore, propertyIndex);
 }
  public InMemoryStoreManager(final Configuration configuration) {

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

    features =
        new StandardStoreFeatures.Builder()
            .orderedScan(true)
            .unorderedScan(true)
            .keyOrdered(true)
            .keyConsistent(GraphDatabaseConfiguration.buildConfiguration())
            .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;
  }
 public WriteConfiguration getConfiguration() {
   ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
   config.set(GraphDatabaseConfiguration.STORAGE_BACKEND, "inmemory");
   return config.getConfiguration();
 }