ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gna...@apache.org
Subject ambari git commit: AMBARI-18024. Pig view not loading After opening huetoambari view. (Pradarttana Panda via gauravn7)
Date Wed, 10 Aug 2016 11:02:05 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 32ef4d4d0 -> 13ec2c661


AMBARI-18024. Pig view not loading After opening huetoambari view.  (Pradarttana Panda via
gauravn7)


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

Branch: refs/heads/trunk
Commit: 13ec2c6616790cb04e2081f983de0aa4b93bae1e
Parents: 32ef4d4
Author: Gaurav Nagar <gnagar@hortonworks.com>
Authored: Wed Aug 10 16:31:39 2016 +0530
Committer: Gaurav Nagar <gnagar@hortonworks.com>
Committed: Wed Aug 10 16:31:39 2016 +0530

----------------------------------------------------------------------
 .../HiveInstanceDetailsUtility.java             | 145 ++++++++++++-------
 .../PigInstanceDetailsUtility.java              |  77 ++++++----
 2 files changed, 144 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/13ec2c66/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/HiveInstanceDetailsUtility.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/HiveInstanceDetailsUtility.java
b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/HiveInstanceDetailsUtility.java
index bcbe4de..7a335d8 100644
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/HiveInstanceDetailsUtility.java
+++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/HiveInstanceDetailsUtility.java
@@ -28,79 +28,126 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.hive.instancedetail.*;
+import org.apache.log4j.Logger;
 
 
 public class HiveInstanceDetailsUtility {
 
   public List<InstanceModel> getInstancedetails(ViewContext view) throws PropertyVetoException,
SQLException, IOException {
 
+    final Logger logger = Logger.getLogger(HiveInstanceDetailsUtility.class);
     List<InstanceModel> instancelist = new ArrayList<>();
     Connection conn = null;
     conn = DataSourceAmbariDatabase.getInstance(view.getProperties().get("ambaridrivername"),
view.getProperties().get("ambarijdbcurl"), view.getProperties().get("ambaridbusername"), view.getProperties().get("ambaridbpassword")).getConnection();
     conn.setAutoCommit(false);
-    PreparedStatement prSt;
-
+    PreparedStatement prSt = null;
     QuerySetAmbariDB ambaridatabase = null;
-
-    if (view.getProperties().get("ambaridrivername").contains("mysql")) {
-      ambaridatabase = new MysqlQuerySetAmbariDB();
-    } else if (view.getProperties().get("ambaridrivername").contains("postgresql")) {
-      ambaridatabase = new PostgressQuerySetAmbariDB();
-    } else if (view.getProperties().get("ambaridrivername").contains("oracle")) {
-      ambaridatabase = new OracleQuerySetAmbariDB();
-    }
-
     ResultSet rs1 = null;
-    prSt = ambaridatabase.getHiveInstanceDeatil(conn);
-    rs1 = prSt.executeQuery();
-    int i = 0;
-
-    while (rs1.next()) {
-      InstanceModel I = new InstanceModel();
-      I.setInstanceName(rs1.getString(1));
-      I.setId(i);
-      instancelist.add(I);
-      i++;
-    }
-    return instancelist;
 
+    try {
+
+      if (view.getProperties().get("ambaridrivername").contains("mysql")) {
+        ambaridatabase = new MysqlQuerySetAmbariDB();
+      } else if (view.getProperties().get("ambaridrivername").contains("postgresql")) {
+        ambaridatabase = new PostgressQuerySetAmbariDB();
+      } else if (view.getProperties().get("ambaridrivername").contains("oracle")) {
+        ambaridatabase = new OracleQuerySetAmbariDB();
+      }
+
+      prSt = ambaridatabase.getHiveInstanceDeatil(conn);
+      rs1 = prSt.executeQuery();
+      int i = 0;
+
+      while (rs1.next()) {
+        InstanceModel I = new InstanceModel();
+        I.setInstanceName(rs1.getString(1));
+        I.setId(i);
+        instancelist.add(I);
+        i++;
+      }
+      return instancelist;
+    } finally {
+      if (rs1 != null) {
+        try {
+          rs1.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing result set : ", e);
+        }
+      }
+      if (prSt != null) {
+        try {
+          prSt.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing PreparedStatement : ", e);
+        }
+      }
+      if (conn != null) {
+        try {
+          conn.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing the connection : ", e);
+        }
+      }
+    }
   }
 
   public List<InstanceModel> getAllInstancedetails(ViewContext view) throws PropertyVetoException,
SQLException, IOException {
 
     List<InstanceModel> instancelist = new ArrayList<>();
+    final Logger logger = Logger.getLogger(HiveInstanceDetailsUtility.class);
     Connection conn = null;
     Statement stmt = null;
     conn = DataSourceAmbariDatabase.getInstance(view.getProperties().get("ambaridrivername"),
view.getProperties().get("ambarijdbcurl"), view.getProperties().get("ambaridbusername"), view.getProperties().get("ambaridbpassword")).getConnection();
     conn.setAutoCommit(false);
-    PreparedStatement prSt;
-
-    QuerySetAmbariDB ambaridatabase = null;
-
-    if (view.getProperties().get("ambaridrivername").contains("mysql")) {
-      ambaridatabase = new MysqlQuerySetAmbariDB();
-    } else if (view.getProperties().get("ambaridrivername").contains("postgresql")) {
-      ambaridatabase = new PostgressQuerySetAmbariDB();
-    } else if (view.getProperties().get("ambaridrivername").contains("oracle")) {
-      ambaridatabase = new OracleQuerySetAmbariDB();
-    }
-
+    PreparedStatement prSt = null;
     ResultSet rs1 = null;
-    int i = 0;
-    prSt = ambaridatabase.getAllInstanceDeatil(conn);
-    rs1 = prSt.executeQuery();
-
-    while (rs1.next()) {
-      InstanceModel I = new InstanceModel();
-      I.setInstanceName(rs1.getString(1));
-      I.setId(i);
-      instancelist.add(I);
-      i++;
+    QuerySetAmbariDB ambaridatabase = null;
+    try {
+
+      if (view.getProperties().get("ambaridrivername").contains("mysql")) {
+        ambaridatabase = new MysqlQuerySetAmbariDB();
+      } else if (view.getProperties().get("ambaridrivername").contains("postgresql")) {
+        ambaridatabase = new PostgressQuerySetAmbariDB();
+      } else if (view.getProperties().get("ambaridrivername").contains("oracle")) {
+        ambaridatabase = new OracleQuerySetAmbariDB();
+      }
+
+      int i = 0;
+      prSt = ambaridatabase.getAllInstanceDeatil(conn);
+      rs1 = prSt.executeQuery();
+
+      while (rs1.next()) {
+        InstanceModel I = new InstanceModel();
+        I.setInstanceName(rs1.getString(1));
+        I.setId(i);
+        instancelist.add(I);
+        i++;
+      }
+      return instancelist;
+    }  finally {
+      if (rs1 != null) {
+        try {
+          rs1.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing result set : ", e);
+        }
+      }
+      if (prSt != null) {
+        try {
+          prSt.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing PreparedStatement : ", e);
+        }
+      }
+      if (conn != null) {
+        try {
+          conn.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing the connection : ", e);
+        }
+      }
     }
-    rs1.close();
-    return instancelist;
-
   }
 
-
 }
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/13ec2c66/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/PigInstanceDetailsUtility.java
----------------------------------------------------------------------
diff --git a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/PigInstanceDetailsUtility.java
b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/PigInstanceDetailsUtility.java
index d3cfb97..92dff507 100644
--- a/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/PigInstanceDetailsUtility.java
+++ b/contrib/views/hueambarimigration/src/main/java/org/apache/ambari/view/huetoambarimigration/migration/configuration/PigInstanceDetailsUtility.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.ambari.view.huetoambarimigration.datasource.queryset.ambariqueryset.pig.instancedetail.*;
+import org.apache.log4j.Logger;
 
 /**
  * Utility class to fetch Pig Instance details
@@ -36,44 +37,62 @@ import org.apache.ambari.view.huetoambarimigration.datasource.queryset.ambarique
 public class PigInstanceDetailsUtility {
 
   public List<InstanceModel> getInstancedetails(ViewContext view) throws PropertyVetoException,
SQLException, IOException {
-
+    final Logger logger = Logger.getLogger(PigInstanceDetailsUtility.class);
     List<InstanceModel> instancelist = new ArrayList<>();
-    Connection conn = null;
-    Statement stmt = null;
-    PreparedStatement prSt;
+    Connection conn;
+    ResultSet rs1 = null;
+    PreparedStatement prSt=null;
     conn = DataSourceAmbariDatabase.getInstance(view.getProperties().get("ambaridrivername"),
view.getProperties().get("ambarijdbcurl"), view.getProperties().get("ambaridbusername"), view.getProperties().get("ambaridbpassword")).getConnection();
     conn.setAutoCommit(false);
-    stmt = conn.createStatement();
     int i = 0;
 
     QuerySetAmbariDB ambaridatabase = null;
-
-    if (view.getProperties().get("ambaridrivername").contains("mysql")) {
-      ambaridatabase = new MysqlQuerySetAmbariDB();
-    } else if (view.getProperties().get("ambaridrivername").contains("postgresql")) {
-      ambaridatabase = new PostgressQuerySetAmbariDB();
-    } else if (view.getProperties().get("ambaridrivername").contains("oracle")) {
-      ambaridatabase = new OracleQuerySetAmbariDB();
+    try {
+      if (view.getProperties().get("ambaridrivername").contains("mysql")) {
+        ambaridatabase = new MysqlQuerySetAmbariDB();
+      } else if (view.getProperties().get("ambaridrivername").contains("postgresql")) {
+        ambaridatabase = new PostgressQuerySetAmbariDB();
+      } else if (view.getProperties().get("ambaridrivername").contains("oracle")) {
+        ambaridatabase = new OracleQuerySetAmbariDB();
+      }
+
+
+      prSt = ambaridatabase.getAllPigInstance(conn);
+      rs1 = prSt.executeQuery();
+
+      while (rs1.next()) {
+        InstanceModel I = new InstanceModel();
+        I.setInstanceName(rs1.getString(1));
+        I.setId(i);
+        instancelist.add(I);
+        i++;
+      }
+      return instancelist;
     }
-
-    ResultSet rs1 = null;
-
-    prSt = ambaridatabase.getAllPigInstance(conn);
-
-    rs1 = prSt.executeQuery();
-
-    while (rs1.next()) {
-      InstanceModel I = new InstanceModel();
-      I.setInstanceName(rs1.getString(1));
-      I.setId(i);
-      instancelist.add(I);
-      i++;
+    finally {
+      if (rs1 != null) {
+        try {
+          rs1.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing result set : ", e);
+        }
+      }
+      if (prSt != null) {
+        try {
+          prSt.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing PreparedStatement : ", e);
+        }
+      }
+      if (conn != null) {
+        try {
+          conn.close();
+        } catch (SQLException e) {
+          logger.error("Sql exception in while closing the connection : ", e);
+        }
+      }
     }
-    rs1.close();
-    stmt.close();
-    return instancelist;
 
   }
 
-
 }


Mime
View raw message