public class RoleHistoryWriter extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
log |
static int |
ROLE_HISTORY_VERSION
Although Avro is designed to handle some changes, we still keep a version
marker in the file to catch changes that are fundamentally incompatible
at the semantic level -changes that require either a different
parser or get rejected outright.
|
| Constructor and Description |
|---|
RoleHistoryWriter() |
| Modifier and Type | Method and Description |
|---|---|
LoadedRoleHistory |
attemptToReadHistory(org.apache.hadoop.fs.FileSystem fileSystem,
List<org.apache.hadoop.fs.Path> paths)
Iterate through the paths until one can be loaded
|
org.apache.hadoop.fs.Path |
createHistoryFilename(org.apache.hadoop.fs.Path historyPath,
long time)
Create the filename for a history file
|
List<org.apache.hadoop.fs.Path> |
findAllHistoryEntries(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path dir,
boolean includeEmptyFiles)
Find all history entries in a dir.
|
LoadedRoleHistory |
loadFromHistoryDir(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path dir)
Try to load the history from a directory -a failure to load a specific
file is downgraded to a log and the next older path attempted instead
|
int |
purgeOlderHistoryEntries(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path keep)
Delete all old history entries older than the one we want to keep.
|
LoadedRoleHistory |
read(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
Read a role history from a path in a filesystem
|
LoadedRoleHistory |
read(InputStream in)
Read a history, returning one that is ready to have its onThaw()
method called
|
LoadedRoleHistory |
read(String resource)
Read from a resource in the classpath -used for testing
|
static void |
sortHistoryPaths(List<org.apache.hadoop.fs.Path> paths) |
long |
write(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
boolean overwrite,
RoleHistory history,
long savetime)
Write the history information to a file
|
long |
write(OutputStream out,
RoleHistory history,
long savetime)
Write out the history.
|
protected static final org.slf4j.Logger log
public static final int ROLE_HISTORY_VERSION
public long write(OutputStream out, RoleHistory history, long savetime) throws IOException
out - outstreamhistory - historysavetime - time in millis for the save time to go in as a recordIOException - IO failurespublic long write(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
boolean overwrite,
RoleHistory history,
long savetime)
throws IOException
fs - filesystempath - pathoverwrite - overwrite flaghistory - historysavetime - time in millis for the save time to go in as a recordIOException - IO failurespublic org.apache.hadoop.fs.Path createHistoryFilename(org.apache.hadoop.fs.Path historyPath,
long time)
time - time valuepublic LoadedRoleHistory read(InputStream in) throws IOException, BadConfigException
in - input sourceIOException - problemsBadConfigExceptionpublic LoadedRoleHistory read(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException, BadConfigException
fs - filesystempath - path to the fileIOException - any problemBadConfigExceptionpublic LoadedRoleHistory read(String resource) throws IOException, BadConfigException
resource - resourceIOException - any problemBadConfigExceptionpublic List<org.apache.hadoop.fs.Path> findAllHistoryEntries(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir, boolean includeEmptyFiles) throws IOException
SliderKeys.HISTORY_FILENAME_MATCH_PATTERN
while dropping empty files and directories which match the pattern.
The list is then sorted with a comparator that sorts on filename,
relying on the filename of newer created files being later than the old ones.fs - filesystemdir - dir to scanincludeEmptyFiles - should empty files be included in the result?IOException - IO problemsFileNotFoundException - if the target dir is actually a pathpublic static void sortHistoryPaths(List<org.apache.hadoop.fs.Path> paths)
public LoadedRoleHistory attemptToReadHistory(org.apache.hadoop.fs.FileSystem fileSystem, List<org.apache.hadoop.fs.Path> paths) throws BadConfigException
paths - paths to loadBadConfigExceptionpublic LoadedRoleHistory loadFromHistoryDir(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) throws IOException, BadConfigException
fs - filesystemdir - dir to load fromIOException - if indexing the history directory fails.BadConfigExceptionpublic int purgeOlderHistoryEntries(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path keep)
throws IOException
fileSystem - filesystemkeep - path to keep -used in thresholding the filesFileNotFoundException - if the path to keep is not present (safety
check to stop the entire dir being purged)IOException - IO problemsCopyright © 2014–2015 The Apache Software Foundation. All rights reserved.