svn commit: r888111 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r888111 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java

jleroux@apache.org
Author: jleroux
Date: Mon Dec  7 20:05:51 2009
New Revision: 888111

URL: http://svn.apache.org/viewvc?rev=888111&view=rev
Log:
Revert r887916, not a solution at all
I did not test eCommerce, it crashes at 1st load :/

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java?rev=888111&r1=888110&r2=888111&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java Mon Dec  7 20:05:51 2009
@@ -618,7 +618,7 @@
             GenericValue serverHit = delegator.makeValue("ServerHit");
 
             serverHit.set("visitId", visitId);
-            serverHit.set("hitStartDateTime", getNowTimestamp()); // A change was introduced with https://issues.apache.org/jira/browse/OFBIZ-2208. Since then startTime is not used anymore
+            serverHit.set("hitStartDateTime", new java.sql.Timestamp(startTime));
             serverHit.set("hitTypeId", ServerHitBin.typeIds[this.type]);
             if (userLogin != null) {
                 serverHit.set("userLoginId", userLogin.get("userLoginId"));
@@ -651,15 +651,27 @@
                 Debug.logError("Unable to get localhost internet address: " + e.toString(), module);
             }
 
+            // The problem with
+            //
+            //     serverHit.create();
+            //
+            // is that if there are two requests with the same startTime (this should only happen with MySQL see https://issues.apache.org/jira/browse/OFBIZ-2208)
+            // then this will go wrong and abort the actual
+            // transaction we are interested in.
+            // Another way instead of using create is to store or update,
+            // that is overwrite in case there already was an entry, thus
+            // avoiding the transaction being aborted which is not
+            // less desirable than having multiple requests with the
+            // same startTime overwriting each other.
+            // This may not satisfy those who want to record each and
+            // every server hit even with equal startTimes but that could be
+            // solved adding a counter to the ServerHit's PK (a counter
+            // counting multiple hits at the same startTime).
             try {
                 serverHit.create();
             } catch (GenericEntityException e) {
-                Debug.logError(e, "Could not save ServerHit: ", module);
+                Debug.logError(e, "Could not save ServerHit:", module);
             }
         }
     }
-    
-    public synchronized java.sql.Timestamp getNowTimestamp() {
-        return new java.sql.Timestamp(System.currentTimeMillis());
-    }
 }