Java Code Examples for com.arangodb.ArangoDatabase

The following examples show how to use com.arangodb.ArangoDatabase. These examples are extracted from open source projects. 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 Project: arangodb-java-driver   Author: arangodb   File: CommunicationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void multiThreadSameDatabases() throws Exception {
    final ArangoDB arangoDB = new ArangoDB.Builder().build();
    arangoDB.getVersion();// authentication

    final ArangoDatabase db = arangoDB.db();

    final Collection<String> result = new ConcurrentLinkedQueue<>();
    final Thread t1 = new Thread(() -> {
        db.query("return sleep(0.1)", null, null, null);
        result.add("1");
    });
    final Thread t2 = new Thread(() -> {
        db.query("return sleep(0.1)", null, null, null);
        result.add("1");
    });
    t2.start();
    t1.start();
    t2.join();
    t1.join();
    assertThat(result.size(), is(2));
}
 
Example #2
Source Project: spring-data   Author: arangodb   File: ArangoTemplate.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void dropDatabase() throws DataAccessException {
	final ArangoDatabase db = db();
	try {
		db.drop();
	} catch (final ArangoDBException e) {
		throw translateExceptionIfPossible(e);
	}
	databaseCache.remove(db.name());
	collectionCache.keySet().stream().filter(key -> key.getDb().equals(db.name()))
			.forEach(key -> collectionCache.remove(key));
}
 
Example #3
Source Project: spring-data   Author: arangodb   File: DefaultUserOperation.java    License: Apache License 2.0 5 votes vote down vote up
protected DefaultUserOperation(final ArangoDatabase db, final String username,
	final PersistenceExceptionTranslator exceptionTranslator, final CollectionCallback collectionCallback) {
	this.db = db;
	this.username = username;
	this.exceptionTranslator = exceptionTranslator;
	this.collectionCallback = collectionCallback;
}
 
Example #4
Source Project: arangodb-java-driver   Author: arangodb   File: ArangoDBImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ArangoDatabase db() {
    return db(ArangoRequestParam.SYSTEM);
}
 
Example #5
Source Project: arangodb-java-driver   Author: arangodb   File: ArangoDBImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ArangoDatabase db(final String name) {
    return new ArangoDatabaseImpl(this, name).setCursorInitializer(cursorInitializer);
}
 
Example #6
Source Project: arangodb-tinkerpop-provider   Author: ArangoDB-Community   File: ArangoDBGraphClient.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Gets the database.
 *
 * @return the ArangoDB
 */

public ArangoDatabase getDB() {
	return db;
}