You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2017/04/06 09:33:45 UTC
[24/41] ambari git commit: AMBARI-20573. Hive view 2.0 fails on LLAP
(Gaurav Nagar via nitirajrathore)
AMBARI-20573. Hive view 2.0 fails on LLAP (Gaurav Nagar via nitirajrathore)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7d4df5b3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7d4df5b3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7d4df5b3
Branch: refs/heads/branch-3.0-perf
Commit: 7d4df5b30819384e7b72fca852b1319244bdab09
Parents: 8c10a07
Author: Nitiraj Singh Rathore <ni...@gmail.com>
Authored: Tue Apr 4 12:43:23 2017 +0530
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Thu Apr 6 12:32:56 2017 +0300
----------------------------------------------------------------------
.../apache/ambari/server/view/ViewRegistry.java | 51 ++++++++++++++++++--
1 file changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d4df5b3/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
index 5b58abc..c7b2f79 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
@@ -85,6 +85,7 @@ import org.apache.ambari.server.orm.entities.ViewEntity;
import org.apache.ambari.server.orm.entities.ViewEntityEntity;
import org.apache.ambari.server.orm.entities.ViewInstanceDataEntity;
import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
+import org.apache.ambari.server.orm.entities.ViewInstancePropertyEntity;
import org.apache.ambari.server.orm.entities.ViewParameterEntity;
import org.apache.ambari.server.orm.entities.ViewResourceEntity;
import org.apache.ambari.server.orm.entities.ViewURLEntity;
@@ -93,6 +94,8 @@ import org.apache.ambari.server.security.authorization.AuthorizationHelper;
import org.apache.ambari.server.security.authorization.ResourceType;
import org.apache.ambari.server.security.authorization.RoleAuthorization;
import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.state.stack.OsFamily;
import org.apache.ambari.server.utils.Closeables;
@@ -988,7 +991,7 @@ public class ViewRegistry {
try {
if (checkAutoInstanceConfig(autoConfig, stackId, event.getServiceName(), serviceNames)) {
- installAutoInstance(clusterId, clusterName, viewEntity, viewName, viewConfig, autoConfig, roles);
+ installAutoInstance(clusterId, clusterName, cluster.getService(event.getServiceName()), viewEntity, viewName, viewConfig, autoConfig, roles);
}
} catch (Exception e) {
LOG.error("Can't auto create instance of view " + viewName + " for cluster " + clusterName +
@@ -1000,9 +1003,10 @@ public class ViewRegistry {
}
}
- private void installAutoInstance(Long clusterId, String clusterName, ViewEntity viewEntity, String viewName, ViewConfig viewConfig, AutoInstanceConfig autoConfig, Collection<String> roles) throws SystemException, ValidationException {
+ private void installAutoInstance(Long clusterId, String clusterName, Service service, ViewEntity viewEntity, String viewName, ViewConfig viewConfig, AutoInstanceConfig autoConfig, Collection<String> roles) throws SystemException, ValidationException {
LOG.info("Auto creating instance of view " + viewName + " for cluster " + clusterName + ".");
ViewInstanceEntity viewInstanceEntity = createViewInstanceEntity(viewEntity, viewConfig, autoConfig);
+ updateHiveLLAPSettingsIfRequired(viewInstanceEntity, service);
viewInstanceEntity.setClusterHandle(clusterId);
installViewInstance(viewInstanceEntity);
setViewInstanceRoleAccess(viewInstanceEntity, roles);
@@ -1015,6 +1019,47 @@ public class ViewRegistry {
}
+ /**
+ * Checks is service is 'HIVE' and INTERACTIVE_SERVICE(LLAP) is enabled. Then, it sets the view instance
+ * parameter 'use.hive.interactive.mode' for the 'AUTO_INSTANCE_VIEW' to be true.
+ * @param viewInstanceEntity
+ * @param service
+ */
+ private void updateHiveLLAPSettingsIfRequired(ViewInstanceEntity viewInstanceEntity, Service service) {
+ String INTERACTIVE_KEY = "use.hive.interactive.mode";
+ String LLAP_COMPONENT_NAME = "HIVE_SERVER_INTERACTIVE";
+ String viewVersion = viewInstanceEntity.getViewDefinition().getVersion();
+ String viewName = viewInstanceEntity.getViewDefinition().getViewName();
+ if(!viewName.equalsIgnoreCase("HIVE") || viewVersion.equalsIgnoreCase("1.0.0")) {
+ return;
+ }
+
+ try {
+ ServiceComponent component = service.getServiceComponent(LLAP_COMPONENT_NAME);
+ if (component.getServiceComponentHosts().size() == 0) {
+ // The LLAP server is not installed in any of the hosts. Hence, return;
+ return;
+ }
+
+ for (Map.Entry<String, String> property : viewInstanceEntity.getPropertyMap().entrySet()) {
+ if (INTERACTIVE_KEY.equals(property.getKey()) && (!"true".equalsIgnoreCase(property.getValue()))) {
+ ViewInstancePropertyEntity propertyEntity = new ViewInstancePropertyEntity();
+ propertyEntity.setViewInstanceName(viewInstanceEntity.getName());
+ propertyEntity.setViewName(viewInstanceEntity.getViewName());
+ propertyEntity.setName(INTERACTIVE_KEY);
+ propertyEntity.setValue("true");
+ propertyEntity.setViewInstanceEntity(viewInstanceEntity);
+ viewInstanceEntity.getProperties().add(propertyEntity);
+ }
+ }
+
+ } catch (AmbariException e) {
+ LOG.error("Failed to update '{}' parameter for viewName: {}, version: {}. Exception: {}",
+ INTERACTIVE_KEY, viewName, viewVersion, e);
+ }
+
+ }
+
private String getUrlName(ViewInstanceEntity viewInstanceEntity) {
return viewInstanceEntity.getViewEntity().getCommonName().toLowerCase() + "_" + viewInstanceEntity.getInstanceName().toLowerCase();
}
@@ -1920,7 +1965,7 @@ public class ViewRegistry {
try {
if (checkAutoInstanceConfig(autoInstanceConfig, stackId, service, serviceNames)) {
- installAutoInstance(clusterId, clusterName, viewEntity, viewName, viewConfig, autoInstanceConfig, roles);
+ installAutoInstance(clusterId, clusterName, cluster.getService(service), viewEntity, viewName, viewConfig, autoInstanceConfig, roles);
}
} catch (Exception e) {
LOG.error("Can't auto create instance of view " + viewName + " for cluster " + clusterName +