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@115289 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-06-10 12:01:33 +00:00
parent 80f9872aff
commit 3a2792d7d5
7 changed files with 20 additions and 17 deletions

View File

@ -494,11 +494,14 @@ public abstract class RawUsageRecord implements UsageRecord, Serializable {
List<FieldAction> fieldValidators = validation.get(key);
if(fieldValidators!=null){
for(FieldAction fieldValidator : fieldValidators){
if(aggregatedFields.contains(key)){
// TODO
}
if(computedFields.contains(key)){
logger.debug("{} is a computed field. To be calculated all the required fields to calcutalate it MUST be set. "
+ "In any case the provided value is ignored.");
}
checkedValue = fieldValidator.validate(key, checkedValue, this);
/*
* Check here if the key is for a ComputedField or for an
* AggregatedField
*/
}
}
return checkedValue;

View File

@ -23,13 +23,17 @@ import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.accounting.exception.InvalidValueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord {
private static Logger logger = LoggerFactory.getLogger(JobUsageRecord.class);
/**
* Generated Serial Version UID
*/
@ -67,14 +71,11 @@ public class JobUsageRecord extends RawUsageRecord implements SingleUsageRecord
try {
long wallDuration = calculateWallDuration();
if(key.compareTo(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.",
WALL_DURATION, JOB_START_TIME, JOB_END_TIME);
value = wallDuration;
}
}catch(InvalidValueException e){
if(key.compareTo(WALL_DURATION)==0){
throw new InvalidValueException(String.format("Unable to set %s. %s and %s MUST be set before.", WALL_DURATION,
JOB_START_TIME, JOB_END_TIME));
}
}
}catch(InvalidValueException e){ }
return value;
}
}

View File

@ -36,7 +36,7 @@ public class JobUsageRecord extends org.gcube.accounting.datamodel.implementatio
*/
@Override
public List<JobUsageRecord> aggregate(List<JobUsageRecord> records) {
// TODO implements
// TODO
throw new UnsupportedOperationException();
}

View File

@ -37,7 +37,7 @@ public class PortletUsageRecord extends org.gcube.accounting.datamodel.implement
*/
@Override
public List<PortletUsageRecord> aggregate(List<PortletUsageRecord> records) {
// TODO implements
// TODO
throw new UnsupportedOperationException();
}

View File

@ -59,7 +59,7 @@ public class ServiceUsageRecord extends org.gcube.accounting.datamodel.implement
*/
@Override
public List<ServiceUsageRecord> aggregate(List<ServiceUsageRecord> records) {
// TODO implements
// TODO
throw new UnsupportedOperationException();
}
}

View File

@ -36,7 +36,7 @@ public class StorageUsageUsageRecord extends org.gcube.accounting.datamodel.impl
*/
@Override
public List<StorageUsageUsageRecord> aggregate(List<StorageUsageUsageRecord> records) {
// TODO implements
// TODO
throw new UnsupportedOperationException();
}
}

View File

@ -79,8 +79,7 @@ public class CouchDBPersistence extends Persistence {
HttpClient httpClient = initHttpClient(host, port, username, password);
couchDbInstance = new StdCouchDbInstance(httpClient);
couchDbConnector = new StdCouchDbConnector(dbName, couchDbInstance);
// TODO remove this
couchDbConnector.createDatabaseIfNotExists();
couchDbConnector.createDatabaseIfNotExists(); // TODO remove this
}
protected void createItem(JsonNode node, String id) throws Exception {