Class HashStoreUpgrader

java.lang.Object
edu.ucsb.nceas.metacat.admin.upgrade.HashStoreUpgrader
All Implemented Interfaces:
UpgradeUtilityInterface

public class HashStoreUpgrader extends Object implements UpgradeUtilityInterface
Author:
Tao This class will upgrade the old metacat file storage (/var/metacat/documents and /var/metacat/data) into the HashStore storage.
  • Field Details

    • nThreads

      protected static int nThreads
  • Constructor Details

  • Method Details

    • upgrade

      public boolean upgrade() throws AdminException
      Specified by:
      upgrade in interface UpgradeUtilityInterface
      Throws:
      AdminException
    • removeCompleteFuture

      protected void removeCompleteFuture(Set<Future> futures)
      This method removes the Future objects from a set which have the done status. So the free space can be used again. If it cannot remove any one, it will wait and try again until some space was freed up.
      Parameters:
      futures - the set which hold the futures to be checked
    • initCandidateList

      protected ResultSet initCandidateList() throws SQLException
      Run a query to select the list of candidate pid from the systemmetadata which will be converted. If the pid exists in the checksums table, we consider it is in the hashstore and wouldn't convert it. Both the checksums table and hashstore are introduced in 3.1.0. Also, it will pick up unsuccessfully converted docids to the dataone identifiers.
      Returns:
      a ResultSet object which contains the list of identifiers:
      Throws:
      SQLException
    • getInfo

      public String getInfo()
      Get the info which users need to handle
      Returns:
      the info string generated by the update method
    • resolve

      protected Path resolve(org.dataone.service.types.v2.SystemMetadata sysMeta) throws SQLException, McdbDocNotFoundException, FileNotFoundException
      Get the object path for the given pid. When a not-found exception arises, it will throw the exception if it is not cn; otherwise returns null. The reason is that cn doesn't harvest the data objects so the data objects don't have the bytes in cn.
      Parameters:
      sysMeta - the system metadata associated with the object
      Returns:
      the object path. Null will be returned if there is no object found.
      Throws:
      SQLException
      McdbDocNotFoundException
      FileNotFoundException
    • writeToFile

      protected static void writeToFile(String message, BufferedWriter writer)
    • writeToFile

      protected static void writeToFile(String message, Exception e, BufferedWriter writer)
    • convertSystemMetadata

      protected static InputStream convertSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysMeta) throws IOException, org.dataone.exceptions.MarshallingException
      Transform the SystemMetadata object to an InputStream object
      Parameters:
      sysMeta - the object will be transformed
      Returns:
      the InputStream object which represents the SystemMetadata object. Return null if the given SystemMetadata object is null.
      Throws:
      IOException
      org.dataone.exceptions.MarshallingException