edu.ucsb.nceas.metacat.dataone.quota

## Class UsageTask

- java.lang.Object
- - edu.ucsb.nceas.metacat.dataone.quota.UsageTask

- All Implemented Interfaces:
    java.lang.Runnable
  Direct Known Subclasses:
    CreateUsageTask, DeleteUsageTask, UpdateUsageTask

      public abstract class UsageTask
      extends java.lang.Object
      implements java.lang.Runnable

  The parent class reporting usages to the remote book keeper server and logging the quota usages events into the local database. The children classes are CreateUsageTask, UpdateUsageTask and DeleteUsageTask.
  Author:
    tao

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected BookKeeperClient` | `bookkeeperClient`
    `protected boolean` | `isLoggedLocally`
    `protected org.dataone.bookkeeper.api.Usage` | `usage`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UsageTask(org.dataone.bookkeeper.api.Usage usage, BookKeeperClient bookkeeperClient)` Constructor

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract int` | `reportToBookKeeper()` The child class needs to implement this method to detail how to report the usage to the remote book keeper server.
    `void` | `run()`
    `void` | `setIsLoggedLocally(boolean isLoggedLocally)` Set the property if the usage has been logged locally or not

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### usage

          protected org.dataone.bookkeeper.api.Usage usage

    - #### bookkeeperClient

          protected BookKeeperClient bookkeeperClient

    - #### isLoggedLocally

          protected boolean isLoggedLocally

  - ### Constructor Detail

    - #### UsageTask

          public UsageTask(org.dataone.bookkeeper.api.Usage usage,
                           BookKeeperClient bookkeeperClient)

      Constructor
      Parameters:
        `usage` - the usage will be reported
        `bookkeeperClient` - the client to report the usage to the remote server

  - ### Method Detail

    - #### setIsLoggedLocally

          public void setIsLoggedLocally(boolean isLoggedLocally)

      Set the property if the usage has been logged locally or not
      Parameters:
        `isLoggedLocally` - true means local database has the record; otherwise false.

    - #### run

          public void run()

      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### reportToBookKeeper

          protected abstract int reportToBookKeeper()
                                             throws java.lang.Exception

      The child class needs to implement this method to detail how to report the usage to the remote book keeper server.
      Throws:
        `java.lang.Exception`

Copyright © 2023 Regents of the University of California. All Rights Reserved.