Search in sources :

Example 21 with TimeSeries

use of com.srotya.sidewinder.core.storage.TimeSeries in project sidewinder by srotya.

the class PersistentMeasurement method getOrCreateTimeSeries.

@Override
public TimeSeries getOrCreateTimeSeries(String valueFieldName, List<String> tags, int timeBucketSize, boolean fp, Map<String, String> conf) throws IOException {
    Collections.sort(tags);
    String seriesId = constructSeriesId(tags, tagIndex);
    int index = 0;
    SeriesFieldMap seriesFieldMap = getSeriesFromKey(seriesId);
    if (seriesFieldMap == null) {
        lock.lock();
        try {
            if ((seriesFieldMap = getSeriesFromKey(seriesId)) == null) {
                index = seriesList.size();
                Measurement.indexRowKey(tagIndex, index, tags);
                seriesFieldMap = new SeriesFieldMap(seriesId);
                seriesList.add(seriesFieldMap);
                seriesMap.put(seriesId, index);
                if (enableMetricsCapture) {
                    metricsTimeSeriesCounter.inc();
                }
                logger.fine("Created new series:" + seriesId + "\t");
            } else {
                index = seriesMap.get(seriesId);
            }
        } finally {
            lock.unlock();
        }
    } else {
        index = seriesMap.get(seriesId);
    }
    TimeSeries series = seriesFieldMap.get(valueFieldName);
    if (series == null) {
        lock.lock();
        try {
            if ((series = seriesFieldMap.get(valueFieldName)) == null) {
                String seriesId2 = seriesId + SERIESID_SEPARATOR + valueFieldName;
                series = new TimeSeries(this, compressionCodec, compactionCodec, seriesId2, timeBucketSize, metadata, fp, conf);
                seriesFieldMap.addSeries(valueFieldName, series);
                appendTimeseriesToMeasurementMetadata(seriesId2, fp, timeBucketSize, index);
                logger.fine("Created new timeseries:" + seriesFieldMap + " for measurement:" + measurementName + "\t" + seriesId + "\t" + metadata.getRetentionHours() + "\t" + seriesList.size());
            }
        } finally {
            lock.unlock();
        }
    }
    return series;
}
Also used : TimeSeries(com.srotya.sidewinder.core.storage.TimeSeries) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap)

Example 22 with TimeSeries

use of com.srotya.sidewinder.core.storage.TimeSeries in project sidewinder by srotya.

the class MemoryMeasurement method getOrCreateTimeSeries.

@Override
public TimeSeries getOrCreateTimeSeries(String valueFieldName, List<String> tags, int timeBucketSize, boolean fp, Map<String, String> conf) throws IOException {
    Collections.sort(tags);
    String seriesId = constructSeriesId(tags, tagIndex);
    SeriesFieldMap seriesFieldMap = getSeriesFromKey(seriesId);
    if (seriesFieldMap == null) {
        lock.lock();
        if ((seriesFieldMap = getSeriesFromKey(seriesId)) == null) {
            Measurement.indexRowKey(tagIndex, seriesId, tags);
            seriesFieldMap = new SeriesFieldMap(seriesId);
            seriesMap.put(seriesId, seriesFieldMap);
        }
        lock.unlock();
    }
    TimeSeries series = seriesFieldMap.get(valueFieldName);
    if (series == null) {
        lock.lock();
        if ((series = seriesFieldMap.get(valueFieldName)) == null) {
            String seriesId2 = seriesId + SERIESID_SEPARATOR + valueFieldName;
            series = new TimeSeries(this, compressionCodec, compactionCodec, seriesId2, timeBucketSize, metadata, fp, conf);
            seriesFieldMap.addSeries(valueFieldName, series);
            logger.fine("Created new timeseries:" + seriesFieldMap + " for measurement:" + measurementName + "\t" + seriesId + "\t" + metadata.getRetentionHours() + "\t" + seriesMap.size());
        }
        lock.unlock();
    }
    return series;
}
Also used : TimeSeries(com.srotya.sidewinder.core.storage.TimeSeries) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap)

Aggregations

TimeSeries (com.srotya.sidewinder.core.storage.TimeSeries)22 DataPoint (com.srotya.sidewinder.core.storage.DataPoint)14 Test (org.junit.Test)14 File (java.io.File)12 LinkedHashMap (java.util.LinkedHashMap)12 HashMap (java.util.HashMap)11 IOException (java.io.IOException)9 Series (com.srotya.sidewinder.core.storage.Series)8 ArrayList (java.util.ArrayList)8 ByzantineWriter (com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter)6 Measurement (com.srotya.sidewinder.core.storage.Measurement)5 BackgrounThreadFactory (com.srotya.sidewinder.core.utils.BackgrounThreadFactory)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 Point (com.srotya.sidewinder.core.rpc.Point)4 List (java.util.List)4 ExecutorService (java.util.concurrent.ExecutorService)4 DBMetadata (com.srotya.sidewinder.core.storage.DBMetadata)3 SeriesFieldMap (com.srotya.sidewinder.core.storage.SeriesFieldMap)3 Tag (com.srotya.sidewinder.core.filters.Tag)2