org.rhq.common.drift
Interface ChangeSetWriter
- All Known Implementing Classes:
- ChangeSetWriterImpl
public interface ChangeSetWriter
Generates a change set file. A change set is stored as a UTF-8 text file. It consists of
file paths with some associated meta data. The meta data includes the SHA-256 hash, the
old SHA-256 hash (if one exists), and a single character code indicating whether the file
has been added, changed, or removed in the change set. The codes are taken from
DriftCategory.
The current format of the change set file is:
HEADERS
FILE_ENTRY (1..N)
where HEADER corresponds to Headers and the header fields are written out in the
following order:
- resource id
- drift definition id
- drift definition name
- drift definition base directory
- change set type flag indicating whether this is a coverage or drift changeset
- change set version number
FILE_ENTRY has six, space-delimited fields:
- type
- file_size
- timestamp
- new_sha
- old_sha
- file_name
Here is an example change set:
1001
2345
Core Server JARs
/var/lib/myserver
C 1024 1321975943000 1706b5c18e4358041b463995efc30f8f721766fab0e018d50d85978b46df013c 1536b5c18e4358041b463995efc30f8f721766fab0e018d50d85978b46df013c lib/foo.jar
A 512 1121975943000 2706b5c18e4358041b463995efc30f8f721766fab0e018d50d85978b46df013a 0 lib/bar.jar
R -1 -1 0 2206b5af8e4358041b463995efc30f8f721766fab0e018d50d85978b46df013a conf/foo.conf
Note that the file paths in each entry are relative to the path in the base directory
header. The timestamp field is the last modification time of the file. For the entry
with a path of lib/bar.jar notice that the old_sha field has a value of 0. This is
because it is a new file, and there is no previous SHA-256 hash for the file. For the
entry with conf/foo.conf as its path, notices that the new_sha field has a value of 0 for foo.conf.
This is because the file has been deleted and so there is no new SHA-256 hash. Also
note that this entry has a value of -1 for its file size and timestamp fields. This
denotes that those values are no longer available since the file was removed.
Lastly and importantly, the format of this file is still subject to change. Additional
headers may be added, maybe allowing for optional headers. The format of the file entry
may change as well. Currently a place holder value of 0 is used to indicate the lack
of a SHA-256 hash. That place holder is not really needed and may go away.
write
void write(FileEntry entry)
throws IOException
- Parameters:
entry -
- Throws:
IOException
close
void close()
throws IOException
- Throws:
IOException
Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.