clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enrid...@apache.org
Subject [1/4] git commit: CLEREZZA-890 Implemented a simple connection renewal policy. Resources are closed and connection renewed after 10000 statement executions.
Date Sun, 16 Mar 2014 16:51:17 GMT
Repository: clerezza
Updated Branches:
  refs/heads/master 659ad22ab -> 9b0528a86


CLEREZZA-890 Implemented a simple connection renewal policy. Resources are closed and connection
renewed after 10000 statement executions.


Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/a2755676
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/a2755676
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/a2755676

Branch: refs/heads/master
Commit: a2755676a65271f2a090658d5fa859e4bb89521c
Parents: 659ad22
Author: enridaga <enridaga@apache.org>
Authored: Sun Mar 16 16:45:25 2014 +0000
Committer: enridaga <enridaga@apache.org>
Committed: Sun Mar 16 16:45:25 2014 +0000

----------------------------------------------------------------------
 .../rdf/virtuoso/storage/access/DataAccess.java    | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/a2755676/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/access/DataAccess.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/access/DataAccess.java
b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/access/DataAccess.java
index d5abc36..f420f99 100644
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/access/DataAccess.java
+++ b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/access/DataAccess.java
@@ -1,6 +1,5 @@
 package rdf.virtuoso.storage.access;
 
-import java.io.PrintWriter;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -110,11 +109,6 @@ public class DataAccess {
 		try {
 			Class.forName(VirtuosoWeightedProvider.DRIVER, true, this
 					.getClass().getClassLoader());
-			if (logger.isDebugEnabled()) {
-				logger.debug("Activating logging for DriverManager in stderr");
-				// FIXME! How to redirect logging to our logger???
-				DriverManager.setLogWriter(new PrintWriter(System.err));
-			}
 			VirtuosoConnection c = (VirtuosoConnection) DriverManager
 					.getConnection(connectionString, user, pwd);
 			c.setAutoCommit(true);
@@ -126,8 +120,16 @@ public class DataAccess {
 		}
 	}
 
+	// A simple renewal policy
+	private int statementCalls = 0;
 	protected PreparedStatement getStatement(String query)
 			throws VirtuosoException {
+		if(statementCalls >= 10000){
+			statementCalls=0; 
+			renew();
+		}else{
+			statementCalls++;
+		}
 		if (!preparedStatements.containsKey(query)) {
 			VirtuosoPreparedStatement ps = (VirtuosoPreparedStatement) connection
 					.prepareStatement(query);
@@ -158,6 +160,7 @@ public class DataAccess {
 	}
 
 	public void close() {
+		logger.trace("closing resources...");
 		Collection<VirtuosoPreparedStatement> pss = preparedStatements.values();
 		for (VirtuosoPreparedStatement ps : pss) {
 			try {
@@ -167,9 +170,11 @@ public class DataAccess {
 				logger.error("Cannot close statement", e);
 			}
 		}
+		logger.trace("closed {} statements.", pss.size());
 		preparedStatements.clear();
 		try {
 			connection.close();
+			logger.trace("Connection closed");
 		} catch (Exception e) {
 			logger.error("Cannot close connection", e);
 		}


Mime
View raw message