|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jets3t.service.utils.FileComparer
public class FileComparer
File comparison utility to compare files on the local computer with objects present in a service account and determine whether there are any differences. This utility contains methods to build maps of the contents of the local file system or service account for comparison, and methods to find differences in these maps.
File comparisons are based primarily on MD5 hashes of the files' contents. If a local file does not match an object in the service with the same name, this utility determine which of the items is newer by comparing the last modified dates.
Nested Class Summary | |
---|---|
class |
FileComparer.PartialObjectListing
|
Constructor Summary | |
---|---|
FileComparer(Jets3tProperties jets3tProperties)
Constructs the class. |
Method Summary | |
---|---|
FileComparerResults |
buildDiscrepancyLists(java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap,
java.util.Map<java.lang.String,StorageObject> objectsMap)
Compares the contents of a directory on the local file system with the contents of a service resource. |
FileComparerResults |
buildDiscrepancyLists(java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap,
java.util.Map<java.lang.String,StorageObject> objectsMap,
BytesProgressWatcher progressWatcher)
Compares the contents of a directory on the local file system with the contents of a service resource. |
java.util.Map<java.lang.String,java.lang.String> |
buildObjectKeyToFilepathMap(java.io.File[] fileList,
java.lang.String fileKeyPrefix,
boolean includeDirectories)
Builds a map of files and directories that exist on the local system, where the map keys are the object key names that will be used for the files in a remote storage service, and the map values are absolute paths (Strings) to that file in the local file system. |
java.util.Map<java.lang.String,StorageObject> |
buildObjectMap(StorageService service,
java.lang.String bucketName,
java.lang.String targetPath,
java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap,
BytesProgressWatcher progressWatcher,
StorageServiceEventListener eventListener)
Builds a service Object Map containing all the objects within the given target path, where the map's key for each object is the relative path to the object. |
FileComparer.PartialObjectListing |
buildObjectMapPartial(StorageService service,
java.lang.String bucketName,
java.lang.String targetPath,
java.lang.String priorLastKey,
java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap,
boolean completeListing,
BytesProgressWatcher progressWatcher,
StorageServiceEventListener eventListener)
Builds a service Object Map containing a partial set of objects within the given target path, where the map's key for each object is the relative path to the object. |
byte[] |
generateFileMD5Hash(java.io.File file,
java.lang.String relativeFilePath,
BytesProgressWatcher progressWatcher)
|
static FileComparer |
getInstance()
|
static FileComparer |
getInstance(Jets3tProperties jets3tProperties)
|
java.io.File |
getMd5FilesRootDirectoryFile()
|
boolean |
isAssumeLocalLatestInMismatch()
|
boolean |
isGenerateMd5Files()
|
boolean |
isSkipMd5FileUpload()
|
boolean |
isSkipSymlinks()
|
boolean |
isUseMd5Files()
|
StorageObject[] |
listObjectsThreaded(StorageService service,
java.lang.String bucketName,
java.lang.String targetPath)
Lists the objects in a bucket using a partitioning technique to divide the object namespace into separate partitions that can be listed by multiple simultaneous threads. |
StorageObject[] |
listObjectsThreaded(StorageService service,
java.lang.String bucketName,
java.lang.String targetPath,
java.lang.String delimiter,
int toDepth)
Lists the objects in a bucket using a partitioning technique to divide the object namespace into separate partitions that can be listed by multiple simultaneous threads. |
java.util.Map<java.lang.String,StorageObject> |
lookupObjectMetadataForPotentialClashes(StorageService service,
java.lang.String bucketName,
java.lang.String targetPath,
StorageObject[] objectsWithoutMetadata,
java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap,
BytesProgressWatcher progressWatcher,
StorageServiceEventListener eventListener)
Given a set of storage objects for which only minimal information is available, retrieve metadata information for any objects that potentially clash with local files. |
java.util.Map<java.lang.String,StorageObject> |
populateObjectMap(java.lang.String targetPath,
StorageObject[] objects)
Builds a map of key/object pairs each object is associated with a key based on its location in the service target path. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileComparer(Jets3tProperties jets3tProperties)
jets3tProperties
- the object containing the properties that will be applied in this class.Method Detail |
---|
public static FileComparer getInstance(Jets3tProperties jets3tProperties)
jets3tProperties
- the object containing the properties that will be applied in the instance.
public static FileComparer getInstance()
public java.util.Map<java.lang.String,java.lang.String> buildObjectKeyToFilepathMap(java.io.File[] fileList, java.lang.String fileKeyPrefix, boolean includeDirectories)
A file/directory hierarchy is represented using '/' delimiter characters in object key names.
Any file or directory matching a path in a .jets3t-ignore
file will be ignored.
fileList
- the set of files and directories to include in the file map.fileKeyPrefix
- A prefix added to each file path key in the map, e.g. the name of the root directory the
files belong to. If provided, a '/' suffix is always added to the end of the prefix. If null
or empty, no prefix is used.includeDirectories
- If true all directories, including empty ones, will be included in the Map. These directories
will be mere place-holder objects with a trailing slash (/) character in the name and the
content type Mimetypes.MIMETYPE_BINARY_OCTET_STREAM
.
If this variable is false directory objects will not be included in the Map, and it will not
be possible to store empty directories in the service.
public StorageObject[] listObjectsThreaded(StorageService service, java.lang.String bucketName, java.lang.String targetPath, java.lang.String delimiter, int toDepth) throws ServiceException
This partitioning technique will work best for buckets with many objects that are divided into a number of virtual subdirectories of roughly equal size.
service
- the service object that will be used to perform listing requests.bucketName
- the name of the bucket whose contents will be listed.targetPath
- a root path within the bucket to be listed. If this parameter is null, all
the bucket's objects will be listed. Otherwise, only the objects below the
virtual path specified will be listed.delimiter
- the delimiter string used to identify virtual subdirectory partitions
in a bucket. If this parameter is null, or it has a value that is not
present in your object names, no partitioning will take place.toDepth
- the number of delimiter levels this method will traverse to identify
subdirectory partions. If this value is zero, no partitioning will take
place.
ServiceException
public StorageObject[] listObjectsThreaded(StorageService service, java.lang.String bucketName, java.lang.String targetPath) throws ServiceException
This partitioning technique will work best for buckets with many objects that are divided into a number of virtual subdirectories of roughly equal size.
The delimiter and depth properties that define how this method will
partition the bucket's namespace are set in the jets3t.properties file
with the setting:
filecomparer.bucket-listing.<bucketname>=<delim>,<depth>
For example: filecomparer.bucket-listing.my-bucket=/,2
service
- the service object that will be used to perform listing requests.bucketName
- the name of the bucket whose contents will be listed.targetPath
- a root path within the bucket to be listed. If this parameter is null, all
the bucket's objects will be listed. Otherwise, only the objects below the
virtual path specified will be listed.
ServiceException
public java.util.Map<java.lang.String,StorageObject> buildObjectMap(StorageService service, java.lang.String bucketName, java.lang.String targetPath, java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap, BytesProgressWatcher progressWatcher, StorageServiceEventListener eventListener) throws ServiceException
service
- bucketName
- targetPath
- objectKeyToFilepathMap
- map of '/'-delimited object key names to local file absolute pathsprogressWatcher
- watcher to monitor bytes read during comparison operations, may be null.eventListener
-
ServiceException
lookupObjectMetadataForPotentialClashes(StorageService, String, String, StorageObject[], Map, BytesProgressWatcher, StorageServiceEventListener)
public FileComparer.PartialObjectListing buildObjectMapPartial(StorageService service, java.lang.String bucketName, java.lang.String targetPath, java.lang.String priorLastKey, java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap, boolean completeListing, BytesProgressWatcher progressWatcher, StorageServiceEventListener eventListener) throws ServiceException
If the method is asked to perform a complete listing, it will use the
listObjectsThreaded(StorageService, String, String)
method to list the objects
in the bucket, potentially taking advantage of any bucket name partitioning
settings you have applied.
If the method is asked to perform only a partial listing, no bucket name partitioning will be applied.
service
- bucketName
- targetPath
- priorLastKey
- the prior last key value returned by a prior invocation of this method, if any.objectKeyToFilepathMap
- map of '/'-delimited object key names to local file absolute pathscompleteListing
- if true, this method will perform a complete listing of a service target.
If false, the method will list a partial set of objects commencing from the
given prior last key.progressWatcher
- watcher to monitor bytes read during comparison operations, may be null.eventListener
-
ServiceException
lookupObjectMetadataForPotentialClashes(StorageService, String, String, StorageObject[], Map, BytesProgressWatcher, StorageServiceEventListener)
public java.util.Map<java.lang.String,StorageObject> lookupObjectMetadataForPotentialClashes(StorageService service, java.lang.String bucketName, java.lang.String targetPath, StorageObject[] objectsWithoutMetadata, java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap, BytesProgressWatcher progressWatcher, StorageServiceEventListener eventListener) throws ServiceException
service
- bucketName
- targetPath
- objectsWithoutMetadata
- objectKeyToFilepathMap
- progressWatcher
- watcher to monitor bytes read during comparison operations, may be null.eventListener
-
ServiceException
populateObjectMap(String, StorageObject[])
public java.util.Map<java.lang.String,StorageObject> populateObjectMap(java.lang.String targetPath, StorageObject[] objects)
targetPath
- objects
-
public byte[] generateFileMD5Hash(java.io.File file, java.lang.String relativeFilePath, BytesProgressWatcher progressWatcher) throws java.io.IOException, java.security.NoSuchAlgorithmException
file
- relativeFilePath
- progressWatcher
- watcher to monitor bytes read during comparison operations, may be null.
java.io.IOException
java.security.NoSuchAlgorithmException
public FileComparerResults buildDiscrepancyLists(java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap, java.util.Map<java.lang.String,StorageObject> objectsMap) throws java.security.NoSuchAlgorithmException, java.io.FileNotFoundException, java.io.IOException, java.text.ParseException
objectKeyToFilepathMap
- map of '/'-delimited object key names to local file absolute pathsobjectsMap
- a map of keys to StorageObjects.
java.security.NoSuchAlgorithmException
java.io.FileNotFoundException
java.io.IOException
java.text.ParseException
public FileComparerResults buildDiscrepancyLists(java.util.Map<java.lang.String,java.lang.String> objectKeyToFilepathMap, java.util.Map<java.lang.String,StorageObject> objectsMap, BytesProgressWatcher progressWatcher) throws java.security.NoSuchAlgorithmException, java.io.FileNotFoundException, java.io.IOException, java.text.ParseException
objectKeyToFilepathMap
- map of '/'-delimited object key names to local file absolute pathsobjectsMap
- a map of keys to StorageObjects.progressWatcher
- watcher to monitor bytes read during comparison operations, may be null.
java.security.NoSuchAlgorithmException
java.io.FileNotFoundException
java.io.IOException
java.text.ParseException
public boolean isSkipSymlinks()
public boolean isUseMd5Files()
public boolean isGenerateMd5Files()
public boolean isSkipMd5FileUpload()
public boolean isAssumeLocalLatestInMismatch()
public java.io.File getMd5FilesRootDirectoryFile() throws java.io.FileNotFoundException
java.io.FileNotFoundException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |