Search in sources :

Example 16 with Percent

use of de.invesdwin.util.math.decimal.scaled.Percent 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);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Example 17 with Percent

use of de.invesdwin.util.math.decimal.scaled.Percent 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);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Example 18 with Percent

use of de.invesdwin.util.math.decimal.scaled.Percent in project invesdwin-context-persistence by subes.

the class ASegmentedTimeSeriesStorageCache method initSegment.

private void initSegment(final SegmentedKey<K> segmentedKey, final Function<SegmentedKey<K>, ICloseableIterable<? extends V>> source) {
    try {
        final ITimeSeriesUpdater<SegmentedKey<K>, V> updater = newSegmentUpdater(segmentedKey, source);
        final Callable<Void> task = new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                // write lock is reentrant
                updater.update();
                return null;
            }
        };
        final String taskName = "Loading " + getElementsName() + " for " + hashKey;
        final Callable<Percent> progress = new Callable<Percent>() {

            @Override
            public Percent call() throws Exception {
                return updater.getProgress();
            }
        };
        TaskInfoCallable.of(taskName, task, progress).call();
        final FDate minTime = updater.getMinTime();
        if (minTime != null) {
            final FDate segmentFrom = segmentedKey.getSegment().getFrom();
            final TimeRange prevSegment = getSegmentFinder(segmentedKey.getKey()).query().getValue(segmentFrom.addMilliseconds(-1));
            if (prevSegment.getTo().equalsNotNullSafe(segmentFrom) && minTime.isBeforeOrEqualTo(segmentFrom)) {
                throw new IllegalStateException(segmentedKey + ": minTime [" + minTime + "] should not be before or equal to segmentFrom [" + segmentFrom + "] when overlapping segments are used");
            } else if (minTime.isBefore(segmentFrom)) {
                throw new IllegalStateException(segmentedKey + ": minTime [" + minTime + "] should not be before segmentFrom [" + segmentFrom + "] when non overlapping segments are used");
            }
            final FDate maxTime = updater.getMaxTime();
            final FDate segmentTo = segmentedKey.getSegment().getTo();
            if (maxTime.isAfter(segmentTo)) {
                throw new IllegalStateException(segmentedKey + ": maxTime [" + maxTime + "] should not be after segmentTo [" + segmentTo + "]");
            }
        }
    } catch (final Throwable t) {
        if (Throwables.isCausedByType(t, IncompleteUpdateFoundException.class)) {
            segmentedTable.deleteRange(new SegmentedKey<K>(segmentedKey.getKey(), segmentedKey.getSegment()));
            throw new RetryLaterRuntimeException(t);
        } else {
            throw Throwables.propagate(t);
        }
    }
}
Also used : Percent(de.invesdwin.util.math.decimal.scaled.Percent) RetryLaterRuntimeException(de.invesdwin.context.integration.retry.RetryLaterRuntimeException) Callable(java.util.concurrent.Callable) ARetryCallable(de.invesdwin.context.integration.retry.task.ARetryCallable) TaskInfoCallable(de.invesdwin.util.concurrent.taskinfo.provider.TaskInfoCallable) FDate(de.invesdwin.util.time.date.FDate) TimeRange(de.invesdwin.util.time.range.TimeRange) IncompleteUpdateFoundException(de.invesdwin.context.persistence.timeseriesdb.IncompleteUpdateFoundException)

Example 19 with Percent

use of de.invesdwin.util.math.decimal.scaled.Percent 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);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Example 20 with Percent

use of de.invesdwin.util.math.decimal.scaled.Percent 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 long 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);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Aggregations

Percent (de.invesdwin.util.math.decimal.scaled.Percent)20 Duration (de.invesdwin.util.time.duration.Duration)14 ProcessedEventsRateString (de.invesdwin.util.lang.ProcessedEventsRateString)13 FDate (de.invesdwin.util.time.date.FDate)4 ArrayList (java.util.ArrayList)4 IScriptTaskEngine (de.invesdwin.context.integration.script.IScriptTaskEngine)3 IScriptTaskInputs (de.invesdwin.context.integration.script.IScriptTaskInputs)3 IScriptTaskResults (de.invesdwin.context.integration.script.IScriptTaskResults)3 Decimal (de.invesdwin.util.math.decimal.Decimal)3 Instant (de.invesdwin.util.time.Instant)3 List (java.util.List)3 ClassPathResource (org.springframework.core.io.ClassPathResource)3 IncompleteUpdateFoundException (de.invesdwin.context.persistence.timeseriesdb.IncompleteUpdateFoundException)2 ATimeSeriesUpdater (de.invesdwin.context.persistence.timeseriesdb.updater.ATimeSeriesUpdater)2 ATest (de.invesdwin.context.test.ATest)2 ICloseableIterable (de.invesdwin.util.collections.iterable.ICloseableIterable)2 TaskInfoCallable (de.invesdwin.util.concurrent.taskinfo.provider.TaskInfoCallable)2 TypeDelegateSerde (de.invesdwin.util.marshallers.serde.TypeDelegateSerde)2 Callable (java.util.concurrent.Callable)2 Test (org.junit.jupiter.api.Test)2