Search in sources :

Example 1 with SegmentStatus

use of de.invesdwin.context.persistence.timeseriesdb.segmented.SegmentStatus in project invesdwin-context-persistence by subes.

the class PersistentLiveSegment method finish.

public void finish() {
    if (!isEmpty()) {
        final ADelegateRangeTable<String, TimeRange, SegmentStatus> segmentStatusTable = historicalSegmentTable.getStorage().getSegmentStatusTable();
        final SegmentStatus existingStatus = segmentStatusTable.get(hashKey, segmentedKey.getSegment());
        if (existingStatus == SegmentStatus.INITIALIZING) {
            segmentStatusTable.put(hashKey, segmentedKey.getSegment(), SegmentStatus.COMPLETE);
            final ICloseableIterable<V> rangeValues = rangeValues(segmentedKey.getSegment().getFrom(), segmentedKey.getSegment().getTo(), DisabledLock.INSTANCE, null);
            historicalSegmentTable.getLookupTableCache(segmentedKey.getKey()).onSegmentCompleted(segmentedKey, rangeValues);
        }
    }
}
Also used : TimeRange(de.invesdwin.util.time.range.TimeRange) SegmentStatus(de.invesdwin.context.persistence.timeseriesdb.segmented.SegmentStatus)

Example 2 with SegmentStatus

use of de.invesdwin.context.persistence.timeseriesdb.segmented.SegmentStatus in project invesdwin-context-persistence by subes.

the class PersistentLiveSegment method putNextLiveValues.

public void putNextLiveValues(final ICloseableIterable<V> memoryValues) {
    final ADelegateRangeTable<String, TimeRange, SegmentStatus> segmentStatusTable = historicalSegmentTable.getStorage().getSegmentStatusTable();
    final SegmentStatus existingStatus = segmentStatusTable.get(hashKey, segmentedKey.getSegment());
    if (existingStatus == null) {
        segmentStatusTable.put(hashKey, segmentedKey.getSegment(), SegmentStatus.INITIALIZING);
    } else if (existingStatus != SegmentStatus.INITIALIZING) {
        throw UnknownArgumentException.newInstance(SegmentStatus.class, existingStatus);
    }
    final ATimeSeriesUpdater<SegmentedKey<K>, V> updater = new ATimeSeriesUpdater<SegmentedKey<K>, V>(segmentedKey, table) {

        @Override
        protected ICloseableIterable<? extends V> getSource(final FDate updateFrom) {
            return memoryValues;
        }

        @Override
        protected void onUpdateFinished(final Instant updateStart) {
        }

        @Override
        protected void onUpdateStart() {
        }

        @Override
        protected FDate extractEndTime(final V element) {
            return historicalSegmentTable.extractEndTime(element);
        }

        @Override
        protected void onFlush(final int flushIndex, final ATimeSeriesUpdater<SegmentedKey<K>, V>.UpdateProgress updateProgress) {
        }

        @Override
        protected boolean shouldRedoLastFile() {
            return false;
        }

        @Override
        public Percent getProgress() {
            return null;
        }
    };
    try {
        Assertions.checkTrue(updater.update());
    } catch (final IncompleteUpdateFoundException e) {
        throw new RuntimeException(e);
    }
    empty = false;
}
Also used : SegmentStatus(de.invesdwin.context.persistence.timeseriesdb.segmented.SegmentStatus) Instant(de.invesdwin.util.time.Instant) FDate(de.invesdwin.util.time.date.FDate) TimeRange(de.invesdwin.util.time.range.TimeRange) ATimeSeriesUpdater(de.invesdwin.context.persistence.timeseriesdb.updater.ATimeSeriesUpdater) SegmentedKey(de.invesdwin.context.persistence.timeseriesdb.segmented.SegmentedKey) IncompleteUpdateFoundException(de.invesdwin.context.persistence.timeseriesdb.IncompleteUpdateFoundException)

Aggregations

SegmentStatus (de.invesdwin.context.persistence.timeseriesdb.segmented.SegmentStatus)2 TimeRange (de.invesdwin.util.time.range.TimeRange)2 IncompleteUpdateFoundException (de.invesdwin.context.persistence.timeseriesdb.IncompleteUpdateFoundException)1 SegmentedKey (de.invesdwin.context.persistence.timeseriesdb.segmented.SegmentedKey)1 ATimeSeriesUpdater (de.invesdwin.context.persistence.timeseriesdb.updater.ATimeSeriesUpdater)1 Instant (de.invesdwin.util.time.Instant)1 FDate (de.invesdwin.util.time.date.FDate)1