public class AccountingPersistenceQuery extends Object implements AccountingPersistenceBackendQuery
| Modifier and Type | Field and Description |
|---|---|
protected AccountingPersistenceBackendQuery |
accountingPersistenceBackendQuery |
protected Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> |
clz |
protected Set<String> |
contexts |
static int |
DEFAULT_LIMIT_RESULT_NUMBER |
protected Collection<? extends Filter> |
filters |
protected org.gcube.com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
protected TemporalConstraint |
temporalConstraint |
KEY_VALUES_LIMIT| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the connection to persistence
|
SortedMap<Filter,SortedMap<Calendar,Info>> |
getContextTimeSeries()
Return a SortedMap containing the TimeSeries for each context.
|
SortedMap<Filter,SortedMap<Calendar,Info>> |
getContextTimeSeries(boolean pad) |
SortedSet<String> |
getDataType() |
static String |
getDefaultOrderingProperties(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> clz) |
SortedSet<NumberedFilter> |
getFilterValues(String key) |
SortedSet<NumberedFilter> |
getFilterValues(String key,
Integer limit) |
protected static AccountingPersistenceQuery |
getInstance() |
protected org.gcube.com.fasterxml.jackson.databind.JsonNode |
getPaddingJsonNode(Map<Calendar,Info> unpaddedResults) |
static SortedSet<String> |
getQuerableKeys(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> clz) |
org.gcube.documentstore.records.Record |
getRecord(String recordId,
String type) |
SortedMap<Filter,SortedMap<Calendar,Info>> |
getSpaceTimeSeries(Set<String> dataTypes) |
SortedMap<Calendar,Info> |
getTimeSeries()
Query the persistence obtaining a Map where the date is the key and the
#Info is the value.
|
SortedMap<Calendar,Info> |
getTimeSeries(boolean pad) |
SortedMap<NumberedFilter,SortedMap<Calendar,Info>> |
getTopValues(String topKey) |
SortedMap<NumberedFilter,SortedMap<Calendar,Info>> |
getTopValues(String topKey,
String orderingProperty,
boolean pad,
Integer limit) |
SortedMap<NumberedFilter,SortedMap<Calendar,Info>> |
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.
|
List<UsageValue> |
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]
]
|
boolean |
isConnectionActive() |
protected SortedMap<Calendar,Info> |
padMap(SortedMap<Calendar,Info> unpaddedData)
Pad the data
|
protected SortedMap<Calendar,Info> |
padMapStorage(SortedMap<Calendar,Info> unpaddedData) |
void |
prepareConnection(AccountingPersistenceBackendQueryConfiguration configuration) |
void |
setContexts(Set<String> contexts) |
void |
setFilters(Collection<? extends Filter> filters) |
void |
setRequestedRecords(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> clz) |
void |
setTemporalConstraint(TemporalConstraint temporalConstraint) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetScopeToQuerypublic static final int DEFAULT_LIMIT_RESULT_NUMBER
protected Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> clz
protected TemporalConstraint temporalConstraint
protected Collection<? extends Filter> filters
protected org.gcube.com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected AccountingPersistenceBackendQuery accountingPersistenceBackendQuery
protected static AccountingPersistenceQuery getInstance()
public void setRequestedRecords(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> clz)
setRequestedRecords in interface AccountingPersistenceBackendQueryclz - the Usage Record Class of interest
Requiredpublic void setTemporalConstraint(TemporalConstraint temporalConstraint)
setTemporalConstraint in interface AccountingPersistenceBackendQuerytemporalConstraint - the TemporalConstraint (interval and aggregation)
Requiredpublic void setContexts(Set<String> contexts)
setContexts in interface AccountingPersistenceBackendQuerycontexts - 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.public void setFilters(Collection<? extends Filter> filters)
setFilters in interface AccountingPersistenceBackendQueryfilters - 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.public static SortedSet<String> getQuerableKeys(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> clz) throws Exception
Exceptionpublic static String getDefaultOrderingProperties(Class<? extends org.gcube.documentstore.records.AggregatedRecord<?,?>> clz)
protected org.gcube.com.fasterxml.jackson.databind.JsonNode getPaddingJsonNode(Map<Calendar,Info> unpaddedResults) throws Exception
Exceptionprotected SortedMap<Calendar,Info> padMap(SortedMap<Calendar,Info> unpaddedData) throws Exception
unpaddedData - the data to be padtemporalConstraint - temporalConstraint the temporal interval and the granularity
of the data to padException - if failspublic SortedMap<Calendar,Info> getTimeSeries() throws DuplicatedKeyFilterException, KeyException, ValueException, Exception
AccountingPersistenceBackendQuerygetTimeSeries in interface AccountingPersistenceBackendQueryExceptionDuplicatedKeyFilterExceptionKeyExceptionValueExceptionpublic SortedMap<Calendar,Info> getTimeSeries(boolean pad) throws DuplicatedKeyFilterException, KeyException, ValueException, Exception
public SortedMap<NumberedFilter,SortedMap<Calendar,Info>> getTopValues(String topKey, String orderingProperty, boolean pad, Integer limit) throws DuplicatedKeyFilterException, KeyException, ValueException, Exception
public SortedMap<NumberedFilter,SortedMap<Calendar,Info>> getTopValues(String topKey) throws DuplicatedKeyFilterException, KeyException, ValueException, Exception
public SortedMap<NumberedFilter,SortedMap<Calendar,Info>> getTopValues(String topKey, String orderingProperty, Integer limit) throws Exception
AccountingPersistenceBackendQuerygetTopValues in interface AccountingPersistenceBackendQuerytopKey - the key to obtain top valuesExceptionpublic void close()
throws Exception
AccountingPersistenceBackendQueryclose in interface AccountingPersistenceBackendQueryException - if the close failspublic void prepareConnection(AccountingPersistenceBackendQueryConfiguration configuration) throws Exception
prepareConnection in interface AccountingPersistenceBackendQueryExceptionpublic SortedSet<NumberedFilter> getFilterValues(String key) throws Exception
getFilterValues in interface AccountingPersistenceBackendQueryExceptionpublic SortedSet<NumberedFilter> getFilterValues(String key, Integer limit) throws Exception
getFilterValues in interface AccountingPersistenceBackendQueryExceptionpublic List<UsageValue> getUsageValueQuotaTotal(List<UsageValue> listUsage) throws Exception
AccountingPersistenceBackendQuerygetUsageValueQuotaTotal in interface AccountingPersistenceBackendQueryExceptionpublic SortedMap<Filter,SortedMap<Calendar,Info>> getContextTimeSeries() throws Exception
AccountingPersistenceBackendQuerygetContextTimeSeries in interface AccountingPersistenceBackendQueryExceptionpublic SortedMap<Filter,SortedMap<Calendar,Info>> getContextTimeSeries(boolean pad) throws DuplicatedKeyFilterException, Exception
public org.gcube.documentstore.records.Record getRecord(String recordId, String type) throws Exception
getRecord in interface AccountingPersistenceBackendQueryExceptionpublic SortedMap<Filter,SortedMap<Calendar,Info>> getSpaceTimeSeries(Set<String> dataTypes) throws Exception
getSpaceTimeSeries in interface AccountingPersistenceBackendQueryExceptionprotected SortedMap<Calendar,Info> padMapStorage(SortedMap<Calendar,Info> unpaddedData) throws Exception
Exceptionpublic boolean isConnectionActive()
throws Exception
isConnectionActive in interface AccountingPersistenceBackendQueryExceptionCopyright © 2021. All Rights Reserved.