Added calledMethod field

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@117179 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-07-13 09:26:50 +00:00
parent 196351946f
commit c1867e56ce
4 changed files with 22 additions and 4 deletions

View File

@ -22,6 +22,7 @@ public class ServiceUsageRecordAggregationStrategy extends AggregationStrategy<S
this.aggregationField.add(ServiceUsageRecord.HOST);
this.aggregationField.add(ServiceUsageRecord.SERVICE_CLASS);
this.aggregationField.add(ServiceUsageRecord.SERVICE_NAME);
this.aggregationField.add(ServiceUsageRecord.CALLED_METHOD);
}
protected long durationWeightedAverage(ServiceUsageRecord record){

View File

@ -27,7 +27,7 @@ public abstract class ServiceUsageRecord extends BasicUsageRecord {
* KEY for : hostname:port of the Hosting Node made the service call
*/
@RequiredField @NotEmpty
public static final String CALLER_HOST = "callerHOST";
public static final String CALLER_HOST = "callerHost";
/**
* KEY for : hostname:port of the Hosting Node receiving the service call
@ -47,6 +47,12 @@ public abstract class ServiceUsageRecord extends BasicUsageRecord {
@RequiredField @NotEmpty
public static final String SERVICE_NAME = "serviceName";
/**
* KEY for : Service Name
*/
@RequiredField @NotEmpty
public static final String CALLED_METHOD = "calledMethod";
/**
* KEY for : Service Name
*/
@ -93,10 +99,18 @@ public abstract class ServiceUsageRecord extends BasicUsageRecord {
setResourceProperty(SERVICE_NAME, serviceName);
}
public String getCalledMethod() {
return (String) this.resourceProperties.get(CALLED_METHOD);
}
public void setCalledMethod(String calledMethod) throws InvalidValueException {
setResourceProperty(CALLED_METHOD, calledMethod);
}
public Long getDuration() {
return (Long) this.resourceProperties.get(DURATION);
}
public void setDuration(Long duration) throws InvalidValueException {
setResourceProperty(DURATION, duration);
}

View File

@ -27,6 +27,7 @@ public class TestUsageRecord {
public final static String TEST_SERVICE_CLASS = "TestServiceClass";
public final static String TEST_SERVICE_NAME = "TestServiceName";
public final static String TEST_CALLED_METHOD = "TestCalledMethod";
public final static String TEST_CALLER_HOST = "remotehost";
public final static String TEST_HOST = "localhost";
@ -61,8 +62,9 @@ public class TestUsageRecord {
usageRecord.setHost(TEST_HOST);
usageRecord.setServiceClass(TEST_SERVICE_CLASS);
usageRecord.setServiceName(TEST_SERVICE_NAME);
usageRecord.setServiceName(TEST_SERVICE_NAME);
usageRecord.setCalledMethod(TEST_CALLED_METHOD);
usageRecord.setDuration(generateRandomLong(MIN_DURATION, MAX_DURATION));

View File

@ -30,6 +30,7 @@ public class ServiceUsageRecordTest {
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.HOST);
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.SERVICE_CLASS);
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.SERVICE_NAME);
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.CALLED_METHOD);
expectedRequiredFields.add(org.gcube.accounting.datamodel.basetypes.ServiceUsageRecord.DURATION);
return expectedRequiredFields;
}