diff --git a/opennms-rrd/opennms-rrd-newts/src/main/java/org/opennms/netmgt/rrd/newts/NewtsPersistor.java b/opennms-rrd/opennms-rrd-newts/src/main/java/org/opennms/netmgt/rrd/newts/NewtsPersistor.java index 994b93a4ccba..00bd0e1f6b72 100644 --- a/opennms-rrd/opennms-rrd-newts/src/main/java/org/opennms/netmgt/rrd/newts/NewtsPersistor.java +++ b/opennms-rrd/opennms-rrd-newts/src/main/java/org/opennms/netmgt/rrd/newts/NewtsPersistor.java @@ -33,6 +33,10 @@ */ public class NewtsPersistor implements Runnable { + public static final boolean NO_DELAY = false; + + public static final long DELAY_IN_MS = 250; + public static final long MAX_CACHE_ENTRIES = 4096; private static final Logger LOG = LoggerFactory.getLogger(NewtsPersistor.class); @@ -78,6 +82,15 @@ public void run() { // Block and wait for an element samples.add(m_queue.take()); try { + if (!NO_DELAY) { + // We only have a single sample, if there are no other samples + // pending on the queue, then sleep for short delay before + // checking again and initiating the insert + if (m_queue.size() == 0) { + Thread.sleep(DELAY_IN_MS); + } + } + // Grab all of the remaining samples on the queue and flatten them m_queue.drainTo(samples); samples.stream().forEach(flattenedSamples::addAll);