diff --git a/core/src/main/java/com/arangodb/ArangoDB.java b/core/src/main/java/com/arangodb/ArangoDB.java index 0b11794a6..bf9881cb8 100644 --- a/core/src/main/java/com/arangodb/ArangoDB.java +++ b/core/src/main/java/com/arangodb/ArangoDB.java @@ -24,10 +24,7 @@ import com.arangodb.internal.ArangoDBImpl; import com.arangodb.internal.InternalArangoDBBuilder; import com.arangodb.internal.net.*; -import com.arangodb.model.DBCreateOptions; -import com.arangodb.model.LogOptions; -import com.arangodb.model.UserCreateOptions; -import com.arangodb.model.UserUpdateOptions; +import com.arangodb.model.*; import javax.annotation.concurrent.ThreadSafe; import java.util.Collection; @@ -298,6 +295,14 @@ public interface ArangoDB extends ArangoSerdeAccessor { */ LogLevelEntity getLogLevel(); + /** + * Returns the server's current loglevel settings. + * + * @return the server's current loglevel settings + * @since ArangoDB 3.10 + */ + LogLevelEntity getLogLevel(LogLevelOptions options); + /** * Modifies and returns the server's current loglevel settings. * @@ -307,6 +312,15 @@ public interface ArangoDB extends ArangoSerdeAccessor { */ LogLevelEntity setLogLevel(LogLevelEntity entity); + /** + * Modifies and returns the server's current loglevel settings. + * + * @param entity loglevel settings + * @return the server's current loglevel settings + * @since ArangoDB 3.10 + */ + LogLevelEntity setLogLevel(LogLevelEntity entity, LogLevelOptions options); + /** * @return the list of available rules and their respective flags * @since ArangoDB 3.10 diff --git a/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java b/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java index b66c30c71..09bb02365 100644 --- a/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java +++ b/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java @@ -27,10 +27,7 @@ import com.arangodb.internal.net.HostResolver; import com.arangodb.internal.net.ProtocolProvider; import com.arangodb.internal.serde.SerdeUtils; -import com.arangodb.model.DBCreateOptions; -import com.arangodb.model.LogOptions; -import com.arangodb.model.UserCreateOptions; -import com.arangodb.model.UserUpdateOptions; +import com.arangodb.model.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -185,12 +182,22 @@ public LogEntriesEntity getLogEntries(final LogOptions options) { @Override public LogLevelEntity getLogLevel() { - return executor.execute(getLogLevelRequest(), LogLevelEntity.class); + return getLogLevel(new LogLevelOptions()); + } + + @Override + public LogLevelEntity getLogLevel(final LogLevelOptions options) { + return executor.execute(getLogLevelRequest(options), LogLevelEntity.class); } @Override public LogLevelEntity setLogLevel(final LogLevelEntity entity) { - return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class); + return setLogLevel(entity, new LogLevelOptions()); + } + + @Override + public LogLevelEntity setLogLevel(final LogLevelEntity entity, final LogLevelOptions options) { + return executor.execute(setLogLevelRequest(entity, options), LogLevelEntity.class); } @Override diff --git a/core/src/main/java/com/arangodb/internal/InternalArangoDB.java b/core/src/main/java/com/arangodb/internal/InternalArangoDB.java index c2d57374e..595b7c601 100644 --- a/core/src/main/java/com/arangodb/internal/InternalArangoDB.java +++ b/core/src/main/java/com/arangodb/internal/InternalArangoDB.java @@ -187,12 +187,14 @@ protected InternalRequest getLogEntriesRequest(final LogOptions options) { .putQueryParam(LogOptions.PROPERTY_SORT, params.getSort()); } - protected InternalRequest getLogLevelRequest() { - return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_ADMIN_LOG_LEVEL); + protected InternalRequest getLogLevelRequest(final LogLevelOptions options) { + return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_ADMIN_LOG_LEVEL) + .putQueryParam("serverId", options.getServerId()); } - protected InternalRequest setLogLevelRequest(final LogLevelEntity entity) { + protected InternalRequest setLogLevelRequest(final LogLevelEntity entity, final LogLevelOptions options) { return request(ArangoRequestParam.SYSTEM, RequestType.PUT, PATH_API_ADMIN_LOG_LEVEL) + .putQueryParam("serverId", options.getServerId()) .setBody(getSerde().serialize(entity)); } diff --git a/core/src/main/java/com/arangodb/model/LogLevelOptions.java b/core/src/main/java/com/arangodb/model/LogLevelOptions.java new file mode 100644 index 000000000..9ce6ca52e --- /dev/null +++ b/core/src/main/java/com/arangodb/model/LogLevelOptions.java @@ -0,0 +1,14 @@ +package com.arangodb.model; + +public class LogLevelOptions { + private String serverId; + + public String getServerId() { + return serverId; + } + + public LogLevelOptions serverId(final String serverId) { + this.serverId = serverId; + return this; + } +} diff --git a/driver/src/test/java/com/arangodb/ArangoDBTest.java b/driver/src/test/java/com/arangodb/ArangoDBTest.java index a80b16bbe..b02a351f4 100644 --- a/driver/src/test/java/com/arangodb/ArangoDBTest.java +++ b/driver/src/test/java/com/arangodb/ArangoDBTest.java @@ -538,6 +538,25 @@ void setAllLogLevel(ArangoDB arangoDB) { } } + @ParameterizedTest(name = "{index}") + @MethodSource("arangos") + void logLevelWithServerId(ArangoDB arangoDB) { + assumeTrue(isAtLeastVersion(3, 10)); + assumeTrue(isCluster()); + String serverId = arangoDB.getServerId(); + LogLevelOptions options = new LogLevelOptions().serverId(serverId); + final LogLevelEntity entity = new LogLevelEntity(); + try { + entity.setGraphs(LogLevelEntity.LogLevel.ERROR); + final LogLevelEntity logLevel = arangoDB.setLogLevel(entity, options); + assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + assertThat(arangoDB.getLogLevel(options).getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + } finally { + entity.setGraphs(LogLevelEntity.LogLevel.INFO); + arangoDB.setLogLevel(entity); + } + } + @ParameterizedTest(name = "{index}") @MethodSource("arangos") void getQueryOptimizerRules(ArangoDB arangoDB) {