public abstract class QuotaService
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static BookKeeperClient |
client |
static int |
DEFAULT_QUOTA_ID |
protected static java.util.concurrent.ExecutorService |
executor |
static java.lang.String |
nodeId |
Constructor and Description |
---|
QuotaService() |
Modifier and Type | Method and Description |
---|---|
protected int |
checkQuota(boolean checkEnoughSpace,
java.lang.String quotaSubject,
java.lang.String requestor,
java.lang.String quotaType,
double quantity,
java.lang.String instanceId)
Check if the quota has enough space for this request.
|
protected void |
deleteUsage(int quotaId,
java.lang.String instanceId,
double quantity)
Delete a usage associated with the given quota id in the remote book keeper server.
|
abstract void |
enforce(java.lang.String quotaSubject,
org.dataone.service.types.v1.Subject requestor,
java.lang.String instanceId,
org.dataone.service.types.v2.SystemMetadata sysmeta,
java.lang.String method)
The method will be implemented by the child classes to enforce the quota service
|
protected boolean |
isLastUnarchivedInChain(java.lang.String pid,
java.lang.String sid)
Checking if the given pid is last one in this series chain hasn't been archived
|
protected boolean |
isLastUndeletedInChain(java.lang.String pid,
java.lang.String sid)
Checking if the given pid is last one in this series chain hasn't been deleted
|
protected void |
updateUsage(int quotaId,
java.lang.String instanceId,
double quantity)
Update a usage with the archived status associated with the given quota id in the remote book keeper server.
|
public static java.lang.String nodeId
public static int DEFAULT_QUOTA_ID
protected static java.util.concurrent.ExecutorService executor
protected static BookKeeperClient client
public abstract void enforce(java.lang.String quotaSubject, org.dataone.service.types.v1.Subject requestor, java.lang.String instanceId, org.dataone.service.types.v2.SystemMetadata sysmeta, java.lang.String method) throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.InsufficientResources, org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.NotFound, java.io.UnsupportedEncodingException
quotaSubject
- the subject of the quota which will be usedrequestor
- the subject of the user who requests the usageinstanceId
- the id of the object will be applied the quotasysmeta
- the system metadata of the object which will use the quotamethod
- the method name which will call the createUsage method (create or update)org.dataone.service.exceptions.ServiceFailure
org.dataone.service.exceptions.InvalidRequest
org.dataone.service.exceptions.InsufficientResources
org.dataone.service.exceptions.NotImplemented
org.dataone.service.exceptions.NotFound
java.io.UnsupportedEncodingException
protected boolean isLastUnarchivedInChain(java.lang.String pid, java.lang.String sid) throws org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure
pid
- the pid of the object will be checkedsid
- the id of the series chain will be checkedjava.sql.SQLException
org.dataone.service.exceptions.InvalidRequest
org.dataone.service.exceptions.ServiceFailure
protected boolean isLastUndeletedInChain(java.lang.String pid, java.lang.String sid) throws org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure
pid
- the pid of the object will be checkedsid
- the id of the series chain will be checkedjava.sql.SQLException
org.dataone.service.exceptions.InvalidRequest
org.dataone.service.exceptions.ServiceFailure
protected int checkQuota(boolean checkEnoughSpace, java.lang.String quotaSubject, java.lang.String requestor, java.lang.String quotaType, double quantity, java.lang.String instanceId) throws org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InsufficientResources, org.dataone.service.exceptions.NotFound, java.io.UnsupportedEncodingException
checkEnoughSpace
- indicator if we need to check if the found quota has enough space for this usagequotaSubject
- the subject of the quota which will be usedrequestor
- the subject of the user who requests the usagequotaType
- the type of quotaquantity
- the amount of the usage for the requestorg.dataone.service.exceptions.InvalidRequest
java.io.IOException
org.dataone.service.exceptions.ServiceFailure
org.dataone.service.exceptions.NotFound
org.apache.http.client.ClientProtocolException
org.dataone.service.exceptions.InsufficientResources
java.io.UnsupportedEncodingException
protected void updateUsage(int quotaId, java.lang.String instanceId, double quantity)
quotaId
- the quota id which the usage will be associated withinstanceId
- the id of the usage instance (pid for the storage type, and sid for the portal type)quantity
- the amount of the usageprotected void deleteUsage(int quotaId, java.lang.String instanceId, double quantity)
quotaId
- the quota id which the usage will be associated withinstanceId
- the id of the usage instance (pid for the storage type, and sid for the portal type)quantity
- the amount of the usageCopyright © 2023 Regents of the University of California. All Rights Reserved.