You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by db...@apache.org on 2016/03/21 15:48:06 UTC
ambari git commit: AMBARI-15335 : adding hive metastore location
property for the detached server.(Nitiraj Rathore via dipayanb)
Repository: ambari
Updated Branches:
refs/heads/trunk e0bf50fdc -> b52073ad9
AMBARI-15335 : adding hive metastore location property for the detached server.(Nitiraj Rathore via dipayanb)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b52073ad
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b52073ad
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b52073ad
Branch: refs/heads/trunk
Commit: b52073ad9dc1a612cdf2e64190ef5b0626c84728
Parents: e0bf50f
Author: Dipayan Bhowmick <di...@gmail.com>
Authored: Mon Mar 21 20:17:49 2016 +0530
Committer: Dipayan Bhowmick <di...@gmail.com>
Committed: Mon Mar 21 20:17:49 2016 +0530
----------------------------------------------------------------------
.../hive/resources/uploads/UploadService.java | 21 +++++++++++---------
contrib/views/hive/src/main/resources/view.xml | 10 ++++++++++
.../ambari/view/utils/ambari/AmbariApi.java | 8 ++++++++
3 files changed, 30 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/b52073ad/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/UploadService.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/UploadService.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/UploadService.java
index 6935ec5..83eae9b 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/UploadService.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/uploads/UploadService.java
@@ -33,7 +33,6 @@ import org.apache.ambari.view.hive.resources.uploads.query.*;
import org.apache.ambari.view.hive.utils.ServiceFormattedException;
import org.apache.ambari.view.hive.utils.SharedObjectsFactory;
import org.apache.ambari.view.utils.ambari.AmbariApi;
-import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.input.ReaderInputStream;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -63,11 +62,12 @@ import java.util.*;
public class UploadService extends BaseService {
private AmbariApi ambariApi;
-
protected JobResourceManager resourceManager;
- final private static String HIVE_META_STORE_LOCATION_KEY = "hive.metastore.warehouse.dir";
+ final private static String HIVE_METASTORE_LOCATION_KEY = "hive.metastore.warehouse.dir";
final private static String HIVE_SITE = "hive-site";
+ final private static String HIVE_METASTORE_LOCATION_KEY_VIEW_PROPERTY = HIVE_METASTORE_LOCATION_KEY;
+ private static final String HIVE_DEFAULT_METASTORE_LOCATION = "/apps/hive/warehouse" ;
final private static String HIVE_DEFAULT_DB = "default";
@POST
@@ -262,11 +262,10 @@ public class UploadService extends BaseService {
private String uploadIntoTable(Reader reader, String databaseName, String tempTableName) {
try {
String basePath = getHiveMetaStoreLocation();
- if (null == basePath)
- basePath = "/apps/hive/warehouse";
- if (!basePath.endsWith("/"))
+ if (!basePath.endsWith("/")) {
basePath = basePath + "/";
+ }
if (databaseName != null && !databaseName.equals(HIVE_DEFAULT_DB)) {
basePath = basePath + databaseName + ".db/";
@@ -330,7 +329,13 @@ public class UploadService extends BaseService {
}
private String getHiveMetaStoreLocation() {
- return this.getAmbariApi().getCluster().getConfigurationValue(HIVE_SITE, HIVE_META_STORE_LOCATION_KEY);
+ String dir = this.getAmbariApi().getProperty(HIVE_SITE,HIVE_METASTORE_LOCATION_KEY,HIVE_METASTORE_LOCATION_KEY_VIEW_PROPERTY);
+ if(dir != null && !dir.trim().isEmpty()){
+ return dir;
+ }else{
+ LOG.debug("Neither found associated cluster nor found the view property {}. Returning default location : {}", HIVE_METASTORE_LOCATION_KEY_VIEW_PROPERTY, HIVE_DEFAULT_METASTORE_LOCATION);
+ return HIVE_DEFAULT_METASTORE_LOCATION;
+ }
}
private void uploadFile(final String filePath, InputStream uploadedInputStream)
@@ -357,11 +362,9 @@ public class UploadService extends BaseService {
DataParser dataParser = new DataParser(new InputStreamReader(uploadedInputStream), parseOptions);
return dataParser.parsePreview();
-
}
private Response createPreviewResponse(PreviewData pd, Boolean isFirstRowHeader, String tableName) {
-
Map<String, Object> retData = new HashMap<String, Object>();
retData.put("header", pd.getHeader());
retData.put("rows", pd.getPreviewRows());
http://git-wip-us.apache.org/repos/asf/ambari/blob/b52073ad/contrib/views/hive/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/view.xml b/contrib/views/hive/src/main/resources/view.xml
index 892f044..8f8a470 100644
--- a/contrib/views/hive/src/main/resources/view.xml
+++ b/contrib/views/hive/src/main/resources/view.xml
@@ -84,6 +84,16 @@
<required>false</required>
</parameter>
+ <parameter>
+ <name>hive.metastore.warehouse.dir</name>
+ <description>Hive Metastore directory (example: /apps/hive/warehouse)</description>
+ <label>Hive Metastore directory</label>
+ <placeholder>/apps/hive/warehouse</placeholder>
+ <default-value>/apps/hive/warehouse</default-value>
+ <cluster-config>hive-site/hive.metastore.warehouse.dir</cluster-config>
+ <required>false</required>
+ </parameter>
+
<!-- HDFS Configs -->
<parameter>
<name>webhdfs.url</name>
http://git-wip-us.apache.org/repos/asf/ambari/blob/b52073ad/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApi.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApi.java b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApi.java
index f18448c..6b88b6f 100644
--- a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApi.java
+++ b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApi.java
@@ -312,4 +312,12 @@ public class AmbariApi {
}
return services;
}
+
+ public String getProperty(String type, String key, String instanceProperty) {
+ try {
+ return this.getCluster().getConfigurationValue(type, key);
+ } catch (NoClusterAssociatedException e) {
+ return context.getProperties().get(instanceProperty);
+ }
+ }
}