com.arangodb.ArangoDatabase Java Examples

The following examples show how to use com.arangodb.ArangoDatabase. 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: CommunicationTest.java    From arangodb-java-driver with 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 File: ArangoTemplate.java    From spring-data with 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 File: DefaultUserOperation.java    From spring-data with 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 File: ArangoDBImpl.java    From arangodb-java-driver with Apache License 2.0 4 votes vote down vote up
@Override
public ArangoDatabase db() {
    return db(ArangoRequestParam.SYSTEM);
}
 
Example #5
Source File: ArangoDBImpl.java    From arangodb-java-driver with 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 File: ArangoDBGraphClient.java    From arangodb-tinkerpop-provider with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the database.
 *
 * @return the ArangoDB
 */

public ArangoDatabase getDB() {
	return db;
}