Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ArangoDatabase::getEngine
  • Loading branch information
michele committed Aug 8, 2019
commit f854b886d0da3a37ef7d4f6208b3da8d4b58a26c
18 changes: 11 additions & 7 deletions src/main/java/com/arangodb/ArangoDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@

import javax.net.ssl.SSLContext;

import com.arangodb.entity.ArangoDBVersion;
import com.arangodb.entity.LoadBalancingStrategy;
import com.arangodb.entity.LogEntity;
import com.arangodb.entity.LogLevelEntity;
import com.arangodb.entity.Permissions;
import com.arangodb.entity.ServerRole;
import com.arangodb.entity.UserEntity;
import com.arangodb.entity.*;
import com.arangodb.internal.ArangoContext;
import com.arangodb.internal.ArangoDBImpl;
import com.arangodb.internal.ArangoDefaults;
Expand Down Expand Up @@ -717,6 +711,16 @@ public synchronized ArangoDB build() {
*/
ArangoDBVersion getVersion() throws ArangoDBException;

/**
* Returns the server storage engine.
*
* @see <a href="https://docs.arangodb.com/current/HTTP/MiscellaneousFunctions/index.html#return-server-database-engine-type">API
* Documentation</a>
* @return the storage engine name
* @throws ArangoDBException
*/
ArangoDBEngine getEngine() throws ArangoDBException;

/**
* Returns the server role.
*
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/arangodb/ArangoDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public interface ArangoDatabase extends ArangoSerializationAccessor {
*/
ArangoDBVersion getVersion() throws ArangoDBException;

/**
* Returns the name of the used storage engine.
*
* @return the storage engine name
* @throws ArangoDBException
* @see <a href="https://docs.arangodb.com/current/HTTP/MiscellaneousFunctions/index.html#return-server-database-engine-type">API
* Documentation</a>
*/
ArangoDBEngine getEngine() throws ArangoDBException;

/**
* Checks whether the database exists
*
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/arangodb/entity/ArangoDBEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* DISCLAIMER
*
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright holder is ArangoDB GmbH, Cologne, Germany
*/

package com.arangodb.entity;

/**
* @author Michele Rastelli
* @see <a href="https://docs.arangodb.com/current/HTTP/MiscellaneousFunctions/index.html#return-server-database-engine-type">API
* Documentation</a>
*/
public class ArangoDBEngine implements Entity {

public enum StorageEngineName {
mmfiles, rocksdb
}

private StorageEngineName name;

public ArangoDBEngine() {
super();
}

/**
* @return the storage engine name
*/
public StorageEngineName getName() {
return name;
}

}
12 changes: 6 additions & 6 deletions src/main/java/com/arangodb/internal/ArangoDBImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@
import java.io.IOException;
import java.util.Collection;

import com.arangodb.entity.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.arangodb.ArangoDB;
import com.arangodb.ArangoDBException;
import com.arangodb.ArangoDatabase;
import com.arangodb.Protocol;
import com.arangodb.entity.ArangoDBVersion;
import com.arangodb.entity.LogEntity;
import com.arangodb.entity.LogLevelEntity;
import com.arangodb.entity.Permissions;
import com.arangodb.entity.ServerRole;
import com.arangodb.entity.UserEntity;
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
import com.arangodb.internal.http.HttpCommunication;
import com.arangodb.internal.http.HttpProtocol;
Expand Down Expand Up @@ -163,6 +158,11 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
return db().getVersion();
}

@Override
public ArangoDBEngine getEngine() throws ArangoDBException {
return db().getEngine();
}

@Override
public ServerRole getRole() throws ArangoDBException {
return executor.execute(getRoleRequest(), getRoleResponseDeserializer());
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
return executor.execute(getVersionRequest(), ArangoDBVersion.class);
}

@Override
public ArangoDBEngine getEngine() throws ArangoDBException {
return executor.execute(getEngineRequest(), ArangoDBEngine.class);
}

@Override
public boolean exists() throws ArangoDBException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public abstract class InternalArangoDatabase<A extends InternalArangoDB<E>, E ex

protected static final String PATH_API_DATABASE = "/_api/database";
private static final String PATH_API_VERSION = "/_api/version";
private static final String PATH_API_ENGINE = "/_api/engine";
private static final String PATH_API_CURSOR = "/_api/cursor";
private static final String PATH_API_TRANSACTION = "/_api/transaction";
private static final String PATH_API_BEGIN_STREAM_TRANSACTION = "/_api/transaction/begin";
Expand Down Expand Up @@ -92,6 +93,10 @@ protected Request getVersionRequest() {
return request(name, RequestType.GET, PATH_API_VERSION);
}

protected Request getEngineRequest() {
return request(name, RequestType.GET, PATH_API_ENGINE);
}

protected Request createCollectionRequest(final String name, final CollectionCreateOptions options) {

VPackSlice body = util()
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/arangodb/ArangoDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ public void getVersion() {
assertThat(version.getVersion(), is(notNullValue()));
}

@Test
public void getEngine() {
final ArangoDBEngine engine = db.getEngine();
assertThat(engine, is(notNullValue()));
assertThat(engine.getName(), is(notNullValue()));
}

@Test
public void exists() {
assertThat(db.exists(), is(true));
Expand Down