throttle loading of files to 500/s

This commit is contained in:
Zlatin Balevsky
2019-10-09 16:34:09 +01:00
parent f530ab999d
commit 251080d08f

View File

@@ -49,6 +49,7 @@ class PersisterService extends Service {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY)
if (location.exists() && location.isFile()) {
int loaded = 0
def slurper = new JsonSlurper()
try {
location.eachLine {
@@ -58,6 +59,9 @@ class PersisterService extends Service {
if (event != null) {
log.fine("loaded file $event.loadedFile.file")
listener.publish event
loaded++
if (loaded % 50 == 0)
Thread.sleep(10)
}
}
}