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;
}
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;
}
Aggregations