mirror of
https://github.com/Febbweiss/logstash-forwarder-java.git
synced 2026-03-05 06:35:44 +00:00
FileWatcher debugging.
This commit is contained in:
@@ -68,7 +68,8 @@ public class FileWatcher implements FileAlterationListener {
|
|||||||
|
|
||||||
public void checkFiles() throws IOException {
|
public void checkFiles() throws IOException {
|
||||||
logger.debug("Checking files");
|
logger.debug("Checking files");
|
||||||
//printWatchMap();
|
logger.trace("==============");
|
||||||
|
|
||||||
for(FileAlterationObserver observer : observerList) {
|
for(FileAlterationObserver observer : observerList) {
|
||||||
observer.checkAndNotify();
|
observer.checkAndNotify();
|
||||||
}
|
}
|
||||||
@@ -77,15 +78,22 @@ public class FileWatcher implements FileAlterationListener {
|
|||||||
printWatchMap();
|
printWatchMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void readFiles() {
|
||||||
|
logger.debug("Reading files");
|
||||||
|
logger.trace("==============");
|
||||||
|
}
|
||||||
|
|
||||||
private void processModifications() throws IOException {
|
private void processModifications() throws IOException {
|
||||||
|
|
||||||
for(File file : changedWatchMap.keySet()) {
|
for(File file : changedWatchMap.keySet()) {
|
||||||
FileState state = changedWatchMap.get(file);
|
FileState state = changedWatchMap.get(file);
|
||||||
|
if(logger.isTraceEnabled()) {
|
||||||
logger.trace("Checking file : " + file.getCanonicalPath());
|
logger.trace("Checking file : " + file.getCanonicalPath());
|
||||||
logger.trace("-- Last modified : " + state.getLastModified());
|
logger.trace("-- Last modified : " + state.getLastModified());
|
||||||
logger.trace("-- Size : " + state.getSize());
|
logger.trace("-- Size : " + state.getSize());
|
||||||
logger.trace("-- Directory : " + state.getDirectory());
|
logger.trace("-- Directory : " + state.getDirectory());
|
||||||
logger.trace("-- Filename : " + state.getFileName());
|
logger.trace("-- Filename : " + state.getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if file is still the same
|
// Determine if file is still the same
|
||||||
logger.trace("Determine if file has just been written to");
|
logger.trace("Determine if file has just been written to");
|
||||||
@@ -125,7 +133,9 @@ public class FileWatcher implements FileAlterationListener {
|
|||||||
for(File otherFile : watchMap.keySet()) {
|
for(File otherFile : watchMap.keySet()) {
|
||||||
FileState otherState = watchMap.get(otherFile);
|
FileState otherState = watchMap.get(otherFile);
|
||||||
if(otherState != null && state.getSize() >= otherState.getSize() && state.getDirectory().equals(otherState.getDirectory())) {
|
if(otherState != null && state.getSize() >= otherState.getSize() && state.getDirectory().equals(otherState.getDirectory())) {
|
||||||
|
if(logger.isTraceEnabled()) {
|
||||||
logger.trace("Comparing to : " + otherFile.getCanonicalPath());
|
logger.trace("Comparing to : " + otherFile.getCanonicalPath());
|
||||||
|
}
|
||||||
// File in the same directory which was smaller
|
// File in the same directory which was smaller
|
||||||
if(otherState.getSignatureLength() == state.getSignatureLength() && otherState.getSignature() == state.getSignature()) {
|
if(otherState.getSignatureLength() == state.getSignatureLength() && otherState.getSignature() == state.getSignature()) {
|
||||||
// File is the same
|
// File is the same
|
||||||
@@ -156,7 +166,9 @@ public class FileWatcher implements FileAlterationListener {
|
|||||||
// Refresh file state
|
// Refresh file state
|
||||||
logger.trace("Refreshing file state");
|
logger.trace("Refreshing file state");
|
||||||
for(File file : changedWatchMap.keySet()) {
|
for(File file : changedWatchMap.keySet()) {
|
||||||
|
if(logger.isTraceEnabled()) {
|
||||||
logger.trace("Refreshing file : " + file.getCanonicalPath());
|
logger.trace("Refreshing file : " + file.getCanonicalPath());
|
||||||
|
}
|
||||||
FileState state = changedWatchMap.get(file);
|
FileState state = changedWatchMap.get(file);
|
||||||
FileState oldState = state.getOldFileState();
|
FileState oldState = state.getOldFileState();
|
||||||
if(oldState == null) {
|
if(oldState == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user