Refs #10188: Add a way to esplicitly set the scope in accounting-analytics
Task-Url: https://support.d4science.org/issues/10188 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics-persistence-couchbase@161933 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
407f5d1d17
commit
2edcb5a076
|
@ -44,7 +44,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
|
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||||
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
|
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.documentstore.records.AggregatedRecord;
|
import org.gcube.documentstore.records.AggregatedRecord;
|
||||||
import org.gcube.documentstore.records.RecordUtility;
|
import org.gcube.documentstore.records.RecordUtility;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -326,8 +325,8 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
return String.format("%s%s", MAP_REDUCE__DESIGN, recordClass.newInstance().getRecordType());
|
return String.format("%s%s", MAP_REDUCE__DESIGN, recordClass.newInstance().getRecordType());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getDesignDocIdSpecific(Class<? extends AggregatedRecord<?, ?>> recordClass,
|
protected String getDesignDocIdSpecific(Class<? extends AggregatedRecord<?,?>> recordClass, Collection<String> keys)
|
||||||
Collection<String> keys) throws InstantiationException, IllegalAccessException {
|
throws InstantiationException, IllegalAccessException {
|
||||||
String specific = "all";
|
String specific = "all";
|
||||||
if(!keys.isEmpty()) {
|
if(!keys.isEmpty()) {
|
||||||
specific = keys.iterator().next();
|
specific = keys.iterator().next();
|
||||||
|
@ -484,11 +483,12 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
protected SortedMap<Calendar,Info> mapReduceQuery(Class<? extends AggregatedRecord<?,?>> clz,
|
protected SortedMap<Calendar,Info> mapReduceQuery(Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters, String context, Boolean valueEmpty,
|
TemporalConstraint temporalConstraint, List<Filter> filters, String context, Boolean valueEmpty,
|
||||||
Boolean noScope) throws Exception {
|
Boolean noScope) throws Exception {
|
||||||
String currentScope = null;
|
String currentScope = AccountingPersistenceBackendQuery.getScopeToQuery();
|
||||||
if (context == null)
|
|
||||||
currentScope = ScopeProvider.instance.get();
|
if(context != null) {
|
||||||
else
|
|
||||||
currentScope = context;
|
currentScope = context;
|
||||||
|
}
|
||||||
|
|
||||||
JsonArray startKey = JsonArray.create();
|
JsonArray startKey = JsonArray.create();
|
||||||
|
|
||||||
JsonArray endKey = JsonArray.create();
|
JsonArray endKey = JsonArray.create();
|
||||||
|
@ -668,9 +668,9 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
public SortedMap<NumberedFilter,SortedMap<Calendar,Info>> getTopValues(Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
Class<? extends AggregatedRecord<?, ?>> clz, TemporalConstraint temporalConstraint, List<Filter> filters,
|
TemporalConstraint temporalConstraint, List<Filter> filters, String topKey, String orderingProperty)
|
||||||
String topKey, String orderingProperty) throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
Comparator<NumberedFilter> comparator = new Comparator<NumberedFilter>() {
|
Comparator<NumberedFilter> comparator = new Comparator<NumberedFilter>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -812,7 +812,7 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
logger.debug("getNextPossibleValuesWithMap init");
|
logger.debug("getNextPossibleValuesWithMap init");
|
||||||
String currentScope = ScopeProvider.instance.get();
|
String currentScope = AccountingPersistenceBackendQuery.getScopeToQuery();
|
||||||
|
|
||||||
if(orderingProperty == null) {
|
if(orderingProperty == null) {
|
||||||
orderingProperty = AccountingPersistenceQuery.getDefaultOrderingProperties(clz);
|
orderingProperty = AccountingPersistenceQuery.getDefaultOrderingProperties(clz);
|
||||||
|
@ -983,8 +983,7 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters, String key, String orderingProperty)
|
TemporalConstraint temporalConstraint, List<Filter> filters, String key, String orderingProperty)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
String currentScope = ScopeProvider.instance.get();
|
String currentScope = AccountingPersistenceBackendQuery.getScopeToQuery();
|
||||||
// String recordType = clz.newInstance().getRecordType();
|
|
||||||
|
|
||||||
if(orderingProperty == null) {
|
if(orderingProperty == null) {
|
||||||
orderingProperty = AccountingPersistenceQuery.getDefaultOrderingProperties(clz);
|
orderingProperty = AccountingPersistenceQuery.getDefaultOrderingProperties(clz);
|
||||||
|
@ -1111,9 +1110,8 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<Filter, SortedMap<Calendar, Info>> getContextTimeSeries(
|
public SortedMap<Filter,SortedMap<Calendar,Info>> getContextTimeSeries(Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
Class<? extends AggregatedRecord<?, ?>> clz, TemporalConstraint temporalConstraint, List<Filter> filters,
|
TemporalConstraint temporalConstraint, List<Filter> filters, List<String> contexts) throws Exception {
|
||||||
List<String> contexts) throws Exception {
|
|
||||||
logger.trace("getContextTimeSeries for contexts:{}", contexts.toString());
|
logger.trace("getContextTimeSeries for contexts:{}", contexts.toString());
|
||||||
SortedSet<Filter> listContexts = new TreeSet<Filter>();
|
SortedSet<Filter> listContexts = new TreeSet<Filter>();
|
||||||
for(String context : contexts) {
|
for(String context : contexts) {
|
||||||
|
@ -1169,7 +1167,7 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
public SortedSet<NumberedFilter> getFilterValues(Class<? extends AggregatedRecord<?,?>> clz,
|
public SortedSet<NumberedFilter> getFilterValues(Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters, String key, Integer limit) throws Exception {
|
TemporalConstraint temporalConstraint, List<Filter> filters, String key, Integer limit) throws Exception {
|
||||||
|
|
||||||
String currentScope = ScopeProvider.instance.get();
|
String currentScope = AccountingPersistenceBackendQuery.getScopeToQuery();
|
||||||
|
|
||||||
JsonArray startKey = JsonArray.create();
|
JsonArray startKey = JsonArray.create();
|
||||||
startKey.add(currentScope);
|
startKey.add(currentScope);
|
||||||
|
@ -1242,7 +1240,7 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
public JSONObject getUsageValue(Class<? extends AggregatedRecord<?,?>> clz, TemporalConstraint temporalConstraint,
|
public JSONObject getUsageValue(Class<? extends AggregatedRecord<?,?>> clz, TemporalConstraint temporalConstraint,
|
||||||
Filter applicant) throws Exception {
|
Filter applicant) throws Exception {
|
||||||
|
|
||||||
String currentScope = ScopeProvider.instance.get();
|
String currentScope = AccountingPersistenceBackendQuery.getScopeToQuery();
|
||||||
|
|
||||||
JsonArray startKey = JsonArray.create();
|
JsonArray startKey = JsonArray.create();
|
||||||
startKey.add(currentScope);
|
startKey.add(currentScope);
|
||||||
|
@ -1396,7 +1394,6 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// do {
|
// do {
|
||||||
String viewNameTmp = null;
|
String viewNameTmp = null;
|
||||||
JsonArray startKeyTmp = JsonArray.create();
|
JsonArray startKeyTmp = JsonArray.create();
|
||||||
|
@ -1535,7 +1532,7 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SortedSet<String> getSpaceProvidersIds() throws Exception {
|
public SortedSet<String> getSpaceProvidersIds() throws Exception {
|
||||||
String currentScope = ScopeProvider.instance.get();
|
String currentScope = AccountingPersistenceBackendQuery.getScopeToQuery();
|
||||||
|
|
||||||
JsonArray startKey = JsonArray.create();
|
JsonArray startKey = JsonArray.create();
|
||||||
startKey.add(currentScope);
|
startKey.add(currentScope);
|
||||||
|
@ -1585,8 +1582,7 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
|
||||||
public SortedMap<Filter,SortedMap<Calendar,Long>> getSpaceTimeSeries(Class<? extends AggregatedRecord<?,?>> clz,
|
public SortedMap<Filter,SortedMap<Calendar,Long>> getSpaceTimeSeries(Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters, List<String> providersId) throws Exception {
|
TemporalConstraint temporalConstraint, List<Filter> filters, List<String> providersId) throws Exception {
|
||||||
|
|
||||||
String currentScope = null;
|
String currentScope = AccountingPersistenceBackendQuery.getScopeToQuery();
|
||||||
currentScope = ScopeProvider.instance.get();
|
|
||||||
|
|
||||||
JsonArray startKey = JsonArray.create();
|
JsonArray startKey = JsonArray.create();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
package org.gcube.accounting.analytics.persistence.couchbase;
|
package org.gcube.accounting.analytics.persistence.couchbase;
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
@ -75,20 +71,15 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
AccountingPersistenceBackendQueryConfiguration configuration = new
|
AccountingPersistenceBackendQueryConfiguration configuration = new AccountingPersistenceBackendQueryConfiguration(
|
||||||
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class);
|
AccountingPersistenceQueryCouchBase.class);
|
||||||
|
|
||||||
accountingPersistenceQueryCouchBase = new AccountingPersistenceQueryCouchBase();
|
accountingPersistenceQueryCouchBase = new AccountingPersistenceQueryCouchBase();
|
||||||
accountingPersistenceQueryCouchBase.prepareConnection(configuration);
|
accountingPersistenceQueryCouchBase.prepareConnection(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void printMap(Map<Calendar,Info> map) {
|
public void printMap(Map<Calendar,Info> map) {
|
||||||
for(Info info : map.values()) {
|
for(Info info : map.values()) {
|
||||||
logger.debug("{}", info);
|
logger.debug("{}", info);
|
||||||
|
@ -113,24 +104,21 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
|
|
||||||
logger.debug("EndTime {}", endTime.getTimeInMillis());
|
logger.debug("EndTime {}", endTime.getTimeInMillis());
|
||||||
|
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.MONTHLY);
|
endTime.getTimeInMillis(), AggregationMode.MONTHLY);
|
||||||
|
|
||||||
Class<AggregatedServiceUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz = AggregatedServiceUsageRecord.class;
|
||||||
AggregatedServiceUsageRecord.class;
|
|
||||||
|
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
//Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "DataMiner");
|
//Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "DataMiner");
|
||||||
Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "RConnector");
|
Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "RConnector");
|
||||||
filters.add(filter);
|
filters.add(filter);
|
||||||
|
|
||||||
|
|
||||||
for(String context : contexts) {
|
for(String context : contexts) {
|
||||||
ScopeProvider.instance.set(context);
|
ScopeProvider.instance.set(context);
|
||||||
|
|
||||||
SortedSet<NumberedFilter> top = accountingPersistenceQueryCouchBase.getNextPossibleValuesWithMap(clz, temporalConstraint, filters, ServiceUsageRecord.CONSUMER_ID, null);
|
SortedSet<NumberedFilter> top = accountingPersistenceQueryCouchBase.getNextPossibleValuesWithMap(clz,
|
||||||
|
temporalConstraint, filters, ServiceUsageRecord.CONSUMER_ID, null);
|
||||||
|
|
||||||
logger.info("Context : {} - Users [{}] : {}", context, top.size(), top);
|
logger.info("Context : {} - Users [{}] : {}", context, top.size(), top);
|
||||||
|
|
||||||
|
@ -150,25 +138,18 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
|
|
||||||
logger.debug("EndTime {}", endTime.getTimeInMillis());
|
logger.debug("EndTime {}", endTime.getTimeInMillis());
|
||||||
|
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "DataMiner");
|
Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "DataMiner");
|
||||||
//Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "RConnector");
|
//Filter filter = new Filter(ServiceUsageRecord.SERVICE_NAME, "RConnector");
|
||||||
filters.add(filter);
|
filters.add(filter);
|
||||||
|
|
||||||
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
TemporalConstraint temporalConstraint =
|
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.MONTHLY);
|
endTime.getTimeInMillis(), AggregationMode.MONTHLY);
|
||||||
|
|
||||||
Class<AggregatedServiceUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz = AggregatedServiceUsageRecord.class;
|
||||||
AggregatedServiceUsageRecord.class;
|
|
||||||
|
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
|
||||||
accountingPersistenceQueryCouchBase.getTopValues(
|
|
||||||
clz, temporalConstraint, filters,
|
|
||||||
ServiceUsageRecord.CONSUMER_ID, null);
|
|
||||||
|
|
||||||
|
SortedMap<NumberedFilter,SortedMap<Calendar,Info>> set = accountingPersistenceQueryCouchBase.getTopValues(clz,
|
||||||
|
temporalConstraint, filters, ServiceUsageRecord.CONSUMER_ID, null);
|
||||||
|
|
||||||
logger.debug("Result {}", set);
|
logger.debug("Result {}", set);
|
||||||
}
|
}
|
||||||
|
@ -176,20 +157,19 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTimeSeries() throws Exception {
|
public void testTimeSeries() throws Exception {
|
||||||
|
|
||||||
|
//AccountingPersistenceQueryFactory.getForcedScope().set("/gcube/devNext/NextNext");
|
||||||
|
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
startTime.set(2015, Calendar.AUGUST, 20);
|
startTime.set(2017, Calendar.NOVEMBER, 29);
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
endTime.set(2016, Calendar.SEPTEMBER, 29,23,59);
|
endTime.set(2017, Calendar.DECEMBER, 29);
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
|
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
Class<AggregatedJobUsageRecord> clz =
|
Class<AggregatedJobUsageRecord> clz = AggregatedJobUsageRecord.class;
|
||||||
AggregatedJobUsageRecord.class;
|
SortedMap<Calendar,Info> set = accountingPersistenceQueryCouchBase.getTimeSeries(clz, temporalConstraint,
|
||||||
SortedMap<Calendar, Info> set =
|
filters);
|
||||||
accountingPersistenceQueryCouchBase.getTimeSeries(
|
|
||||||
clz, temporalConstraint, filters);
|
|
||||||
logger.debug("Result final{}", set);
|
logger.debug("Result final{}", set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,44 +187,32 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
new Filter(AggregatedServiceUsageRecord.CALLED_METHOD, "WebProcessingService");
|
new Filter(AggregatedServiceUsageRecord.CALLED_METHOD, "WebProcessingService");
|
||||||
filters.add(filter);
|
filters.add(filter);
|
||||||
*/
|
*/
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
Class<AggregatedServiceUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz = AggregatedServiceUsageRecord.class;
|
||||||
AggregatedServiceUsageRecord.class;
|
SortedMap<Calendar,Info> set = accountingPersistenceQueryCouchBase.getNoContextTimeSeries(clz,
|
||||||
SortedMap<Calendar, Info> set =
|
temporalConstraint, filters);
|
||||||
accountingPersistenceQueryCouchBase.getNoContextTimeSeries(
|
|
||||||
clz, temporalConstraint, filters);
|
|
||||||
logger.debug("Result final{}", set);
|
logger.debug("Result final{}", set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getUsageValue() throws Exception {
|
public void getUsageValue() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
startTime.set(2015, Calendar.MAY, 1);
|
startTime.set(2015, Calendar.MAY, 1);
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
ScopeProvider.instance.set("/gcube");
|
ScopeProvider.instance.set("/gcube");
|
||||||
Filter filter =
|
Filter filter = new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "alessandro.pieve");
|
||||||
new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "alessandro.pieve");
|
|
||||||
|
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
|
||||||
JSONObject filterValue =
|
JSONObject filterValue = accountingPersistenceQueryCouchBase.getUsageValue(AggregatedServiceUsageRecord.class,
|
||||||
accountingPersistenceQueryCouchBase.getUsageValue(AggregatedServiceUsageRecord.class,
|
|
||||||
temporalConstraint, filter);
|
temporalConstraint, filter);
|
||||||
|
|
||||||
logger.info("result:" + filterValue.toString());
|
logger.info("result:" + filterValue.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* utilizzato per effettuare una singola chiamata ad accounting analytics in modo che ritorni una lista di quote riempite
|
* utilizzato per effettuare una singola chiamata ad accounting analytics in modo che ritorni una lista di quote riempite
|
||||||
*
|
*
|
||||||
|
@ -286,11 +254,9 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
startTime.set(2017, Calendar.MAY, 1);
|
startTime.set(2017, Calendar.MAY, 1);
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
|
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
|
||||||
|
|
||||||
/*ask quota for user alessandro pieve
|
/*ask quota for user alessandro pieve
|
||||||
*
|
*
|
||||||
* SERVICE
|
* SERVICE
|
||||||
|
@ -298,24 +264,21 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
filters.add(new Filter("serviceClass", "DataAccess"));
|
filters.add(new Filter("serviceClass", "DataAccess"));
|
||||||
filters.add(new Filter("serviceName", "CkanConnector"));
|
filters.add(new Filter("serviceName", "CkanConnector"));
|
||||||
UsageValue totalfilter=new UsageServiceValue(context,"lucio.lelii",AggregatedServiceUsageRecord.class,temporalConstraint,filters);
|
UsageValue totalfilter = new UsageServiceValue(context, "lucio.lelii", AggregatedServiceUsageRecord.class,
|
||||||
|
temporalConstraint, filters);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
*Example call storage status for each consumer id (quota total used )
|
*Example call storage status for each consumer id (quota total used )
|
||||||
*/
|
*/
|
||||||
//Call quota total for consumerID
|
//Call quota total for consumerID
|
||||||
UsageValue totalfilterStorageStatus=new UsageStorageValue(context,"name.surname",AggregatedStorageStatusRecord.class);
|
UsageValue totalfilterStorageStatus = new UsageStorageValue(context, "name.surname",
|
||||||
UsageValue totalfilterStorageStatus_2=new UsageStorageValue(context,"lucio.lelii",AggregatedStorageStatusRecord.class);
|
AggregatedStorageStatusRecord.class);
|
||||||
UsageValue totalfilterStorageStatus_3=new UsageStorageValue(context,"alessandro.pieve",AggregatedStorageStatusRecord.class);
|
UsageValue totalfilterStorageStatus_2 = new UsageStorageValue(context, "lucio.lelii",
|
||||||
UsageValue totalfilterStorageStatus_4=new UsageStorageValue(context,"giancarlo.panichi",AggregatedStorageStatusRecord.class);
|
AggregatedStorageStatusRecord.class);
|
||||||
|
UsageValue totalfilterStorageStatus_3 = new UsageStorageValue(context, "alessandro.pieve",
|
||||||
|
AggregatedStorageStatusRecord.class);
|
||||||
|
UsageValue totalfilterStorageStatus_4 = new UsageStorageValue(context, "giancarlo.panichi",
|
||||||
|
AggregatedStorageStatusRecord.class);
|
||||||
|
|
||||||
/****
|
/****
|
||||||
*Example call storage status for each consumer id( quota into period)
|
*Example call storage status for each consumer id( quota into period)
|
||||||
|
@ -328,10 +291,8 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
/*TemporalConstraint temporalConstraintStorage =new TemporalConstraint(startTimeStorage.getTimeInMillis(),
|
/*TemporalConstraint temporalConstraintStorage =new TemporalConstraint(startTimeStorage.getTimeInMillis(),
|
||||||
endTimeStorage.getTimeInMillis(), AggregationMode.DAILY);*/
|
endTimeStorage.getTimeInMillis(), AggregationMode.DAILY);*/
|
||||||
TemporalConstraint temporalConstraintStorage = null;
|
TemporalConstraint temporalConstraintStorage = null;
|
||||||
UsageValue totalfilterStorageStatusPeriod=new UsageStorageValue(context,"alessandro.pieve",AggregatedStorageStatusRecord.class,temporalConstraintStorage);
|
UsageValue totalfilterStorageStatusPeriod = new UsageStorageValue(context, "alessandro.pieve",
|
||||||
|
AggregatedStorageStatusRecord.class, temporalConstraintStorage);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//richiedo la lista di dati usati totali
|
//richiedo la lista di dati usati totali
|
||||||
List<UsageValue> listTotalFilter = new ArrayList<UsageValue>();
|
List<UsageValue> listTotalFilter = new ArrayList<UsageValue>();
|
||||||
|
@ -342,17 +303,11 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
listTotalFilter.add(totalfilterStorageStatus_4);
|
listTotalFilter.add(totalfilterStorageStatus_4);
|
||||||
listTotalFilter.add(totalfilterStorageStatusPeriod);
|
listTotalFilter.add(totalfilterStorageStatusPeriod);
|
||||||
|
|
||||||
|
|
||||||
logger.info("filterPackageQuota:" + listTotalFilter);
|
logger.info("filterPackageQuota:" + listTotalFilter);
|
||||||
List<UsageValue> filterValue =
|
List<UsageValue> filterValue = accountingPersistenceQueryCouchBase.getUsageValueQuotaTotal(listTotalFilter);
|
||||||
accountingPersistenceQueryCouchBase.getUsageValueQuotaTotal(listTotalFilter);
|
|
||||||
logger.info("result:" + filterValue.toString());
|
logger.info("result:" + filterValue.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getQuerableKeyJob() throws Exception {
|
public void getQuerableKeyJob() throws Exception {
|
||||||
SortedSet<String> keys;
|
SortedSet<String> keys;
|
||||||
|
@ -376,17 +331,13 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
//filters.add(new Filter(AggregatedServiceUsageRecord.SERVICE_NAME, "IS-Registry"));
|
//filters.add(new Filter(AggregatedServiceUsageRecord.SERVICE_NAME, "IS-Registry"));
|
||||||
//filters.add(new Filter(AggregatedServiceUsageRecord.SERVICE_CLASS, "Common"));
|
//filters.add(new Filter(AggregatedServiceUsageRecord.SERVICE_CLASS, "Common"));
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
|
||||||
Class<AggregatedServiceUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz = AggregatedServiceUsageRecord.class;
|
||||||
AggregatedServiceUsageRecord.class;
|
|
||||||
|
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
SortedMap<NumberedFilter,SortedMap<Calendar,Info>> set = accountingPersistenceQueryCouchBase.getTopValues(clz,
|
||||||
accountingPersistenceQueryCouchBase.getTopValues(
|
temporalConstraint, filters, AggregatedServiceUsageRecord.OPERATION_RESULT, null);
|
||||||
clz, temporalConstraint, filters,
|
|
||||||
AggregatedServiceUsageRecord.OPERATION_RESULT, null);
|
|
||||||
|
|
||||||
logger.debug("Result final{}", set);
|
logger.debug("Result final{}", set);
|
||||||
|
|
||||||
|
@ -399,34 +350,20 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
endTime.set(2017, Calendar.FEBRUARY, 28, 23, 59);
|
endTime.set(2017, Calendar.FEBRUARY, 28, 23, 59);
|
||||||
|
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "scarponi"));
|
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "scarponi"));
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
|
||||||
Class<AggregatedStorageUsageRecord> clz =
|
Class<AggregatedStorageUsageRecord> clz = AggregatedStorageUsageRecord.class;
|
||||||
AggregatedStorageUsageRecord.class;
|
|
||||||
|
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
SortedMap<NumberedFilter,SortedMap<Calendar,Info>> set = accountingPersistenceQueryCouchBase.getTopValues(clz,
|
||||||
accountingPersistenceQueryCouchBase.getTopValues(
|
temporalConstraint, filters, AggregatedStorageUsageRecord.OPERATION_TYPE, null);
|
||||||
clz, temporalConstraint, filters,
|
|
||||||
AggregatedStorageUsageRecord.OPERATION_TYPE, null);
|
|
||||||
|
|
||||||
logger.debug("Result final{}", set);
|
logger.debug("Result final{}", set);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getQuerableKeyService() throws Exception {
|
public void getQuerableKeyService() throws Exception {
|
||||||
SortedSet<String> keys;
|
SortedSet<String> keys;
|
||||||
|
@ -440,8 +377,7 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
logger.debug("List FilterKeys:" + keys.toString());
|
logger.debug("List FilterKeys:" + keys.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SortedMap<Calendar, Info> padMap(
|
public static SortedMap<Calendar,Info> padMap(SortedMap<Calendar,Info> unpaddedData,
|
||||||
SortedMap<Calendar, Info> unpaddedData,
|
|
||||||
TemporalConstraint temporalConstraint) throws Exception {
|
TemporalConstraint temporalConstraint) throws Exception {
|
||||||
JSONObject jsonObject = getPaddingJSONObject(unpaddedData);
|
JSONObject jsonObject = getPaddingJSONObject(unpaddedData);
|
||||||
SortedSet<Calendar> sequence = temporalConstraint.getCalendarSequence();
|
SortedSet<Calendar> sequence = temporalConstraint.getCalendarSequence();
|
||||||
|
@ -454,8 +390,8 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
}
|
}
|
||||||
return unpaddedData;
|
return unpaddedData;
|
||||||
}
|
}
|
||||||
public static JSONObject getPaddingJSONObject(
|
|
||||||
Map<Calendar, Info> unpaddedResults) throws JSONException {
|
public static JSONObject getPaddingJSONObject(Map<Calendar,Info> unpaddedResults) throws JSONException {
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
//verify data consistency
|
//verify data consistency
|
||||||
|
@ -485,20 +421,15 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
//endTime.set(2016, Calendar.AUGUST, 29, 23, 59);
|
//endTime.set(2016, Calendar.AUGUST, 29, 23, 59);
|
||||||
endTime.set(2016, Calendar.AUGUST, 31, 23, 59);
|
endTime.set(2016, Calendar.AUGUST, 31, 23, 59);
|
||||||
|
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
|
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
|
||||||
Class<AggregatedServiceUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz = AggregatedServiceUsageRecord.class;
|
||||||
AggregatedServiceUsageRecord.class;
|
|
||||||
|
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
SortedMap<NumberedFilter,SortedMap<Calendar,Info>> set = accountingPersistenceQueryCouchBase
|
||||||
accountingPersistenceQueryCouchBase.getTopValues(
|
.getTopValues(clz, temporalConstraint, filters, AggregatedServiceUsageRecord.CALLED_METHOD, null);
|
||||||
clz, temporalConstraint, filters,
|
|
||||||
AggregatedServiceUsageRecord.CALLED_METHOD, null);
|
|
||||||
/**pad*/
|
/**pad*/
|
||||||
int limit = 0;
|
int limit = 0;
|
||||||
boolean pad = true;
|
boolean pad = true;
|
||||||
|
@ -522,16 +453,13 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
logger.debug("First removal key set:" + set.subMap(set.firstKey(), firstRemovalKey));
|
logger.debug("First removal key set:" + set.subMap(set.firstKey(), firstRemovalKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logger.debug("set: " + set);
|
logger.debug("set: " + set);
|
||||||
|
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContextService() throws Exception {
|
public void testContextService() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
@ -541,16 +469,13 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
//filters.add(new Filter(AggregatedServiceUsageRecord.CALLED_METHOD, "WebProcessingService"));
|
//filters.add(new Filter(AggregatedServiceUsageRecord.CALLED_METHOD, "WebProcessingService"));
|
||||||
//filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "alessandro.pieve"));
|
//filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "alessandro.pieve"));
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
|
||||||
Class<AggregatedServiceUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz = AggregatedServiceUsageRecord.class;
|
||||||
AggregatedServiceUsageRecord.class;
|
|
||||||
|
|
||||||
List<String> context = new ArrayList<String>();
|
List<String> context = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
||||||
// , /gcube/devsec/TestCreation12, /gcube/devsec/TestCreation13, /gcube/devsec/TestCreation14, /gcube/devsec/TestCreation15, /gcube/devsec/TestCreation16, /gcube/devsec/TestCreation17, /gcube/devsec/TestCreation7, /gcube/devsec/TestCreation8, /gcube/devsec/TestCreation9, /gcube/devsec/TestLucio2]]
|
// , /gcube/devsec/TestCreation12, /gcube/devsec/TestCreation13, /gcube/devsec/TestCreation14, /gcube/devsec/TestCreation15, /gcube/devsec/TestCreation16, /gcube/devsec/TestCreation17, /gcube/devsec/TestCreation7, /gcube/devsec/TestCreation8, /gcube/devsec/TestCreation9, /gcube/devsec/TestLucio2]]
|
||||||
context.add("/gcube");
|
context.add("/gcube");
|
||||||
context.add("/gcube/devNext");
|
context.add("/gcube/devNext");
|
||||||
|
@ -567,15 +492,12 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
context.add("/gcube/preprod/preVRE");
|
context.add("/gcube/preprod/preVRE");
|
||||||
context.add("/gcube/preprod");
|
context.add("/gcube/preprod");
|
||||||
*/
|
*/
|
||||||
SortedMap<Filter, SortedMap<Calendar, Info>> setContext =
|
SortedMap<Filter,SortedMap<Calendar,Info>> setContext = accountingPersistenceQueryCouchBase
|
||||||
accountingPersistenceQueryCouchBase.getContextTimeSeries(
|
.getContextTimeSeries(clz, temporalConstraint, filters, context);
|
||||||
clz, temporalConstraint, filters,
|
|
||||||
context);
|
|
||||||
logger.debug("Result final{}", setContext);
|
logger.debug("Result final{}", setContext);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getListUsage() throws Exception {
|
public void getListUsage() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
@ -585,8 +507,7 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "valentina.marioli"));
|
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "valentina.marioli"));
|
||||||
////TemporalConstraint temporalConstraint =
|
////TemporalConstraint temporalConstraint =
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
new TemporalConstraint(startTime.getTimeInMillis(), endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
|
||||||
//String context="/gcube/devNext";
|
//String context="/gcube/devNext";
|
||||||
List<String> parameters = new ArrayList<String>();
|
List<String> parameters = new ArrayList<String>();
|
||||||
parameters.add("serviceClass");
|
parameters.add("serviceClass");
|
||||||
|
@ -597,8 +518,6 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRecord() throws Exception {
|
public void getRecord() throws Exception {
|
||||||
String recordId = "91e1c339-d811-45d7-a13f-7385af59e3c8";
|
String recordId = "91e1c339-d811-45d7-a13f-7385af59e3c8";
|
||||||
|
@ -607,10 +526,8 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
String document = accountingPersistenceQueryCouchBase.getRecord(recordId, type);
|
String document = accountingPersistenceQueryCouchBase.getRecord(recordId, type);
|
||||||
logger.debug("document:{}", document);
|
logger.debug("document:{}", document);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getQuerableKeyStorageStatus() throws Exception {
|
public void getQuerableKeyStorageStatus() throws Exception {
|
||||||
SortedSet<String> keys;
|
SortedSet<String> keys;
|
||||||
|
@ -625,26 +542,23 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSpaceProvidersIds() throws Exception {
|
public void testGetSpaceProvidersIds() throws Exception {
|
||||||
SortedSet<String> listProvidersId =
|
SortedSet<String> listProvidersId = accountingPersistenceQueryCouchBase.getSpaceProvidersIds();
|
||||||
accountingPersistenceQueryCouchBase.getSpaceProvidersIds();
|
|
||||||
logger.debug("Result final{}", listProvidersId);
|
logger.debug("Result final{}", listProvidersId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetFilterValue() throws Exception {
|
public void testGetFilterValue() throws Exception {
|
||||||
|
|
||||||
//String key="consumerId";
|
//String key="consumerId";
|
||||||
String key = "dataServiceId";
|
String key = "dataServiceId";
|
||||||
|
|
||||||
SortedSet<NumberedFilter> listFilterValue =
|
SortedSet<NumberedFilter> listFilterValue = accountingPersistenceQueryCouchBase
|
||||||
accountingPersistenceQueryCouchBase.getFilterValues(AggregatedStorageStatusRecord.class, null, null, key, null);
|
.getFilterValues(AggregatedStorageStatusRecord.class, null, null, key, null);
|
||||||
logger.debug("Result final{}", listFilterValue);
|
logger.debug("Result final{}", listFilterValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUsageStorage() throws Exception {
|
public void testUsageStorage() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
@ -654,28 +568,17 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
//filters.add(new Filter(AggregatedStorageStatusRecord.DATA_SERVICEID, "identifier"));
|
//filters.add(new Filter(AggregatedStorageStatusRecord.DATA_SERVICEID, "identifier"));
|
||||||
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "alessandro.pieve"));
|
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "alessandro.pieve"));
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint = new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
|
||||||
endTime.getTimeInMillis(), AggregationMode.YEARLY);
|
endTime.getTimeInMillis(), AggregationMode.YEARLY);
|
||||||
|
|
||||||
|
|
||||||
List<String> providerId = new ArrayList<String>();
|
List<String> providerId = new ArrayList<String>();
|
||||||
Class<AggregatedStorageStatusRecord> clz =
|
Class<AggregatedStorageStatusRecord> clz = AggregatedStorageStatusRecord.class;
|
||||||
AggregatedStorageStatusRecord.class;
|
|
||||||
|
|
||||||
//providerId.add("Rstudio");
|
//providerId.add("Rstudio");
|
||||||
providerId.add("MongoDb");
|
providerId.add("MongoDb");
|
||||||
|
|
||||||
SortedMap<Filter, SortedMap<Calendar, Long>> setContext =
|
SortedMap<Filter,SortedMap<Calendar,Long>> setContext = accountingPersistenceQueryCouchBase
|
||||||
accountingPersistenceQueryCouchBase.getSpaceTimeSeries(
|
.getSpaceTimeSeries(clz, temporalConstraint, filters, providerId);
|
||||||
clz,
|
|
||||||
temporalConstraint, filters,
|
|
||||||
providerId);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int count = setContext.size();
|
int count = setContext.size();
|
||||||
Filter firstRemovalKey = null;
|
Filter firstRemovalKey = null;
|
||||||
|
@ -700,14 +603,11 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Result final{}", setContext);
|
logger.debug("Result final{}", setContext);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedMap<Calendar, Long> padMapStorage(
|
public SortedMap<Calendar,Long> padMapStorage(SortedMap<Calendar,Long> unpaddedData,
|
||||||
SortedMap<Calendar, Long> unpaddedData,
|
|
||||||
TemporalConstraint temporalConstraint) throws Exception {
|
TemporalConstraint temporalConstraint) throws Exception {
|
||||||
|
|
||||||
//JSONObject jsonObject = getPaddingJSONObject(unpaddedData);
|
//JSONObject jsonObject = getPaddingJSONObject(unpaddedData);
|
||||||
|
@ -726,6 +626,4 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
|
||||||
return unpaddedData;
|
return unpaddedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.accounting.analytics.persistence.couchbase;
|
package org.gcube.accounting.analytics.persistence.couchbase;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -23,9 +20,6 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class ScopedTest {
|
public class ScopedTest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
|
||||||
|
|
||||||
protected static final String PROPERTIES_FILENAME = "token.properties";
|
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||||
|
@ -45,7 +39,6 @@ public class ScopedTest {
|
||||||
public static final String SA_VARNAME = "SA";
|
public static final String SA_VARNAME = "SA";
|
||||||
public static final String SA;
|
public static final String SA;
|
||||||
|
|
||||||
|
|
||||||
public static final String DEFAULT_TEST_SCOPE;
|
public static final String DEFAULT_TEST_SCOPE;
|
||||||
public static final String ALTERNATIVE_TEST_SCOPE;
|
public static final String ALTERNATIVE_TEST_SCOPE;
|
||||||
|
|
||||||
|
@ -68,7 +61,7 @@ public class ScopedTest {
|
||||||
|
|
||||||
SA = properties.getProperty(SA_VARNAME);
|
SA = properties.getProperty(SA_VARNAME);
|
||||||
|
|
||||||
DEFAULT_TEST_SCOPE = SA;
|
DEFAULT_TEST_SCOPE = GCUBE_DEVNEXT;
|
||||||
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVSEC;
|
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVSEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +72,6 @@ public class ScopedTest {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setContext(String token) throws ObjectNotFound, Exception {
|
public static void setContext(String token) throws ObjectNotFound, Exception {
|
||||||
SecurityTokenProvider.instance.set(token);
|
SecurityTokenProvider.instance.set(token);
|
||||||
ScopeProvider.instance.set(getCurrentScope(token));
|
ScopeProvider.instance.set(getCurrentScope(token));
|
||||||
|
|
Reference in New Issue