org/sonews/feed/PullFeeder.java
changeset 3 2fdc9cc89502
parent 1 6fceb66e1ad7
child 7 0b76e099eb96
     1.1 --- a/org/sonews/feed/PullFeeder.java	Wed Jul 01 10:48:22 2009 +0200
     1.2 +++ b/org/sonews/feed/PullFeeder.java	Wed Jul 22 14:04:05 2009 +0200
     1.3 @@ -25,14 +25,14 @@
     1.4  import java.net.Socket;
     1.5  import java.net.SocketException;
     1.6  import java.net.UnknownHostException;
     1.7 -import java.sql.SQLException;
     1.8  import java.util.ArrayList;
     1.9  import java.util.HashMap;
    1.10  import java.util.List;
    1.11  import java.util.Map;
    1.12 -import org.sonews.daemon.Config;
    1.13 +import org.sonews.config.Config;
    1.14  import org.sonews.util.Log;
    1.15 -import org.sonews.daemon.storage.Database;
    1.16 +import org.sonews.storage.StorageBackendException;
    1.17 +import org.sonews.storage.StorageManager;
    1.18  import org.sonews.util.Stats;
    1.19  import org.sonews.util.io.ArticleReader;
    1.20  import org.sonews.util.io.ArticleWriter;
    1.21 @@ -154,7 +154,7 @@
    1.22      while(isRunning())
    1.23      {
    1.24        int pullInterval = 1000 * 
    1.25 -        Config.getInstance().get(Config.FEED_PULLINTERVAL, 3600);
    1.26 +        Config.inst().get(Config.FEED_PULLINTERVAL, 3600);
    1.27        String host = "localhost";
    1.28        int    port = 119;
    1.29        
    1.30 @@ -189,36 +189,34 @@
    1.31  
    1.32                for(String messageID : messageIDs)
    1.33                {
    1.34 -                if(Database.getInstance().isArticleExisting(messageID))
    1.35 +                if(!StorageManager.current().isArticleExisting(messageID))
    1.36                  {
    1.37 -                  continue;
    1.38 -                }
    1.39 -
    1.40 -                try
    1.41 -                {
    1.42 -                  // Post the message via common socket connection
    1.43 -                  ArticleReader aread =
    1.44 -                    new ArticleReader(sub.getHost(), sub.getPort(), messageID);
    1.45 -                  byte[] abuf = aread.getArticleData();
    1.46 -                  if (abuf == null)
    1.47 +                  try
    1.48                    {
    1.49 -                    Log.msg("Could not feed " + messageID + " from " + sub.getHost(), true);
    1.50 +                    // Post the message via common socket connection
    1.51 +                    ArticleReader aread =
    1.52 +                      new ArticleReader(sub.getHost(), sub.getPort(), messageID);
    1.53 +                    byte[] abuf = aread.getArticleData();
    1.54 +                    if (abuf == null)
    1.55 +                    {
    1.56 +                      Log.msg("Could not feed " + messageID + " from " + sub.getHost(), true);
    1.57 +                    }
    1.58 +                    else
    1.59 +                    {
    1.60 +                      Log.msg("Feeding " + messageID, true);
    1.61 +                      ArticleWriter awrite = new ArticleWriter(
    1.62 +                        "localhost", Config.inst().get(Config.PORT, 119));
    1.63 +                      awrite.writeArticle(abuf);
    1.64 +                      awrite.close();
    1.65 +                    }
    1.66 +                    Stats.getInstance().mailFeeded(sub.getGroup());
    1.67                    }
    1.68 -                  else
    1.69 +                  catch(IOException ex)
    1.70                    {
    1.71 -                    Log.msg("Feeding " + messageID, true);
    1.72 -                    ArticleWriter awrite = new ArticleWriter(
    1.73 -                      "localhost", Config.getInstance().get(Config.PORT, 119));
    1.74 -                    awrite.writeArticle(abuf);
    1.75 -                    awrite.close();
    1.76 +                    // There may be a temporary network failure
    1.77 +                    ex.printStackTrace();
    1.78 +                    Log.msg("Skipping mail " + messageID + " due to exception.", false);
    1.79                    }
    1.80 -                  Stats.getInstance().mailFeeded(sub.getGroup());
    1.81 -                }
    1.82 -                catch(IOException ex)
    1.83 -                {
    1.84 -                  // There may be a temporary network failure
    1.85 -                  ex.printStackTrace();
    1.86 -                  Log.msg("Skipping mail " + messageID + " due to exception.", false);
    1.87                  }
    1.88                } // for(;;)
    1.89                this.highMarks.put(sub, newMark);
    1.90 @@ -226,7 +224,7 @@
    1.91              
    1.92              disconnect();
    1.93            }
    1.94 -          catch(SQLException ex)
    1.95 +          catch(StorageBackendException ex)
    1.96            {
    1.97              ex.printStackTrace();
    1.98            }