@@ -35,7 +35,6 @@ |
import com.mongodb.gridfs.GridFS; |
import com.mongodb.gridfs.GridFSDBFile; |
import com.mongodb.gridfs.GridFSInputFile; |
-import com.sun.javafx.scene.control.skin.VirtualFlow; |
import csip.ModelDataService.Task; |
import csip.utils.Binaries; |
import java.io.ByteArrayInputStream; |
@@ -47,6 +46,7 @@ |
import java.lang.reflect.Method; |
import java.sql.Connection; |
import java.sql.SQLException; |
+import java.sql.SQLTimeoutException; |
import java.sql.Statement; |
import java.text.DateFormat; |
import java.text.SimpleDateFormat; |
@@ -105,7 +105,7 @@ |
/* |
The CSIP version |
*/ |
- put("csip.version", "$version: 2.1.10 dec2e8c6030c 2016-03-30 od, built at 2016-03-31 20:57 by od$"); |
+ put("csip.version", "$version: 2.1.11 0904889a1467 2016-04-01 od, built at 2016-04-01 21:23 by od$"); |
|
/* |
* The runtime architecture. |
@@ -206,6 +206,17 @@ |
|
put("csip.accesslog.postgres.url", "jdbc:postgresql://localhost/od?user=od&password=od"); |
|
+ /* |
+ connection timeout in sec to write to accesslog |
+ */ |
+ put("csip.accesslog.postgres.timeout", "3"); |
+ |
+ /* |
+ Number of timeouts before giving up on trying to write to accesslog |
+ If this number of reached no further attempt is made. |
+ */ |
+ put("csip.accesslog.postgres.retry", "10"); |
+ |
// some generic server parameter for hazelcast and redis. |
/* |
The connection timeout for all redis connections. |
@@ -1092,6 +1103,8 @@ |
|
SessionLogger l = new SessionLogger(null, "PostgresAccessLog", ""); |
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); |
+ int timeout = getInt("csip.accesslog.postgres.timeout", 2); |
+ int retry = getInt("csip.accesslog.postgres.retry", 10); |
|
|
PostgresAccessLogStore(String url) { |
@@ -1113,8 +1126,12 @@ |
*/ |
@Override |
public synchronized void log(String suid, String service_url, String req_ip, String node_ip, String req_time, String status, int duration) { |
+ if (retry == 0) { |
+ return; |
+ } |
try (Connection c = Binaries.getConnection(jdbc_session_id, l)) { |
try (Statement st = c.createStatement()) { |
+ st.setQueryTimeout(timeout); |
st.executeUpdate("insert into accesslog(suid,date,service_url,status,duration,req_ip,node_ip) values('" |
+ suid + "','" |
+ df.format(new Date()) + "','" |
@@ -1124,6 +1141,8 @@ |
+ req_ip + "','" |
+ node_ip + "');"); |
} |
+ } catch (SQLTimeoutException to) { |
+ retry--; |
} catch (SQLException | ServiceException ex) { |
l.log(Level.SEVERE, null, ex); |
LOG.log(Level.SEVERE, null, ex); |