mirror of
https://github.com/Febbweiss/logstash-forwarder-java.git
synced 2026-03-04 22:25:39 +00:00
Repaired sincedb initialization
This commit is contained in:
@@ -48,7 +48,8 @@ public class FileWatcher {
|
|||||||
private boolean stdinConfigured = false;
|
private boolean stdinConfigured = false;
|
||||||
private String sincedbFile = null;
|
private String sincedbFile = null;
|
||||||
|
|
||||||
public FileWatcher() {
|
public FileWatcher(String sincedbFileName) {
|
||||||
|
sincedbFile = sincedbFileName;
|
||||||
try {
|
try {
|
||||||
logger.debug("Loading saved states");
|
logger.debug("Loading saved states");
|
||||||
savedStates = Registrar.readStateFromJson(sincedbFile);
|
savedStates = Registrar.readStateFromJson(sincedbFile);
|
||||||
@@ -363,9 +364,4 @@ public class FileWatcher {
|
|||||||
public void setTail(boolean tail) {
|
public void setTail(boolean tail) {
|
||||||
this.tail = tail;
|
this.tail = tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSincedb(String sincedbFile) {
|
|
||||||
this.sincedbFile = sincedbFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,10 +72,9 @@ public class Forwarder {
|
|||||||
try {
|
try {
|
||||||
parseOptions(args);
|
parseOptions(args);
|
||||||
setupLogging();
|
setupLogging();
|
||||||
watcher = new FileWatcher();
|
watcher = new FileWatcher(sincedbFile);
|
||||||
watcher.setMaxSignatureLength(signatureLength);
|
watcher.setMaxSignatureLength(signatureLength);
|
||||||
watcher.setTail(tailSelected);
|
watcher.setTail(tailSelected);
|
||||||
watcher.setSincedb(sincedbFile);
|
|
||||||
configManager = new ConfigurationManager(config);
|
configManager = new ConfigurationManager(config);
|
||||||
configManager.readConfiguration();
|
configManager.readConfiguration();
|
||||||
for(FilesSection files : configManager.getConfig().getFiles()) {
|
for(FilesSection files : configManager.getConfig().getFiles()) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class FileWatcherTest {
|
|||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void testFileWatch() throws InterruptedException, IOException {
|
public void testFileWatch() throws InterruptedException, IOException {
|
||||||
FileWatcher watcher = new FileWatcher();
|
FileWatcher watcher = new FileWatcher(".logstash-forwarder-java");
|
||||||
watcher.addFilesToWatch("./test.txt", new Event().addField("test", "test"), FileWatcher.ONE_DAY);
|
watcher.addFilesToWatch("./test.txt", new Event().addField("test", "test"), FileWatcher.ONE_DAY);
|
||||||
for(int i = 0; i < 100; i++) {
|
for(int i = 0; i < 100; i++) {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
@@ -60,7 +60,7 @@ public class FileWatcherTest {
|
|||||||
logger.warn("Not executing this test on windows");
|
logger.warn("Not executing this test on windows");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FileWatcher watcher = new FileWatcher();
|
FileWatcher watcher = new FileWatcher(".logstash-forwarder-java");
|
||||||
watcher.addFilesToWatch("./testFileWatcher*.txt", new Event().addField("test", "test"), FileWatcher.ONE_DAY);
|
watcher.addFilesToWatch("./testFileWatcher*.txt", new Event().addField("test", "test"), FileWatcher.ONE_DAY);
|
||||||
watcher.initialize();
|
watcher.initialize();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user