changeset 308:a077bb098eb4

Fixed broken SQL statement. Added debug output. artifacts/trunk@2427 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 31 Jul 2011 17:28:07 +0000
parents d96bcb40dbf9
children 86dd32b45d87
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/java/de/intevation/artifactdatabase/db/DBConnection.java artifact-database/src/main/resources/sql/org-h2-driver.properties artifact-database/src/main/resources/sql/org-postgresql-driver.properties
diffstat 6 files changed, 39 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jul 31 15:18:57 2011 +0000
+++ b/ChangeLog	Sun Jul 31 17:28:07 2011 +0000
@@ -1,3 +1,14 @@
+2011-07-31	Sascha L. Teichmann	<teichmann@intevation.de>
+
+	* artifact-database/src/main/resources/sql/org-h2-driver.properties,
+	  artifact-database/src/main/resources/sql/org-postgresql-driver.properties:
+	  Fixed broken SQL statement.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java,
+	  artifact-database/src/main/java/de/intevation/artifactdatabase/db/DBConnection.java,
+	  artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: Added
+	  debug output.
+
 2011-07-31	Sascha L. Teichmann	<teichmann@intevation.de>
 
 	Make artifact server bootable again.
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Sun Jul 31 15:18:57 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Sun Jul 31 17:28:07 2011 +0000
@@ -1736,6 +1736,8 @@
             ltl.systemUp(context);
         }
 
+        logger.debug("all lifetime listeners started");
+
         Runtime.getRuntime().addShutdownHook(new Thread() {
             @Override
             public void run() {
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Sun Jul 31 15:18:57 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Sun Jul 31 17:28:07 2011 +0000
@@ -19,6 +19,7 @@
 
 import de.intevation.artifacts.common.utils.StringUtils;
 import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.artifacts.common.utils.LRUCache;
 
 import de.intevation.artifactdatabase.db.SQLExecutor;
 import de.intevation.artifactdatabase.db.SQL;
@@ -1568,23 +1569,21 @@
 
     public boolean loadAllArtifacts(final ArtifactLoadedCallback alc) {
 
+        logger.debug("loadAllArtifacts");
+
         if (factoryLookup == null) {
             logger.error("factory lookup == null");
             return false;
         }
 
-        return sqlExecutor.new Instance() {
+        boolean success = sqlExecutor.new Instance() {
+            @Override
             public boolean doIt() throws SQLException {
+                logger.debug("doIt");
 
                 // a little cache to avoid too much deserializations.
-                Map<String, Artifact> alreadyLoaded =
-                    new LinkedHashMap<String, Artifact>() {
-                        @Override
-                        protected boolean removeEldestEntry(Map.Entry eldest) {
-                            // store only the last 200 to avoid memory flooding
-                            return size() > 200;
-                        }
-                    };
+                LRUCache<String, Artifact> alreadyLoaded =
+                    new LRUCache<String, Artifact>(200);
 
                 prepareStatement(SQL_ALL_ARTIFACTS);
                 result = stmnt.executeQuery();
@@ -1624,6 +1623,12 @@
                 return true;
             }
         }.runRead();
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("loadAllArtifacts success: " + success);
+        }
+
+        return success;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/db/DBConnection.java	Sun Jul 31 15:18:57 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/db/DBConnection.java	Sun Jul 31 17:28:07 2011 +0000
@@ -10,8 +10,12 @@
 
 import de.intevation.artifacts.common.utils.Config;
 
+import org.apache.log4j.Logger;
+
 public class DBConnection
 {
+    private static Logger log = Logger.getLogger(DBConnection.class);
+
     public static final String DEFAULT_DRIVER        = "org.h2.Driver";
     public static final String DEFAULT_USER          = "";
     public static final String DEFAULT_PASSWORD      = "";
@@ -96,6 +100,12 @@
 
     public synchronized DataSource getDataSource() {
         if (dataSource == null) {
+            if (log.isDebugEnabled()) {
+                log.debug("create new datasource:");
+                log.debug(" driver: " + driver);
+                log.debug(" url   : " + url);
+                log.debug(" user  : " + user);
+            }
             dataSource = new BasicDataSource();
 
             dataSource.setDriverClassName(driver);
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties	Sun Jul 31 15:18:57 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties	Sun Jul 31 17:28:07 2011 +0000
@@ -186,5 +186,5 @@
     SELECT u.gid AS u_gid, c.gid AS c_gid, a.gid AS a_gid, a.factory AS factory, a.data AS data FROM \
         users u INNER JOIN collections c       ON u.id = c.owner_id \
                 INNER JOIN collection_items ci ON c.id = ci.collection_id \
-                INNER JOIN artifacts a         ON a.if = ci.artifact_id \
+                INNER JOIN artifacts a         ON a.id = ci.artifact_id \
         ORDER BY u_gid, c_gid
--- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Sun Jul 31 15:18:57 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties	Sun Jul 31 17:28:07 2011 +0000
@@ -175,5 +175,5 @@
     SELECT u.gid AS u_gid, c.gid AS c_gid, a.gid AS a_gid, a.factory AS factory, a.data AS data FROM \
         users u INNER JOIN collections c       ON u.id = c.owner_id \
                 INNER JOIN collection_items ci ON c.id = ci.collection_id \
-                INNER JOIN artifacts a         ON a.if = ci.artifact_id \
+                INNER JOIN artifacts a         ON a.id = ci.artifact_id \
         ORDER BY u_gid, c_gid

http://dive4elements.wald.intevation.org