Class HashStoreUpgrader
java.lang.Object
edu.ucsb.nceas.metacat.admin.upgrade.HashStoreUpgrader
- All Implemented Interfaces:
UpgradeUtilityInterface
- Author:
- Tao This class will upgrade the old metacat file storage (/var/metacat/documents and /var/metacat/data) into the HashStore storage.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static InputStreamconvertSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysMeta) Transform the SystemMetadata object to an InputStream objectgetInfo()Get the info which users need to handleprotected ResultSetRun a query to select the list of candidate pid from the systemmetadata which will be converted.protected Pathresolve(org.dataone.service.types.v2.SystemMetadata sysMeta) Get the object path for the given pid.booleanupgrade()protected static voidwriteToFile(String message, BufferedWriter writer) protected static voidwriteToFile(String message, Exception e, BufferedWriter writer)
-
Field Details
-
nThreads
protected static int nThreads
-
-
Constructor Details
-
HashStoreUpgrader
public HashStoreUpgrader() throws edu.ucsb.nceas.utilities.GeneralPropertyException, org.dataone.service.exceptions.ServiceFailure, IOException, NoSuchAlgorithmException, ServiceException, MetacatUtilException, edu.ucsb.nceas.utilities.PropertyNotFoundExceptionConstructor- Throws:
edu.ucsb.nceas.utilities.PropertyNotFoundExceptionorg.dataone.service.exceptions.ServiceFailureIOExceptionNoSuchAlgorithmExceptionServiceExceptionMetacatUtilExceptionedu.ucsb.nceas.utilities.GeneralPropertyException
-
-
Method Details
-
upgrade
- Specified by:
upgradein interfaceUpgradeUtilityInterface- Throws:
AdminException
-
initCandidateList
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
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:
SQLExceptionMcdbDocNotFoundExceptionFileNotFoundException
-
writeToFile
-
writeToFile
-
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:
IOExceptionorg.dataone.exceptions.MarshallingException
-