Renamed classes to avoid name and import conflicts
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@117529 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
268dafea5a
commit
9995c4873b
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-lib</artifactId>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<name>Accounting Library</name>
|
||||
<description>Accounting Library</description>
|
||||
<packaging>jar</packaging>
|
||||
|
|
|
@ -7,13 +7,15 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public class JobUsageRecord extends org.gcube.accounting.datamodel.basetypes.JobUsageRecord implements AggregatedUsageRecord<JobUsageRecord, org.gcube.accounting.datamodel.usagerecords.JobUsageRecord> {
|
||||
public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements AggregatedUsageRecord<AggregatedJobUsageRecord, JobUsageRecord> {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -24,12 +26,12 @@ public class JobUsageRecord extends org.gcube.accounting.datamodel.basetypes.Job
|
|||
this.resourceProperties.put(AGGREGATED, true);
|
||||
}
|
||||
|
||||
public JobUsageRecord(){
|
||||
public AggregatedJobUsageRecord(){
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public JobUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
public AggregatedJobUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
init();
|
||||
}
|
||||
|
@ -38,8 +40,7 @@ public class JobUsageRecord extends org.gcube.accounting.datamodel.basetypes.Job
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public JobUsageRecord getAggregatedUsageRecord(
|
||||
org.gcube.accounting.datamodel.usagerecords.JobUsageRecord b)
|
||||
public AggregatedJobUsageRecord getAggregatedUsageRecord(JobUsageRecord b)
|
||||
throws InvalidValueException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
|
@ -7,13 +7,15 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public class TaskUsageRecord extends org.gcube.accounting.datamodel.basetypes.TaskUsageRecord implements AggregatedUsageRecord<TaskUsageRecord, org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord> {
|
||||
public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord implements AggregatedUsageRecord<AggregatedPortletUsageRecord, PortletUsageRecord> {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -25,12 +27,12 @@ public class TaskUsageRecord extends org.gcube.accounting.datamodel.basetypes.Ta
|
|||
this.resourceProperties.put(AGGREGATED, true);
|
||||
}
|
||||
|
||||
public TaskUsageRecord(){
|
||||
public AggregatedPortletUsageRecord(){
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public TaskUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
public AggregatedPortletUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
init();
|
||||
}
|
||||
|
@ -39,8 +41,7 @@ public class TaskUsageRecord extends org.gcube.accounting.datamodel.basetypes.Ta
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TaskUsageRecord getAggregatedUsageRecord(
|
||||
org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord usageRecord)
|
||||
public AggregatedPortletUsageRecord getAggregatedUsageRecord(PortletUsageRecord usageRecord)
|
||||
throws InvalidValueException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
|
@ -8,8 +8,10 @@ import java.util.Calendar;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.AggregatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
@ -17,7 +19,7 @@ import org.gcube.accounting.exception.InvalidValueException;
|
|||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public class ServiceUsageRecord extends org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord implements AggregatedUsageRecord<ServiceUsageRecord, org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord> {
|
||||
public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord implements AggregatedUsageRecord<AggregatedServiceUsageRecord, ServiceUsageRecord> {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -26,7 +28,7 @@ public class ServiceUsageRecord extends org.gcube.accounting.datamodel.basetypes
|
|||
|
||||
// Redefining DURATION to Set @AggregatedField
|
||||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String DURATION = org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.DURATION;
|
||||
public static final String DURATION = org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.DURATION;
|
||||
|
||||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String MAX_INVOCATION_TIME = "maxInvocationTime";
|
||||
|
@ -37,17 +39,17 @@ public class ServiceUsageRecord extends org.gcube.accounting.datamodel.basetypes
|
|||
this.resourceProperties.put(AGGREGATED, true);
|
||||
}
|
||||
|
||||
public ServiceUsageRecord(){
|
||||
public AggregatedServiceUsageRecord(){
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
protected ServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
protected AggregatedServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
init();
|
||||
}
|
||||
|
||||
public ServiceUsageRecord(org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord record) throws InvalidValueException{
|
||||
public AggregatedServiceUsageRecord(org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord record) throws InvalidValueException{
|
||||
super(record.getResourceProperties());
|
||||
this.setOperationCount(1);
|
||||
long duration = record.getDuration();
|
||||
|
@ -90,10 +92,9 @@ public class ServiceUsageRecord extends org.gcube.accounting.datamodel.basetypes
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ServiceUsageRecord getAggregatedUsageRecord(
|
||||
org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord usageRecord)
|
||||
public AggregatedServiceUsageRecord getAggregatedUsageRecord(ServiceUsageRecord usageRecord)
|
||||
throws InvalidValueException {
|
||||
return new ServiceUsageRecord(usageRecord);
|
||||
return new AggregatedServiceUsageRecord(usageRecord);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,8 +8,10 @@ import java.util.Calendar;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.decorators.AggregatedField;
|
||||
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
@ -17,7 +19,7 @@ import org.gcube.accounting.exception.InvalidValueException;
|
|||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public class StorageUsageRecord extends org.gcube.accounting.datamodel.basetypes.StorageUsageRecord implements AggregatedUsageRecord<StorageUsageRecord, org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord> {
|
||||
public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord implements AggregatedUsageRecord<AggregatedStorageUsageRecord, StorageUsageRecord> {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -26,23 +28,23 @@ public class StorageUsageRecord extends org.gcube.accounting.datamodel.basetypes
|
|||
|
||||
// Redefining DATA_VOLUME to Set @AggregatedField
|
||||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String DATA_VOLUME = org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.DATA_VOLUME;
|
||||
public static final String DATA_VOLUME = org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DATA_VOLUME;
|
||||
|
||||
private void init(){
|
||||
this.resourceProperties.put(AGGREGATED, true);
|
||||
}
|
||||
|
||||
public StorageUsageRecord() {
|
||||
public AggregatedStorageUsageRecord() {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public StorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
public AggregatedStorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
init();
|
||||
}
|
||||
|
||||
public StorageUsageRecord(org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord record) throws InvalidValueException{
|
||||
public AggregatedStorageUsageRecord(org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord record) throws InvalidValueException{
|
||||
super(record.getResourceProperties());
|
||||
this.setOperationCount(1);
|
||||
Calendar creationTime = record.getCreationTime();
|
||||
|
@ -67,10 +69,9 @@ public class StorageUsageRecord extends org.gcube.accounting.datamodel.basetypes
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public StorageUsageRecord getAggregatedUsageRecord(
|
||||
org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord usageRecord)
|
||||
public AggregatedStorageUsageRecord getAggregatedUsageRecord(StorageUsageRecord usageRecord)
|
||||
throws InvalidValueException {
|
||||
return new StorageUsageRecord(usageRecord);
|
||||
return new AggregatedStorageUsageRecord(usageRecord);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,13 +7,15 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public class PortletUsageRecord extends org.gcube.accounting.datamodel.basetypes.PortletUsageRecord implements AggregatedUsageRecord<PortletUsageRecord, org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord> {
|
||||
public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implements AggregatedUsageRecord<AggregatedTaskUsageRecord, TaskUsageRecord> {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -25,12 +27,12 @@ public class PortletUsageRecord extends org.gcube.accounting.datamodel.basetypes
|
|||
this.resourceProperties.put(AGGREGATED, true);
|
||||
}
|
||||
|
||||
public PortletUsageRecord(){
|
||||
public AggregatedTaskUsageRecord(){
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
public PortletUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
public AggregatedTaskUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
init();
|
||||
}
|
||||
|
@ -39,8 +41,7 @@ public class PortletUsageRecord extends org.gcube.accounting.datamodel.basetypes
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PortletUsageRecord getAggregatedUsageRecord(
|
||||
org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord usageRecord)
|
||||
public AggregatedTaskUsageRecord getAggregatedUsageRecord(TaskUsageRecord usageRecord)
|
||||
throws InvalidValueException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
|
@ -7,6 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.aggregation.strategy.ServiceUsageRecordAggregationStrategy;
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.AggregationStrategy;
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
|
@ -49,15 +51,15 @@ public abstract class AggregationScheduler {
|
|||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected Class<? extends AggregatedUsageRecord> getAggregatedUsageRecordClass(String usageRecordName) throws ClassNotFoundException {
|
||||
protected Class<? extends AggregatedUsageRecord> getAggregatedUsageRecordClass(String usageRecordType) throws ClassNotFoundException {
|
||||
Class<? extends AggregatedUsageRecord> clz;
|
||||
String aggregatedURFullyQualifiedName;
|
||||
try {
|
||||
Package aggregatedPackage = org.gcube.accounting.aggregation.ServiceUsageRecord.class.getPackage();
|
||||
aggregatedURFullyQualifiedName = String.format("%s.%s", aggregatedPackage.getName(), usageRecordName);
|
||||
Package aggregatedPackage = AggregatedServiceUsageRecord.class.getPackage();
|
||||
aggregatedURFullyQualifiedName = String.format("%s.Aggregated%s", aggregatedPackage.getName(), usageRecordType);
|
||||
clz = (Class<? extends AggregatedUsageRecord>) Class.forName(aggregatedURFullyQualifiedName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("Unable To find the Aggregation Class for {}", usageRecordName);
|
||||
logger.error("Unable To find the Aggregation Class for {}", usageRecordType);
|
||||
throw e;
|
||||
}
|
||||
return clz;
|
||||
|
@ -65,8 +67,8 @@ public abstract class AggregationScheduler {
|
|||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected AggregatedUsageRecord instantiateAggregatedUsageRecord(UsageRecord usageRecord) throws Exception{
|
||||
String usageRecordName = usageRecord.getClass().getSimpleName();
|
||||
Class<? extends AggregatedUsageRecord> clz = getAggregatedUsageRecordClass(usageRecordName);
|
||||
String usageRecordType = usageRecord.getUsageRecordType();
|
||||
Class<? extends AggregatedUsageRecord> clz = getAggregatedUsageRecordClass(usageRecordType);
|
||||
Class[] argTypes = { usageRecord.getClass() };
|
||||
Constructor<? extends AggregatedUsageRecord> constructor = clz.getDeclaredConstructor(argTypes);
|
||||
Object[] arguments = {usageRecord};
|
||||
|
@ -75,15 +77,15 @@ public abstract class AggregationScheduler {
|
|||
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected Class<? extends AggregationStrategy> getAggregattionStrategyUsageRecordClass(String usageRecordName) throws ClassNotFoundException {
|
||||
protected Class<? extends AggregationStrategy> getAggregattionStrategyUsageRecordClass(String usageRecordType) throws ClassNotFoundException {
|
||||
Class<? extends AggregationStrategy> clz;
|
||||
String aggregationStrategyName;
|
||||
try {
|
||||
Package aggregationStrategyPackage = org.gcube.accounting.aggregation.strategy.ServiceUsageRecordAggregationStrategy.class.getPackage();
|
||||
aggregationStrategyName = String.format("%s.%s%s", aggregationStrategyPackage.getName(), usageRecordName, AggregationStrategy.class.getSimpleName());
|
||||
Package aggregationStrategyPackage = ServiceUsageRecordAggregationStrategy.class.getPackage();
|
||||
aggregationStrategyName = String.format("%s.%s%s", aggregationStrategyPackage.getName(), usageRecordType, AggregationStrategy.class.getSimpleName());
|
||||
clz = (Class<? extends AggregationStrategy>) Class.forName(aggregationStrategyName);
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable To find the Aggregation Strategy Class for {}", usageRecordName);
|
||||
logger.error("Unable To find the Aggregation Strategy Class for {}", usageRecordType);
|
||||
throw e;
|
||||
}
|
||||
return clz;
|
||||
|
@ -91,8 +93,8 @@ public abstract class AggregationScheduler {
|
|||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected AggregationStrategy instantiateAggregationStrategy(AggregatedUsageRecord aggregatedUsageRecord) throws Exception{
|
||||
String usageRecordName = aggregatedUsageRecord.getClass().getSimpleName();
|
||||
Class<? extends AggregationStrategy> clz = getAggregattionStrategyUsageRecordClass(usageRecordName);
|
||||
String usageRecordType = aggregatedUsageRecord.getUsageRecordType();
|
||||
Class<? extends AggregationStrategy> clz = getAggregattionStrategyUsageRecordClass(usageRecordType);
|
||||
Class[] argTypes = { aggregatedUsageRecord.getClass() };
|
||||
Constructor<? extends AggregationStrategy> constructor = clz.getDeclaredConstructor(argTypes);
|
||||
Object[] arguments = {aggregatedUsageRecord};
|
||||
|
@ -102,12 +104,12 @@ public abstract class AggregationScheduler {
|
|||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected void madeAggregation(UsageRecord usageRecord){
|
||||
String usageRecordName = usageRecord.getClass().getSimpleName();
|
||||
String usageRecordType = usageRecord.getUsageRecordType();
|
||||
|
||||
List<AggregationStrategy> aggregationStrategies;
|
||||
|
||||
if(this.records.containsKey(usageRecordName)){
|
||||
aggregationStrategies = this.records.get(usageRecordName);
|
||||
if(this.records.containsKey(usageRecordType)){
|
||||
aggregationStrategies = this.records.get(usageRecordType);
|
||||
boolean found = false;
|
||||
for(AggregationStrategy aggregationStrategy : aggregationStrategies){
|
||||
try {
|
||||
|
@ -123,7 +125,7 @@ public abstract class AggregationScheduler {
|
|||
}
|
||||
}else{
|
||||
aggregationStrategies = new ArrayList<AggregationStrategy>();
|
||||
this.records.put(usageRecordName, aggregationStrategies);
|
||||
this.records.put(usageRecordType, aggregationStrategies);
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,7 +141,7 @@ public abstract class AggregationScheduler {
|
|||
// org.gcube.accounting.datamodel.aggregation package
|
||||
aggregatedUsageRecord = instantiateAggregatedUsageRecord(usageRecord);
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to Istantiate the Aggregation Class for {}. The Record will be persisted as is (Better than nothing).", usageRecordName);
|
||||
logger.error("Unable to Istantiate the Aggregation Class for {}. The Record will be persisted as is (Better than nothing).", usageRecordType);
|
||||
unaggregableRecords.add(usageRecord);
|
||||
totalBufferedRecords++;
|
||||
return;
|
||||
|
@ -152,7 +154,7 @@ public abstract class AggregationScheduler {
|
|||
aggregationStrategies.add(aggregationStrategy);
|
||||
totalBufferedRecords++;
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to Istantiate the Aggregation Strategy Class for {}. The Record will be persisted as is (Better than nothing).", usageRecordName);
|
||||
logger.error("Unable to Istantiate the Aggregation Strategy Class for {}. The Record will be persisted as is (Better than nothing).", usageRecordType);
|
||||
unaggregableRecords.add(usageRecord);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,36 +3,37 @@
|
|||
*/
|
||||
package org.gcube.accounting.aggregation.strategy;
|
||||
|
||||
import org.gcube.accounting.aggregation.ServiceUsageRecord;
|
||||
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.AggregationStrategy;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.accounting.exception.NotAggregatableRecordsExceptions;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class ServiceUsageRecordAggregationStrategy extends AggregationStrategy<ServiceUsageRecord, org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord>{
|
||||
public class ServiceUsageRecordAggregationStrategy extends AggregationStrategy<AggregatedServiceUsageRecord, ServiceUsageRecord>{
|
||||
|
||||
/**
|
||||
* @param serviceUsageRecord
|
||||
*/
|
||||
public ServiceUsageRecordAggregationStrategy(ServiceUsageRecord serviceUsageRecord) {
|
||||
public ServiceUsageRecordAggregationStrategy(AggregatedServiceUsageRecord serviceUsageRecord) {
|
||||
super(serviceUsageRecord);
|
||||
this.aggregationField.add(ServiceUsageRecord.CALLER_HOST);
|
||||
this.aggregationField.add(ServiceUsageRecord.HOST);
|
||||
this.aggregationField.add(ServiceUsageRecord.SERVICE_CLASS);
|
||||
this.aggregationField.add(ServiceUsageRecord.SERVICE_NAME);
|
||||
this.aggregationField.add(ServiceUsageRecord.CALLED_METHOD);
|
||||
this.aggregationField.add(AggregatedServiceUsageRecord.CALLER_HOST);
|
||||
this.aggregationField.add(AggregatedServiceUsageRecord.HOST);
|
||||
this.aggregationField.add(AggregatedServiceUsageRecord.SERVICE_CLASS);
|
||||
this.aggregationField.add(AggregatedServiceUsageRecord.SERVICE_NAME);
|
||||
this.aggregationField.add(AggregatedServiceUsageRecord.CALLED_METHOD);
|
||||
}
|
||||
|
||||
protected long durationWeightedAverage(ServiceUsageRecord record){
|
||||
protected long durationWeightedAverage(AggregatedServiceUsageRecord record){
|
||||
long tDuration = t.getDuration() * t.getOperationCount();
|
||||
long recordDuration = record.getDuration() * record.getOperationCount();
|
||||
long totalOperationCount = t.getOperationCount() + record.getOperationCount();
|
||||
return (tDuration + recordDuration) / totalOperationCount;
|
||||
}
|
||||
|
||||
protected ServiceUsageRecord reallyAggregate(ServiceUsageRecord record)
|
||||
protected AggregatedServiceUsageRecord reallyAggregate(AggregatedServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
||||
try {
|
||||
|
|
|
@ -3,30 +3,31 @@
|
|||
*/
|
||||
package org.gcube.accounting.aggregation.strategy;
|
||||
|
||||
import org.gcube.accounting.aggregation.StorageUsageRecord;
|
||||
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.AggregationStrategy;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
||||
import org.gcube.accounting.exception.NotAggregatableRecordsExceptions;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class StorageUsageRecordAggregationStrategy extends AggregationStrategy<StorageUsageRecord, org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord>{
|
||||
public class StorageUsageRecordAggregationStrategy extends AggregationStrategy<AggregatedStorageUsageRecord, StorageUsageRecord>{
|
||||
|
||||
/**
|
||||
* @param serviceUsageRecord
|
||||
*/
|
||||
public StorageUsageRecordAggregationStrategy(StorageUsageRecord storageUsageRecord) {
|
||||
public StorageUsageRecordAggregationStrategy(AggregatedStorageUsageRecord storageUsageRecord) {
|
||||
super(storageUsageRecord);
|
||||
this.aggregationField.add(StorageUsageRecord.RESOURCE_OWNER);
|
||||
this.aggregationField.add(StorageUsageRecord.RESOURCE_SCOPE);
|
||||
this.aggregationField.add(StorageUsageRecord.RESOURCE_URI);
|
||||
this.aggregationField.add(StorageUsageRecord.PROVIDER_URI);
|
||||
this.aggregationField.add(StorageUsageRecord.OPERATION_TYPE);
|
||||
this.aggregationField.add(StorageUsageRecord.DATA_TYPE);
|
||||
this.aggregationField.add(AggregatedStorageUsageRecord.RESOURCE_OWNER);
|
||||
this.aggregationField.add(AggregatedStorageUsageRecord.RESOURCE_SCOPE);
|
||||
this.aggregationField.add(AggregatedStorageUsageRecord.RESOURCE_URI);
|
||||
this.aggregationField.add(AggregatedStorageUsageRecord.PROVIDER_URI);
|
||||
this.aggregationField.add(AggregatedStorageUsageRecord.OPERATION_TYPE);
|
||||
this.aggregationField.add(AggregatedStorageUsageRecord.DATA_TYPE);
|
||||
}
|
||||
|
||||
protected StorageUsageRecord reallyAggregate(StorageUsageRecord record)
|
||||
protected AggregatedStorageUsageRecord reallyAggregate(AggregatedStorageUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
||||
try {
|
||||
|
|
|
@ -205,7 +205,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
|
|||
public BasicUsageRecord(){
|
||||
init();
|
||||
this.resourceProperties.put(ID, UUID.randomUUID().toString());
|
||||
this.resourceProperties.put(USAGE_RECORD_TYPE, this.getClass().getSimpleName());
|
||||
this.setUsageRecordType();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
this.resourceProperties.put(CREATION_TIME, calendar.getTimeInMillis());
|
||||
}
|
||||
|
@ -215,6 +215,20 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
|
|||
setResourceProperties(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getUsageRecordType() {
|
||||
return (String) this.resourceProperties.get(USAGE_RECORD_TYPE);
|
||||
}
|
||||
|
||||
protected abstract String giveMeUsageRecordType();
|
||||
|
||||
protected void setUsageRecordType(){
|
||||
this.resourceProperties.put(USAGE_RECORD_TYPE, this.giveMeUsageRecordType());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -496,7 +510,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
|
|||
|
||||
Class<? extends UsageRecord> utilityClass = org.gcube.accounting.datamodel.usagerecords.JobUsageRecord.class;
|
||||
if(aggregated){
|
||||
utilityClass = org.gcube.accounting.aggregation.JobUsageRecord.class;
|
||||
utilityClass = org.gcube.accounting.aggregation.AggregatedJobUsageRecord.class;
|
||||
}
|
||||
|
||||
String classCanonicalName = utilityClass.getCanonicalName();
|
||||
|
|
|
@ -437,6 +437,15 @@ public class RawUsageRecord extends BasicUsageRecord implements SingleUsageRecor
|
|||
logger.error("Unable to Set {}", FULLY_QUALIFIED_CONSUMER_ID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String giveMeUsageRecordType() {
|
||||
// This implementation is just a placeholder
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,12 @@ public interface UsageRecord extends Comparable<UsageRecord> {
|
|||
*/
|
||||
public Set<String> getRequiredFields();
|
||||
|
||||
/**
|
||||
* Return the Usage Record Type
|
||||
* @return {#UsageRecord} Type
|
||||
*/
|
||||
public String getUsageRecordType();
|
||||
|
||||
/**
|
||||
* Return the unique id for this {#UsageRecord}
|
||||
* @return {#UsageRecord} Unique ID
|
||||
|
|
|
@ -29,9 +29,9 @@ import org.slf4j.LoggerFactory;
|
|||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public abstract class JobUsageRecord extends BasicUsageRecord {
|
||||
public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(JobUsageRecord.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(AbstractJobUsageRecord.class);
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -80,14 +80,24 @@ public abstract class JobUsageRecord extends BasicUsageRecord {
|
|||
}
|
||||
|
||||
|
||||
public JobUsageRecord(){
|
||||
public AbstractJobUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public JobUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
public AbstractJobUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String giveMeUsageRecordType() {
|
||||
return AbstractJobUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Job Id
|
||||
*/
|
|
@ -25,7 +25,7 @@ import org.gcube.accounting.exception.InvalidValueException;
|
|||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public abstract class PortletUsageRecord extends BasicUsageRecord {
|
||||
public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -55,14 +55,24 @@ public abstract class PortletUsageRecord extends BasicUsageRecord {
|
|||
@NotEmptyIfNotNull
|
||||
public static final String MESSAGE = "message";
|
||||
|
||||
public PortletUsageRecord(){
|
||||
public AbstractPortletUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public PortletUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
public AbstractPortletUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String giveMeUsageRecordType() {
|
||||
return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
/* *
|
||||
* Use {@link #getConsumerId()} instead
|
||||
* @return the Consumer ID
|
|
@ -16,7 +16,7 @@ import org.gcube.accounting.exception.InvalidValueException;
|
|||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public abstract class ServiceUsageRecord extends BasicUsageRecord {
|
||||
public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -59,13 +59,23 @@ public abstract class ServiceUsageRecord extends BasicUsageRecord {
|
|||
@RequiredField @ValidLong
|
||||
public static final String DURATION = "duration";
|
||||
|
||||
public ServiceUsageRecord(){
|
||||
public AbstractServiceUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public ServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
public AbstractServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String giveMeUsageRecordType() {
|
||||
return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
public String getCallerHost() {
|
||||
return (String) this.resourceProperties.get(CALLER_HOST);
|
|
@ -21,7 +21,7 @@ import org.gcube.accounting.exception.InvalidValueException;
|
|||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public abstract class StorageUsageRecord extends BasicUsageRecord {
|
||||
public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -103,13 +103,23 @@ public abstract class StorageUsageRecord extends BasicUsageRecord {
|
|||
@NotEmptyIfNotNull
|
||||
public static final String QUALIFIER = "qualifier";
|
||||
|
||||
public StorageUsageRecord() {
|
||||
public AbstractStorageUsageRecord() {
|
||||
super();
|
||||
}
|
||||
|
||||
public StorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
public AbstractStorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String giveMeUsageRecordType() {
|
||||
return AbstractStorageUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identity id of the storage resource owner
|
|
@ -20,7 +20,7 @@ import org.gcube.accounting.exception.InvalidValueException;
|
|||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public abstract class TaskUsageRecord extends BasicUsageRecord {
|
||||
public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -66,13 +66,23 @@ public abstract class TaskUsageRecord extends BasicUsageRecord {
|
|||
@ValidInteger
|
||||
public static final String PROCESSORS = "processors";
|
||||
|
||||
public TaskUsageRecord(){
|
||||
public AbstractTaskUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public TaskUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
public AbstractTaskUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String giveMeUsageRecordType() {
|
||||
return AbstractTaskUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Job Id
|
|
@ -132,8 +132,8 @@ public class TestUsageRecord {
|
|||
usageRecord.setResourceURI(new URI(TEST_RESOURCE_URI));
|
||||
usageRecord.setProviderURI(new URI(TEST_PROVIDER_URI));
|
||||
|
||||
usageRecord.setOperationType(StorageUsageRecord.OperationType.READ);
|
||||
usageRecord.setDataType(StorageUsageRecord.DataType.STORAGE);
|
||||
usageRecord.setOperationType(AbstractStorageUsageRecord.OperationType.READ);
|
||||
usageRecord.setDataType(AbstractStorageUsageRecord.DataType.STORAGE);
|
||||
|
||||
usageRecord.setDataVolume(generateRandomLong(MIN_DATA_VOLUME, MAX_DATA_VOLUME));
|
||||
|
||||
|
|
|
@ -4,9 +4,10 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class JobUsageRecord extends org.gcube.accounting.datamodel.basetypes.JobUsageRecord implements SingleUsageRecord {
|
||||
public class JobUsageRecord extends AbstractJobUsageRecord implements SingleUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
|
|
@ -4,9 +4,10 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class PortletUsageRecord extends org.gcube.accounting.datamodel.basetypes.PortletUsageRecord implements SingleUsageRecord {
|
||||
public class PortletUsageRecord extends AbstractPortletUsageRecord implements SingleUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
|
|
@ -4,9 +4,10 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class ServiceUsageRecord extends org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord implements SingleUsageRecord {
|
||||
public class ServiceUsageRecord extends AbstractServiceUsageRecord implements SingleUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
|
|
@ -4,9 +4,10 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class StorageUsageRecord extends org.gcube.accounting.datamodel.basetypes.StorageUsageRecord implements SingleUsageRecord {
|
||||
public class StorageUsageRecord extends AbstractStorageUsageRecord implements SingleUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
|
|
@ -4,9 +4,10 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.SingleUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
public class TaskUsageRecord extends org.gcube.accounting.datamodel.basetypes.TaskUsageRecord implements SingleUsageRecord {
|
||||
public class TaskUsageRecord extends AbstractTaskUsageRecord implements SingleUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.accounting.datamodel.validations.validators;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.DataType;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
|
||||
import org.gcube.accounting.datamodel.decorators.FieldAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.io.Serializable;
|
|||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
||||
import org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.OperationType;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OperationType;
|
||||
import org.gcube.accounting.datamodel.decorators.FieldAction;
|
||||
import org.gcube.accounting.exception.InvalidValueException;
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ public class ServiceUsageRecordTest {
|
|||
public void testRequiredFields() throws InvalidValueException {
|
||||
org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord serviceUsageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
|
||||
ServiceUsageRecord aggregatedServiceUsageRecord = new ServiceUsageRecord(serviceUsageRecord);
|
||||
AggregatedServiceUsageRecord aggregatedServiceUsageRecord = new AggregatedServiceUsageRecord(serviceUsageRecord);
|
||||
|
||||
Set<String> expectedRequiredFields = org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecordTest.getExpectedRequiredFields();
|
||||
expectedRequiredFields.add(ServiceUsageRecord.DURATION);
|
||||
expectedRequiredFields.add(ServiceUsageRecord.MAX_INVOCATION_TIME);
|
||||
expectedRequiredFields.add(ServiceUsageRecord.MIN_INVOCATION_TIME);
|
||||
expectedRequiredFields.add(AggregatedServiceUsageRecord.DURATION);
|
||||
expectedRequiredFields.add(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
|
||||
expectedRequiredFields.add(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
|
||||
|
||||
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package org.gcube.accounting.aggregation.strategy;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.aggregation.strategy.ServiceUsageRecordAggregationStrategy;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
|
@ -31,8 +32,7 @@ public class ServiceUsageRecordAggregationStrategyTest {
|
|||
serviceUsageRecord.validate();
|
||||
logger.debug("ServiceUsageRecord : {}", serviceUsageRecord);
|
||||
|
||||
org.gcube.accounting.aggregation.ServiceUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.ServiceUsageRecord(serviceUsageRecord);
|
||||
AggregatedServiceUsageRecord aggregated = new AggregatedServiceUsageRecord(serviceUsageRecord);
|
||||
logger.debug("ServiceUsageRecord Converted to Aggregated: {}", aggregated);
|
||||
aggregated.validate();
|
||||
|
||||
|
@ -61,6 +61,7 @@ public class ServiceUsageRecordAggregationStrategyTest {
|
|||
|
||||
Assert.assertFalse(aggregated.getResourceProperties().containsKey(TestUsageRecord.TEST_PROPERTY_NAME));
|
||||
|
||||
Assert.assertTrue(aggregated.getUsageRecordType().compareTo(ServiceUsageRecord.class.getSimpleName())==0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,8 +72,7 @@ public class ServiceUsageRecordAggregationStrategyTest {
|
|||
serviceUsageRecord.validate();
|
||||
logger.debug("ServiceUsageRecord : {}", serviceUsageRecord);
|
||||
|
||||
org.gcube.accounting.aggregation.ServiceUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.ServiceUsageRecord(serviceUsageRecord);
|
||||
AggregatedServiceUsageRecord aggregated = new AggregatedServiceUsageRecord(serviceUsageRecord);
|
||||
logger.debug("ServiceUsageRecord Converted to Aggregated: {}", aggregated);
|
||||
aggregated.validate();
|
||||
|
||||
|
@ -80,8 +80,7 @@ public class ServiceUsageRecordAggregationStrategyTest {
|
|||
serviceUsageRecord2.setResourceProperty(TestUsageRecord.TEST_PROPERTY_NAME, TestUsageRecord.TEST_PROPERTY_VALUE);
|
||||
serviceUsageRecord2.validate();
|
||||
logger.debug("ServiceUsageRecord 2 : {}", serviceUsageRecord2);
|
||||
org.gcube.accounting.aggregation.ServiceUsageRecord converted =
|
||||
new org.gcube.accounting.aggregation.ServiceUsageRecord(serviceUsageRecord2);
|
||||
AggregatedServiceUsageRecord converted = new AggregatedServiceUsageRecord(serviceUsageRecord2);
|
||||
logger.debug("ServiceUsageRecord 2 Converted to Aggregated: {}", converted);
|
||||
converted.validate();
|
||||
|
||||
|
@ -105,6 +104,8 @@ public class ServiceUsageRecordAggregationStrategyTest {
|
|||
Assert.assertTrue(aggregated.getMinInvocationTime() == firstduration);
|
||||
}
|
||||
Assert.assertFalse(aggregated.getResourceProperties().containsKey(TestUsageRecord.TEST_PROPERTY_NAME));
|
||||
|
||||
Assert.assertTrue(aggregated.getUsageRecordType().compareTo(ServiceUsageRecord.class.getSimpleName())==0);
|
||||
}
|
||||
|
||||
protected long durationWeightedAverage(int numberA, long durationA, int numberB, long durationB){
|
||||
|
@ -119,8 +120,7 @@ public class ServiceUsageRecordAggregationStrategyTest {
|
|||
serviceUsageRecord.validate();
|
||||
logger.debug("ServiceUsageRecord : {}", serviceUsageRecord);
|
||||
|
||||
org.gcube.accounting.aggregation.ServiceUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.ServiceUsageRecord(serviceUsageRecord);
|
||||
AggregatedServiceUsageRecord aggregated = new AggregatedServiceUsageRecord(serviceUsageRecord);
|
||||
logger.debug("ServiceUsageRecord Converted to Aggregated: {}", aggregated);
|
||||
aggregated.validate();
|
||||
|
||||
|
@ -161,6 +161,8 @@ public class ServiceUsageRecordAggregationStrategyTest {
|
|||
Assert.assertFalse(aggregated.getResourceProperties().containsKey(TestUsageRecord.TEST_PROPERTY_NAME));
|
||||
}
|
||||
|
||||
Assert.assertTrue(aggregated.getUsageRecordType().compareTo(ServiceUsageRecord.class.getSimpleName())==0);
|
||||
|
||||
logger.debug("Resulting Aggregated ServiceUsageRecord: {}", aggregated);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ public class StorageUsageRecordAggregationStrategyTest {
|
|||
storageUsageRecord.validate();
|
||||
logger.debug("StorageUsageRecord : {}", storageUsageRecord);
|
||||
|
||||
org.gcube.accounting.aggregation.StorageUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.StorageUsageRecord(storageUsageRecord);
|
||||
org.gcube.accounting.aggregation.AggregatedStorageUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.AggregatedStorageUsageRecord(storageUsageRecord);
|
||||
logger.debug("StorageUsageRecord Converted to Aggregated: {}", aggregated);
|
||||
aggregated.validate();
|
||||
|
||||
|
@ -60,8 +60,8 @@ public class StorageUsageRecordAggregationStrategyTest {
|
|||
storageUsageRecord.validate();
|
||||
logger.debug("StorageUsageRecord : {}", storageUsageRecord);
|
||||
|
||||
org.gcube.accounting.aggregation.StorageUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.StorageUsageRecord(storageUsageRecord);
|
||||
org.gcube.accounting.aggregation.AggregatedStorageUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.AggregatedStorageUsageRecord(storageUsageRecord);
|
||||
logger.debug("StorageUsageRecord Converted to Aggregated: {}", aggregated);
|
||||
aggregated.validate();
|
||||
|
||||
|
@ -69,8 +69,8 @@ public class StorageUsageRecordAggregationStrategyTest {
|
|||
storageUsageRecord2.setResourceProperty(TestUsageRecord.TEST_PROPERTY_NAME, TestUsageRecord.TEST_PROPERTY_VALUE);
|
||||
storageUsageRecord2.validate();
|
||||
logger.debug("StorageUsageRecord 2 : {}", storageUsageRecord2);
|
||||
org.gcube.accounting.aggregation.StorageUsageRecord converted =
|
||||
new org.gcube.accounting.aggregation.StorageUsageRecord(storageUsageRecord2);
|
||||
org.gcube.accounting.aggregation.AggregatedStorageUsageRecord converted =
|
||||
new org.gcube.accounting.aggregation.AggregatedStorageUsageRecord(storageUsageRecord2);
|
||||
logger.debug("StorageUsageRecord Converted to Aggregated: {}", converted);
|
||||
converted.validate();
|
||||
|
||||
|
@ -97,8 +97,8 @@ public class StorageUsageRecordAggregationStrategyTest {
|
|||
storageUsageRecord.validate();
|
||||
logger.debug("StorageUsageRecord : {}", storageUsageRecord);
|
||||
|
||||
org.gcube.accounting.aggregation.StorageUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.StorageUsageRecord(storageUsageRecord);
|
||||
org.gcube.accounting.aggregation.AggregatedStorageUsageRecord aggregated =
|
||||
new org.gcube.accounting.aggregation.AggregatedStorageUsageRecord(storageUsageRecord);
|
||||
logger.debug("StorageUsageRecord Converted to Aggregated: {}", aggregated);
|
||||
aggregated.validate();
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ public class ServiceUsageRecordTest {
|
|||
expectedRequiredFields.add(BasicUsageRecordUtility.USAGE_RECORD_TYPE);
|
||||
expectedRequiredFields.add(BasicUsageRecord.SCOPE);
|
||||
expectedRequiredFields.add(BasicUsageRecord.OPERATION_RESULT);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.CALLER_HOST);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.HOST);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.SERVICE_CLASS);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.SERVICE_NAME);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.CALLED_METHOD);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.DURATION);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.CALLER_HOST);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.HOST);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.SERVICE_CLASS);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.SERVICE_NAME);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.CALLED_METHOD);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord.DURATION);
|
||||
return expectedRequiredFields;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ public class StorageUsageRecordTest {
|
|||
expectedRequiredFields.add(BasicUsageRecordUtility.USAGE_RECORD_TYPE);
|
||||
expectedRequiredFields.add(BasicUsageRecord.SCOPE);
|
||||
expectedRequiredFields.add(BasicUsageRecord.OPERATION_RESULT);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.RESOURCE_OWNER);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.RESOURCE_SCOPE);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.RESOURCE_URI);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.PROVIDER_URI);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.OPERATION_TYPE);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.DATA_TYPE);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.StorageUsageRecord.DATA_VOLUME);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.RESOURCE_OWNER);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.RESOURCE_SCOPE);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.RESOURCE_URI);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.PROVIDER_URI);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OPERATION_TYPE);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DATA_TYPE);
|
||||
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DATA_VOLUME);
|
||||
return expectedRequiredFields;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue