Added fix for old records persisted using double instead of long for creationTime, startTime, endTime and instead of int for duration.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-aggregator-se-plugin@162662 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
07677541f1
commit
4cf6d72113
|
@ -141,7 +141,41 @@ public class Aggregator {
|
||||||
|
|
||||||
String recordType = content.getString(Record.RECORD_TYPE);
|
String recordType = content.getString(Record.RECORD_TYPE);
|
||||||
if(recordType.contains(SIMPLE)){
|
if(recordType.contains(SIMPLE)){
|
||||||
recordType.replace(SIMPLE, SINGLE);
|
recordType = recordType.replace(SIMPLE, SINGLE);
|
||||||
|
content.put(Record.RECORD_TYPE, recordType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(content.containsKey(AggregatedRecord.CREATION_TIME)) {
|
||||||
|
Object object = content.get(AggregatedRecord.CREATION_TIME);
|
||||||
|
if(object instanceof Double) {
|
||||||
|
Double d = ((Double) object);
|
||||||
|
content.put(AggregatedRecord.CREATION_TIME, d.longValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(content.containsKey(AggregatedRecord.START_TIME)) {
|
||||||
|
Object object = content.get(AggregatedRecord.START_TIME);
|
||||||
|
if(object instanceof Double) {
|
||||||
|
Double d = ((Double) object);
|
||||||
|
content.put(AggregatedRecord.START_TIME, d.longValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(content.containsKey(AggregatedRecord.END_TIME)) {
|
||||||
|
Object object = content.get(AggregatedRecord.END_TIME);
|
||||||
|
if(object instanceof Double) {
|
||||||
|
Double d = ((Double) object);
|
||||||
|
content.put(AggregatedRecord.END_TIME, d.longValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(content.containsKey(AggregatedRecord.OPERATION_COUNT)) {
|
||||||
|
Object object = content.get(AggregatedRecord.OPERATION_COUNT);
|
||||||
|
if(object instanceof Double) {
|
||||||
|
Double d = ((Double) object);
|
||||||
|
content.put(AggregatedRecord.OPERATION_COUNT, d.intValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String record = content.toString();
|
String record = content.toString();
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||||
import org.gcube.accounting.aggregator.aggregation.AggregationType;
|
import org.gcube.accounting.aggregator.aggregation.AggregationType;
|
||||||
import org.gcube.accounting.aggregator.plugin.AccountingAggregatorPlugin.ElaborationType;
|
import org.gcube.accounting.aggregator.plugin.AccountingAggregatorPlugin.ElaborationType;
|
||||||
import org.gcube.accounting.aggregator.utility.Utility;
|
import org.gcube.accounting.aggregator.utility.Utility;
|
||||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -24,7 +24,7 @@ public class AccountingAggregatorPluginTest extends ScopedTest {
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||||
|
|
||||||
//type aggregation
|
//type aggregation
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, AggregationType.DAILY.name());
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, AggregationType.MONTHLY.name());
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
||||||
|
|
||||||
|
@ -33,21 +33,19 @@ public class AccountingAggregatorPluginTest extends ScopedTest {
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(20, 30));
|
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(20, 30));
|
||||||
|
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, ServiceUsageRecord.class.newInstance().getRecordType());
|
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, StorageUsageRecord.class.newInstance().getRecordType());
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER, true);
|
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER, false);
|
||||||
|
|
||||||
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2017, Calendar.OCTOBER, 2);
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2016, Calendar.SEPTEMBER, 1);
|
||||||
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
||||||
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
||||||
|
|
||||||
/*
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2016, Calendar.OCTOBER, 1);
|
||||||
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2017, Calendar.AUGUST, 3);
|
|
||||||
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
||||||
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
||||||
*/
|
|
||||||
|
|
||||||
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin(null);
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin(null);
|
||||||
logger.debug("Going to launch {} with inputs {}", AccountingAggregatorPluginDeclaration.NAME, inputs);
|
logger.debug("Going to launch {} with inputs {}", AccountingAggregatorPluginDeclaration.NAME, inputs);
|
||||||
|
@ -66,12 +64,12 @@ public class AccountingAggregatorPluginTest extends ScopedTest {
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(8, 0));
|
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(8, 0));
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(20, 30));
|
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(20, 30));
|
||||||
|
|
||||||
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2017, Calendar.JULY, 26);
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2016, Calendar.JANUARY, 1);
|
||||||
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
||||||
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
||||||
|
|
||||||
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2017, Calendar.JULY, 27);
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2016, Calendar.FEBRUARY, 1);
|
||||||
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
||||||
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
||||||
|
|
Loading…
Reference in New Issue