use of de.invesdwin.util.lang.ProcessedEventsRateString in project invesdwin-context-persistence by subes.
the class ADatabasePerformanceTest method printProgress.
protected void printProgress(final String action, final Instant start, final long count, final int maxCount) {
final Duration duration = start.toDuration();
log.info("%s: %s/%s (%s) %s during %s", action, count, maxCount, new Percent(count, maxCount).toString(PercentScale.PERCENT), new ProcessedEventsRateString(count, duration), duration);
}
use of de.invesdwin.util.lang.ProcessedEventsRateString in project invesdwin-context-persistence by subes.
the class DatabasePerformanceTest method printProgress.
private void printProgress(final String action, final Instant start, final long count, final int maxCount) {
final Duration duration = start.toDuration();
log.info("%s: %s/%s (%s) %s during %s", action, count, maxCount, new Percent(count, maxCount).toString(PercentScale.PERCENT), new ProcessedEventsRateString(count, duration), duration);
}
use of de.invesdwin.util.lang.ProcessedEventsRateString in project invesdwin-context-persistence by subes.
the class ADataUpdater method doUpdate.
protected final FDate doUpdate() throws IncompleteUpdateFoundException {
final ATimeSeriesUpdater<K, V> updater = new ATimeSeriesUpdater<K, V>(key, getTable()) {
private static final int BATCH_LOG_INTERVAL = 100_000 / BATCH_FLUSH_INTERVAL;
@GuardedBy("this")
private Integer lastFlushIndex;
@GuardedBy("this")
private Duration flushDuration;
@GuardedBy("this")
private long flushElementCount;
@GuardedBy("this")
private FDate lastFlushMaxTime;
@GuardedBy("this")
private Instant lastFlushTime;
@Override
protected FDate extractTime(final V element) {
return ADataUpdater.this.extractTime(element);
}
@Override
protected FDate extractEndTime(final V element) {
return ADataUpdater.this.extractEndTime(element);
}
@Override
protected ICloseableIterable<? extends V> getSource(final FDate updateFrom) {
final ICloseableIterable<? extends V> downloadElements = downloadElements(key, updateFrom);
return downloadElements;
}
@Override
protected void onUpdateStart() {
log.info("Updating %s for [%s]", getElementsName(), keyToString(key));
}
@Override
protected synchronized void onFlush(final int flushIndex, final Instant flushStart, final UpdateProgress progress) {
lastFlushIndex = Integers.max(lastFlushIndex, flushIndex);
if (flushDuration == null) {
flushDuration = flushStart.toDuration();
} else {
flushDuration = flushDuration.add(flushStart.toDuration());
}
flushElementCount += progress.getCount();
lastFlushMaxTime = FDates.max(lastFlushMaxTime, progress.getMaxTime());
if (flushIndex % BATCH_LOG_INTERVAL == 0) {
logFlush();
}
}
private void logFlush() {
Assertions.assertThat(lastFlushIndex).isNotNull();
// if we are too fast, only print status once a second
if (lastFlushTime == null || lastFlushTime.toDuration().isGreaterThan(Duration.ONE_SECOND)) {
log.info("Persisted %s. %s batch for [%s]. Reached time [%s]. Processed [%s] during %s", lastFlushIndex, getElementsName(), keyToString(key), lastFlushMaxTime, new ProcessedEventsRateString(flushElementCount, flushDuration), flushDuration);
lastFlushTime = new Instant();
}
lastFlushIndex = null;
flushDuration = null;
flushElementCount = 0;
lastFlushMaxTime = null;
}
@Override
protected synchronized void onUpdateFinished(final Instant updateStart) {
if (lastFlushIndex != null) {
logFlush();
}
log.info("Finished updating %s %s for [%s] from [%s] to [%s] after %s", getCount(), getElementsName(), keyToString(key), getMinTime(), getMaxTime(), updateStart);
}
};
updater.update();
return updater.getMaxTime();
}
use of de.invesdwin.util.lang.ProcessedEventsRateString in project invesdwin-context-persistence by subes.
the class ALoggingTimeSeriesUpdater method logFlush.
private void logFlush() {
Assertions.assertThat(lastFlushIndex).isNotNull();
// if we are too fast, only print status once a second
if (lastFlushTime == null || lastFlushTime.isGreaterThan(Duration.ONE_SECOND)) {
final Duration flushDuration = updateStart.toDuration();
final Percent progress = getProgress();
if (progress != null) {
log.info("Persisted %s. %s batch for [%s]. Reached [%s] at time [%s]. Processed [%s] during %s", lastFlushIndex, getElementsName(), keyToString(getKey()), progress.asScale(PercentScale.PERCENT), lastFlushMaxTime, new ProcessedEventsRateString(flushElementCount, flushDuration), flushDuration);
} else {
log.info("Persisted %s. %s batch for [%s]. Reached time [%s]. Processed [%s] during %s", lastFlushIndex, getElementsName(), keyToString(getKey()), lastFlushMaxTime, new ProcessedEventsRateString(flushElementCount, flushDuration), flushDuration);
}
lastFlushTime = new Instant();
}
lastFlushIndex = null;
lastFlushMaxTime = null;
}
use of de.invesdwin.util.lang.ProcessedEventsRateString in project invesdwin-context-persistence by subes.
the class InfluxDBPerformanceTest method printProgress.
private void printProgress(final String action, final Instant start, final long count, final int maxCount) {
final Duration duration = start.toDuration();
log.info("%s: %s/%s (%s) %s during %s", action, count, maxCount, new Percent(count, maxCount).toString(PercentScale.PERCENT), new ProcessedEventsRateString(count, duration), duration);
}
Aggregations