public class FileMonitor extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FileMonitor.FileItem
One element in the directory
|
static class |
FileMonitor.FileMonitorInformation
Used by Waarp Business information
|
protected class |
FileMonitor.FileMonitorTimerInformationTask
Class to run Waarp Business information in fixed delay rather than after each check
|
protected static class |
FileMonitor.FileMonitorTimerTask
Timer task
|
Constructor and Description |
---|
FileMonitor(String name,
File statusFile,
File stopFile,
File directory,
org.waarp.common.digest.FilesystemBasedDigest.DigestAlgo digest,
long elapseTime,
FileFilter filter,
boolean scanSubdir,
FileMonitorCommandRunnableFuture commandValidFile,
FileMonitorCommandRunnableFuture commandRemovedFile,
FileMonitorCommandRunnableFuture commandCheckIteration) |
Modifier and Type | Method and Description |
---|---|
void |
addDirectory(File directory)
Add a directory to scan
|
protected boolean |
checkFiles()
Check Files
|
protected boolean |
checkOneDir(boolean fileItemsChanged,
File directory) |
long |
getCurrentHistoryNb() |
long |
getElapseTime() |
long |
getElapseWaarpTime() |
String |
getStatus() |
boolean |
initialized() |
static void |
main(String[] args) |
File |
peek() |
File |
poll() |
protected void |
reloadStatus() |
void |
removeDirectory(File directory)
Add a directory to scan
|
protected void |
saveStatus() |
void |
setCommandCheckIteration(FileMonitorCommandRunnableFuture commandCheckIteration) |
void |
setCommandValidFileFactory(FileMonitorCommandFactory factory,
int fixedPool) |
void |
setElapseTime(long elapseTime) |
void |
setElapseWaarpTime(long elapseWaarpTime)
if set greater than 1000 ms, will be parallel,
else will be sequential after each check and ignoring this timer
|
void |
setFilter(FileFilter filter) |
void |
setNextAsFullStatus()
Reset such that next status will be full (not partial)
|
protected void |
setNextDay() |
protected void |
setThreadName() |
void |
start() |
void |
stop() |
void |
waitForStopFile()
Wait until the Stop file is created
|
protected static volatile WaarpLogger logger
protected static final org.waarp.common.digest.FilesystemBasedDigest.DigestAlgo defaultDigestAlgo
protected static final long minimalDelay
protected static final long defaultDelay
protected WaarpFuture future
protected WaarpFuture internalfuture
protected boolean stopped
protected final String name
protected final File statusFile
protected final File stopFile
protected final org.waarp.common.digest.FilesystemBasedDigest.DigestAlgo digest
protected long elapseTime
protected long elapseWaarpTime
protected io.netty.util.Timer timer
protected io.netty.util.Timer timerWaarp
protected boolean scanSubDir
protected boolean initialized
protected File checkFile
protected final ConcurrentHashMap<String,FileMonitor.FileItem> fileItems
protected ConcurrentHashMap<String,FileMonitor.FileItem> lastFileItems
protected FileFilter filter
protected FileMonitorCommandRunnableFuture commandValidFile
protected FileMonitorCommandFactory commandValidFileFactory
protected ExecutorService executor
protected int fixedThreadPool
protected FileMonitorCommandRunnableFuture commandRemovedFile
protected FileMonitorCommandRunnableFuture commandCheckIteration
protected ConcurrentLinkedQueue<FileMonitor.FileItem> toUse
protected final ConcurrentLinkedQueue<Future<?>> results
protected AtomicLong globalok
protected AtomicLong globalerror
protected AtomicLong todayok
protected AtomicLong todayerror
protected Date nextDay
public FileMonitor(String name, File statusFile, File stopFile, File directory, org.waarp.common.digest.FilesystemBasedDigest.DigestAlgo digest, long elapseTime, FileFilter filter, boolean scanSubdir, FileMonitorCommandRunnableFuture commandValidFile, FileMonitorCommandRunnableFuture commandRemovedFile, FileMonitorCommandRunnableFuture commandCheckIteration)
name
- name of this daemonstatusFile
- the file where the current status is saved (current files)stopFile
- the file when created (.exists()) will stop the daemondirectory
- the directory where files will be monitoreddigest
- the digest to use (default if null is MD5)elapseTime
- the time to wait in ms for between 2 checks (default is 1000ms, minimum is 100ms)filter
- the filter to be applied on selected files (default is isFile())commandValidFile
- the commandValidFile to run (may be null, which means poll() commandValidFile has to be used)commandRemovedFile
- the commandRemovedFile to run (may be null)commandCheckIteration
- the commandCheckIteration to run (may be null), runs after each check (elapseTime)protected void setNextDay()
public void setCommandCheckIteration(FileMonitorCommandRunnableFuture commandCheckIteration)
commandCheckIteration
- the commandCheckIteration to run (may be null), runs after each check (elapseTime)public void setCommandValidFileFactory(FileMonitorCommandFactory factory, int fixedPool)
factory
- the factory to used instead of simple instance (enables parallelism)fixedPool
- if > 0, set the number of parallel threads allowedpublic long getElapseWaarpTime()
public void setElapseWaarpTime(long elapseWaarpTime)
elapseWaarpTime
- the elapseWaarpTime to setpublic void addDirectory(File directory)
directory
- public void removeDirectory(File directory)
directory
- protected void setThreadName()
protected void reloadStatus()
public boolean initialized()
protected void saveStatus()
public long getCurrentHistoryNb()
public void setNextAsFullStatus()
public String getStatus()
public long getElapseTime()
public void setElapseTime(long elapseTime)
elapseTime
- the elapseTime to setpublic void setFilter(FileFilter filter)
filter
- the filter to setpublic void start()
public void stop()
public File peek()
public File poll()
public void waitForStopFile()
protected boolean checkFiles()
protected boolean checkOneDir(boolean fileItemsChanged, File directory)
fileItemsChanged
- directory
- public static void main(String[] args)
Copyright © 2009–2019 Waarp. All rights reserved.