From dc49c6e2952db8845f505b4b04b6fa44b1cacd88 Mon Sep 17 00:00:00 2001 From: Michele Rastelli Date: Thu, 5 Sep 2024 17:11:07 +0200 Subject: [PATCH] implemented reset log levels --- core/src/main/java/com/arangodb/ArangoDB.java | 7 + .../main/java/com/arangodb/ArangoDBAsync.java | 5 + .../com/arangodb/entity/LogLevelEntity.java | 395 +++++++++++++++--- .../arangodb/internal/ArangoDBAsyncImpl.java | 5 + .../com/arangodb/internal/ArangoDBImpl.java | 5 + .../arangodb/internal/InternalArangoDB.java | 5 + .../java/com/arangodb/ArangoDBAsyncTest.java | 33 ++ .../test/java/com/arangodb/ArangoDBTest.java | 35 ++ 8 files changed, 425 insertions(+), 65 deletions(-) diff --git a/core/src/main/java/com/arangodb/ArangoDB.java b/core/src/main/java/com/arangodb/ArangoDB.java index ad9b3bf43..63e62e29b 100644 --- a/core/src/main/java/com/arangodb/ArangoDB.java +++ b/core/src/main/java/com/arangodb/ArangoDB.java @@ -352,6 +352,13 @@ public interface ArangoDB extends ArangoSerdeAccessor { */ LogLevelEntity setLogLevel(LogLevelEntity entity, LogLevelOptions options); + /** + * Reset the server log levels + * Revert the server's log level settings to the values they had at startup, as determined by the startup options specified on the command-line, a configuration file, and the factory defaults. + * @since ArangoDB 3.12 + */ + LogLevelEntity resetLogLevels(LogLevelOptions options); + /** * @return the list of available rules and their respective flags * @see API diff --git a/core/src/main/java/com/arangodb/ArangoDBAsync.java b/core/src/main/java/com/arangodb/ArangoDBAsync.java index 9639a6dee..8ea6985e3 100644 --- a/core/src/main/java/com/arangodb/ArangoDBAsync.java +++ b/core/src/main/java/com/arangodb/ArangoDBAsync.java @@ -186,6 +186,11 @@ public interface ArangoDBAsync extends ArangoSerdeAccessor { */ CompletableFuture setLogLevel(LogLevelEntity entity, LogLevelOptions options); + /** + * Asynchronous version of {@link ArangoDB#resetLogLevels(LogLevelOptions)} + */ + CompletableFuture resetLogLevels(LogLevelOptions options); + /** * Asynchronous version of {@link ArangoDB#getQueryOptimizerRules()} */ diff --git a/core/src/main/java/com/arangodb/entity/LogLevelEntity.java b/core/src/main/java/com/arangodb/entity/LogLevelEntity.java index 890998a68..39daaf59b 100644 --- a/core/src/main/java/com/arangodb/entity/LogLevelEntity.java +++ b/core/src/main/java/com/arangodb/entity/LogLevelEntity.java @@ -20,6 +20,8 @@ package com.arangodb.entity; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * @author Mark Vollmary */ @@ -28,22 +30,53 @@ public final class LogLevelEntity { private LogLevel all; private LogLevel agency; private LogLevel agencycomm; + private LogLevel agencystore; + private LogLevel backup; + private LogLevel bench; private LogLevel cluster; - private LogLevel collector; private LogLevel communication; - private LogLevel compactor; + private LogLevel authentication; private LogLevel config; - private LogLevel datafiles; - private LogLevel graphs; - private LogLevel heartbeat; - private LogLevel mmap; - private LogLevel performance; - private LogLevel queries; - private LogLevel replication; - private LogLevel requests; + private LogLevel crash; + private LogLevel dump; + private LogLevel engines; + private LogLevel cache; + private LogLevel security; private LogLevel startup; + private LogLevel trx; + private LogLevel supervision; private LogLevel threads; + private LogLevel ttl; + private LogLevel ssl; + private LogLevel replication2; + private LogLevel restore; + private LogLevel memory; + private LogLevel validation; + private LogLevel statistics; private LogLevel v8; + private LogLevel syscall; + private LogLevel libiresearch; + private LogLevel license; + private LogLevel deprecation; + private LogLevel rocksdb; + private LogLevel requests; + @JsonProperty("rep-wal") + private LogLevel repWal; + private LogLevel arangosearch; + private LogLevel views; + @JsonProperty("rep-state") + private LogLevel repState; + private LogLevel authorization; + private LogLevel queries; + private LogLevel aql; + private LogLevel graphs; + private LogLevel maintenance; + private LogLevel development; + private LogLevel replication; + private LogLevel httpclient; + private LogLevel heartbeat; + private LogLevel flush; + private LogLevel general; public LogLevelEntity() { super(); @@ -53,7 +86,7 @@ public LogLevel getAll() { return all; } - public void setAll(final LogLevel all) { + public void setAll(LogLevel all) { this.all = all; } @@ -61,7 +94,7 @@ public LogLevel getAgency() { return agency; } - public void setAgency(final LogLevel agency) { + public void setAgency(LogLevel agency) { this.agency = agency; } @@ -69,136 +102,368 @@ public LogLevel getAgencycomm() { return agencycomm; } - public void setAgencycomm(final LogLevel agencycomm) { + public void setAgencycomm(LogLevel agencycomm) { this.agencycomm = agencycomm; } - public LogLevel getCluster() { - return cluster; + public LogLevel getAgencystore() { + return agencystore; } - public void setCluster(final LogLevel cluster) { - this.cluster = cluster; + public void setAgencystore(LogLevel agencystore) { + this.agencystore = agencystore; } - public LogLevel getCollector() { - return collector; + public LogLevel getBackup() { + return backup; } - public void setCollector(final LogLevel collector) { - this.collector = collector; + public void setBackup(LogLevel backup) { + this.backup = backup; + } + + public LogLevel getBench() { + return bench; + } + + public void setBench(LogLevel bench) { + this.bench = bench; + } + + public LogLevel getCluster() { + return cluster; + } + + public void setCluster(LogLevel cluster) { + this.cluster = cluster; } public LogLevel getCommunication() { return communication; } - public void setCommunication(final LogLevel communication) { + public void setCommunication(LogLevel communication) { this.communication = communication; } - public LogLevel getCompactor() { - return compactor; + public LogLevel getAuthentication() { + return authentication; } - public void setCompactor(final LogLevel compactor) { - this.compactor = compactor; + public void setAuthentication(LogLevel authentication) { + this.authentication = authentication; } public LogLevel getConfig() { return config; } - public void setConfig(final LogLevel config) { + public void setConfig(LogLevel config) { this.config = config; } - public LogLevel getDatafiles() { - return datafiles; + public LogLevel getCrash() { + return crash; } - public void setDatafiles(final LogLevel datafiles) { - this.datafiles = datafiles; + public void setCrash(LogLevel crash) { + this.crash = crash; } - public LogLevel getGraphs() { - return graphs; + public LogLevel getDump() { + return dump; } - public void setGraphs(final LogLevel graphs) { - this.graphs = graphs; + public void setDump(LogLevel dump) { + this.dump = dump; } - public LogLevel getHeartbeat() { - return heartbeat; + public LogLevel getEngines() { + return engines; } - public void setHeartbeat(final LogLevel heartbeat) { - this.heartbeat = heartbeat; + public void setEngines(LogLevel engines) { + this.engines = engines; + } + + public LogLevel getCache() { + return cache; } - public LogLevel getMmap() { - return mmap; + public void setCache(LogLevel cache) { + this.cache = cache; } - public void setMmap(final LogLevel mmap) { - this.mmap = mmap; + public LogLevel getSecurity() { + return security; } - public LogLevel getPerformance() { - return performance; + public void setSecurity(LogLevel security) { + this.security = security; } - public void setPerformance(final LogLevel performance) { - this.performance = performance; + public LogLevel getStartup() { + return startup; + } + + public void setStartup(LogLevel startup) { + this.startup = startup; + } + + public LogLevel getTrx() { + return trx; + } + + public void setTrx(LogLevel trx) { + this.trx = trx; + } + + public LogLevel getSupervision() { + return supervision; + } + + public void setSupervision(LogLevel supervision) { + this.supervision = supervision; + } + + public LogLevel getThreads() { + return threads; + } + + public void setThreads(LogLevel threads) { + this.threads = threads; + } + + public LogLevel getTtl() { + return ttl; + } + + public void setTtl(LogLevel ttl) { + this.ttl = ttl; + } + + public LogLevel getSsl() { + return ssl; + } + + public void setSsl(LogLevel ssl) { + this.ssl = ssl; + } + + public LogLevel getReplication2() { + return replication2; + } + + public void setReplication2(LogLevel replication2) { + this.replication2 = replication2; + } + + public LogLevel getRestore() { + return restore; + } + + public void setRestore(LogLevel restore) { + this.restore = restore; + } + + public LogLevel getMemory() { + return memory; + } + + public void setMemory(LogLevel memory) { + this.memory = memory; + } + + public LogLevel getValidation() { + return validation; + } + + public void setValidation(LogLevel validation) { + this.validation = validation; + } + + public LogLevel getStatistics() { + return statistics; + } + + public void setStatistics(LogLevel statistics) { + this.statistics = statistics; + } + + public LogLevel getV8() { + return v8; + } + + public void setV8(LogLevel v8) { + this.v8 = v8; + } + + public LogLevel getSyscall() { + return syscall; + } + + public void setSyscall(LogLevel syscall) { + this.syscall = syscall; + } + + public LogLevel getLibiresearch() { + return libiresearch; + } + + public void setLibiresearch(LogLevel libiresearch) { + this.libiresearch = libiresearch; + } + + public LogLevel getLicense() { + return license; + } + + public void setLicense(LogLevel license) { + this.license = license; + } + + public LogLevel getDeprecation() { + return deprecation; + } + + public void setDeprecation(LogLevel deprecation) { + this.deprecation = deprecation; + } + + public LogLevel getRocksdb() { + return rocksdb; + } + + public void setRocksdb(LogLevel rocksdb) { + this.rocksdb = rocksdb; + } + + public LogLevel getRequests() { + return requests; + } + + public void setRequests(LogLevel requests) { + this.requests = requests; + } + + public LogLevel getRepWal() { + return repWal; + } + + public void setRepWal(LogLevel repWal) { + this.repWal = repWal; + } + + public LogLevel getArangosearch() { + return arangosearch; + } + + public void setArangosearch(LogLevel arangosearch) { + this.arangosearch = arangosearch; + } + + public LogLevel getViews() { + return views; + } + + public void setViews(LogLevel views) { + this.views = views; + } + + public LogLevel getRepState() { + return repState; + } + + public void setRepState(LogLevel repState) { + this.repState = repState; + } + + public LogLevel getAuthorization() { + return authorization; + } + + public void setAuthorization(LogLevel authorization) { + this.authorization = authorization; } public LogLevel getQueries() { return queries; } - public void setQueries(final LogLevel queries) { + public void setQueries(LogLevel queries) { this.queries = queries; } + public LogLevel getAql() { + return aql; + } + + public void setAql(LogLevel aql) { + this.aql = aql; + } + + public LogLevel getGraphs() { + return graphs; + } + + public void setGraphs(LogLevel graphs) { + this.graphs = graphs; + } + + public LogLevel getMaintenance() { + return maintenance; + } + + public void setMaintenance(LogLevel maintenance) { + this.maintenance = maintenance; + } + + public LogLevel getDevelopment() { + return development; + } + + public void setDevelopment(LogLevel development) { + this.development = development; + } + public LogLevel getReplication() { return replication; } - public void setReplication(final LogLevel replication) { + public void setReplication(LogLevel replication) { this.replication = replication; } - public LogLevel getRequests() { - return requests; + public LogLevel getHttpclient() { + return httpclient; } - public void setRequests(final LogLevel requests) { - this.requests = requests; + public void setHttpclient(LogLevel httpclient) { + this.httpclient = httpclient; } - public LogLevel getStartup() { - return startup; + public LogLevel getHeartbeat() { + return heartbeat; } - public void setStartup(final LogLevel startup) { - this.startup = startup; + public void setHeartbeat(LogLevel heartbeat) { + this.heartbeat = heartbeat; } - public LogLevel getThreads() { - return threads; + public LogLevel getFlush() { + return flush; } - public void setThreads(final LogLevel threads) { - this.threads = threads; + public void setFlush(LogLevel flush) { + this.flush = flush; } - public LogLevel getV8() { - return v8; + public LogLevel getGeneral() { + return general; } - public void setV8(final LogLevel v8) { - this.v8 = v8; + public void setGeneral(LogLevel general) { + this.general = general; } public enum LogLevel { diff --git a/core/src/main/java/com/arangodb/internal/ArangoDBAsyncImpl.java b/core/src/main/java/com/arangodb/internal/ArangoDBAsyncImpl.java index 76593b8c6..80486499d 100644 --- a/core/src/main/java/com/arangodb/internal/ArangoDBAsyncImpl.java +++ b/core/src/main/java/com/arangodb/internal/ArangoDBAsyncImpl.java @@ -189,6 +189,11 @@ public CompletableFuture setLogLevel(final LogLevelEntity entity return executorAsync().execute(() -> setLogLevelRequest(entity, options), LogLevelEntity.class); } + @Override + public CompletableFuture resetLogLevels(LogLevelOptions options) { + return executorAsync().execute(() -> resetLogLevelsRequest(options), LogLevelEntity.class); + } + @Override public CompletableFuture> getQueryOptimizerRules() { return executorAsync().execute(this::getQueryOptimizerRulesRequest, SerdeUtils.constructListType(QueryOptimizerRule.class)); diff --git a/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java b/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java index 7554c9919..24c4f164d 100644 --- a/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java +++ b/core/src/main/java/com/arangodb/internal/ArangoDBImpl.java @@ -203,6 +203,11 @@ public LogLevelEntity setLogLevel(final LogLevelEntity entity, final LogLevelOpt return executorSync().execute(setLogLevelRequest(entity, options), LogLevelEntity.class); } + @Override + public LogLevelEntity resetLogLevels(LogLevelOptions options) { + return executorSync().execute(resetLogLevelsRequest(options), LogLevelEntity.class); + } + @Override public Collection getQueryOptimizerRules() { return executorSync().execute(getQueryOptimizerRulesRequest(), SerdeUtils.constructListType(QueryOptimizerRule.class)); diff --git a/core/src/main/java/com/arangodb/internal/InternalArangoDB.java b/core/src/main/java/com/arangodb/internal/InternalArangoDB.java index 6cefb34f2..264c8fdc4 100644 --- a/core/src/main/java/com/arangodb/internal/InternalArangoDB.java +++ b/core/src/main/java/com/arangodb/internal/InternalArangoDB.java @@ -203,6 +203,11 @@ protected InternalRequest setLogLevelRequest(final LogLevelEntity entity, final .setBody(getSerde().serialize(entity)); } + protected InternalRequest resetLogLevelsRequest(final LogLevelOptions options) { + return request(ArangoRequestParam.SYSTEM, RequestType.DELETE, PATH_API_ADMIN_LOG_LEVEL) + .putQueryParam("serverId", options.getServerId()); + } + protected InternalRequest getQueryOptimizerRulesRequest() { return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_QUERY_RULES); } diff --git a/test-functional/src/test/java/com/arangodb/ArangoDBAsyncTest.java b/test-functional/src/test/java/com/arangodb/ArangoDBAsyncTest.java index dedd57f5d..1598a7ca1 100644 --- a/test-functional/src/test/java/com/arangodb/ArangoDBAsyncTest.java +++ b/test-functional/src/test/java/com/arangodb/ArangoDBAsyncTest.java @@ -575,6 +575,39 @@ void logLevelWithServerId(ArangoDBAsync arangoDB) throws ExecutionException, Int } } + @ParameterizedTest + @MethodSource("asyncArangos") + void resetLogLevels(ArangoDBAsync arangoDB) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + LogLevelOptions options = new LogLevelOptions(); + LogLevelEntity entity = new LogLevelEntity(); + entity.setGraphs(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity err = arangoDB.setLogLevel(entity, options).get(); + assertThat(err.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity logLevel = arangoDB.resetLogLevels(options).get(); + assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.INFO); + } + + @ParameterizedTest + @MethodSource("asyncArangos") + void resetLogLevelsWithServerId(ArangoDBAsync arangoDB) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + assumeTrue(isCluster()); + String serverId = arangoDB.getServerId().get(); + LogLevelOptions options = new LogLevelOptions().serverId(serverId); + + LogLevelEntity entity = new LogLevelEntity(); + entity.setGraphs(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity err = arangoDB.setLogLevel(entity, options).get(); + assertThat(err.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity logLevel = arangoDB.resetLogLevels(options).get(); + assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.INFO); + } + @ParameterizedTest @MethodSource("asyncArangos") void getQueryOptimizerRules(ArangoDBAsync arangoDB) throws ExecutionException, InterruptedException { diff --git a/test-functional/src/test/java/com/arangodb/ArangoDBTest.java b/test-functional/src/test/java/com/arangodb/ArangoDBTest.java index 991e0e2d4..081b7bedf 100644 --- a/test-functional/src/test/java/com/arangodb/ArangoDBTest.java +++ b/test-functional/src/test/java/com/arangodb/ArangoDBTest.java @@ -560,6 +560,8 @@ void setAllLogLevel(ArangoDB arangoDB) { final LogLevelEntity logLevel = arangoDB.setLogLevel(entity); assertThat(logLevel.getAgency()).isEqualTo(LogLevelEntity.LogLevel.ERROR); assertThat(logLevel.getQueries()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + assertThat(logLevel.getRepWal()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + assertThat(logLevel.getRepState()).isEqualTo(LogLevelEntity.LogLevel.ERROR); LogLevelEntity retrievedLevels = arangoDB.getLogLevel(); assertThat(retrievedLevels.getAgency()).isEqualTo(LogLevelEntity.LogLevel.ERROR); } finally { @@ -587,6 +589,39 @@ void logLevelWithServerId(ArangoDB arangoDB) { } } + @ParameterizedTest + @MethodSource("arangos") + void resetLogLevels(ArangoDB arangoDB) { + assumeTrue(isAtLeastVersion(3, 12)); + LogLevelOptions options = new LogLevelOptions(); + LogLevelEntity entity = new LogLevelEntity(); + entity.setGraphs(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity err = arangoDB.setLogLevel(entity, options); + assertThat(err.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity logLevel = arangoDB.resetLogLevels(options); + assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.INFO); + } + + @ParameterizedTest + @MethodSource("arangos") + void resetLogLevelsWithServerId(ArangoDB arangoDB) { + assumeTrue(isAtLeastVersion(3, 12)); + assumeTrue(isCluster()); + String serverId = arangoDB.getServerId(); + LogLevelOptions options = new LogLevelOptions().serverId(serverId); + + LogLevelEntity entity = new LogLevelEntity(); + entity.setGraphs(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity err = arangoDB.setLogLevel(entity, options); + assertThat(err.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.ERROR); + + LogLevelEntity logLevel = arangoDB.resetLogLevels(options); + assertThat(logLevel.getGraphs()).isEqualTo(LogLevelEntity.LogLevel.INFO); + } + @ParameterizedTest @MethodSource("arangos") void getQueryOptimizerRules(ArangoDB arangoDB) {