Skip to content

Commit 3e1a9ab

Browse files
authored
[DE-557] serverId query parameter for /_admin/log/level (#498)
* serverId query parameter for /_admin/log/level * fixed javadoc
1 parent 898b9d8 commit 3e1a9ab

File tree

5 files changed

+69
-13
lines changed

5 files changed

+69
-13
lines changed

core/src/main/java/com/arangodb/ArangoDB.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
import com.arangodb.internal.ArangoDBImpl;
2525
import com.arangodb.internal.InternalArangoDBBuilder;
2626
import com.arangodb.internal.net.*;
27-
import com.arangodb.model.DBCreateOptions;
28-
import com.arangodb.model.LogOptions;
29-
import com.arangodb.model.UserCreateOptions;
30-
import com.arangodb.model.UserUpdateOptions;
27+
import com.arangodb.model.*;
3128

3229
import javax.annotation.concurrent.ThreadSafe;
3330
import java.util.Collection;
@@ -298,6 +295,14 @@ public interface ArangoDB extends ArangoSerdeAccessor {
298295
*/
299296
LogLevelEntity getLogLevel();
300297

298+
/**
299+
* Returns the server's current loglevel settings.
300+
*
301+
* @return the server's current loglevel settings
302+
* @since ArangoDB 3.10
303+
*/
304+
LogLevelEntity getLogLevel(LogLevelOptions options);
305+
301306
/**
302307
* Modifies and returns the server's current loglevel settings.
303308
*
@@ -307,6 +312,15 @@ public interface ArangoDB extends ArangoSerdeAccessor {
307312
*/
308313
LogLevelEntity setLogLevel(LogLevelEntity entity);
309314

315+
/**
316+
* Modifies and returns the server's current loglevel settings.
317+
*
318+
* @param entity loglevel settings
319+
* @return the server's current loglevel settings
320+
* @since ArangoDB 3.10
321+
*/
322+
LogLevelEntity setLogLevel(LogLevelEntity entity, LogLevelOptions options);
323+
310324
/**
311325
* @return the list of available rules and their respective flags
312326
* @since ArangoDB 3.10

core/src/main/java/com/arangodb/internal/ArangoDBImpl.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
import com.arangodb.internal.net.HostResolver;
2828
import com.arangodb.internal.net.ProtocolProvider;
2929
import com.arangodb.internal.serde.SerdeUtils;
30-
import com.arangodb.model.DBCreateOptions;
31-
import com.arangodb.model.LogOptions;
32-
import com.arangodb.model.UserCreateOptions;
33-
import com.arangodb.model.UserUpdateOptions;
30+
import com.arangodb.model.*;
3431
import org.slf4j.Logger;
3532
import org.slf4j.LoggerFactory;
3633

@@ -185,12 +182,22 @@ public LogEntriesEntity getLogEntries(final LogOptions options) {
185182

186183
@Override
187184
public LogLevelEntity getLogLevel() {
188-
return executor.execute(getLogLevelRequest(), LogLevelEntity.class);
185+
return getLogLevel(new LogLevelOptions());
186+
}
187+
188+
@Override
189+
public LogLevelEntity getLogLevel(final LogLevelOptions options) {
190+
return executor.execute(getLogLevelRequest(options), LogLevelEntity.class);
189191
}
190192

191193
@Override
192194
public LogLevelEntity setLogLevel(final LogLevelEntity entity) {
193-
return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class);
195+
return setLogLevel(entity, new LogLevelOptions());
196+
}
197+
198+
@Override
199+
public LogLevelEntity setLogLevel(final LogLevelEntity entity, final LogLevelOptions options) {
200+
return executor.execute(setLogLevelRequest(entity, options), LogLevelEntity.class);
194201
}
195202

196203
@Override

core/src/main/java/com/arangodb/internal/InternalArangoDB.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,14 @@ protected InternalRequest getLogEntriesRequest(final LogOptions options) {
187187
.putQueryParam(LogOptions.PROPERTY_SORT, params.getSort());
188188
}
189189

190-
protected InternalRequest getLogLevelRequest() {
191-
return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_ADMIN_LOG_LEVEL);
190+
protected InternalRequest getLogLevelRequest(final LogLevelOptions options) {
191+
return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_ADMIN_LOG_LEVEL)
192+
.putQueryParam("serverId", options.getServerId());
192193
}
193194

194-
protected InternalRequest setLogLevelRequest(final LogLevelEntity entity) {
195+
protected InternalRequest setLogLevelRequest(final LogLevelEntity entity, final LogLevelOptions options) {
195196
return request(ArangoRequestParam.SYSTEM, RequestType.PUT, PATH_API_ADMIN_LOG_LEVEL)
197+
.putQueryParam("serverId", options.getServerId())
196198
.setBody(getSerde().serialize(entity));
197199
}
198200

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.arangodb.model;
2+
3+
public class LogLevelOptions {
4+
private String serverId;
5+
6+
public String getServerId() {
7+
return serverId;
8+
}
9+
10+
public LogLevelOptions serverId(final String serverId) {
11+
this.serverId = serverId;
12+
return this;
13+
}
14+
}

driver/src/test/java/com/arangodb/ArangoDBTest.java

+19
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,25 @@ void setAllLogLevel(ArangoDB arangoDB) {
538538
}
539539
}
540540

541+
@ParameterizedTest(name = "{index}")
542+
@MethodSource("arangos")
543+
void logLevelWithServerId(ArangoDB arangoDB) {
544+
assumeTrue(isAtLeastVersion(3, 10));
545+
assumeTrue(isCluster());
546+
String serverId = arangoDB.getServerId();
547+
LogLevelOptions options = new LogLevelOptions().serverId(serverId);
548+
final LogLevelEntity entity = new LogLevelEntity();
549+
try {
550+
entity.setGraphs(LogLevelEntity.LogLevel.ERROR);
551+
final LogLevelEntity logLevel = arangoDB.setLogLevel(entity, options);
552+
assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR);
553+
assertThat(arangoDB.getLogLevel(options).getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR);
554+
} finally {
555+
entity.setGraphs(LogLevelEntity.LogLevel.INFO);
556+
arangoDB.setLogLevel(entity);
557+
}
558+
}
559+
541560
@ParameterizedTest(name = "{index}")
542561
@MethodSource("arangos")
543562
void getQueryOptimizerRules(ArangoDB arangoDB) {

0 commit comments

Comments
 (0)