Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6bef3ec

Browse files
authored
serverId query parameter for /_admin/log/level (#499)
1 parent 3b737fa commit 6bef3ec

File tree

8 files changed

+133
-23
lines changed

8 files changed

+133
-23
lines changed

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838
import com.arangodb.internal.util.DefaultArangoSerialization;
3939
import com.arangodb.internal.velocystream.VstCommunicationSync;
4040
import com.arangodb.internal.velocystream.VstConnectionFactorySync;
41-
import com.arangodb.model.DBCreateOptions;
42-
import com.arangodb.model.LogOptions;
43-
import com.arangodb.model.UserCreateOptions;
44-
import com.arangodb.model.UserUpdateOptions;
41+
import com.arangodb.model.*;
4542
import com.arangodb.util.*;
4643
import com.arangodb.velocypack.VPack;
4744
import com.arangodb.velocypack.VPackAnnotationFieldFilter;
@@ -1036,6 +1033,14 @@ default Boolean createDatabase(String name) throws ArangoDBException {
10361033
*/
10371034
LogLevelEntity getLogLevel() throws ArangoDBException;
10381035

1036+
/**
1037+
* Returns the server's current loglevel settings.
1038+
*
1039+
* @return the server's current loglevel settings
1040+
* @since ArangoDB 3.10
1041+
*/
1042+
LogLevelEntity getLogLevel(LogLevelOptions options) throws ArangoDBException;
1043+
10391044
/**
10401045
* Modifies and returns the server's current loglevel settings.
10411046
*
@@ -1046,6 +1051,15 @@ default Boolean createDatabase(String name) throws ArangoDBException {
10461051
*/
10471052
LogLevelEntity setLogLevel(LogLevelEntity entity) throws ArangoDBException;
10481053

1054+
/**
1055+
* Modifies and returns the server's current loglevel settings.
1056+
*
1057+
* @param entity loglevel settings
1058+
* @return the server's current loglevel settings
1059+
* @since ArangoDB 3.10
1060+
*/
1061+
LogLevelEntity setLogLevel(LogLevelEntity entity, LogLevelOptions options) throws ArangoDBException;
1062+
10491063
/**
10501064
* @return the list of available rules and their respective flags
10511065
* @throws ArangoDBException

‎src/main/java/com/arangodb/async/ArangoDBAsync.java‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
import com.arangodb.internal.util.DefaultArangoSerialization;
3838
import com.arangodb.internal.velocystream.VstCommunicationSync;
3939
import com.arangodb.internal.velocystream.VstConnectionFactorySync;
40-
import com.arangodb.model.DBCreateOptions;
41-
import com.arangodb.model.LogOptions;
42-
import com.arangodb.model.UserCreateOptions;
43-
import com.arangodb.model.UserUpdateOptions;
40+
import com.arangodb.model.*;
4441
import com.arangodb.util.ArangoDeserializer;
4542
import com.arangodb.util.ArangoSerialization;
4643
import com.arangodb.util.ArangoSerializer;
@@ -197,6 +194,16 @@ default CompletableFuture<Boolean> createDatabase(final String name) {
197194
*/
198195
CompletableFuture<ServerRole> getRole();
199196

197+
/**
198+
* Returns the id of a server in a cluster.
199+
*
200+
* @return the server id
201+
* @throws ArangoDBException
202+
* @see <a href="https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-id-of-a-server-in-a-cluster">API
203+
* Documentation</a>
204+
*/
205+
CompletableFuture<String> getServerId() throws ArangoDBException;
206+
200207
/**
201208
* Create a new user. This user will not have access to any database. You need permission to the _system database in
202209
* order to execute this call.
@@ -331,6 +338,14 @@ default CompletableFuture<Boolean> createDatabase(final String name) {
331338
*/
332339
CompletableFuture<LogLevelEntity> getLogLevel();
333340

341+
/**
342+
* Returns the server's current loglevel settings.
343+
*
344+
* @return the server's current loglevel settings
345+
* @since ArangoDB 3.10
346+
*/
347+
CompletableFuture<LogLevelEntity> getLogLevel(final LogLevelOptions options);
348+
334349
/**
335350
* Modifies and returns the server's current loglevel settings.
336351
*
@@ -339,6 +354,15 @@ default CompletableFuture<Boolean> createDatabase(final String name) {
339354
*/
340355
CompletableFuture<LogLevelEntity> setLogLevel(final LogLevelEntity entity);
341356

357+
/**
358+
* Modifies and returns the server's current loglevel settings.
359+
*
360+
* @param entity loglevel settings
361+
* @return the server's current loglevel settings
362+
* @since ArangoDB 3.10
363+
*/
364+
CompletableFuture<LogLevelEntity> setLogLevel(final LogLevelEntity entity, final LogLevelOptions options);
365+
342366
/**
343367
* @return the list of available rules and their respective flags
344368
* @since ArangoDB 3.10

‎src/main/java/com/arangodb/async/internal/ArangoDBAsyncImpl.java‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
import com.arangodb.internal.velocystream.VstCommunicationSync;
3838
import com.arangodb.internal.velocystream.VstProtocol;
3939
import com.arangodb.internal.velocystream.internal.VstConnectionSync;
40-
import com.arangodb.model.DBCreateOptions;
41-
import com.arangodb.model.LogOptions;
42-
import com.arangodb.model.UserCreateOptions;
43-
import com.arangodb.model.UserUpdateOptions;
40+
import com.arangodb.model.*;
4441
import com.arangodb.velocypack.Type;
4542
import com.arangodb.velocystream.Request;
4643
import com.arangodb.velocystream.Response;
@@ -168,6 +165,11 @@ public CompletableFuture<ServerRole> getRole() {
168165
return executor.execute(getRoleRequest(), getRoleResponseDeserializer());
169166
}
170167

168+
@Override
169+
public CompletableFuture<String> getServerId() {
170+
return executor.execute(getServerIdRequest(), getServerIdResponseDeserializer());
171+
}
172+
171173
@Override
172174
public CompletableFuture<UserEntity> createUser(final String user, final String passwd) {
173175
return executor.execute(createUserRequest(db().dbName(), user, passwd, new UserCreateOptions()),
@@ -234,12 +236,22 @@ public CompletableFuture<LogEntriesEntity> getLogEntries(final LogOptions option
234236

235237
@Override
236238
public CompletableFuture<LogLevelEntity> getLogLevel() {
237-
return executor.execute(getLogLevelRequest(), LogLevelEntity.class);
239+
return getLogLevel(new LogLevelOptions());
240+
}
241+
242+
@Override
243+
public CompletableFuture<LogLevelEntity> getLogLevel(final LogLevelOptions options) {
244+
return executor.execute(getLogLevelRequest(options), LogLevelEntity.class);
238245
}
239246

240247
@Override
241248
public CompletableFuture<LogLevelEntity> setLogLevel(final LogLevelEntity entity) {
242-
return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class);
249+
return setLogLevel(entity, new LogLevelOptions());
250+
}
251+
252+
@Override
253+
public CompletableFuture<LogLevelEntity> setLogLevel(final LogLevelEntity entity, final LogLevelOptions options) {
254+
return executor.execute(setLogLevelRequest(entity, options), LogLevelEntity.class);
243255
}
244256

245257
@Override

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
import com.arangodb.internal.util.ArangoSerializationFactory.Serializer;
3333
import com.arangodb.internal.velocystream.VstCommunicationSync;
3434
import com.arangodb.internal.velocystream.VstProtocol;
35-
import com.arangodb.model.DBCreateOptions;
36-
import com.arangodb.model.LogOptions;
37-
import com.arangodb.model.UserCreateOptions;
38-
import com.arangodb.model.UserUpdateOptions;
35+
import com.arangodb.model.*;
3936
import com.arangodb.util.ArangoCursorInitializer;
4037
import com.arangodb.util.ArangoSerialization;
4138
import com.arangodb.velocypack.Type;
@@ -262,12 +259,22 @@ public LogEntriesEntity getLogEntries(final LogOptions options) throws ArangoDBE
262259

263260
@Override
264261
public LogLevelEntity getLogLevel() throws ArangoDBException {
265-
return executor.execute(getLogLevelRequest(), LogLevelEntity.class);
262+
return getLogLevel(new LogLevelOptions());
263+
}
264+
265+
@Override
266+
public LogLevelEntity getLogLevel(final LogLevelOptions options) throws ArangoDBException {
267+
return executor.execute(getLogLevelRequest(options), LogLevelEntity.class);
266268
}
267269

268270
@Override
269271
public LogLevelEntity setLogLevel(final LogLevelEntity entity) throws ArangoDBException {
270-
return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class);
272+
return setLogLevel(entity, new LogLevelOptions());
273+
}
274+
275+
@Override
276+
public LogLevelEntity setLogLevel(final LogLevelEntity entity, final LogLevelOptions options) {
277+
return executor.execute(setLogLevelRequest(entity, options), LogLevelEntity.class);
271278
}
272279

273280
@Override

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,14 @@ protected Request getLogEntriesRequest(final LogOptions options) {
189189
.putQueryParam(LogOptions.PROPERTY_SORT, params.getSort());
190190
}
191191

192-
protected Request getLogLevelRequest() {
193-
return request(DbName.SYSTEM, RequestType.GET, PATH_API_ADMIN_LOG_LEVEL);
192+
protected Request getLogLevelRequest(final LogLevelOptions options) {
193+
return request(DbName.SYSTEM, RequestType.GET, PATH_API_ADMIN_LOG_LEVEL)
194+
.putQueryParam("serverId", options.getServerId());
194195
}
195196

196-
protected Request setLogLevelRequest(final LogLevelEntity entity) {
197+
protected Request setLogLevelRequest(final LogLevelEntity entity, finalLogLevelOptionsoptions) {
197198
return request(DbName.SYSTEM, RequestType.PUT, PATH_API_ADMIN_LOG_LEVEL)
199+
.putQueryParam("serverId", options.getServerId())
198200
.setBody(util().serialize(entity));
199201
}
200202

Lines changed: 14 additions & 0 deletions
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+
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,25 @@ void setAllLogLevel(ArangoDB arangoDB) {
644644
}
645645
}
646646

647+
@ParameterizedTest(name = "{index}")
648+
@MethodSource("arangos")
649+
void logLevelWithServerId(ArangoDB arangoDB) {
650+
assumeTrue(isAtLeastVersion(3, 10));
651+
assumeTrue(isCluster());
652+
String serverId = arangoDB.getServerId();
653+
LogLevelOptions options = new LogLevelOptions().serverId(serverId);
654+
final LogLevelEntity entity = new LogLevelEntity();
655+
try {
656+
entity.setGraphs(LogLevelEntity.LogLevel.ERROR);
657+
final LogLevelEntity logLevel = arangoDB.setLogLevel(entity, options);
658+
assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR);
659+
assertThat(arangoDB.getLogLevel(options).getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR);
660+
} finally {
661+
entity.setGraphs(LogLevelEntity.LogLevel.INFO);
662+
arangoDB.setLogLevel(entity);
663+
}
664+
}
665+
647666
@ParameterizedTest(name = "{index}")
648667
@MethodSource("arangos")
649668
void getQueryOptimizerRules(ArangoDB arangoDB) {

‎src/test/java/com/arangodb/async/ArangoDBTest.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,24 @@ void setLogLevel() throws InterruptedException, ExecutionException {
636636
}
637637
}
638638

639+
@Test
640+
void logLevelWithServerId() throws InterruptedException, ExecutionException {
641+
assumeTrue(isAtLeastVersion(3, 10));
642+
assumeTrue(isCluster());
643+
String serverId = arangoDB.getServerId().get();
644+
LogLevelOptions options = new LogLevelOptions().serverId(serverId);
645+
final LogLevelEntity entity = new LogLevelEntity();
646+
try {
647+
entity.setGraphs(LogLevelEntity.LogLevel.ERROR);
648+
final LogLevelEntity logLevel = arangoDB.setLogLevel(entity, options).get();
649+
assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR);
650+
assertThat(arangoDB.getLogLevel(options).get().getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR);
651+
} finally {
652+
entity.setGraphs(LogLevelEntity.LogLevel.INFO);
653+
arangoDB.setLogLevel(entity);
654+
}
655+
}
656+
639657
@Test
640658
void queueTime() throws InterruptedException, ExecutionException {
641659
List<CompletableFuture<ArangoCursorAsync<Void>>> reqs = IntStream.range(0, 80)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /