Fixed jackson serialization
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@153094 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8e592a4f0f
commit
dff433de7c
|
@ -9,12 +9,15 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
import org.gcube.documentstore.records.implementation.AggregatedField;
|
||||
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
|
@ -29,19 +32,14 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
*/
|
||||
private static final long serialVersionUID = -3376423316219914682L;
|
||||
|
||||
/*
|
||||
/ *add a field max e min invocation* /
|
||||
@AggregatedField
|
||||
public static final String DURATION = AbstractServiceUsageRecord.DURATION;
|
||||
|
||||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String MAX_INVOCATION_TIME = "maxInvocationTime";
|
||||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String MIN_INVOCATION_TIME = "minInvocationTime";
|
||||
|
||||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String JOB_START_TIME = "jobStartTime";
|
||||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String JOB_END_TIME = "jobEndTime";
|
||||
*/
|
||||
|
||||
public AggregatedJobUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
@ -52,58 +50,46 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
|
||||
// TODO
|
||||
public AggregatedJobUsageRecord(JobUsageRecord record) throws InvalidValueException{
|
||||
//throw new UnsupportedOperationException();
|
||||
super(record.getResourceProperties());
|
||||
this.setOperationCount(1);
|
||||
/*
|
||||
long duration = record.getDuration();
|
||||
this.setMinInvocationTime(duration);
|
||||
this.setMaxInvocationTime(duration);
|
||||
*/
|
||||
Calendar creationTime = record.getCreationTime();
|
||||
this.setCreationTime(Calendar.getInstance());
|
||||
this.setStartTime(creationTime);
|
||||
this.setEndTime(creationTime);
|
||||
|
||||
}
|
||||
@JsonIgnore
|
||||
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
}
|
||||
|
||||
/*
|
||||
@JsonIgnore
|
||||
public long getMaxInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
||||
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getMinInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
||||
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -112,7 +98,6 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -121,7 +106,6 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -130,75 +114,78 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
|
||||
//Introduced to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
public void setAggregated(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregated(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
public Boolean isAggregated() {
|
||||
return super.isAggregated();
|
||||
}
|
||||
//End Introduced to serialize Java Object
|
||||
|
||||
/*
|
||||
|
||||
protected long durationWeightedAverage(AggregatedJobUsageRecord record) throws InvalidValueException{
|
||||
long thisDuration = this.getDuration() * this.getOperationCount();
|
||||
long recordDuration = record.getDuration() * record.getOperationCount();
|
||||
long totalOperationCount = this.getOperationCount() + record.getOperationCount();
|
||||
return (thisDuration + recordDuration) / totalOperationCount;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedJobUsageRecord aggregate(AggregatedJobUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
throw new NotAggregatableRecordsExceptions();
|
||||
/*
|
||||
try {
|
||||
|
||||
/*
|
||||
* It is also checked in aggregationUtility.aggregate(record)
|
||||
* but has to be also checked before modifying values
|
||||
*/
|
||||
if(!isAggregable(record)){
|
||||
throw new NotAggregatableRecordsExceptions("The Record provided as argument has different values for field wich must be common to be aggregatable");
|
||||
}
|
||||
|
||||
AggregationUtility<AggregatedJobUsageRecord> aggregationUtility = new AggregationUtility<AggregatedJobUsageRecord>(this);
|
||||
|
||||
setDuration(durationWeightedAverage(record));
|
||||
|
||||
long max = record.getMaxInvocationTime();
|
||||
if(max > this.getMaxInvocationTime()){
|
||||
this.setMaxInvocationTime(max);
|
||||
}
|
||||
|
||||
|
||||
long min = record.getMinInvocationTime();
|
||||
if(min < this.getMinInvocationTime()){
|
||||
this.setMinInvocationTime(min);
|
||||
}
|
||||
|
||||
// This statement is at the end because the aggregate method
|
||||
// sum operation counts. If this statement is moved at the
|
||||
// beginning the weighted average is not calculated correctly
|
||||
aggregationUtility.aggregate(record);
|
||||
|
||||
} catch(NotAggregatableRecordsExceptions e){
|
||||
throw e;
|
||||
throw e;
|
||||
} catch(Exception ex){
|
||||
throw new NotAggregatableRecordsExceptions(ex);
|
||||
}
|
||||
|
||||
return this;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedJobUsageRecord aggregate(JobUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -238,13 +225,9 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<JobUsageRecord> getAggregable() {
|
||||
return JobUsageRecord.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanExtraFields(){
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.gcube.documentstore.exception.InvalidValueException;
|
|||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
|
@ -51,13 +50,17 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
//throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
|
@ -66,7 +69,6 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -75,7 +77,6 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -84,7 +85,6 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -93,33 +93,31 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
public void setAggregated(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregated(aggregate);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Boolean isAggregated() {
|
||||
return super.isAggregated();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedPortletUsageRecord aggregate(AggregatedPortletUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -137,15 +135,10 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
//throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedPortletUsageRecord aggregate(PortletUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -176,12 +169,10 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<PortletUsageRecord> getAggregable() {
|
||||
return PortletUsageRecord.class;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.gcube.documentstore.records.implementation.AggregatedField;
|
|||
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
|
@ -32,8 +31,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
*/
|
||||
private static final long serialVersionUID = 6387584974618335623L;
|
||||
|
||||
|
||||
|
||||
@AggregatedField
|
||||
public static final String DURATION = AbstractServiceUsageRecord.DURATION;
|
||||
|
||||
|
@ -42,7 +39,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
@RequiredField @ValidLong @AggregatedField
|
||||
public static final String MIN_INVOCATION_TIME = "minInvocationTime";
|
||||
|
||||
public AggregatedServiceUsageRecord(){
|
||||
public AggregatedServiceUsageRecord() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -62,35 +59,28 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
this.setEndTime(creationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getMaxInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MAX_INVOCATION_TIME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMaxInvocationTime(long maxInvocationTime) throws InvalidValueException {
|
||||
super.setResourceProperty(MAX_INVOCATION_TIME, maxInvocationTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public long getMinInvocationTime() {
|
||||
return (Long) this.resourceProperties.get(MIN_INVOCATION_TIME);
|
||||
}
|
||||
@JsonIgnore
|
||||
|
||||
public void setMinInvocationTime(long minInvocationTime) throws InvalidValueException {
|
||||
setResourceProperty(MIN_INVOCATION_TIME, minInvocationTime);
|
||||
}
|
||||
|
@ -98,7 +88,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -107,7 +96,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -116,7 +104,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -125,27 +112,26 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
public void setAggregated(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregated(aggregate);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Boolean isAggregated() {
|
||||
return super.isAggregated();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
|
||||
protected long durationWeightedAverage(AggregatedServiceUsageRecord record){
|
||||
|
@ -159,7 +145,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedServiceUsageRecord aggregate(AggregatedServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -203,7 +188,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedServiceUsageRecord aggregate(ServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -218,7 +202,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isAggregable(AggregatedServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
@ -229,7 +212,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isAggregable(ServiceUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
@ -246,7 +228,6 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<ServiceUsageRecord> getAggregable() {
|
||||
return ServiceUsageRecord.class;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
|||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
import org.gcube.documentstore.records.implementation.AggregatedField;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
|
@ -54,13 +53,11 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
this.setEndTime(creationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
|
@ -69,7 +66,6 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -78,7 +74,6 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
|
@ -87,7 +82,6 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -96,33 +90,28 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
public void setAggregated(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregated(aggregate);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
public Boolean isAggregated() {
|
||||
return super.isAggregated();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageStatusRecord aggregate(
|
||||
AggregatedStorageStatusRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
@ -144,7 +133,6 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageStatusRecord aggregate(StorageStatusRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -185,7 +173,6 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<StorageStatusRecord> getAggregable() {
|
||||
return StorageStatusRecord.class;
|
||||
}
|
||||
|
|
|
@ -15,14 +15,13 @@ import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
|||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
import org.gcube.documentstore.records.implementation.AggregatedField;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="AggregatedStorageUsageRecord")
|
||||
@JsonTypeName(value="StorageUsageRecord")
|
||||
public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord implements AggregatedUsageRecord<AggregatedStorageUsageRecord, StorageUsageRecord> {
|
||||
|
||||
/**
|
||||
|
@ -51,13 +50,11 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
this.setEndTime(creationTime);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
|
@ -66,7 +63,6 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
|
@ -83,7 +79,6 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
|
@ -92,33 +87,27 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
//Introduce for to serialize Java Object
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setAggregate(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregate(aggregate);
|
||||
public void setAggregated(Boolean aggregate) throws InvalidValueException {
|
||||
super.setAggregated(aggregate);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Boolean getAggregate() {
|
||||
return super.getAggregate();
|
||||
public Boolean isAggregated() {
|
||||
return super.isAggregated();
|
||||
}
|
||||
//End Introduce for to serialize Java Object
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageUsageRecord aggregate(
|
||||
AggregatedStorageUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
|
@ -138,7 +127,6 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public AggregatedStorageUsageRecord aggregate(StorageUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
|
@ -179,7 +167,6 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Class<StorageUsageRecord> getAggregable() {
|
||||
return StorageUsageRecord.class;
|
||||
}
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.aggregation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
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.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* This Class is for library internal use only
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="AggregatedTaskUsageRecord")
|
||||
public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implements AggregatedUsageRecord<AggregatedTaskUsageRecord, TaskUsageRecord> {
|
||||
|
||||
/**
|
||||
* Generated Serial version UID
|
||||
*/
|
||||
private static final long serialVersionUID = 7445526162102677455L;
|
||||
|
||||
public AggregatedTaskUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public AggregatedTaskUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
// TODO
|
||||
public AggregatedTaskUsageRecord(TaskUsageRecord taskUsageRecord) throws InvalidValueException{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public int getOperationCount() {
|
||||
return super.getOperationCount();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setOperationCount(int operationCount) throws InvalidValueException {
|
||||
super.setOperationCount(operationCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
return super.getStartTimeAsCalendar();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
super.setStartTime(startTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
return super.getEndTimeAsCalendar();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
super.setEndTime(endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AggregatedTaskUsageRecord aggregate(AggregatedTaskUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
throw new NotAggregatableRecordsExceptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AggregatedTaskUsageRecord aggregate(TaskUsageRecord record)
|
||||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
return aggregate(new AggregatedTaskUsageRecord(record));
|
||||
} catch(NotAggregatableRecordsExceptions e){
|
||||
throw e;
|
||||
} catch(Exception ex){
|
||||
throw new NotAggregatableRecordsExceptions(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isAggregable(AggregatedTaskUsageRecord record) throws NotAggregatableRecordsExceptions {
|
||||
AggregationUtility<AggregatedTaskUsageRecord> aggregationUtility = new AggregationUtility<AggregatedTaskUsageRecord>(this);
|
||||
return aggregationUtility.isAggregable(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isAggregable(TaskUsageRecord record) throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
return isAggregable(new AggregatedTaskUsageRecord(record));
|
||||
} catch(NotAggregatableRecordsExceptions e){
|
||||
throw e;
|
||||
} catch(Exception ex){
|
||||
throw new NotAggregatableRecordsExceptions(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Class<TaskUsageRecord> getAggregable() {
|
||||
return TaskUsageRecord.class;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.documentstore.records.implementation.FieldDecorator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@FieldDecorator(action=MoveToJobWallDurationAction.class)
|
||||
public @interface MoveToJobWallDuration { }
|
|
@ -1,19 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
|
||||
public class MoveToJobWallDurationAction implements FieldAction {
|
||||
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
return null; //Returning null the initial key is removed from Record
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.documentstore.records.implementation.FieldDecorator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@FieldDecorator(action=MoveToTaskEndTimeAction.class)
|
||||
public @interface MoveToTaskEndTime {
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class MoveToTaskEndTimeAction implements FieldAction {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(String key,
|
||||
Serializable value, Record record)
|
||||
throws InvalidValueException {
|
||||
record.setResourceProperty(AbstractTaskUsageRecord.TASK_END_TIME, value);
|
||||
return null; //Returning null the initial key is removed from Record
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.documentstore.records.implementation.FieldDecorator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@FieldDecorator(action=MoveToTaskStartTimeAction.class)
|
||||
public @interface MoveToTaskStartTime {
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class MoveToTaskStartTimeAction implements FieldAction {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(String key,
|
||||
Serializable value, Record record)
|
||||
throws InvalidValueException {
|
||||
record.setResourceProperty(AbstractTaskUsageRecord.TASK_START_TIME, value);
|
||||
return null; //Returning null the initial key is removed from Record
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.documentstore.records.implementation.FieldDecorator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@FieldDecorator(action=MoveToTaskWallDurationAction.class)
|
||||
public @interface MoveToTaskWallDuration { }
|
|
@ -1,19 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
|
||||
public class MoveToTaskWallDurationAction implements FieldAction {
|
||||
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
return null; //Returning null the initial key is removed from Record
|
||||
}
|
||||
|
||||
}
|
|
@ -4,23 +4,16 @@
|
|||
package org.gcube.accounting.datamodel.basetypes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.implementation.ComputedField;
|
||||
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
||||
|
||||
|
@ -29,22 +22,46 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
*/
|
||||
private static final long serialVersionUID = -8648691183939346858L;
|
||||
|
||||
|
||||
/**
|
||||
* KEY for : hostname:port of the Hosting Node receiving the service call
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
public static final String JOB_ID = "jobId";
|
||||
|
||||
@NotEmptyIfNotNull
|
||||
public static final String JOB_NAME = "jobName";
|
||||
@NotEmptyIfNotNull
|
||||
public static final String JOB_QUALIFIER = "jobQualifier";
|
||||
public static final String HOST = "host";
|
||||
|
||||
/**
|
||||
* KEY for : Duration
|
||||
*/
|
||||
@RequiredField @ValidLong
|
||||
public static final String JOB_START_TIME = "jobStartTime";
|
||||
@RequiredField @ValidLong
|
||||
public static final String JOB_END_TIME = "jobEndTime";
|
||||
|
||||
@RequiredField @ComputedField(action=CalculateJobWallDurationAction.class) @ValidLong
|
||||
public static final String DURATION = "duration";
|
||||
|
||||
|
||||
/**
|
||||
* KEY for : Service Class
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
public static final String SERVICE_CLASS = "serviceClass";
|
||||
|
||||
/**
|
||||
* KEY for : Service Class
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
public static final String SERVICE_NAME = "serviceName";
|
||||
|
||||
/**
|
||||
* KEY for : Job Name
|
||||
*/
|
||||
@RequiredField
|
||||
public static final String JOB_NAME = "jobName";
|
||||
|
||||
/**
|
||||
* KEY for : callerQualifier
|
||||
*
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
public static final String CALLER_QUALIFIER = "callerQualifier";
|
||||
|
||||
|
||||
public AbstractJobUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
@ -59,102 +76,53 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
|
|||
public String getRecordType() {
|
||||
return AbstractJobUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<String> getQuerableKeys()
|
||||
throws Exception {
|
||||
SortedSet<String> properties = super.getQuerableKeys();
|
||||
properties.remove(JOB_START_TIME);
|
||||
properties.remove(JOB_END_TIME);
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Job Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getJobId() {
|
||||
return (String) this.resourceProperties.get(JOB_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jobId Job Id
|
||||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setJobId(String jobId) throws InvalidValueException {
|
||||
setResourceProperty(JOB_ID, jobId);
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getJobQualifier() {
|
||||
return (String) this.resourceProperties.get(JOB_QUALIFIER);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobQualifier(String jobQualifier) throws InvalidValueException {
|
||||
setResourceProperty(JOB_QUALIFIER, jobQualifier);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getJobName() {
|
||||
return (String) this.resourceProperties.get(JOB_NAME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobName(String jobName) throws InvalidValueException {
|
||||
setResourceProperty(JOB_NAME, jobName);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getJobStartTime() {
|
||||
long millis = (Long) this.resourceProperties.get(JOB_START_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
public String getHost() {
|
||||
return (String) this.resourceProperties.get(HOST);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobStartTime(Calendar jobStartTime) throws InvalidValueException {
|
||||
setResourceProperty(JOB_START_TIME, jobStartTime.getTimeInMillis());
|
||||
|
||||
public void setHost(String host) throws InvalidValueException {
|
||||
setResourceProperty(HOST, host);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getJobEndTime() {
|
||||
long millis = (Long) this.resourceProperties.get(JOB_END_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
public String getServiceClass() {
|
||||
return (String) this.resourceProperties.get(SERVICE_CLASS);
|
||||
}
|
||||
|
||||
public void setServiceClass(String serviceClass) throws InvalidValueException {
|
||||
setResourceProperty(SERVICE_CLASS, serviceClass);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setJobEndTime(Calendar jobEndTime) throws InvalidValueException {
|
||||
setResourceProperty(JOB_END_TIME, jobEndTime.getTimeInMillis());
|
||||
public String getServiceName() {
|
||||
return (String) this.resourceProperties.get(SERVICE_NAME);
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) throws InvalidValueException {
|
||||
setResourceProperty(SERVICE_NAME, serviceName);
|
||||
}
|
||||
|
||||
protected long calculateDuration() throws InvalidValueException {
|
||||
try {
|
||||
long endTime = (Long) this.resourceProperties.get(JOB_END_TIME);
|
||||
long startTime = (Long) this.resourceProperties.get(JOB_START_TIME);
|
||||
long wallDuration = endTime - startTime;
|
||||
setResourceProperty(AbstractJobUsageRecord.DURATION, wallDuration);
|
||||
return wallDuration;
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(String.format("To calculate Wall Duration both %s and %s must be set",
|
||||
JOB_START_TIME, JOB_END_TIME), e);
|
||||
}
|
||||
public Long getDuration() {
|
||||
return (Long) this.resourceProperties.get(DURATION);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDuration() throws InvalidValueException {
|
||||
Long duration = (Long) this.resourceProperties.get(DURATION);
|
||||
if(duration == null){
|
||||
try {
|
||||
duration = calculateDuration();
|
||||
} catch(InvalidValueException e){
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
@JsonIgnore
|
||||
|
||||
public void setDuration(Long duration) throws InvalidValueException {
|
||||
setResourceProperty(DURATION, duration);
|
||||
}
|
||||
|
||||
public String getCallerQualifier() {
|
||||
return (String) this.resourceProperties.get(CALLER_QUALIFIER);
|
||||
}
|
||||
|
||||
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
||||
setResourceProperty(CALLER_QUALIFIER, callerQualifier);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,11 +12,8 @@ import org.gcube.documentstore.records.implementation.RequiredField;
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
|
||||
|
||||
|
@ -50,33 +47,28 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
|
|||
return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getPortletId() {
|
||||
return (String) this.resourceProperties.get(PORTLET_ID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setPortletId(String portletId) throws InvalidValueException {
|
||||
setResourceProperty(PORTLET_ID, portletId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getOperationId() {
|
||||
return (String) this.resourceProperties.get(OPERATION_ID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setOperationId(String operationId) throws InvalidValueException {
|
||||
setResourceProperty(OPERATION_ID, operationId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getMessage() {
|
||||
return (String) this.resourceProperties.get(MESSAGE);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setMessage(String message) throws InvalidValueException {
|
||||
setResourceProperty(MESSAGE, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,12 +12,9 @@ import org.gcube.documentstore.records.implementation.RequiredField;
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
|
||||
public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
|
@ -64,18 +61,26 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
|||
|
||||
/**
|
||||
* KEY for : callerQualifier
|
||||
*
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
public static final String CALLER_QUALIFIER = "callerQualifier";
|
||||
|
||||
protected static final String UNKNOWN = "UNKNOWN";
|
||||
|
||||
public AbstractServiceUsageRecord(){
|
||||
super();
|
||||
try{
|
||||
// Need to fix old ServiceUsageRecords which does not have such a field
|
||||
setResourceProperty(CALLER_QUALIFIER, UNKNOWN);
|
||||
}catch (Exception e) {
|
||||
throw new RuntimeException("Unable to set " + CALLER_QUALIFIER + " to " + UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractServiceUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
// Need to fix old ServiceUsageRecords which does not have such a field
|
||||
setResourceProperty(CALLER_QUALIFIER, UNKNOWN);
|
||||
}
|
||||
|
||||
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
||||
|
@ -86,72 +91,60 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
|||
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getCallerHost() {
|
||||
return (String) this.resourceProperties.get(CALLER_HOST);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setCallerHost(String callerHost) throws InvalidValueException {
|
||||
setResourceProperty(CALLER_HOST, callerHost);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getHost() {
|
||||
return (String) this.resourceProperties.get(HOST);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setHost(String host) throws InvalidValueException {
|
||||
setResourceProperty(HOST, host);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getServiceClass() {
|
||||
return (String) this.resourceProperties.get(SERVICE_CLASS);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setServiceClass(String serviceClass) throws InvalidValueException {
|
||||
setResourceProperty(SERVICE_CLASS, serviceClass);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getServiceName() {
|
||||
return (String) this.resourceProperties.get(SERVICE_NAME);
|
||||
}
|
||||
@JsonIgnore
|
||||
|
||||
public void setServiceName(String serviceName) throws InvalidValueException {
|
||||
setResourceProperty(SERVICE_NAME, serviceName);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getCalledMethod() {
|
||||
return (String) this.resourceProperties.get(CALLED_METHOD);
|
||||
}
|
||||
@JsonIgnore
|
||||
|
||||
public void setCalledMethod(String calledMethod) throws InvalidValueException {
|
||||
setResourceProperty(CALLED_METHOD, calledMethod);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Long getDuration() {
|
||||
return (Long) this.resourceProperties.get(DURATION);
|
||||
}
|
||||
@JsonIgnore
|
||||
|
||||
public void setDuration(Long duration) throws InvalidValueException {
|
||||
setResourceProperty(DURATION, duration);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getCallerQualifier() {
|
||||
return (String) this.resourceProperties.get(CALLER_QUALIFIER);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
||||
setResourceProperty(CALLER_QUALIFIER, callerQualifier);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,11 +16,9 @@ import org.gcube.documentstore.records.implementation.RequiredField;
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
||||
*
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
||||
|
||||
|
@ -93,72 +91,58 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
return AbstractStorageStatusRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDataVolume() {
|
||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public DataType getDataType() {
|
||||
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataType(DataType dataType) throws InvalidValueException {
|
||||
setResourceProperty(DATA_TYPE, dataType);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDataCount() {
|
||||
return (Long) this.resourceProperties.get(DATA_COUNT);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataCount(long dataCount) throws InvalidValueException {
|
||||
setResourceProperty(DATA_COUNT, dataCount);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDataServiceClass() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICECLASS);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataServiceClass(String dataServiceClass) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICECLASS, dataServiceClass);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDataServiceName() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICENAME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataServiceName(String dataServiceName) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICENAME, dataServiceName);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDataServiceId() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICEID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataServiceId(String dataServiceId) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICEID, dataServiceId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public URI getProviderId() {
|
||||
return (URI) this.resourceProperties.get(PROVIDER_ID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setProviderId(URI provideId) throws InvalidValueException {
|
||||
setResourceProperty(PROVIDER_ID, provideId);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,8 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
|
|||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
||||
|
||||
|
@ -115,7 +112,6 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* Return the identity id of the storage resource owner
|
||||
* @return the identity id of the accounting owner
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getResourceOwner() {
|
||||
return (String) this.resourceProperties.get(RESOURCE_OWNER);
|
||||
}
|
||||
|
@ -125,7 +121,6 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* @param owner the identity id of the storage resource owner
|
||||
* @throws InvalidValueException
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setResourceOwner(String owner) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_OWNER, owner);
|
||||
}
|
||||
|
@ -133,7 +128,6 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* Return the scope of the storage resource
|
||||
* @return The scope id of the storage resource
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getResourceScope() {
|
||||
return (String) this.resourceProperties.get(RESOURCE_SCOPE);
|
||||
}
|
||||
|
@ -143,67 +137,54 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* @param scope the scope of the storage resource
|
||||
* @throws InvalidValueException
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setResourceScope(String scope) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_SCOPE, scope);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public URI getProviderURI() {
|
||||
return (URI) this.resourceProperties.get(PROVIDER_URI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setProviderURI(URI providerURI) throws InvalidValueException {
|
||||
setResourceProperty(PROVIDER_URI, providerURI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public URI getResourceURI() {
|
||||
return (URI) this.resourceProperties.get(RESOURCE_URI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setResourceURI(URI resourceURI) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_URI, resourceURI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public OperationType getOperationType() {
|
||||
return (OperationType) this.resourceProperties.get(OPERATION_TYPE);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setOperationType(OperationType operationType) throws InvalidValueException {
|
||||
setResourceProperty(OPERATION_TYPE, operationType);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public DataType getDataType() {
|
||||
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataType(DataType dataType) throws InvalidValueException {
|
||||
setResourceProperty(DATA_TYPE, dataType);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getDataVolume() {
|
||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getQualifier() {
|
||||
return (String) this.resourceProperties.get(QUALIFIER);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setQualifier(String qualifier) throws InvalidValueException {
|
||||
setResourceProperty(QUALIFIER, qualifier);
|
||||
}
|
||||
|
@ -217,4 +198,5 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
setResourceProperty(CALLERQUALIFIER, callerQualifier);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -1,191 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.basetypes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.implementation.ComputedField;
|
||||
import org.gcube.documentstore.records.implementation.RequiredField;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
||||
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
|
||||
public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
*/
|
||||
private static final long serialVersionUID = -2208425042550641240L;
|
||||
|
||||
|
||||
@RequiredField @NotEmpty
|
||||
public static final String TASK_ID = "taskId";
|
||||
@NotEmptyIfNotNull
|
||||
public static final String REF_JOB_ID = "refJobId";
|
||||
|
||||
@NotEmptyIfNotNull
|
||||
public static final String HOST = "host";
|
||||
@NotEmptyIfNotNull
|
||||
public static final String REF_HOSTING_NODE_ID = "refHostingNodeId";
|
||||
|
||||
@ValidLong @RequiredField
|
||||
public static final String TASK_START_TIME = "taskStartTime";
|
||||
@ValidLong @RequiredField
|
||||
public static final String TASK_END_TIME = "taskEndTime";
|
||||
|
||||
@RequiredField @ComputedField(action=CalculateTaskWallDurationAction.class) @ValidLong
|
||||
public static final String WALL_DURATION = "wallDuration";
|
||||
|
||||
/*
|
||||
@NotEmptyIfNotNull
|
||||
public static final String INPUT_PARAMETERS = "inputParameters";
|
||||
*/
|
||||
|
||||
public AbstractTaskUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public AbstractTaskUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
||||
|
||||
@Override
|
||||
public String getRecordType() {
|
||||
return AbstractTaskUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Task Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getTaskId() {
|
||||
return (String) this.resourceProperties.get(TASK_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param taskId Task Id
|
||||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setTaskId(String taskId) throws InvalidValueException {
|
||||
setResourceProperty(TASK_ID, taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Referenced Job Id
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getRefJobId() {
|
||||
return (String) this.resourceProperties.get(REF_JOB_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param refJobId Referenced Job Id
|
||||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setRefJobId(String refJobId) throws InvalidValueException {
|
||||
setResourceProperty(REF_JOB_ID, refJobId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getHost() {
|
||||
return (String) this.resourceProperties.get(HOST);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setHost(String host) throws InvalidValueException {
|
||||
setResourceProperty(HOST, host);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getRefHostingNodeId() {
|
||||
return (String) this.resourceProperties.get(REF_HOSTING_NODE_ID);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setRefHostingNodeId(String refHostingNodeId) throws InvalidValueException {
|
||||
setResourceProperty(REF_HOSTING_NODE_ID, refHostingNodeId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getTaskStartTime() {
|
||||
long millis = (Long) this.resourceProperties.get(TASK_START_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setTaskStartTime(Calendar startTime) throws InvalidValueException {
|
||||
setResourceProperty(TASK_START_TIME, startTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Calendar getTaskEndTime() {
|
||||
long millis = (Long) this.resourceProperties.get(TASK_END_TIME);
|
||||
return timestampToCalendar(millis);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setTaskEndTime(Calendar endTime) throws InvalidValueException {
|
||||
setResourceProperty(TASK_END_TIME, endTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
protected long calculateWallDuration() throws InvalidValueException {
|
||||
try {
|
||||
long endTime = (Long) this.resourceProperties.get(TASK_END_TIME);
|
||||
long startTime = (Long) this.resourceProperties.get(TASK_START_TIME);
|
||||
long wallDuration = endTime - startTime;
|
||||
return wallDuration;
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(String.format("To calculate Wall Duration both %s and %s must be set",
|
||||
TASK_START_TIME, TASK_END_TIME), e);
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getWallDuration() throws InvalidValueException {
|
||||
Long wallDuration = (Long) this.resourceProperties.get(WALL_DURATION);
|
||||
if(wallDuration == null){
|
||||
try {
|
||||
wallDuration = calculateWallDuration();
|
||||
} catch(InvalidValueException e){
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return wallDuration;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setWallDuration(Long duration) throws InvalidValueException {
|
||||
setResourceProperty(WALL_DURATION, duration);
|
||||
}
|
||||
|
||||
/*
|
||||
@SuppressWarnings("unchecked")
|
||||
//@JsonIgnore
|
||||
public Map<String, Serializable> getInputParameters(){
|
||||
return (HashMap<String, Serializable>) getResourceProperty(INPUT_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
//@JsonIgnore
|
||||
@JsonProperty(value=INPUT_PARAMETERS)
|
||||
public void setInputParameters(HashMap<String, Serializable> inputParameters) throws InvalidValueException{
|
||||
setResourceProperty(INPUT_PARAMETERS, inputParameters);
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.basetypes;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class CalculateJobWallDurationAction implements FieldAction {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CalculateJobWallDurationAction.class);
|
||||
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
try {
|
||||
long wallDuration = ((AbstractJobUsageRecord) record).calculateDuration();
|
||||
if(key.compareTo(AbstractJobUsageRecord.DURATION)==0){
|
||||
logger.warn("{} is automatically computed using {} and {}. This invocation has the only effect of recalculating the value. Any provided value is ignored.",
|
||||
AbstractJobUsageRecord.DURATION, AbstractJobUsageRecord.JOB_START_TIME, AbstractJobUsageRecord.JOB_END_TIME);
|
||||
value = wallDuration;
|
||||
}
|
||||
}catch(InvalidValueException e){ }
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.basetypes;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class CalculateTaskWallDurationAction implements FieldAction {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CalculateTaskWallDurationAction.class);
|
||||
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
try {
|
||||
long wallDuration = ((AbstractTaskUsageRecord) record).calculateWallDuration();
|
||||
if(key.compareTo(AbstractTaskUsageRecord.WALL_DURATION)==0){
|
||||
logger.warn("{} is automatically computed using {} and {}. This invocation has the only effect of recalculating the value. Any provided value is ignored.",
|
||||
AbstractTaskUsageRecord.WALL_DURATION, AbstractTaskUsageRecord.TASK_START_TIME, AbstractTaskUsageRecord.TASK_END_TIME);
|
||||
value = wallDuration;
|
||||
}else{
|
||||
record.setResourceProperty(AbstractTaskUsageRecord.WALL_DURATION, wallDuration);
|
||||
}
|
||||
}catch(InvalidValueException e){ }
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ public class ServiceUsageRecord extends AbstractServiceUsageRecord {
|
|||
*/
|
||||
private static final long serialVersionUID = 1941140440484309668L;
|
||||
|
||||
public ServiceUsageRecord(){
|
||||
public ServiceUsageRecord() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package org.gcube.accounting.datamodel.usagerecords;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value="SingleTaskUsageRecord")
|
||||
public class TaskUsageRecord extends AbstractTaskUsageRecord {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
*/
|
||||
private static final long serialVersionUID = 5053135599013854281L;
|
||||
|
||||
public TaskUsageRecord(){
|
||||
super();
|
||||
}
|
||||
|
||||
public TaskUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
||||
super(properties);
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ package org.gcube.accounting.datamodel.aggregation;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecordTest;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
|
@ -38,10 +37,8 @@ public class AggregatedJobUsageRecordTest extends ScopedTest {
|
|||
AggregatedJobUsageRecord aggregatedJobUsageRecord = new AggregatedJobUsageRecord(jobUsageRecord);
|
||||
|
||||
Set<String> expectedRequiredFields = JobUsageRecordTest.getExpectedRequiredFields();
|
||||
/*
|
||||
expectedRequiredFields.add(AggregatedJobUsageRecord.MAX_INVOCATION_TIME);
|
||||
expectedRequiredFields.add(AggregatedJobUsageRecord.MIN_INVOCATION_TIME);
|
||||
*/
|
||||
|
||||
expectedRequiredFields.addAll(AggregatedUsageRecordTest.getExpectedRequiredFields());
|
||||
|
||||
|
@ -57,7 +54,7 @@ public class AggregatedJobUsageRecordTest extends ScopedTest {
|
|||
|
||||
}
|
||||
|
||||
@Test(expected=NotAggregatableRecordsExceptions.class)
|
||||
@Test
|
||||
public void secondAsNotAggregated() throws InvalidValueException, NotAggregatableRecordsExceptions {
|
||||
SecurityTokenProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
|
@ -65,7 +62,10 @@ public class AggregatedJobUsageRecordTest extends ScopedTest {
|
|||
JobUsageRecord jobUsageRecord = TestUsageRecord.createTestJobUsageRecord();
|
||||
Assert.assertTrue(jobUsageRecord.getScope()==null);
|
||||
jobUsageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
jobUsageRecord.setJobQualifier("TEST QUALIFIER JOB USAGE RECORD 1");
|
||||
|
||||
|
||||
jobUsageRecord.setResourceProperty(TestUsageRecord.TEST_PROPERTY_NAME, TestUsageRecord.TEST_PROPERTY_VALUE);
|
||||
|
||||
jobUsageRecord.validate();
|
||||
AggregatedJobUsageRecord aggregated = new AggregatedJobUsageRecord(jobUsageRecord);
|
||||
logger.debug("jobUsageRecord Converted to Aggregated: {}", aggregated);
|
||||
|
@ -79,15 +79,30 @@ public class AggregatedJobUsageRecordTest extends ScopedTest {
|
|||
jobUsageRecord2.validate();
|
||||
logger.debug("JobUsageRecord 2 : {}", jobUsageRecord2);
|
||||
|
||||
long firstDuration = jobUsageRecord.getDuration();
|
||||
long secondDuration = jobUsageRecord2.getDuration();
|
||||
|
||||
aggregated.aggregate(jobUsageRecord2);
|
||||
/*
|
||||
logger.debug("jobUsageRecord2 Converted to Aggregated: {}", aggregated);
|
||||
logger.debug("Resulting Aggregated ServiceUsageRecord: {}", aggregated);
|
||||
aggregated.validate();
|
||||
logger.debug("jobUsageRecord2 Converted to Aggregated post validate: {}", aggregated);
|
||||
*/
|
||||
|
||||
Assert.assertTrue(aggregated.getDuration() == ((firstDuration + secondDuration)/2));
|
||||
Assert.assertTrue(aggregated.getOperationCount() == 2);
|
||||
|
||||
if(firstDuration >= secondDuration){
|
||||
Assert.assertTrue(aggregated.getMaxInvocationTime() == firstDuration);
|
||||
Assert.assertTrue(aggregated.getMinInvocationTime() == secondDuration);
|
||||
}else{
|
||||
Assert.assertTrue(aggregated.getMaxInvocationTime() == secondDuration);
|
||||
Assert.assertTrue(aggregated.getMinInvocationTime() == firstDuration);
|
||||
}
|
||||
|
||||
Assert.assertFalse(aggregated.getResourceProperties().containsKey(TestUsageRecord.TEST_PROPERTY_NAME));
|
||||
|
||||
Assert.assertTrue(aggregated.getRecordType().compareTo(JobUsageRecord.class.getSimpleName())==0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@Test
|
||||
public void secondAsAggregated() throws InvalidValueException, NotAggregatableRecordsExceptions {
|
||||
SecurityTokenProvider.instance.reset();
|
||||
|
@ -168,26 +183,26 @@ public class AggregatedJobUsageRecordTest extends ScopedTest {
|
|||
long minInvocationTime = aggregated.getMinInvocationTime();
|
||||
long maxInvocationTime = aggregated.getMaxInvocationTime();
|
||||
long oldDuration = aggregated.getDuration();
|
||||
long surDuration = jur.getDuration();
|
||||
long jurDuration = jur.getDuration();
|
||||
|
||||
aggregated.aggregate(jur);
|
||||
logger.debug("Resulting Aggregated JobUsageRecord: {}", aggregated);
|
||||
aggregated.validate();
|
||||
|
||||
long avgDuration = durationWeightedAverage(i-1, oldDuration, 1, surDuration);
|
||||
long avgDuration = durationWeightedAverage(i-1, oldDuration, 1, jurDuration);
|
||||
Assert.assertTrue(aggregated.getDuration() == (avgDuration));
|
||||
Assert.assertTrue(aggregated.getOperationCount() == i);
|
||||
|
||||
if(minInvocationTime >= surDuration){
|
||||
Assert.assertTrue(aggregated.getMinInvocationTime() == surDuration);
|
||||
if(minInvocationTime >= jurDuration){
|
||||
Assert.assertTrue(aggregated.getMinInvocationTime() == jurDuration);
|
||||
}else{
|
||||
Assert.assertTrue(aggregated.getMinInvocationTime() == minInvocationTime);
|
||||
}
|
||||
|
||||
if(maxInvocationTime >= surDuration){
|
||||
if(maxInvocationTime >= jurDuration){
|
||||
Assert.assertTrue(aggregated.getMaxInvocationTime() == maxInvocationTime);
|
||||
}else{
|
||||
Assert.assertTrue(aggregated.getMaxInvocationTime() == surDuration);
|
||||
Assert.assertTrue(aggregated.getMaxInvocationTime() == jurDuration);
|
||||
}
|
||||
|
||||
Assert.assertFalse(aggregated.getResourceProperties().containsKey(TestUsageRecord.TEST_PROPERTY_NAME));
|
||||
|
@ -197,5 +212,6 @@ public class AggregatedJobUsageRecordTest extends ScopedTest {
|
|||
|
||||
logger.debug("Resulting Aggregated JobUsageRecord: {}", aggregated);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,10 +34,13 @@ public class JobUsageRecordTest extends ScopedTest {
|
|||
expectedRequiredFields.add(UsageRecord.CREATION_TIME);
|
||||
expectedRequiredFields.add(UsageRecord.SCOPE);
|
||||
expectedRequiredFields.add(UsageRecord.OPERATION_RESULT);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_ID);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.HOST);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.DURATION);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_END_TIME);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_START_TIME);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.SERVICE_CLASS);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.SERVICE_NAME);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_NAME);
|
||||
expectedRequiredFields.add(AbstractJobUsageRecord.CALLER_QUALIFIER);
|
||||
|
||||
return expectedRequiredFields;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.usagerecords;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.testutility.ScopedTest;
|
||||
import org.gcube.testutility.TestUsageRecord;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class TaskUsageRecordTest extends ScopedTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TaskUsageRecordTest.class);
|
||||
|
||||
public static Set<String> getExpectedRequiredFields(){
|
||||
Set<String> expectedRequiredFields = new HashSet<String>();
|
||||
expectedRequiredFields.add(Record.ID);
|
||||
expectedRequiredFields.add(UsageRecord.CONSUMER_ID);
|
||||
expectedRequiredFields.add(UsageRecord.CREATION_TIME);
|
||||
expectedRequiredFields.add(UsageRecord.SCOPE);
|
||||
expectedRequiredFields.add(UsageRecord.OPERATION_RESULT);
|
||||
expectedRequiredFields.add(AbstractTaskUsageRecord.TASK_ID);
|
||||
expectedRequiredFields.add(AbstractTaskUsageRecord.WALL_DURATION);
|
||||
expectedRequiredFields.add(AbstractTaskUsageRecord.TASK_START_TIME);
|
||||
expectedRequiredFields.add(AbstractTaskUsageRecord.TASK_END_TIME);
|
||||
return expectedRequiredFields;
|
||||
}
|
||||
|
||||
@Test(expected=InvalidValueException.class)
|
||||
public void scopeNotSetValidationError() throws InvalidValueException {
|
||||
SecurityTokenProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
TaskUsageRecord usageRecord = TestUsageRecord.createTestTaskUsageRecord();
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFields() throws InvalidValueException{
|
||||
SecurityTokenProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
TaskUsageRecord usageRecord = TestUsageRecord.createTestTaskUsageRecord();
|
||||
Assert.assertTrue(usageRecord.getScope()==null);
|
||||
usageRecord.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
|
||||
Set<String> expectedRequiredFields = getExpectedRequiredFields();
|
||||
logger.debug("Expected Required Fields : {}", expectedRequiredFields);
|
||||
|
||||
Set<String> gotRequiredFields = usageRecord.getRequiredFields();
|
||||
logger.debug("Got Required Fields : {}", gotRequiredFields);
|
||||
|
||||
Assert.assertTrue(expectedRequiredFields.containsAll(gotRequiredFields));
|
||||
Assert.assertTrue(gotRequiredFields.containsAll(expectedRequiredFields));
|
||||
|
||||
usageRecord.validate();
|
||||
logger.debug("{}", usageRecord);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,22 +3,18 @@
|
|||
*/
|
||||
package org.gcube.testutility;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
||||
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -50,12 +46,6 @@ public class TestUsageRecord {
|
|||
|
||||
public final static String TEST_JOB_ID = UUID.randomUUID().toString();
|
||||
public final static String TEST_JOB_NAME = "TestJobName";
|
||||
public final static int TEST_VMS_USED = 2;
|
||||
public final static String TEST_JOB_QUALIFIER = "TestJobQualifier";
|
||||
public final static long HALF_DURATION = 10 * 60 * 1000; // 10 min
|
||||
|
||||
public final static String TEST_TASK_ID = UUID.randomUUID().toString();
|
||||
public final static String TEST_NESTED_MAP = "TestNestedMap";
|
||||
|
||||
public final static String TEST_PORTLET_ID = "TestPortlet";
|
||||
public final static String TEST_PORTLET_OPERATION_ID = "TestPortletOperationID";
|
||||
|
@ -179,65 +169,12 @@ public class TestUsageRecord {
|
|||
try {
|
||||
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
||||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||
|
||||
usageRecord.setJobId(TEST_JOB_ID);
|
||||
usageRecord.setJobName(TEST_JOB_NAME);
|
||||
usageRecord.setJobQualifier("212505");
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.setTimeInMillis(startTime.getTimeInMillis() + HALF_DURATION);
|
||||
startTime.setTimeInMillis(startTime.getTimeInMillis() - HALF_DURATION);
|
||||
|
||||
usageRecord.setJobStartTime(startTime);
|
||||
usageRecord.setJobEndTime(endTime);
|
||||
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
||||
}
|
||||
|
||||
return usageRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static TaskUsageRecord createTestTaskUsageRecord() {
|
||||
|
||||
TaskUsageRecord usageRecord = new TaskUsageRecord();
|
||||
try {
|
||||
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
||||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||
|
||||
usageRecord.setTaskId(TEST_TASK_ID);
|
||||
//usageRecord.setTaskId(TEST_JOB_ID);
|
||||
usageRecord.setHost(TEST_HOST);
|
||||
|
||||
usageRecord.setRefHostingNodeId(UUID.randomUUID().toString());
|
||||
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.setTimeInMillis(startTime.getTimeInMillis() + HALF_DURATION);
|
||||
startTime.setTimeInMillis(startTime.getTimeInMillis() - HALF_DURATION);
|
||||
|
||||
usageRecord.setTaskStartTime(startTime);
|
||||
usageRecord.setTaskEndTime(endTime);
|
||||
|
||||
usageRecord.setResourceProperty("finalState", "DONE") ;
|
||||
usageRecord.setResourceProperty("ESEMpio", "PLUTO") ;
|
||||
|
||||
HashMap<String, Serializable> inputParameters = new HashMap<>();
|
||||
inputParameters.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||
inputParameters.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||
|
||||
|
||||
HashMap<String, Serializable> parameter = new HashMap<>();
|
||||
parameter.put(TEST_PROPERTY_NAME, TEST_PROPERTY_VALUE);
|
||||
parameter.put(TEST_PROPERTY_VALUE, TEST_PROPERTY_NAME);
|
||||
|
||||
inputParameters.put(TEST_NESTED_MAP, parameter);
|
||||
|
||||
//usageRecord.setInputParameters(inputParameters);
|
||||
|
||||
usageRecord.setCallerQualifier(TEST_CALLER_QUALIFIER);
|
||||
usageRecord.setServiceClass(TEST_SERVICE_CLASS);
|
||||
usageRecord.setServiceName(TEST_SERVICE_NAME);
|
||||
usageRecord.setJobName(TEST_JOB_NAME);
|
||||
usageRecord.setDuration(generateRandomLong(MIN_DURATION, MAX_DURATION));
|
||||
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
||||
|
@ -246,7 +183,6 @@ public class TestUsageRecord {
|
|||
return usageRecord;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
@ -257,11 +193,6 @@ public class TestUsageRecord {
|
|||
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
||||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.setTimeInMillis(startTime.getTimeInMillis() + HALF_DURATION);
|
||||
startTime.setTimeInMillis(startTime.getTimeInMillis() - HALF_DURATION);
|
||||
|
||||
usageRecord.setPortletId(TEST_PORTLET_ID);
|
||||
usageRecord.setOperationId(TEST_PORTLET_OPERATION_ID);
|
||||
usageRecord.setMessage(TEST_PORTLET_MESSAGE);
|
||||
|
|
Loading…
Reference in New Issue