Class AccountingPersistenceQuery
java.lang.Object
org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery
- All Implemented Interfaces:
AccountingPersistenceBackendQuery
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AccountingPersistenceBackendQueryprotected Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> static final intprotected Collection<? extends Filter>protected org.gcube.com.fasterxml.jackson.databind.ObjectMapperprotected TemporalConstraintFields inherited from interface org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery
KEY_VALUES_LIMIT -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the connection to persistenceReturn a SortedMap containing the TimeSeries for each context.getContextTimeSeries(boolean pad) static StringgetDefaultOrderingProperties(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?, ?>> clz) getFilterValues(String key) getFilterValues(String key, Integer limit) protected static AccountingPersistenceQueryprotected org.gcube.com.fasterxml.jackson.databind.JsonNodegetPaddingJsonNode(Map<Calendar, Info> unpaddedResults) getQuerableKeys(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?, ?>> clz) org.gcube.documentstore.records.RecordgetSpaceTimeSeries(Set<String> dataTypes) Query the persistence obtaining a Map where the date is the key and the #Info is the value.getTimeSeries(boolean pad) getTopValues(String topKey) getTopValues(String topKey, String orderingProperty, boolean pad, Integer limit) 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] ]booleanPad the datapadMapStorage(SortedMap<Calendar, Info> unpaddedData) voidprepareConnection(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
-
DEFAULT_LIMIT_RESULT_NUMBER
public static final int DEFAULT_LIMIT_RESULT_NUMBER- See Also:
-
clz
-
temporalConstraint
-
contexts
-
filters
-
objectMapper
protected org.gcube.com.fasterxml.jackson.databind.ObjectMapper objectMapper -
accountingPersistenceBackendQuery
-
-
Method Details
-
getInstance
-
setRequestedRecords
public void setRequestedRecords(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?, ?>> clz) - Specified by:
setRequestedRecordsin interfaceAccountingPersistenceBackendQuery- Parameters:
clz- the Usage Record Class of interest Required
-
setTemporalConstraint
- Specified by:
setTemporalConstraintin interfaceAccountingPersistenceBackendQuery- Parameters:
temporalConstraint- the TemporalConstraint (interval and aggregation) Required
-
setContexts
- Specified by:
setContextsin interfaceAccountingPersistenceBackendQuery- 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
- Specified by:
setFiltersin interfaceAccountingPersistenceBackendQuery- 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.
-
getQuerableKeys
public static SortedSet<String> getQuerableKeys(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?, ?>> clz) throws Exception- Throws:
Exception
-
getDefaultOrderingProperties
-
getPaddingJsonNode
protected org.gcube.com.fasterxml.jackson.databind.JsonNode getPaddingJsonNode(Map<Calendar, Info> unpaddedResults) throws Exception- Throws:
Exception
-
padMap
Pad the data- Parameters:
unpaddedData- the data to be padtemporalConstraint- temporalConstraint the temporal interval and the granularity of the data to pad- Returns:
- the data padded taking in account the TemporalConstraint
- Throws:
Exception- if fails
-
getTimeSeries
public SortedMap<Calendar,Info> getTimeSeries() throws DuplicatedKeyFilterException, KeyException, ValueException, ExceptionDescription copied from interface:AccountingPersistenceBackendQueryQuery 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.- Specified by:
getTimeSeriesin interfaceAccountingPersistenceBackendQuery- Returns:
- the Map containing for each date in the required interval the requested data
- Throws:
ExceptionDuplicatedKeyFilterExceptionKeyExceptionValueException
-
getTimeSeries
public SortedMap<Calendar,Info> getTimeSeries(boolean pad) throws DuplicatedKeyFilterException, KeyException, ValueException, Exception -
getTopValues
public SortedMap<NumberedFilter,SortedMap<Calendar, getTopValuesInfo>> (String topKey, String orderingProperty, boolean pad, Integer limit) throws DuplicatedKeyFilterException, KeyException, ValueException, Exception -
getTopValues
public SortedMap<NumberedFilter,SortedMap<Calendar, getTopValuesInfo>> (String topKey) throws DuplicatedKeyFilterException, KeyException, ValueException, Exception -
getTopValues
public SortedMap<NumberedFilter,SortedMap<Calendar, getTopValuesInfo>> (String topKey, String orderingProperty, Integer limit) throws Exception Description copied from interface:AccountingPersistenceBackendQueryReturn 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.- Specified by:
getTopValuesin interfaceAccountingPersistenceBackendQuery- Parameters:
topKey- the key to obtain top values- Returns:
- a SortedMap
- Throws:
Exception
-
close
Description copied from interface:AccountingPersistenceBackendQueryClose the connection to persistence- Specified by:
closein interfaceAccountingPersistenceBackendQuery- Throws:
Exception- if the close fails
-
prepareConnection
public void prepareConnection(AccountingPersistenceBackendQueryConfiguration configuration) throws Exception - Specified by:
prepareConnectionin interfaceAccountingPersistenceBackendQuery- Throws:
Exception
-
getFilterValues
- Specified by:
getFilterValuesin interfaceAccountingPersistenceBackendQuery- Throws:
Exception
-
getFilterValues
- Specified by:
getFilterValuesin interfaceAccountingPersistenceBackendQuery- Throws:
Exception
-
getUsageValueQuotaTotal
Description copied from interface:AccountingPersistenceBackendQuerygetUsageValueQuotaTotal 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] ]- Specified by:
getUsageValueQuotaTotalin interfaceAccountingPersistenceBackendQuery- Returns:
- List
- Throws:
Exception
-
getContextTimeSeries
Description copied from interface:AccountingPersistenceBackendQueryReturn a SortedMap containing the TimeSeries for each context.- Specified by:
getContextTimeSeriesin interfaceAccountingPersistenceBackendQuery- Returns:
- a SortedMap containing the TimeSeries for each context.
- Throws:
Exception
-
getContextTimeSeries
-
getRecord
public org.gcube.documentstore.records.Record getRecord(String recordId, String type) throws Exception - Specified by:
getRecordin interfaceAccountingPersistenceBackendQuery- Throws:
Exception
-
getDataType
- Throws:
Exception
-
getSpaceTimeSeries
public SortedMap<Filter,SortedMap<Calendar, getSpaceTimeSeriesInfo>> (Set<String> dataTypes) throws Exception - Specified by:
getSpaceTimeSeriesin interfaceAccountingPersistenceBackendQuery- Throws:
Exception
-
padMapStorage
protected SortedMap<Calendar,Info> padMapStorage(SortedMap<Calendar, Info> unpaddedData) throws Exception- Throws:
Exception
-
isConnectionActive
- Specified by:
isConnectionActivein interfaceAccountingPersistenceBackendQuery- Throws:
Exception
-