Interface AccountingPersistenceBackendQuery
- All Known Implementing Classes:
AccountingPersistenceQuery
public interface AccountingPersistenceBackendQuery
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the connection to persistenceReturn a SortedMap containing the TimeSeries for each context.getFilterValues(String key) getFilterValues(String key, Integer limit) org.gcube.documentstore.records.Recordstatic StringgetSpaceTimeSeries(Set<String> dataTypes) Query the persistence obtaining a Map where the date is the key and the #Info is the value.getTopValues(String topKey, String orderingProperty, Integer limit) Return a SortedMap containing the TimeSeries for top values for a certain key taking in account all Filters.getUsageValueQuotaTotal(List<UsageValue> listUsage) getUsageValueQuotaTotal Example to require 2 different quota (lucio.lelii for service and alessandro.pieve for storage) Input: [ TotalFilters [ clz=class org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord, temporalConstraint=StartTime : 2015-05-01 11:42:34:515 UTC (1430480554515 millis), EndTime : 2016-11-09 11:42:34:515 UTC (1478691754515 millis), Aggregated DAILY, totalFilters=[ Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "DataAccess" }, { "serviceName" : "CkanConnector" } ], d=null, orderingProperty=null], Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "VREManagement" } ], d=null, orderingProperty=null] ], d=null, orderingProperty=null] ] Output: [ TotalFilters [ clz=class org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord, temporalConstraint=StartTime : 2015-05-01 11:42:34:515 UTC (1430480554515 millis), EndTime : 2016-11-09 11:42:34:515 UTC (1478691754515 millis), Aggregated DAILY, totalFilters=[ Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "DataAccess" }, { "serviceName" : "CkanConnector" } ], d=1.0, orderingProperty=operationCount], Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "VREManagement" } ], d=1.0, orderingProperty=operationCount] ], d=2.0, orderingProperty=null] ]booleanvoidprepareConnection(AccountingPersistenceBackendQueryConfiguration configuration) voidsetContexts(Set<String> contexts) voidsetFilters(Collection<? extends Filter> filters) voidsetRequestedRecords(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?, ?>> clz) voidsetTemporalConstraint(TemporalConstraint temporalConstraint)
-
Field Details
-
KEY_VALUES_LIMIT
static final int KEY_VALUES_LIMIT- See Also:
-
-
Method Details
-
getScopeToQuery
-
prepareConnection
void prepareConnection(AccountingPersistenceBackendQueryConfiguration configuration) throws Exception - Throws:
Exception
-
setRequestedRecords
void setRequestedRecords(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?, ?>> clz) - Parameters:
clz- the Usage Record Class of interest Required
-
setTemporalConstraint
- Parameters:
temporalConstraint- the TemporalConstraint (interval and aggregation) Required
-
setContexts
- Parameters:
contexts- the list of context to use as filter If null or empty list get all data for the interested Record Class with the applying temporal constraint with no contexts constraint. The contexts are evaluated in OR.
-
setFilters
- Parameters:
filters- list of filter to obtain the results. If null or empty list get all data for the interested Record Class with the applying temporal constraint. All Filter must have not null and not empty key and value. The filters must be related to different keys and are in AND. If the list contains more than one filter with the same key an Exception is thrown when trying to query.
-
getTimeSeries
Query the persistence obtaining a Map where the date is the key and the #Info is the value. The result is relative to an Usage Record Type, respect a TemporalConstraint and can be applied one or more filters.- Returns:
- the Map containing for each date in the required interval the requested data
- Throws:
Exception
-
getContextTimeSeries
Return a SortedMap containing the TimeSeries for each context.- Returns:
- a SortedMap containing the TimeSeries for each context.
- Throws:
Exception
-
getTopValues
SortedMap<NumberedFilter,SortedMap<Calendar, getTopValuesInfo>> (String topKey, String orderingProperty, Integer limit) throws Exception Return a SortedMap containing the TimeSeries for top values for a certain key taking in account all Filters. The values are ordered from the most occurred value.- Parameters:
topKey- the key to obtain top valuesorderingProperty-- Returns:
- a SortedMap
- Throws:
Exception
-
close
Close the connection to persistence- Throws:
Exception- if the close fails
-
getFilterValues
- Throws:
Exception
-
getFilterValues
- Throws:
Exception
-
getRecord
- Throws:
Exception
-
getSpaceTimeSeries
SortedMap<Filter,SortedMap<Calendar, getSpaceTimeSeriesInfo>> (Set<String> dataTypes) throws Exception - Throws:
Exception
-
getUsageValueQuotaTotal
getUsageValueQuotaTotal Example to require 2 different quota (lucio.lelii for service and alessandro.pieve for storage) Input: [ TotalFilters [ clz=class org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord, temporalConstraint=StartTime : 2015-05-01 11:42:34:515 UTC (1430480554515 millis), EndTime : 2016-11-09 11:42:34:515 UTC (1478691754515 millis), Aggregated DAILY, totalFilters=[ Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "DataAccess" }, { "serviceName" : "CkanConnector" } ], d=null, orderingProperty=null], Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "VREManagement" } ], d=null, orderingProperty=null] ], d=null, orderingProperty=null] ] Output: [ TotalFilters [ clz=class org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord, temporalConstraint=StartTime : 2015-05-01 11:42:34:515 UTC (1430480554515 millis), EndTime : 2016-11-09 11:42:34:515 UTC (1478691754515 millis), Aggregated DAILY, totalFilters=[ Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "DataAccess" }, { "serviceName" : "CkanConnector" } ], d=1.0, orderingProperty=operationCount], Filters [filters=[ { "consumerId" : "lucio.lelii" }, { "serviceClass" : "VREManagement" } ], d=1.0, orderingProperty=operationCount] ], d=2.0, orderingProperty=null] ]- Parameters:
listUsage-- Returns:
- List
- Throws:
Exception
-
isConnectionActive
- Throws:
Exception
-