diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-05-12 11:25:20 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-05-12 11:25:20 +0200 |
commit | 276adf93ffeb4e71a6fd06a181c2ec629a50007e (patch) | |
tree | 5796fbc81f0b22424ae890729af08db4a34a3bd5 | |
parent | 98206c3aede24f7820c330f7e54e7247acc38c67 (diff) | |
download | Datafiller-276adf93ffeb4e71a6fd06a181c2ec629a50007e.tar.gz |
Fix status reporting
-rw-r--r-- | src/main/Main.java | 4 | ||||
-rw-r--r-- | src/main/Watcher.java | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/main/Main.java b/src/main/Main.java index e7fc372..43e5619 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -111,7 +111,9 @@ public class Main implements Callable<Boolean> { private boolean tweetsToDb(ITweetReader reader) throws IOException { Tweet tweet = null; tweetNo = 1; + System.err.println("Trying to establish DB connection..."); try (Connection connection = cb.create()) { + System.err.println("Connected, starting to read tweets."); /* create the object that fills the database */ DataFiller filler = new DataFiller(connection); while ((tweet = reader.getTweet()) != null) { @@ -137,7 +139,7 @@ public class Main implements Callable<Boolean> { public int getProcessedTweets() { // tweetNo is the tweet number of the tweet that is being processed. - return Math.min(0, tweetNo - 1); + return Math.max(0, tweetNo - 1); } @Override diff --git a/src/main/Watcher.java b/src/main/Watcher.java index bb790f0..6032095 100644 --- a/src/main/Watcher.java +++ b/src/main/Watcher.java @@ -29,6 +29,11 @@ class Watcher implements Runnable { @Override public void run() { int newCount = main.getProcessedTweets(); + if (newCount < 1) { + // database connection is being established? Whatever is the case, + // no status information should be printed. + return; + } int tweets_per_min = (newCount - previousCount) * 60 / interval; int tweets_per_sec = tweets_per_min / 60; elapsed_seconds += interval; |