refs #200: Create accouting-lib library
https://support.d4science.org/issues/200 Implementing library git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115265 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b7fef09600
commit
ecda3255a9
|
@ -11,6 +11,7 @@ import java.util.Arrays;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -70,12 +71,11 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
private static final long serialVersionUID = -2060728578456796388L;
|
||||
|
||||
/**
|
||||
* resource-specific properties
|
||||
*/
|
||||
protected Map<String, Serializable> resourceSpecificProperties;
|
||||
/** resource-specific properties */
|
||||
protected Map<String, Serializable> resourceProperties;
|
||||
|
||||
protected final Map<String, List<ValidatorAction>> validation;
|
||||
protected Map<String, List<ValidatorAction>> validation;
|
||||
protected Set<String> requiredFields;
|
||||
|
||||
protected void initializeValidation() {
|
||||
logger.debug("Initializing Field Validators");
|
||||
|
@ -100,25 +100,34 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
}
|
||||
fieldValidators.add(validator);
|
||||
}
|
||||
if(annotation.getClass().isAssignableFrom(RequiredField.class)){
|
||||
requiredFields.add(keyString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize variable
|
||||
*/
|
||||
private void init() {
|
||||
this.validation = new HashMap<String, List<ValidatorAction>>();
|
||||
this.requiredFields = new HashSet<String>();
|
||||
initializeValidation();
|
||||
}
|
||||
|
||||
protected RawUsageRecord(){
|
||||
this.resourceSpecificProperties = new HashMap<String, Serializable>();
|
||||
this.validation = new HashMap<String, List<ValidatorAction>>();
|
||||
initializeValidation();
|
||||
this.resourceSpecificProperties.put(ID, UUID.randomUUID().toString());
|
||||
this.resourceSpecificProperties.put(RESOURCE_TYPE, this.getClass().getSimpleName());
|
||||
init();
|
||||
this.resourceProperties = new HashMap<String, Serializable>();
|
||||
this.resourceProperties.put(ID, UUID.randomUUID().toString());
|
||||
this.resourceProperties.put(RESOURCE_TYPE, this.getClass().getSimpleName());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
this.resourceSpecificProperties.put(CREATION_TIME, calendar.getTimeInMillis());
|
||||
this.resourceProperties.put(CREATION_TIME, calendar.getTimeInMillis());
|
||||
}
|
||||
|
||||
protected RawUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
this.validation = new HashMap<String, List<ValidatorAction>>();
|
||||
initializeValidation();
|
||||
setResourceSpecificProperties(properties);
|
||||
init();
|
||||
setResourceProperties(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +135,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return (String) this.resourceSpecificProperties.get(ID);
|
||||
return (String) this.resourceProperties.get(ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,7 +143,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void setId(String id) throws InvalidValueException {
|
||||
setResourceSpecificProperty(ID, id);
|
||||
setResourceProperty(ID, id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,7 +151,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public String getCreatorId() {
|
||||
return (String) this.resourceSpecificProperties.get(CREATOR_ID);
|
||||
return (String) this.resourceProperties.get(CREATOR_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +159,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void setCreatorId(String creatorId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(CREATOR_ID, creatorId);
|
||||
setResourceProperty(CREATOR_ID, creatorId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,7 +167,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public String getConsumerId() {
|
||||
return (String) this.resourceSpecificProperties.get(CONSUMER_ID);
|
||||
return (String) this.resourceProperties.get(CONSUMER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +175,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void setConsumerId(String consumerId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(CONSUMER_ID, consumerId);
|
||||
setResourceProperty(CONSUMER_ID, consumerId);
|
||||
}
|
||||
|
||||
protected Calendar timestampStringToCalendar(long millis){
|
||||
|
@ -180,7 +189,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public Calendar getCreationTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(CREATION_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(CREATION_TIME);
|
||||
return timestampStringToCalendar(millis);
|
||||
}
|
||||
|
||||
|
@ -189,13 +198,13 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void setCreationTime(Calendar creationTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(CREATION_TIME, creationTime.getTimeInMillis());
|
||||
setResourceProperty(CREATION_TIME, creationTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Date getCreateTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(CREATION_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(CREATION_TIME);
|
||||
return timestampStringToCalendar(millis).getTime();
|
||||
}
|
||||
|
||||
|
@ -215,7 +224,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public Calendar getStartTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(START_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(START_TIME);
|
||||
return timestampStringToCalendar(millis);
|
||||
}
|
||||
|
||||
|
@ -225,7 +234,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
* @throws InvalidValueException
|
||||
*/
|
||||
protected void setStartTime(Calendar startTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(START_TIME, startTime.getTimeInMillis());
|
||||
setResourceProperty(START_TIME, startTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
/* *
|
||||
|
@ -245,7 +254,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public Calendar getEndTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(END_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(END_TIME);
|
||||
return timestampStringToCalendar(millis);
|
||||
}
|
||||
|
||||
|
@ -255,7 +264,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
* @throws InvalidValueException
|
||||
*/
|
||||
protected void setEndTime(Calendar endTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(END_TIME, endTime.getTimeInMillis());
|
||||
setResourceProperty(END_TIME, endTime.getTimeInMillis());
|
||||
}
|
||||
|
||||
/* *
|
||||
|
@ -270,13 +279,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getUsageRecordType() {
|
||||
protected String getUsageRecordType() {
|
||||
//return (String) this.resourceSpecificProperties.get(RESOURCE_TYPE);
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
@ -301,7 +304,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public String getResourceScope() {
|
||||
return (String) this.resourceSpecificProperties.get(RESOURCE_SCOPE);
|
||||
return (String) this.resourceProperties.get(RESOURCE_SCOPE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,7 +312,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void setResourceScope(String scope) throws InvalidValueException {
|
||||
setResourceSpecificProperty(RESOURCE_SCOPE, scope);
|
||||
setResourceProperty(RESOURCE_SCOPE, scope);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -318,7 +321,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
@Override
|
||||
@Deprecated
|
||||
public String getResourceOwner() {
|
||||
return (String) this.resourceSpecificProperties.get(RESOURCE_OWNER);
|
||||
return (String) this.resourceProperties.get(RESOURCE_OWNER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,7 +330,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
@Override
|
||||
@Deprecated
|
||||
public void setResourceOwner(String owner) throws InvalidValueException {
|
||||
setResourceSpecificProperty(RESOURCE_OWNER, owner);
|
||||
setResourceProperty(RESOURCE_OWNER, owner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,7 +339,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
@Override
|
||||
@Deprecated
|
||||
public String getAggregatedId() {
|
||||
return (String) this.resourceSpecificProperties.get(AGGREGATED_ID);
|
||||
return (String) this.resourceProperties.get(AGGREGATED_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,7 +348,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
@Override@
|
||||
Deprecated
|
||||
public void setAggregatedId(String aggregatedId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(AGGREGATED_ID, aggregatedId);
|
||||
setResourceProperty(AGGREGATED_ID, aggregatedId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -353,7 +356,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public String getAggregatedUsageRecordId() {
|
||||
return (String) this.resourceSpecificProperties.get(AGGREGATED_USAGE_RECORD_ID);
|
||||
return (String) this.resourceProperties.get(AGGREGATED_USAGE_RECORD_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -361,45 +364,88 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void setAggregatedUsageRecordId(String aggregatedId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(AGGREGATED_USAGE_RECORD_ID, aggregatedId);
|
||||
setResourceProperty(AGGREGATED_USAGE_RECORD_ID, aggregatedId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Map<String, Serializable> getResourceSpecificProperties() {
|
||||
return this.resourceSpecificProperties;
|
||||
return getResourceProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setResourceSpecificProperties(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
validate(properties);
|
||||
this.resourceSpecificProperties = new HashMap<String, Serializable>(properties);
|
||||
setResourceProperties(properties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Serializable> getResourceProperties() {
|
||||
return this.resourceProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setResourceProperties(Map<String, Serializable> properties) throws InvalidValueException {
|
||||
validateProperties(properties);
|
||||
this.resourceProperties = new HashMap<String, Serializable>(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Serializable getResourceSpecificProperty(String key) {
|
||||
return this.resourceSpecificProperties.get(key);
|
||||
return getResourceProperty(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setResourceSpecificProperty(String key, Serializable value) throws InvalidValueException {
|
||||
Serializable checkedValue = validateField(key, value);
|
||||
this.resourceSpecificProperties.put(key, checkedValue);
|
||||
setResourceProperty(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable getResourceProperty(String key) {
|
||||
return this.resourceProperties.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setResourceProperty(String key, Serializable value) throws InvalidValueException {
|
||||
Serializable checkedValue = validateField(key, value);
|
||||
if(checkedValue == null){
|
||||
this.resourceProperties.remove(key);
|
||||
}else{
|
||||
this.resourceProperties.put(key, checkedValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected Serializable validateField(String key, Serializable serializable) throws InvalidValueException {
|
||||
if(key == null){
|
||||
throw new InvalidValueException("The key of property to set cannot be null");
|
||||
}
|
||||
Serializable checkedValue = serializable;
|
||||
List<ValidatorAction> fieldValidators = validation.get(key);
|
||||
if(fieldValidators!=null){
|
||||
|
@ -410,7 +456,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
return checkedValue;
|
||||
}
|
||||
|
||||
protected void validate(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
protected void validateProperties(Map<String, Serializable> properties) throws InvalidValueException{
|
||||
for(String key : properties.keySet()){
|
||||
Serializable serializable = properties.get(key);
|
||||
validateField(key, serializable);
|
||||
|
@ -422,12 +468,22 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void validate() throws InvalidValueException {
|
||||
validate(this.resourceSpecificProperties);
|
||||
validateProperties(this.resourceProperties);
|
||||
Set<String> notPresentProperties = new HashSet<String>();
|
||||
for(String key : this.requiredFields){
|
||||
if(!this.resourceProperties.containsKey(key)){
|
||||
notPresentProperties.add(key);
|
||||
}
|
||||
}
|
||||
if(!notPresentProperties.isEmpty()){
|
||||
String pluralManagement = notPresentProperties.size() == 1 ? "y" : "ies";
|
||||
throw new InvalidValueException(String.format("The Usage Record does not contain the following required propert%s %s", pluralManagement, notPresentProperties.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return resourceSpecificProperties.toString();
|
||||
return resourceProperties.toString();
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,7 +509,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public OperationResult getOperationResult(){
|
||||
return OperationResult.valueOf((String) this.resourceSpecificProperties.get(OPERATION_RESULT));
|
||||
return OperationResult.valueOf((String) this.resourceProperties.get(OPERATION_RESULT));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,7 +518,7 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public void setOperationResult(OperationResult operationResult) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OPERATION_RESULT, operationResult);
|
||||
setResourceProperty(OPERATION_RESULT, operationResult);
|
||||
}
|
||||
|
||||
|
||||
|
@ -479,8 +535,8 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public int compareTo(UsageRecord usageRecord) {
|
||||
Set<Entry<String, Serializable>> thisSet = this.resourceSpecificProperties.entrySet();
|
||||
Set<Entry<String, Serializable>> usageRecordSet = usageRecord.getResourceSpecificProperties().entrySet();
|
||||
Set<Entry<String, Serializable>> thisSet = this.resourceProperties.entrySet();
|
||||
Set<Entry<String, Serializable>> usageRecordSet = usageRecord.getResourceProperties().entrySet();
|
||||
if(thisSet.size() != usageRecordSet.size()){
|
||||
return thisSet.size() - usageRecordSet.size();
|
||||
}
|
||||
|
|
|
@ -125,15 +125,6 @@ public interface UsageRecord extends Comparable<UsageRecord>{
|
|||
public void setEndTime(Date endTime) throws InvalidValueException;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the type of the {#UsageRecord}.
|
||||
* It is a alternative way of obj.getClass().getSimpleName() use this
|
||||
* instead
|
||||
* @return Resource Type
|
||||
*/
|
||||
@Deprecated
|
||||
public String getUsageRecordType();
|
||||
|
||||
/**
|
||||
* Use {#getUsageRecordType} instead
|
||||
* @param resourceType
|
||||
|
@ -214,30 +205,66 @@ public interface UsageRecord extends Comparable<UsageRecord>{
|
|||
public void setAggregatedUsageRecordId(String aggregatedId) throws InvalidValueException;
|
||||
|
||||
/**
|
||||
* Return all resource-specific properties
|
||||
* @return
|
||||
* Return all resource properties
|
||||
* Use {@link #getResourceSpecificProperties()}
|
||||
* @return a Map containing the properties
|
||||
*/
|
||||
@Deprecated
|
||||
public Map<String, Serializable> getResourceSpecificProperties();
|
||||
|
||||
/**
|
||||
* Set all resource properties, replacing existing ones
|
||||
* Use {@link #setResourceSpecificProperties()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setResourceSpecificProperties(Map<String, Serializable> resourceSpecificProperties) throws InvalidValueException;
|
||||
|
||||
/**
|
||||
* Return all resource-specific properties
|
||||
* @return a Map containing the properties
|
||||
*/
|
||||
public Map<String, Serializable> getResourceProperties();
|
||||
|
||||
/**
|
||||
* Set all resource-specific properties, replacing existing ones
|
||||
*/
|
||||
public void setResourceSpecificProperties(Map<String, Serializable> resourceSpecificProperties) throws InvalidValueException;
|
||||
public void setResourceProperties(Map<String, Serializable> resourceSpecificProperties) throws InvalidValueException;
|
||||
|
||||
|
||||
/**
|
||||
* Return the value of the given resource-specific property
|
||||
* @param key
|
||||
* @return the value of the given resource-specific property
|
||||
* Return the value of the given resource property.
|
||||
* @param key the key of the requested property
|
||||
* @return the value of the given resource property
|
||||
*/
|
||||
@Deprecated
|
||||
public Serializable getResourceSpecificProperty(String key);
|
||||
|
||||
/**
|
||||
* Set the value of the given resource-specific property
|
||||
* @param key
|
||||
* @param value
|
||||
* Set the value of the given resource property.
|
||||
* If the key has the value of one of the predefined property, the value
|
||||
* is validated.
|
||||
* @param key the key of the requested property
|
||||
* @param value the value of the given resource property
|
||||
*/
|
||||
@Deprecated
|
||||
public void setResourceSpecificProperty(String key, Serializable value) throws InvalidValueException;
|
||||
|
||||
/**
|
||||
* Return the value of the given resource property.
|
||||
* @param key the key of the requested property
|
||||
* @return the value of the given resource property
|
||||
*/
|
||||
public Serializable getResourceProperty(String key);
|
||||
|
||||
/**
|
||||
* Set the value of the given resource property.
|
||||
* If the key has the value of one of the predefined property, the value
|
||||
* is validated.
|
||||
* @param key the key of the requested property
|
||||
* @param value the value of the given resource property
|
||||
*/
|
||||
public void setResourceProperty(String key, Serializable value) throws InvalidValueException;
|
||||
|
||||
/**
|
||||
* The method is deprecated and the implementations in known classes
|
||||
* return Consumer ID
|
||||
|
|
|
@ -58,7 +58,7 @@ public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
* @return the Job Id
|
||||
*/
|
||||
public String getJobId() {
|
||||
return (String) this.resourceSpecificProperties.get(JOB_ID);
|
||||
return (String) this.resourceProperties.get(JOB_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,69 +66,69 @@ public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
public void setJobId(String jobId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(JOB_ID, jobId);
|
||||
setResourceProperty(JOB_ID, jobId);
|
||||
}
|
||||
|
||||
public String getJobQualifier() {
|
||||
return (String) this.resourceSpecificProperties.get(JOB_QUALIFIER);
|
||||
return (String) this.resourceProperties.get(JOB_QUALIFIER);
|
||||
}
|
||||
|
||||
public void setJobQualifier(String jobQualifier) throws InvalidValueException {
|
||||
setResourceSpecificProperty(JOB_QUALIFIER, jobQualifier);
|
||||
setResourceProperty(JOB_QUALIFIER, jobQualifier);
|
||||
}
|
||||
|
||||
public String getJobName() {
|
||||
return (String) this.resourceSpecificProperties.get(JOB_NAME);
|
||||
return (String) this.resourceProperties.get(JOB_NAME);
|
||||
}
|
||||
|
||||
public void setJobName(String jobName) throws InvalidValueException {
|
||||
setResourceSpecificProperty(JOB_NAME, jobName);
|
||||
setResourceProperty(JOB_NAME, jobName);
|
||||
}
|
||||
|
||||
public Calendar getJobStartTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(JOB_START_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(JOB_START_TIME);
|
||||
return timestampStringToCalendar(millis);
|
||||
}
|
||||
|
||||
public void setJobStartTime(Calendar jobStartTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(JOB_START_TIME, jobStartTime.getTimeInMillis());
|
||||
setResourceProperty(JOB_START_TIME, jobStartTime.getTimeInMillis());
|
||||
|
||||
}
|
||||
|
||||
public Calendar getJobEndTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(JOB_END_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(JOB_END_TIME);
|
||||
return timestampStringToCalendar(millis);
|
||||
}
|
||||
|
||||
public void setJobEndTime(Calendar jobEndTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(JOB_END_TIME, jobEndTime.getTimeInMillis());
|
||||
setResourceProperty(JOB_END_TIME, jobEndTime.getTimeInMillis());
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public JobStatus getJobStatus() {
|
||||
return JobStatus.values()[((OperationResult) this.resourceSpecificProperties.get(OPERATION_RESULT)).ordinal()];
|
||||
return JobStatus.values()[((OperationResult) this.resourceProperties.get(OPERATION_RESULT)).ordinal()];
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setJobStatus(JobStatus jobStatus) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OPERATION_RESULT, OperationResult.values()[jobStatus.ordinal()]);
|
||||
setResourceProperty(OPERATION_RESULT, OperationResult.values()[jobStatus.ordinal()]);
|
||||
}
|
||||
|
||||
public int getVmsUsed() {
|
||||
return (Integer) this.resourceSpecificProperties.get(VMS_USED);
|
||||
return (Integer) this.resourceProperties.get(VMS_USED);
|
||||
}
|
||||
|
||||
public void setVmsUsed(int vmsUsed) throws InvalidValueException {
|
||||
setResourceSpecificProperty(VMS_USED, vmsUsed);
|
||||
setResourceProperty(VMS_USED, vmsUsed);
|
||||
}
|
||||
|
||||
protected void calculateWallDuration() throws InvalidValueException {
|
||||
try {
|
||||
long endTime = (Long) this.resourceSpecificProperties.get(JOB_END_TIME);
|
||||
long startTime = (Long) this.resourceSpecificProperties.get(JOB_START_TIME);
|
||||
long endTime = (Long) this.resourceProperties.get(JOB_END_TIME);
|
||||
long startTime = (Long) this.resourceProperties.get(JOB_START_TIME);
|
||||
long wallDuration = endTime - startTime;
|
||||
setResourceSpecificProperty(WALL_DURATION, wallDuration);
|
||||
setResourceProperty(WALL_DURATION, wallDuration);
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(String.format("To calculate Wall Duration both %s and %s must be set",
|
||||
START_TIME, END_TIME), e.getCause());
|
||||
|
@ -136,7 +136,7 @@ public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
}
|
||||
|
||||
public long getWallDuration() throws InvalidValueException {
|
||||
Long wallDuration = (Long) this.resourceSpecificProperties.get(WALL_DURATION);
|
||||
Long wallDuration = (Long) this.resourceProperties.get(WALL_DURATION);
|
||||
if(wallDuration == null){
|
||||
calculateWallDuration();
|
||||
}
|
||||
|
|
|
@ -37,28 +37,28 @@ public class PortletUsageRecord extends RawUsageRecord implements SingleUsageRec
|
|||
|
||||
@Deprecated
|
||||
public String getUserId() {
|
||||
return (String) this.resourceSpecificProperties.get(USER_ID);
|
||||
return (String) this.resourceProperties.get(USER_ID);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setUserId(String userId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(USER_ID, userId);
|
||||
setResourceProperty(USER_ID, userId);
|
||||
}
|
||||
|
||||
public String getPortletId() {
|
||||
return (String) this.resourceSpecificProperties.get(PORTLET_ID);
|
||||
return (String) this.resourceProperties.get(PORTLET_ID);
|
||||
}
|
||||
|
||||
public void setPortletId(String portletId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(PORTLET_ID, portletId);
|
||||
setResourceProperty(PORTLET_ID, portletId);
|
||||
}
|
||||
|
||||
public String getOperationId() {
|
||||
return (String) this.resourceSpecificProperties.get(OPERATION_ID);
|
||||
return (String) this.resourceProperties.get(OPERATION_ID);
|
||||
}
|
||||
|
||||
public void setOperationId(String operationId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OPERATION_ID, operationId);
|
||||
setResourceProperty(OPERATION_ID, operationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,75 +48,75 @@ public class ServiceUsageRecord extends RawUsageRecord implements SingleUsageRec
|
|||
}
|
||||
|
||||
public String getCallerIP() {
|
||||
return (String) this.resourceSpecificProperties.get(CALLER_IP);
|
||||
return (String) this.resourceProperties.get(CALLER_IP);
|
||||
}
|
||||
|
||||
public void setCallerIP(String callerIP) throws InvalidValueException {
|
||||
setResourceSpecificProperty(CALLER_IP, callerIP);
|
||||
setResourceProperty(CALLER_IP, callerIP);
|
||||
}
|
||||
|
||||
public String getCallerScope() {
|
||||
return (String) this.resourceSpecificProperties.get(CALLER_SCOPE);
|
||||
return (String) this.resourceProperties.get(CALLER_SCOPE);
|
||||
}
|
||||
|
||||
public void setCallerScope(String callerScope) throws InvalidValueException {
|
||||
setResourceSpecificProperty(CALLER_SCOPE, callerScope);
|
||||
setResourceProperty(CALLER_SCOPE, callerScope);
|
||||
}
|
||||
|
||||
public String getRefHost() {
|
||||
return (String) this.resourceSpecificProperties.get(REF_HOST);
|
||||
return (String) this.resourceProperties.get(REF_HOST);
|
||||
}
|
||||
|
||||
public void setRefHost(String refHost) throws InvalidValueException {
|
||||
setResourceSpecificProperty(REF_HOST, refHost);
|
||||
setResourceProperty(REF_HOST, refHost);
|
||||
}
|
||||
|
||||
public String getRefVM() {
|
||||
return (String) this.resourceSpecificProperties.get(REF_VM);
|
||||
return (String) this.resourceProperties.get(REF_VM);
|
||||
}
|
||||
|
||||
public void setRefVM(String refVM) throws InvalidValueException {
|
||||
setResourceSpecificProperty(REF_VM, refVM);
|
||||
setResourceProperty(REF_VM, refVM);
|
||||
}
|
||||
|
||||
protected String getDomain() {
|
||||
return (String) this.resourceSpecificProperties.get(DOMAIN);
|
||||
return (String) this.resourceProperties.get(DOMAIN);
|
||||
}
|
||||
|
||||
protected void setDomain(String domain) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DOMAIN, domain);
|
||||
setResourceProperty(DOMAIN, domain);
|
||||
}
|
||||
|
||||
public String getInvocationCount() {
|
||||
return (String) this.resourceSpecificProperties.get(INVOCATION_COUNT);
|
||||
return (String) this.resourceProperties.get(INVOCATION_COUNT);
|
||||
}
|
||||
|
||||
public void setInvocationCount(String invocationCount) throws InvalidValueException {
|
||||
setResourceSpecificProperty(INVOCATION_COUNT, invocationCount);
|
||||
setResourceProperty(INVOCATION_COUNT, invocationCount);
|
||||
}
|
||||
|
||||
public String getAverageInvocationTime() {
|
||||
return (String) this.resourceSpecificProperties.get(AVERAGE_INVOCATION_COUNT);
|
||||
return (String) this.resourceProperties.get(AVERAGE_INVOCATION_COUNT);
|
||||
}
|
||||
|
||||
public void setAverageInvocationTime(String averageInvocationTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(AVERAGE_INVOCATION_COUNT, averageInvocationTime);
|
||||
setResourceProperty(AVERAGE_INVOCATION_COUNT, averageInvocationTime);
|
||||
}
|
||||
|
||||
public String getServiceClass() {
|
||||
return (String) this.resourceSpecificProperties.get(SERVICE_CLASS);
|
||||
return (String) this.resourceProperties.get(SERVICE_CLASS);
|
||||
}
|
||||
|
||||
public void setServiceClass(String serviceClass) throws InvalidValueException {
|
||||
setResourceSpecificProperty(SERVICE_CLASS, serviceClass);
|
||||
setResourceProperty(SERVICE_CLASS, serviceClass);
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return (String) this.resourceSpecificProperties.get(SERVICE_NAME);
|
||||
return (String) this.resourceProperties.get(SERVICE_NAME);
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) throws InvalidValueException {
|
||||
setResourceSpecificProperty(SERVICE_NAME, serviceName);
|
||||
setResourceProperty(SERVICE_NAME, serviceName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,67 +46,67 @@ public class StorageUsageUsageRecord extends RawUsageRecord implements SingleUsa
|
|||
}
|
||||
|
||||
public String getObjectURI() {
|
||||
return (String) this.resourceSpecificProperties.get(OBJECT_URI);
|
||||
return (String) this.resourceProperties.get(OBJECT_URI);
|
||||
}
|
||||
|
||||
public void setObjectURI(String objectURI) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OBJECT_URI, objectURI);
|
||||
setResourceProperty(OBJECT_URI, objectURI);
|
||||
}
|
||||
|
||||
public String getOperationType() {
|
||||
return (String) this.resourceSpecificProperties.get(OPERATION_TYPE);
|
||||
return (String) this.resourceProperties.get(OPERATION_TYPE);
|
||||
}
|
||||
|
||||
public void setOperationType(String operationType) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OPERATION_TYPE, operationType);
|
||||
setResourceProperty(OPERATION_TYPE, operationType);
|
||||
}
|
||||
|
||||
public String getCallerIP() {
|
||||
return (String) this.resourceSpecificProperties.get(CALLER_IP);
|
||||
return (String) this.resourceProperties.get(CALLER_IP);
|
||||
}
|
||||
|
||||
public void setCallerIP(String callerIP) throws InvalidValueException {
|
||||
setResourceSpecificProperty(CALLER_IP, callerIP);
|
||||
setResourceProperty(CALLER_IP, callerIP);
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return (String) this.resourceSpecificProperties.get(PROVIDER_ID);
|
||||
return (String) this.resourceProperties.get(PROVIDER_ID);
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(PROVIDER_ID, providerId);
|
||||
setResourceProperty(PROVIDER_ID, providerId);
|
||||
}
|
||||
|
||||
public String getQualifier() {
|
||||
return (String) this.resourceSpecificProperties.get(QUALIFIER);
|
||||
return (String) this.resourceProperties.get(QUALIFIER);
|
||||
}
|
||||
|
||||
public void setQualifier(String qualifier) throws InvalidValueException {
|
||||
setResourceSpecificProperty(QUALIFIER, qualifier);
|
||||
setResourceProperty(QUALIFIER, qualifier);
|
||||
}
|
||||
|
||||
public String getDataType() {
|
||||
return (String) this.resourceSpecificProperties.get(DATA_TYPE);
|
||||
return (String) this.resourceProperties.get(DATA_TYPE);
|
||||
}
|
||||
|
||||
public void setDataType(String dataType) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DATA_TYPE, dataType);
|
||||
setResourceProperty(DATA_TYPE, dataType);
|
||||
}
|
||||
|
||||
public long getDataVolume() {
|
||||
return (Long) this.resourceSpecificProperties.get(DATA_VOLUME);
|
||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||
}
|
||||
|
||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DATA_VOLUME, dataVolume);
|
||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||
}
|
||||
|
||||
public int getDataCount() {
|
||||
return (Integer) this.resourceSpecificProperties.get(DATA_COUNT);
|
||||
return (Integer) this.resourceProperties.get(DATA_COUNT);
|
||||
}
|
||||
|
||||
public void setDataCount(int dataCount) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DATA_COUNT, dataCount);
|
||||
setResourceProperty(DATA_COUNT, dataCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ public class StorageUsageUsageRecord extends RawUsageRecord implements SingleUsa
|
|||
*/
|
||||
@Override
|
||||
public String getResourceOwner() {
|
||||
return (String) this.resourceSpecificProperties.get(RESOURCE_OWNER);
|
||||
return (String) this.resourceProperties.get(RESOURCE_OWNER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ public class StorageUsageUsageRecord extends RawUsageRecord implements SingleUsa
|
|||
*/
|
||||
@Override
|
||||
public void setResourceOwner(String owner) throws InvalidValueException {
|
||||
setResourceSpecificProperty(RESOURCE_OWNER, owner);
|
||||
setResourceProperty(RESOURCE_OWNER, owner);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
* @return the Job Id
|
||||
*/
|
||||
public String getJobId() {
|
||||
return (String) this.resourceSpecificProperties.get(JOB_ID);
|
||||
return (String) this.resourceProperties.get(JOB_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,23 +78,23 @@ public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
* @throws InvalidValueException if fails
|
||||
*/
|
||||
public void setJobId(String jobId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(JOB_ID, jobId);
|
||||
setResourceProperty(JOB_ID, jobId);
|
||||
}
|
||||
|
||||
public String getRefHost() {
|
||||
return (String) this.resourceSpecificProperties.get(REF_HOST);
|
||||
return (String) this.resourceProperties.get(REF_HOST);
|
||||
}
|
||||
|
||||
public void setRefHost(String refHost) throws InvalidValueException {
|
||||
setResourceSpecificProperty(REF_HOST, refHost);
|
||||
setResourceProperty(REF_HOST, refHost);
|
||||
}
|
||||
|
||||
public String getRefVM() {
|
||||
return (String) this.resourceSpecificProperties.get(REF_VM);
|
||||
return (String) this.resourceProperties.get(REF_VM);
|
||||
}
|
||||
|
||||
public void setRefVM(String refVM) throws InvalidValueException {
|
||||
setResourceSpecificProperty(REF_VM, refVM);
|
||||
setResourceProperty(REF_VM, refVM);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -103,100 +103,100 @@ public class TaskUsageRecord extends RawUsageRecord implements SingleUsageRecord
|
|||
}
|
||||
|
||||
private void setDomain(String domain) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DOMAIN, domain);
|
||||
setResourceProperty(DOMAIN, domain);
|
||||
}
|
||||
*/
|
||||
|
||||
public Calendar getUsageStartTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(USAGE_START_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(USAGE_START_TIME);
|
||||
return timestampStringToCalendar(millis);
|
||||
}
|
||||
|
||||
public void setUsageStartTime(Calendar usageStartTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(USAGE_START_TIME, usageStartTime.getTimeInMillis());
|
||||
setResourceProperty(USAGE_START_TIME, usageStartTime.getTimeInMillis());
|
||||
|
||||
}
|
||||
|
||||
public Calendar getUsageEndTime() {
|
||||
long millis = (Long) this.resourceSpecificProperties.get(USAGE_END_TIME);
|
||||
long millis = (Long) this.resourceProperties.get(USAGE_END_TIME);
|
||||
return timestampStringToCalendar(millis);
|
||||
}
|
||||
|
||||
public void setUsageEndTime(Calendar usageEndTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(USAGE_END_TIME, usageEndTime.getTimeInMillis());
|
||||
setResourceProperty(USAGE_END_TIME, usageEndTime.getTimeInMillis());
|
||||
|
||||
}
|
||||
|
||||
public USAGE_PHASE getUsagePhase() {
|
||||
return (USAGE_PHASE) this.resourceSpecificProperties.get(USAGE_PHASE);
|
||||
return (USAGE_PHASE) this.resourceProperties.get(USAGE_PHASE);
|
||||
}
|
||||
|
||||
public void setUsagePhase(USAGE_PHASE usagePhase) throws InvalidValueException {
|
||||
setResourceSpecificProperty(USAGE_PHASE, usagePhase);
|
||||
setResourceProperty(USAGE_PHASE, usagePhase);
|
||||
}
|
||||
|
||||
public int getInputFilesNumber() {
|
||||
return (Integer) this.resourceSpecificProperties.get(INPUT_FILES_NUMBER);
|
||||
return (Integer) this.resourceProperties.get(INPUT_FILES_NUMBER);
|
||||
}
|
||||
|
||||
public void setInputFilesNumber(int inputFilesNumber) throws InvalidValueException {
|
||||
setResourceSpecificProperty(INPUT_FILES_NUMBER, inputFilesNumber);
|
||||
setResourceProperty(INPUT_FILES_NUMBER, inputFilesNumber);
|
||||
}
|
||||
|
||||
public long getInputFilesSize() {
|
||||
return (Long) this.resourceSpecificProperties.get(INPUT_FILES_SIZE);
|
||||
return (Long) this.resourceProperties.get(INPUT_FILES_SIZE);
|
||||
}
|
||||
|
||||
public void setInputFilesSize(long inputFilesSize) throws InvalidValueException {
|
||||
setResourceSpecificProperty(INPUT_FILES_SIZE, inputFilesSize);
|
||||
setResourceProperty(INPUT_FILES_SIZE, inputFilesSize);
|
||||
}
|
||||
|
||||
public int getOutputFilesNumber() {
|
||||
return (Integer) this.resourceSpecificProperties.get(OUTPUT_FILES_NUMBER);
|
||||
return (Integer) this.resourceProperties.get(OUTPUT_FILES_NUMBER);
|
||||
}
|
||||
|
||||
public void setOutputFilesNumber(int outputFilesNumber) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OUTPUT_FILES_NUMBER, outputFilesNumber);
|
||||
setResourceProperty(OUTPUT_FILES_NUMBER, outputFilesNumber);
|
||||
}
|
||||
|
||||
public long getOutputFilesSize() {
|
||||
return (Long) this.resourceSpecificProperties.get(OUTPUT_FILES_SIZE);
|
||||
return (Long) this.resourceProperties.get(OUTPUT_FILES_SIZE);
|
||||
}
|
||||
|
||||
public void setOutputFilesSize(long outputFilesSize) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OUTPUT_FILES_SIZE, outputFilesSize);
|
||||
setResourceProperty(OUTPUT_FILES_SIZE, outputFilesSize);
|
||||
}
|
||||
|
||||
public long getOverallNetworkIn() {
|
||||
return (Long) this.resourceSpecificProperties.get(OVERALL_NETWORK_IN);
|
||||
return (Long) this.resourceProperties.get(OVERALL_NETWORK_IN);
|
||||
}
|
||||
|
||||
public void setOverallNetworkIn(long overallNetworkIn) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OVERALL_NETWORK_IN, overallNetworkIn);
|
||||
setResourceProperty(OVERALL_NETWORK_IN, overallNetworkIn);
|
||||
}
|
||||
|
||||
public long getOverallNetworkOut() {
|
||||
return (Long) this.resourceSpecificProperties.get(OVERALL_NETWORK_OUT);
|
||||
return (Long) this.resourceProperties.get(OVERALL_NETWORK_OUT);
|
||||
}
|
||||
|
||||
public void setOverallNetworkOut(long overallNetworkOut) throws InvalidValueException {
|
||||
setResourceSpecificProperty(OVERALL_NETWORK_OUT, overallNetworkOut);
|
||||
setResourceProperty(OVERALL_NETWORK_OUT, overallNetworkOut);
|
||||
}
|
||||
|
||||
public int getCores() {
|
||||
return (Integer) this.resourceSpecificProperties.get(CORES);
|
||||
return (Integer) this.resourceProperties.get(CORES);
|
||||
}
|
||||
|
||||
public void setCores(int cores) throws InvalidValueException {
|
||||
setResourceSpecificProperty(CORES, cores);
|
||||
setResourceProperty(CORES, cores);
|
||||
}
|
||||
|
||||
public int getProcessors() {
|
||||
return (Integer) this.resourceSpecificProperties.get(PROCESSORS);
|
||||
return (Integer) this.resourceProperties.get(PROCESSORS);
|
||||
}
|
||||
|
||||
public void setProcessors(int processors) throws InvalidValueException {
|
||||
setResourceSpecificProperty(PROCESSORS, processors);
|
||||
setResourceProperty(PROCESSORS, processors);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,19 +32,19 @@ public class ServiceUsageRecord extends org.gcube.accounting.datamodel.implement
|
|||
|
||||
|
||||
public String getInvocationCount() {
|
||||
return (String) this.resourceSpecificProperties.get(INVOCATION_COUNT);
|
||||
return (String) this.resourceProperties.get(INVOCATION_COUNT);
|
||||
}
|
||||
|
||||
public void setInvocationCount(String invocationCount) throws InvalidValueException {
|
||||
setResourceSpecificProperty(INVOCATION_COUNT, invocationCount);
|
||||
setResourceProperty(INVOCATION_COUNT, invocationCount);
|
||||
}
|
||||
|
||||
public String getAverageInvocationTime() {
|
||||
return (String) this.resourceSpecificProperties.get(AVERAGE_INVOCATION_COUNT);
|
||||
return (String) this.resourceProperties.get(AVERAGE_INVOCATION_COUNT);
|
||||
}
|
||||
|
||||
public void setAverageInvocationTime(String averageInvocationTime) throws InvalidValueException {
|
||||
setResourceSpecificProperty(AVERAGE_INVOCATION_COUNT, averageInvocationTime);
|
||||
setResourceProperty(AVERAGE_INVOCATION_COUNT, averageInvocationTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,43 +36,43 @@ public class StorageStatusUsageRecord extends RawUsageRecord {
|
|||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return (String) this.resourceSpecificProperties.get(PROVIDER_ID);
|
||||
return (String) this.resourceProperties.get(PROVIDER_ID);
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) throws InvalidValueException {
|
||||
setResourceSpecificProperty(PROVIDER_ID, providerId);
|
||||
setResourceProperty(PROVIDER_ID, providerId);
|
||||
}
|
||||
|
||||
public String getQualifier() {
|
||||
return (String) this.resourceSpecificProperties.get(QUALIFIER);
|
||||
return (String) this.resourceProperties.get(QUALIFIER);
|
||||
}
|
||||
|
||||
public void setQualifier(String qualifier) throws InvalidValueException {
|
||||
setResourceSpecificProperty(QUALIFIER, qualifier);
|
||||
setResourceProperty(QUALIFIER, qualifier);
|
||||
}
|
||||
|
||||
public String getDataType() {
|
||||
return (String) this.resourceSpecificProperties.get(DATA_TYPE);
|
||||
return (String) this.resourceProperties.get(DATA_TYPE);
|
||||
}
|
||||
|
||||
public void setDataType(String dataType) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DATA_TYPE, dataType);
|
||||
setResourceProperty(DATA_TYPE, dataType);
|
||||
}
|
||||
|
||||
public long getDataVolume() {
|
||||
return (Long) this.resourceSpecificProperties.get(DATA_VOLUME);
|
||||
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
||||
}
|
||||
|
||||
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DATA_VOLUME, dataVolume);
|
||||
setResourceProperty(DATA_VOLUME, dataVolume);
|
||||
}
|
||||
|
||||
public int getDataCount() {
|
||||
return (Integer) this.resourceSpecificProperties.get(DATA_COUNT);
|
||||
return (Integer) this.resourceProperties.get(DATA_COUNT);
|
||||
}
|
||||
|
||||
public void setDataCount(int dataCount) throws InvalidValueException {
|
||||
setResourceSpecificProperty(DATA_COUNT, dataCount);
|
||||
setResourceProperty(DATA_COUNT, dataCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ResourceAccounting {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public void sendAccountingMessage(@SuppressWarnings("rawtypes") RawUsageRecord message){
|
||||
public void sendAccountingMessage(RawUsageRecord message){
|
||||
persistence.account(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ public class CouchDBPersistence extends Persistence {
|
|||
|
||||
public static JsonNode usageRecordToJsonNode(UsageRecord usageRecord) throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode node = mapper.valueToTree(usageRecord.getResourceSpecificProperties());
|
||||
JsonNode node = mapper.valueToTree(usageRecord.getResourceProperties());
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ public abstract class Persistence {
|
|||
//usageRecord.setStartTime(startTime);
|
||||
//usageRecord.setEndTime(endTime);
|
||||
|
||||
usageRecord.setResourceSpecificProperty("ConnectionTest", "Test");
|
||||
usageRecord.setResourceProperty("ConnectionTest", "Test");
|
||||
|
||||
} catch (InvalidValueException e1) {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class RawUsageRecordTest {
|
|||
@Test
|
||||
public void testCompareToEqualsObject() throws Exception {
|
||||
UsageRecord usageRecord = Persistence.createTestRawUsageRecord();
|
||||
UsageRecord ur = RawUsageRecord.getUsageRecord(usageRecord.getResourceSpecificProperties());
|
||||
UsageRecord ur = RawUsageRecord.getUsageRecord(usageRecord.getResourceProperties());
|
||||
Assert.assertEquals(0, usageRecord.compareTo(ur));
|
||||
Assert.assertEquals(0, ur.compareTo(usageRecord));
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ public class RawUsageRecordTest {
|
|||
@Test
|
||||
public void testCompareToComparedAddedProperty() throws Exception {
|
||||
UsageRecord usageRecord = Persistence.createTestRawUsageRecord();
|
||||
UsageRecord ur = RawUsageRecord.getUsageRecord(usageRecord.getResourceSpecificProperties());
|
||||
UsageRecord ur = RawUsageRecord.getUsageRecord(usageRecord.getResourceProperties());
|
||||
for(int i=1; i<31; i++){
|
||||
ur.setResourceSpecificProperty(Integer.toString(i), i);
|
||||
ur.setResourceProperty(Integer.toString(i), i);
|
||||
Assert.assertEquals(-i, usageRecord.compareTo(ur));
|
||||
Assert.assertEquals(i, ur.compareTo(usageRecord));
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ public class RawUsageRecordTest {
|
|||
@Test
|
||||
public void testCompareToDifferentForAddedProperties() throws Exception {
|
||||
UsageRecord usageRecord = Persistence.createTestRawUsageRecord();
|
||||
UsageRecord ur = RawUsageRecord.getUsageRecord(usageRecord.getResourceSpecificProperties());
|
||||
usageRecord.setResourceSpecificProperty(Integer.toString(1), 2);
|
||||
ur.setResourceSpecificProperty(Integer.toString(2), 2);
|
||||
UsageRecord ur = RawUsageRecord.getUsageRecord(usageRecord.getResourceProperties());
|
||||
usageRecord.setResourceProperty(Integer.toString(1), 2);
|
||||
ur.setResourceProperty(Integer.toString(2), 2);
|
||||
Assert.assertEquals(1, usageRecord.compareTo(ur));
|
||||
Assert.assertEquals(1, ur.compareTo(usageRecord));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue