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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static InputStream
convertSystemMetadata
(org.dataone.service.types.v2.SystemMetadata sysMeta) Transform the SystemMetadata object to an InputStream objectgetInfo()
Get the info which users need to handleprotected ResultSet
Run a query to select the list of candidate pid from the systemmetadata which will be converted.protected void
removeCompleteFuture
(Set<Future> futures) This method removes the Future objects from a set which have the done status.protected Path
resolve
(org.dataone.service.types.v2.SystemMetadata sysMeta) Get the object path for the given pid.boolean
upgrade()
protected static void
writeToFile
(String message, BufferedWriter writer) protected static void
writeToFile
(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.PropertyNotFoundException
org.dataone.service.exceptions.ServiceFailure
IOException
NoSuchAlgorithmException
ServiceException
MetacatUtilException
edu.ucsb.nceas.utilities.GeneralPropertyException
-
-
Method Details
-
upgrade
- Specified by:
upgrade
in interfaceUpgradeUtilityInterface
- Throws:
AdminException
-
removeCompleteFuture
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
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:
SQLException
McdbDocNotFoundException
FileNotFoundException
-
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:
IOException
org.dataone.exceptions.MarshallingException
-