From 729dfde0b7bbfb01f574970cc372585e6c20aee4 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 15 Dec 2017 13:33:28 +0000 Subject: [PATCH] Created fake accounting-lib git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/fake-accounting-lib@160561 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 36 ++++++ .project | 23 ++++ distro/LICENSE | 4 + distro/README | 67 +++++++++++ distro/changelog.xml | 45 ++++++++ distro/profile.xml | 28 +++++ pom.xml | 43 ++++++++ .../datamodel/BasicUsageRecord.java | 84 ++++++++++++++ .../accounting/datamodel/UsageRecord.java | 73 ++++++++++++ .../basetypes/AbstractJobUsageRecord.java | 85 ++++++++++++++ .../basetypes/AbstractPortletUsageRecord.java | 59 ++++++++++ .../basetypes/AbstractServiceUsageRecord.java | 89 +++++++++++++++ .../AbstractStorageStatusRecord.java | 90 +++++++++++++++ .../basetypes/AbstractStorageUsageRecord.java | 104 ++++++++++++++++++ .../usagerecords/JobUsageRecord.java | 26 +++++ .../usagerecords/PortletUsageRecord.java | 27 +++++ .../usagerecords/ServiceUsageRecord.java | 26 +++++ .../usagerecords/StorageStatusRecord.java | 27 +++++ .../usagerecords/StorageUsageRecord.java | 27 +++++ .../persistence/AccountingPersistence.java | 51 +++++++++ .../AccountingPersistenceFactory.java | 48 ++++++++ ...ersistence.PersistenceBackendConfiguration | 1 + src/test/resources/logback-test.xml | 18 +++ src/test/resources/test.log | 1 + 24 files changed, 1082 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 distro/LICENSE create mode 100644 distro/README create mode 100644 distro/changelog.xml create mode 100644 distro/profile.xml create mode 100644 pom.xml create mode 100644 src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/UsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/usagerecords/PortletUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageStatusRecord.java create mode 100644 src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecord.java create mode 100644 src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java create mode 100644 src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java create mode 100644 src/main/resources/META-INF/services/org.gcube.documentstore.persistence.PersistenceBackendConfiguration create mode 100644 src/test/resources/logback-test.xml create mode 100644 src/test/resources/test.log diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..8433ca6 --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..1ecc090 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + accounting-lib-trunk_ultimo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..cdf50bd --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1,4 @@ +gCube System - License +------------------------------------------------------------ + +${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..1af7add --- /dev/null +++ b/distro/README @@ -0,0 +1,67 @@ +The gCube System - ${name} +-------------------------------------------------- + +${description} + + +${gcube.description} + +${gcube.funding} + + +Version +-------------------------------------------------- + +${version} (${buildDate}) + +Please see the file named "changelog.xml" in this directory for the release notes. + + +Authors +-------------------------------------------------- + +* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). +* Alessandro Pieve (alessandro.pieve-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + + +Maintainers +----------- + +* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + + +Download information +-------------------------------------------------- + +Source code is available from SVN: + ${scm.url} + +Binaries can be downloaded from the gCube website: + ${gcube.website} + + +Installation +-------------------------------------------------- + +Installation documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/Accounting_Lib + + +Documentation +-------------------------------------------------- + +Documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/Accounting_Lib + + +Support +-------------------------------------------------- + +Bugs and support requests can be reported in the gCube issue tracking tool: + ${gcube.issueTracking} + + +Licensing +-------------------------------------------------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..acbf09d --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,45 @@ + + + + + Changed pom.xml to use new make-servicearchive directive #10142 + Added the possibility to rewrite the calledMethod which match a regular expression #10646 + + + Refined Jackson support #9617 + Changed JobUsageRecord Model #9646 + Removed TaskUsageRecord #9647 + + + Added Jackson support on Usage Record model to allow to use it for marshalling and unmarshalling + + + Added shutdown() method to pass to document store lib + + + Added new Usage Record (StorageStatusRecord) + + + Added callerQualifier field to ServiceUsageRecord #4949 + + + Removed dependency over reflection library (refs #2358) + + + Ready for ScopeProvider Removal #2194 + Fixed Bug on StorageUsageRecord aggregation #2316 + Fixed Bug on recovery of UsageRecords accounted on Fallback + + + Separated Accounting Model and generalize solution. the library now depends from document-store-lib #1746 + Managed UsageRecords discovered dinamically on classpath #1295 + Persistence is re-checked every 10 min when Fallback is used #1349 + Repetitive thread retry to persist UsageRecords accounted on Fallback #1352 + + + Changed Single and Aggregated classes names to avoid mistakes for the developers. + + + First Release + + diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..1e5db40 --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,28 @@ + + + + + Service + + ${description} + ${serviceClass} + ${artifactId} + 1.0.0 + + + ${description} + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + Library + + ${build.finalName}.${project.packaging} + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..120473e --- /dev/null +++ b/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + + org.gcube.tools + maven-parent + 1.0.0 + + + org.gcube.accounting + accounting-lib + 3.2.0-SNAPSHOT + Accounting Library + Accounting Library + jar + + + UTF-8 + ${project.basedir}/distro + Accounting + + + + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/${project.artifactId} + https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/${project.artifactId} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + make-servicearchive + package + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java new file mode 100644 index 0000000..ceaf6b3 --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java @@ -0,0 +1,84 @@ +/** + * + */ +package org.gcube.accounting.datamodel; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.documentstore.exception.InvalidValueException; +import org.gcube.documentstore.records.implementation.AbstractRecord; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public abstract class BasicUsageRecord extends AbstractRecord implements UsageRecord { + + + /** + * + */ + private static final long serialVersionUID = -8414241700150395605L; + + public BasicUsageRecord() { + } + + public BasicUsageRecord(Map properties) throws InvalidValueException { + } + + /** + * {@inheritDoc} + */ + @Override + public String getConsumerId() { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public void setConsumerId(String consumerId) throws InvalidValueException { + + } + + @Override + public String getRecordType() { + return BasicUsageRecord.class.getSimpleName(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getScope() { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public void setScope(String scope) throws InvalidValueException { + + } + + /** + * {@inheritDoc} + */ + @Override + public OperationResult getOperationResult() { + return OperationResult.SUCCESS; + } + + /** + * {@inheritDoc} + * + * @throws InvalidValueException + */ + + @Override + public void setOperationResult(OperationResult operationResult) throws InvalidValueException { + } + +} diff --git a/src/main/java/org/gcube/accounting/datamodel/UsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/UsageRecord.java new file mode 100644 index 0000000..c449aa4 --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/UsageRecord.java @@ -0,0 +1,73 @@ +package org.gcube.accounting.datamodel; + +import java.io.Serializable; + +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public interface UsageRecord { + + public enum OperationResult implements Serializable, Comparable { + SUCCESS, FAILED + } + + /** + * KEY for : The Operation Result of the accounted operation. + * The value is expressed as OperationResult + */ + public static final String OPERATION_RESULT = "operationResult"; + + /** + * KEY for : The user (or the Consumer Identity, that in the S2S + * communication is another service). + */ + public static final String CONSUMER_ID = "consumerId"; + + /** + * KEY for : The scope + */ + public static final String SCOPE = "scope"; + + /** + * @return the Operation Result of the accounted operation. + */ + public OperationResult getOperationResult(); + + /** + * Set the Operation Result related to the accounted Usage Record + * @param operationResult the Operation Result to set + * @throws InvalidValueException + */ + public void setOperationResult(OperationResult operationResult) throws InvalidValueException; + + /** + * Return the user (or the Consumer Identity, that in the S2S + * communication is another service) + * @return Consumer ID + */ + public String getConsumerId(); + + /** + * Set the user (or the Consumer Identity, that in the S2S + * communication is another service) + * @param consumerId Consumer ID + * @throws InvalidValueException + */ + public void setConsumerId(String consumerId) throws InvalidValueException; + + /** + * Return the scope of this {#UsageRecord} + * @return The scope of this {#UsageRecord} + */ + public String getScope(); + + /** + * Set the scope of the {#UsageRecord} + * @param scope the scope of the {#UsageRecord} + * @throws InvalidValueException + */ + public void setScope(String scope) throws InvalidValueException; + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java new file mode 100644 index 0000000..f49fa2a --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java @@ -0,0 +1,85 @@ +/** + * + */ +package org.gcube.accounting.datamodel.basetypes; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.BasicUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public abstract class AbstractJobUsageRecord extends BasicUsageRecord { + + /** + * + */ + private static final long serialVersionUID = 2361524354045135160L; + + public AbstractJobUsageRecord() { + + } + + public AbstractJobUsageRecord(Map properties) throws InvalidValueException { + + } + + private static final String ABSTRACT_TO_REPLACE = "Abstract"; + + @Override + public String getRecordType() { + return AbstractJobUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, ""); + } + + public String getJobName() { + return (String) null; + } + + public void setJobName(String jobName) throws InvalidValueException { + + } + + public String getHost() { + return null; + } + + public void setHost(String host) throws InvalidValueException { + + } + + public String getServiceClass() { + return null; + } + + public void setServiceClass(String serviceClass) throws InvalidValueException { + + } + + public String getServiceName() { + return null; + } + + public void setServiceName(String serviceName) throws InvalidValueException { + + } + + public Long getDuration() { + return null; + } + + public void setDuration(Long duration) throws InvalidValueException { + + } + + public String getCallerQualifier() { + return null; + } + + public void setCallerQualifier(String callerQualifier) throws InvalidValueException { + + } + +} diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java new file mode 100644 index 0000000..165e54d --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java @@ -0,0 +1,59 @@ +/** + * + */ +package org.gcube.accounting.datamodel.basetypes; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.BasicUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public abstract class AbstractPortletUsageRecord extends BasicUsageRecord { + + /** + * + */ + private static final long serialVersionUID = -6521755521955331201L; + + public AbstractPortletUsageRecord() { + + } + + public AbstractPortletUsageRecord(Map properties) throws InvalidValueException { + + } + + private static final String ABSTRACT_TO_REPLACE = "Abstract"; + + @Override + public String getRecordType() { + return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, ""); + } + + public String getPortletId() { + return null; + } + + public void setPortletId(String portletId) throws InvalidValueException { + + } + + public String getOperationId() { + return null; + } + + public void setOperationId(String operationId) throws InvalidValueException { + } + + public String getMessage() { + return null; + } + + public void setMessage(String message) throws InvalidValueException { + } + +} diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java new file mode 100644 index 0000000..416b1c4 --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java @@ -0,0 +1,89 @@ +/** + * + */ +package org.gcube.accounting.datamodel.basetypes; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.BasicUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public abstract class AbstractServiceUsageRecord extends BasicUsageRecord { + + /** + * + */ + private static final long serialVersionUID = -8015539265774575233L; + + public AbstractServiceUsageRecord() { + + } + + public AbstractServiceUsageRecord(Map properties) throws InvalidValueException { + + } + + private static final String ABSTRACT_TO_REPLACE = "Abstract"; + + @Override + public String getRecordType() { + return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, ""); + + } + + public String getCallerHost() { + return null; + } + + public void setCallerHost(String callerHost) throws InvalidValueException { + + } + + public String getHost() { + return null; + } + + public void setHost(String host) throws InvalidValueException { + + } + + public String getServiceClass() { + return null; + } + + public void setServiceClass(String serviceClass) throws InvalidValueException { + } + + public String getServiceName() { + return null; + } + + public void setServiceName(String serviceName) throws InvalidValueException { + } + + public String getCalledMethod() { + return null; + } + + public void setCalledMethod(String calledMethod) throws InvalidValueException { + } + + public Long getDuration() { + return null; + } + + public void setDuration(Long duration) throws InvalidValueException { + } + + public String getCallerQualifier() { + return null; + } + + public void setCallerQualifier(String callerQualifier) throws InvalidValueException { + } + +} diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java new file mode 100644 index 0000000..18fb70d --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageStatusRecord.java @@ -0,0 +1,90 @@ +/** + * + */ +package org.gcube.accounting.datamodel.basetypes; + +import java.io.Serializable; +import java.net.URI; +import java.util.Map; + +import org.gcube.accounting.datamodel.BasicUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +public abstract class AbstractStorageStatusRecord extends BasicUsageRecord { + + /** + * + */ + private static final long serialVersionUID = -8414496937550686240L; + + public enum DataType { + STORAGE, TREE, GEO, DATABASE, OTHER + } + + public AbstractStorageStatusRecord() { + } + + public AbstractStorageStatusRecord(Map properties) throws InvalidValueException { + } + + private static final String ABSTRACT_TO_REPLACE = "Abstract"; + + @Override + public String getRecordType() { + return AbstractStorageStatusRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, ""); + } + + public long getDataVolume() { + return 1; + } + + public void setDataVolume(long dataVolume) throws InvalidValueException { + + } + + public DataType getDataType() { + return null; + } + + public void setDataType(DataType dataType) throws InvalidValueException { + + } + + public long getDataCount() { + return 1; + } + + public void setDataCount(long dataCount) throws InvalidValueException { + + } + + public String getDataServiceClass() { + return null; + } + + public void setDataServiceClass(String dataServiceClass) throws InvalidValueException { + } + + public String getDataServiceName() { + return null; + } + + public void setDataServiceName(String dataServiceName) throws InvalidValueException { + + } + + public String getDataServiceId() { + return null; + } + + public void setDataServiceId(String dataServiceId) throws InvalidValueException { + } + + public URI getProviderId() { + return null; + } + + public void setProviderId(URI provideId) throws InvalidValueException { + } + +} diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java new file mode 100644 index 0000000..aa2432c --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java @@ -0,0 +1,104 @@ +/** + * + */ +package org.gcube.accounting.datamodel.basetypes; + +import java.io.Serializable; +import java.net.URI; +import java.util.Map; + +import org.gcube.accounting.datamodel.BasicUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public abstract class AbstractStorageUsageRecord extends BasicUsageRecord { + + /** + * + */ + private static final long serialVersionUID = -4538851408789372335L; + + public enum OperationType { + CREATE, READ, UPDATE, DELETE + } + + public enum DataType { + STORAGE, TREE, GEO, DATABASE, OTHER + } + + public AbstractStorageUsageRecord() { + } + + public AbstractStorageUsageRecord(Map properties) throws InvalidValueException { + } + + private static final String ABSTRACT_TO_REPLACE = "Abstract"; + + @Override + public String getRecordType() { + return AbstractStorageUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, ""); + } + + public String getResourceOwner() { + return null; + } + + public void setResourceOwner(String owner) throws InvalidValueException { + } + + public String getResourceScope() { + return null; + } + + public void setResourceScope(String scope) throws InvalidValueException { + + } + + public URI getProviderURI() { + return null; + } + + public void setProviderURI(URI providerURI) throws InvalidValueException { + + } + + public URI getResourceURI() { + return null; + } + + public void setResourceURI(URI resourceURI) throws InvalidValueException { + + } + + public OperationType getOperationType() { + return null; + } + + public void setOperationType(OperationType operationType) throws InvalidValueException { + } + + public DataType getDataType() { + return null; + } + + public void setDataType(DataType dataType) throws InvalidValueException { + } + + public long getDataVolume() { + return 1; + } + + public void setDataVolume(long dataVolume) throws InvalidValueException { + + } + + public String getQualifier() { + return null; + } + + public void setQualifier(String qualifier) throws InvalidValueException { + } + +} diff --git a/src/main/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecord.java new file mode 100644 index 0000000..59e153c --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecord.java @@ -0,0 +1,26 @@ +package org.gcube.accounting.datamodel.usagerecords; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class JobUsageRecord extends AbstractJobUsageRecord { + + /** + * + */ + private static final long serialVersionUID = -2409704377456095140L; + + public JobUsageRecord() { + super(); + } + + public JobUsageRecord(Map properties) throws InvalidValueException { + super(properties); + } +} diff --git a/src/main/java/org/gcube/accounting/datamodel/usagerecords/PortletUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/usagerecords/PortletUsageRecord.java new file mode 100644 index 0000000..4580c52 --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/usagerecords/PortletUsageRecord.java @@ -0,0 +1,27 @@ +package org.gcube.accounting.datamodel.usagerecords; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class PortletUsageRecord extends AbstractPortletUsageRecord { + + /** + * + */ + private static final long serialVersionUID = 236711996072341709L; + + public PortletUsageRecord() { + super(); + } + + public PortletUsageRecord(Map properties) throws InvalidValueException { + super(properties); + } + +} diff --git a/src/main/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecord.java new file mode 100644 index 0000000..0570386 --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecord.java @@ -0,0 +1,26 @@ +package org.gcube.accounting.datamodel.usagerecords; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class ServiceUsageRecord extends AbstractServiceUsageRecord { + + /** + * + */ + private static final long serialVersionUID = -8611860162342017139L; + + public ServiceUsageRecord() { + super(); + } + + public ServiceUsageRecord(Map properties) throws InvalidValueException { + super(properties); + } +} diff --git a/src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageStatusRecord.java b/src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageStatusRecord.java new file mode 100644 index 0000000..86d6f8d --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageStatusRecord.java @@ -0,0 +1,27 @@ +package org.gcube.accounting.datamodel.usagerecords; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it + * + */ +public class StorageStatusRecord extends AbstractStorageStatusRecord { + + /** + * + */ + private static final long serialVersionUID = 7281637553846301944L; + + public StorageStatusRecord() { + super(); + } + + public StorageStatusRecord(Map properties) throws InvalidValueException { + super(properties); + } +} diff --git a/src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecord.java new file mode 100644 index 0000000..ff07614 --- /dev/null +++ b/src/main/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecord.java @@ -0,0 +1,27 @@ +package org.gcube.accounting.datamodel.usagerecords; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord; +import org.gcube.documentstore.exception.InvalidValueException; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class StorageUsageRecord extends AbstractStorageUsageRecord { + + /** + * + */ + private static final long serialVersionUID = 5487568054203888507L; + + public StorageUsageRecord() { + super(); + } + + public StorageUsageRecord(Map properties) throws InvalidValueException { + super(properties); + } + +} diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java new file mode 100644 index 0000000..a7946a1 --- /dev/null +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java @@ -0,0 +1,51 @@ +/** + * + */ +package org.gcube.accounting.persistence; + +import java.util.concurrent.TimeUnit; + +import org.gcube.documentstore.exception.InvalidValueException; +import org.gcube.documentstore.records.Record; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class AccountingPersistence { + + protected AccountingPersistence(String context){ + + } + + protected AccountingPersistence(){ + + } + + public void account(final Record record) throws InvalidValueException { + + } + + public void flush() throws Exception { + + } + + /** + * Used {@link AccountingPersistence#flush() instead} + * @param timeout + * @param timeUnit + * @throws Exception + */ + @Deprecated + public void flush(long timeout, TimeUnit timeUnit) throws Exception { + this.flush(); + } + + public void close() throws Exception{ + + } + + public boolean isConnectionActive() throws Exception { + return true; + } + +} diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java new file mode 100644 index 0000000..24ba2d7 --- /dev/null +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java @@ -0,0 +1,48 @@ +/** + * + */ +package org.gcube.accounting.persistence; + +import java.util.concurrent.TimeUnit; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class AccountingPersistenceFactory { + + private AccountingPersistenceFactory(){} + + + + public static void setFallbackLocation(String path){ + + } + + public synchronized static AccountingPersistence getPersistence() { + AccountingPersistence accountingPersistence = new AccountingPersistence(); + return accountingPersistence; + } + + public static void flushAll(){ + + } + + /** + * Use {@link AccountingPersistenceFactory#flushAll() instead} + * @param timeout + * @param timeUnit + */ + @Deprecated + public static void flushAll(long timeout, TimeUnit timeUnit){ + AccountingPersistenceFactory.flushAll(); + } + + public static void shutDown(){ + //flush all and shutdown connection and thread + + } + + public static void shutDown(long timeout, TimeUnit timeUnit){ + + } +} diff --git a/src/main/resources/META-INF/services/org.gcube.documentstore.persistence.PersistenceBackendConfiguration b/src/main/resources/META-INF/services/org.gcube.documentstore.persistence.PersistenceBackendConfiguration new file mode 100644 index 0000000..46715d0 --- /dev/null +++ b/src/main/resources/META-INF/services/org.gcube.documentstore.persistence.PersistenceBackendConfiguration @@ -0,0 +1 @@ +org.gcube.accounting.persistence.AccountingPersistenceConfiguration \ No newline at end of file diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..4fa8510 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,18 @@ + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/test.log b/src/test/resources/test.log new file mode 100644 index 0000000..c37877e --- /dev/null +++ b/src/test/resources/test.log @@ -0,0 +1 @@ +{"recordType":"SingleTaskUsageRecord","ESEMpio":"PLUTO","creationTime":1503928807106,"refHostingNodeId":"4f96f787-44b4-46f7-9d85-359e57313840","consumerId":"name.surname","wallDuration":1200000,"taskStartTime":1503928207106,"scope":"/gcube/devNext","host":"localhost","id":"ab97bb13-ca9a-4b01-bd4c-564da3f27759","taskId":"6776f112-4f62-4d13-ad33-d0cab5a98c76","finalState":"DONE","operationResult":"SUCCESS","taskEndTime":1503929407106}