accounting-lib/src/main/java/org/gcube/accounting/datamodel/implementations/ServiceUsageRecord.java

120 lines
3.0 KiB
Java
Raw Normal View History

/**
*
*/
package org.gcube.accounting.datamodel.implementations;
import java.io.Serializable;
import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.SingleUsageRecord;
import org.gcube.accounting.datamodel.decorators.RequiredField;
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
import org.gcube.accounting.datamodel.validations.annotations.ValidIP;
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.accounting.exception.InvalidValueException;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class ServiceUsageRecord extends BasicUsageRecord implements SingleUsageRecord {
/**
* Generated Serial Version UID
*/
private static final long serialVersionUID = -4214891294699473587L;
/**
* KEY for : IP address that originated the service call
*/
@ValidIP
public static final String CALLER_IP = "callerIP";
/**
* KEY for : hostname:port of the Hosting Node
*/
@RequiredField @NotEmpty
public static final String REF_HOST = "refHost";
/**
* KEY for : Hosting Node ID
*/
@RequiredField @NotEmpty
public static final String REF_VM = "refVM";
/**
* KEY for : Service Class
*/
@RequiredField @NotEmpty
public static final String SERVICE_CLASS = "serviceClass";
/**
* KEY for : Service Name
*/
@RequiredField @NotEmpty
public static final String SERVICE_NAME = "serviceName";
/**
* KEY for : Service Name
*/
@RequiredField @ValidLong
public static final String DURATION = "duration";
public ServiceUsageRecord(){
super();
}
public ServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
super(properties);
}
public String getCallerIP() {
return (String) this.resourceProperties.get(CALLER_IP);
}
public void setCallerIP(String callerIP) throws InvalidValueException {
setResourceProperty(CALLER_IP, callerIP);
}
public String getRefHost() {
return (String) this.resourceProperties.get(REF_HOST);
}
public void setRefHost(String refHost) throws InvalidValueException {
setResourceProperty(REF_HOST, refHost);
}
public String getRefVM() {
return (String) this.resourceProperties.get(REF_VM);
}
public void setRefVM(String refVM) throws InvalidValueException {
setResourceProperty(REF_VM, refVM);
}
public String getServiceClass() {
return (String) this.resourceProperties.get(SERVICE_CLASS);
}
public void setServiceClass(String serviceClass) throws InvalidValueException {
setResourceProperty(SERVICE_CLASS, serviceClass);
}
public String getServiceName() {
return (String) this.resourceProperties.get(SERVICE_NAME);
}
public void setServiceName(String serviceName) throws InvalidValueException {
setResourceProperty(SERVICE_NAME, serviceName);
}
public Long getDuration() {
return (Long) this.resourceProperties.get(DURATION);
}
public void setDuration(Long duration) throws InvalidValueException {
setResourceProperty(DURATION, duration);
}
}