public final class PathAlterationObserverScheduler extends Object implements Runnable
PathAlterationObserver at a specified interval.
Based on FileAlterationMonitor, implemented monitoring
thread to periodically check the monitored file in thread pool.| Constructor and Description |
|---|
PathAlterationObserverScheduler() |
PathAlterationObserverScheduler(long interval) |
| Modifier and Type | Method and Description |
|---|---|
void |
addObserver(PathAlterationObserver observer)
Add a file system observer to this monitor.
|
void |
addPathAlterationObserver(PathAlterationListener listener,
com.google.common.base.Optional<PathAlterationObserver> observerOptional,
org.apache.hadoop.fs.Path rootDirPath)
Create and attach
PathAlterationObserverSchedulers for the given
root directory and any nested subdirectories under the root directory to the given
PathAlterationObserverScheduler. |
Iterable<PathAlterationObserver> |
getObservers()
Returns the set of
PathAlterationObserver registered with
this monitor. |
void |
removeObserver(PathAlterationObserver observer)
Remove a file system observer from this monitor.
|
void |
run() |
void |
start()
Start monitoring.
|
void |
stop()
Stop monitoring
|
void |
stop(long stopInterval)
Stop monitoring
|
public PathAlterationObserverScheduler()
public PathAlterationObserverScheduler(long interval)
public void addObserver(PathAlterationObserver observer)
observer - The file system observer to addpublic void removeObserver(PathAlterationObserver observer)
observer - The file system observer to removepublic Iterable<PathAlterationObserver> getObservers()
PathAlterationObserver registered with
this monitor.PathAlterationObserverpublic void start()
throws IOException
IOException - if an error occurs initializing the observerpublic void stop()
throws IOException,
InterruptedException
Exception - if an error occurs initializing the observerIOExceptionInterruptedExceptionpublic void stop(long stopInterval)
throws IOException,
InterruptedException
stopInterval - the amount of time in milliseconds to wait for the thread to finish.
A value of zero will wait until the thread is finished (see Thread.join(long)).IOException - if an error occurs initializing the observerInterruptedExceptionpublic void addPathAlterationObserver(PathAlterationListener listener, com.google.common.base.Optional<PathAlterationObserver> observerOptional, org.apache.hadoop.fs.Path rootDirPath) throws IOException
PathAlterationObserverSchedulers for the given
root directory and any nested subdirectories under the root directory to the given
PathAlterationObserverScheduler.detector - a PathAlterationObserverSchedulerlistener - a PathAlterationListenerobserverOptional - Optional observer object. For testing routine, this has been initialized by user.
But for general usage, the observer object is created inside this method.rootDirPath - root directoryIOException