Skip to content

Commit 1bf5e50

Browse files
committed
chore(batch): change default logging format for tests
1 parent 5eec6aa commit 1bf5e50

4 files changed

Lines changed: 31 additions & 21 deletions

File tree

pom.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@
235235
<plugin>
236236
<artifactId>maven-surefire-plugin</artifactId>
237237
<version>3.5.4</version>
238+
<configuration>
239+
<systemPropertyVariables>
240+
<java.util.logging.config.file>
241+
${project.basedir}/src/test/resources/logging.properties
242+
</java.util.logging.config.file>
243+
</systemPropertyVariables>
244+
</configuration>
238245
</plugin>
239246
<plugin>
240247
<groupId>org.projectlombok</groupId>
@@ -537,12 +544,4 @@
537544
</plugin>
538545
</plugins>
539546
</build>
540-
<profiles>
541-
<profile>
542-
<id>debug</id>
543-
<properties>
544-
<argLine>-Djava.util.logging.config.file=src/test/resources/logging.properties</argLine>
545-
</properties>
546-
</profile>
547-
</profiles>
548547
</project>

src/main/java/io/weaviate/client6/v1/api/collections/batch/BatchContext.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ private void onAcks(Event.Acks acks) {
826826
log.atInfo()
827827
.addKeyValue("count_acks", acks.acked().size())
828828
.addKeyValue("wip_tasks", wip::size)
829-
.log("Received Results");
829+
.log("Received Acks");
830830

831831
Collection<String> removed = batch.clear();
832832
if (!acks.acked().containsAll(removed)) {
@@ -865,6 +865,10 @@ private void onBackoff(Event.Backoff backoff) {
865865
}
866866

867867
private void onOom(Event.Oom oom) {
868+
log.atInfo()
869+
.addKeyValue("wip_tasks", wip::size)
870+
.log("Server is out of memory");
871+
868872
setState(new Oom(oom.delaySeconds()));
869873
}
870874

@@ -915,22 +919,26 @@ public String toString() {
915919
* after which it will force stream termination by imitating server shutdown.
916920
*/
917921
private final class Oom extends BaseState {
918-
private final long delaySeconds;
922+
private final long shutdownAfterSeconds;
919923
private ScheduledFuture<?> shutdown;
920924

921-
private Oom(long delaySeconds) {
925+
private Oom(long shutdownAfterSeconds) {
922926
super("OOM");
923-
this.delaySeconds = delaySeconds;
927+
this.shutdownAfterSeconds = shutdownAfterSeconds;
928+
929+
log.atDebug()
930+
.addKeyValue("grace_period", shutdownAfterSeconds)
931+
.log("Server is out of memory");
924932
}
925933

926934
@Override
927935
public void onEnter(State prev) {
928-
shutdown = scheduledService.schedule(this::initiateShutdown, delaySeconds, TimeUnit.SECONDS);
936+
shutdown = scheduledService.schedule(this::initiateShutdown, shutdownAfterSeconds, TimeUnit.SECONDS);
929937
}
930938

931939
/** Imitate server shutdown sequence. */
932940
private void initiateShutdown() {
933-
log.info("No update from the server after {}s, context will be forcibly restarted", delaySeconds);
941+
log.info("No update from the server after {}s, context will be forcibly restarted", shutdownAfterSeconds);
934942

935943
// We cannot route event handling via normal BatchContext#onEvent, because
936944
// it delegates to the current state, which is Oom. If Oom#onEvent were to
@@ -985,7 +993,7 @@ private ServerShuttingDown(State prev) {
985993
log.atDebug()
986994
.addKeyValue("prev_state", prev)
987995
.addKeyValue("can_prepare_next", canPrepareNext)
988-
.log("Server shutting down");
996+
.log("Server is shutting down");
989997
}
990998

991999
@Override
@@ -1051,9 +1059,7 @@ public void onEvent(Event event) {
10511059
assert retries <= maxRetries : "maxRetries exceeded";
10521060

10531061
if (event == Event.STARTED) {
1054-
log.atInfo()
1055-
.addArgument(retries)
1056-
.log("Reconnected after {} retries");
1062+
log.info("Reconnected after {} retries", retries);
10571063

10581064
setState(ACTIVE);
10591065
} else if (event instanceof Event.StreamHangup) {

src/test/java/io/weaviate/client6/v1/api/collections/batch/BatchContextTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import io.weaviate.client6.v1.internal.orm.CollectionDescriptor;
3333

3434
public class BatchContextTest {
35-
private static final Logger log = LoggerFactory.getLogger(BatchContext.class);
35+
private static final Logger log = LoggerFactory.getLogger(BatchContextTest.class);
3636

3737
private static final CollectionDescriptor<Map<String, Object>> DESCRIPTOR = CollectionDescriptor
3838
.ofMap("BatchContextTest");
@@ -141,7 +141,7 @@ public void reset() throws Exception {
141141

142142
REQUEST_QUEUE.clear();
143143

144-
log.debug("==================================================");
144+
log.debug("===================closeContext==================");
145145
}
146146

147147
private static final WeaviateProtoBatch.BatchStreamRequest.MessageCase START = WeaviateProtoBatch.BatchStreamRequest.MessageCase.START;
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
.level=INFO
2+
23
handlers=java.util.logging.ConsoleHandler
3-
java.util.logging.ConsoleHandler.level=FINE
4+
java.util.logging.ConsoleHandler.level=FINEST
5+
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
6+
java.util.logging.SimpleFormatter.format=[%4$s] %1$tH:%1$tM:%1$tS.%1$tL %5$s%n
7+
48
io.weaviate.client6.level=FINE
9+
io.weaviate.client6.v1.api.collections.batch.BatchContextTest.level=FINEST

0 commit comments

Comments
 (0)