trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hzel...@apache.org
Subject [31/37] incubator-trafodion git commit: add more logs and add NO TRANSACTION REQUIRED
Date Tue, 01 Mar 2016 22:36:17 GMT
add more logs and add NO TRANSACTION REQUIRED


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

Branch: refs/heads/master
Commit: e5757fd8bccca92d9f9bdb6f2420f1188a82b892
Parents: f2c547e
Author: Kevin Xu <kaihua.xu@esgyn.cn>
Authored: Wed Jan 20 17:11:07 2016 +0800
Committer: Kevin Xu <kaihua.xu@esgyn.cn>
Committed: Wed Jan 20 17:11:07 2016 +0800

----------------------------------------------------------------------
 .../java/org/trafodion/libmgmt/FileMgmt.java    | 46 +++++++++++++++++---
 .../lib_mgmt/src/main/resources/init_libmgmt.sh | 15 +++++--
 2 files changed, 51 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e5757fd8/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
----------------------------------------------------------------------
diff --git a/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java b/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
index aa41412..b317612 100644
--- a/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
+++ b/core/sql/lib_mgmt/src/main/java/org/trafodion/libmgmt/FileMgmt.java
@@ -120,25 +120,35 @@ public class FileMgmt {
 		checkFileName(fileName);
 		Connection conn = getConn();
 		Statement st = null;
+		String sql = "";
 		try {
 			st = conn.createStatement();
 			String userPath = getCodeFilePath(conn);
-			String sql = "create library " + libName + " file '" + userPath
+			sql = "create library " + libName + " file '" + userPath
 					+ fileName + "'";
-			if (hostName != null) {
+			if (hostName != null && !"".equals(hostName.trim())) {
 				sql += " HOST NAME '" + hostName + "'";
 			}
-			if (localFile != null) {
+			if (localFile != null && !"".equals(localFile.trim())) {
 				sql += " LOCAL FILE '" + localFile + "'";
 			}
 			st.execute(sql);
-		} finally {
+		} catch(SQLException e){
+			LOG.error(sql,e);
+			throw e;
+		}finally {
 			if (st != null) {
 				try {
 					st.close();
 				} catch (Exception e) {
 				}
 			}
+			if (conn != null){
+				try {
+					conn.close();
+				} catch (Exception e) {
+				}
+			}
 		}
 	}
 
@@ -162,18 +172,27 @@ public class FileMgmt {
 		String sql = "alter library " + libName + " FILE '" + userPath
 				+ fileName + "'";
 
-		if (hostName != null) {
+		if (hostName != null  && !"".equals(hostName.trim())) {
 			sql += " HOST NAME '" + hostName + "'";
 		}
-		if (localFile != null) {
+		if (localFile != null  && !"".equals(localFile.trim())) {
 			sql += " LOCAL FILE '" + localFile + "'";
 		}
 		try {
 			st = conn.createStatement();
 			st.execute(sql);
+		} catch(SQLException e){
+			LOG.error(sql,e);
+			throw e;
 		} finally {
 			if (st != null)
 				st.close();
+			if (conn != null){
+				try {
+					conn.close();
+				} catch (Exception e) {
+				}
+			}
 		}
 	}
 
@@ -199,9 +218,18 @@ public class FileMgmt {
 					sql += " CASCADE";
 
 			st.execute(sql);
+		} catch(SQLException e){
+			LOG.error(sql,e);
+			throw e;
 		} finally {
 			if (st != null)
 				st.close();
+			if (con != null){
+				try {
+					con.close();
+				} catch (Exception e) {
+				}
+			}
 		}
 	}
 
@@ -289,6 +317,9 @@ public class FileMgmt {
 				LOG.info("Download: " + fileName + ", offset:" + offset + ",compressed length:" + fileData[0].length()
 						+ ",file length:" + fileLength[0]);
 			}
+		} catch(IOException e){
+			LOG.error(fileName,e);
+			throw e;
 		} finally {
 			if (rAFile != null) {
 				try {
@@ -319,6 +350,7 @@ public class FileMgmt {
 			LOG.info("Remove " + fileName + " successfully!");
 			return;
 		} else {
+			LOG.error("No such file[" + fileName + "]");
 			throw new SQLException("No such file[" + fileName + "]");
 		}
 	}
@@ -479,7 +511,7 @@ public class FileMgmt {
 		Connection conn = null;
 		try {
 			conn = DriverManager.getConnection(url);
-			LOG.info("Create connection successfully.  " + conn);
+			LOG.info("Create connection successfully.  " + conn +", autocommit:"+conn.getAutoCommit());
 		} catch (Throwable t) {
 			LOG.error("Error encountered while getting connection ", t);
 			throw new SQLException(t.getMessage());

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e5757fd8/core/sql/lib_mgmt/src/main/resources/init_libmgmt.sh
----------------------------------------------------------------------
diff --git a/core/sql/lib_mgmt/src/main/resources/init_libmgmt.sh b/core/sql/lib_mgmt/src/main/resources/init_libmgmt.sh
index f8c2f3c..6811f28 100644
--- a/core/sql/lib_mgmt/src/main/resources/init_libmgmt.sh
+++ b/core/sql/lib_mgmt/src/main/resources/init_libmgmt.sh
@@ -80,7 +80,8 @@ function createProcedures {
       EXTERNAL SECURITY DEFINER
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
-      READS SQL DATA
+      CONTAINS SQL
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE ADDLIB TO ${DB__LIBMGRROLE};
 
@@ -92,7 +93,8 @@ function createProcedures {
       LIBRARY ${LIB_NAME}
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
-      READS SQL DATA
+      CONTAINS SQL
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE DROPLIB TO ${DB__LIBMGRROLE};
 
@@ -106,7 +108,8 @@ function createProcedures {
       LIBRARY ${LIB_NAME}
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
-      READS SQL DATA
+      CONTAINS SQL
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE ALTERLIB TO ${DB__LIBMGRROLE};
 
@@ -120,6 +123,7 @@ function createProcedures {
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
       READS SQL DATA
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE PUT TO ${DB__LIBMGRROLE};
       
@@ -132,6 +136,7 @@ function createProcedures {
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
       READS SQL DATA
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE LS TO ${DB__LIBMGRROLE};
       
@@ -143,6 +148,7 @@ function createProcedures {
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
       READS SQL DATA
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE LSALL TO ${DB__LIBMGRROLE};
       
@@ -154,6 +160,7 @@ function createProcedures {
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
       READS SQL DATA
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE RM TO ${DB__LIBMGRROLE};
       
@@ -166,6 +173,7 @@ function createProcedures {
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
       READS SQL DATA
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE RMREX TO ${DB__LIBMGRROLE};
 
@@ -180,6 +188,7 @@ function createProcedures {
       LANGUAGE JAVA
       PARAMETER STYLE JAVA
       READS SQL DATA
+      NO TRANSACTION REQUIRED
       ;
       GRANT EXECUTE ON PROCEDURE GETFILE TO ${DB__LIBMGRROLE};
       


Mime
View raw message