public abstract class AbstractPersistentAcceptOnceFileListFilter<F> extends AbstractFileListFilter<F> implements ReversibleFileListFilter<F>, ResettableFileListFilter<F>, java.io.Closeable
Modifier and Type | Field and Description |
---|---|
protected java.io.Flushable |
flushableStore |
protected boolean |
flushOnUpdate |
protected java.lang.String |
prefix |
protected ConcurrentMetadataStore |
store |
Constructor and Description |
---|
AbstractPersistentAcceptOnceFileListFilter(ConcurrentMetadataStore store,
java.lang.String prefix) |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(F file)
Subclasses must implement this method.
|
protected java.lang.String |
buildKey(F file)
The default key is the
prefix plus the full filename. |
void |
close() |
protected abstract java.lang.String |
fileName(F file) |
protected boolean |
fileStillExists(F file)
Check if the file still exists; default implementation returns true.
|
protected void |
flushIfNeeded()
Flush the store if it's a
Flushable and
flushOnUpdate is true. |
protected boolean |
isEqual(F file,
java.lang.String value)
Override this method if you wish to use something other than the
modified timestamp to determine equality.
|
protected abstract long |
modified(F file) |
boolean |
remove(F fileToRemove)
Remove the specified file from the filter so it will pass on the next attempt.
|
void |
rollback(F file,
java.util.List<F> files)
Indicate that not all files previously passed by this filter (in
FileListFilter.filterFiles(Object[])
have been processed; the file must be in the list of files; it, and all files after it, will
be considered to have not been processed and will be considered next time. |
void |
setFlushOnUpdate(boolean flushOnUpdate)
Determine whether the metadataStore should be flushed on each update (if
Flushable ). |
filterFiles
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
filterFiles
protected final ConcurrentMetadataStore store
protected final java.io.Flushable flushableStore
protected final java.lang.String prefix
protected volatile boolean flushOnUpdate
public AbstractPersistentAcceptOnceFileListFilter(ConcurrentMetadataStore store, java.lang.String prefix)
public void setFlushOnUpdate(boolean flushOnUpdate)
Flushable
).flushOnUpdate
- true to flush.public boolean accept(F file)
AbstractFileListFilter
accept
in class AbstractFileListFilter<F>
file
- The file.protected boolean fileStillExists(F file)
file
- the file.public void rollback(F file, java.util.List<F> files)
FileListFilter.filterFiles(Object[])
have been processed; the file must be in the list of files; it, and all files after it, will
be considered to have not been processed and will be considered next time.rollback
in interface ReversibleFileListFilter<F>
file
- the file which failed.files
- the list of files that were returned by FileListFilter.filterFiles(Object[])
.public boolean remove(F fileToRemove)
ResettableFileListFilter
remove
in interface ResettableFileListFilter<F>
fileToRemove
- the element to remove.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
protected boolean isEqual(F file, java.lang.String value)
file
- The file.value
- The current value for the key in the store.protected java.lang.String buildKey(F file)
prefix
plus the full filename.file
- The file.protected void flushIfNeeded()
Flushable
and
flushOnUpdate
is true.protected abstract long modified(F file)
protected abstract java.lang.String fileName(F file)