Skip to content

Commit

Permalink
Troubleshoot bulk previews
Browse files Browse the repository at this point in the history
  • Loading branch information
olovy committed Nov 14, 2024
1 parent 0efc783 commit 5446e29
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion housekeeping/src/main/groovy/whelk/HouseKeepingServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterC
}

public static void main(String[] args) throws Exception {
new HouseKeepingServer().run();
new HouseKeepingServer().run();
}
}
15 changes: 11 additions & 4 deletions whelktool/src/main/groovy/whelk/datatool/WhelkTool.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package whelk.datatool

import com.google.common.util.concurrent.MoreExecutors
import groovy.transform.Immutable
import org.apache.logging.log4j.Logger
import org.codehaus.groovy.jsr223.GroovyScriptEngineImpl
import whelk.Document
import whelk.IdGenerator
Expand Down Expand Up @@ -71,6 +72,7 @@ class WhelkTool {
PrintWriter createdLog
PrintWriter deletedLog
ConcurrentHashMap<String, PrintWriter> reports = new ConcurrentHashMap<>()
Logger logger

Counter counter = new Counter()

Expand Down Expand Up @@ -428,9 +430,9 @@ class WhelkTool {
var newGlobals = bindings.keySet() - globals
if (newGlobals) {
String msg = "FORBIDDEN - new bindings detected: ${newGlobals}"
System.err.println(msg)
System.err.println("Adding new global bindings during record processing is forbidden (since they share state across threads).")
System.err.println("Aborting.")
log(msg)
log("Adding new global bindings during record processing is forbidden (since they share state across threads).")
log("Aborting.")
errorDetected = new Exception(msg)
return false
}
Expand Down Expand Up @@ -741,8 +743,13 @@ class WhelkTool {
}

private void log(String msg) {
if (logger) {
logger.info(msg)
} else {
System.err.println(msg)
}

mainLog.println(msg)
System.err.println(msg)
}

private void repeat(String msg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public BulkPreviewJob(Whelk whelk, String id) throws IOException {
tool.setDryRun(true);
tool.setRecordChanges(true);
tool.setRecordingLimit(RECORD_MAX_ITEMS);
tool.setLogger(log);
}

public boolean isFinished() {
Expand Down

0 comments on commit 5446e29

Please sign in to comment.