Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 97F94200C62 for ; Tue, 11 Apr 2017 20:28:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 96C4D160B7D; Tue, 11 Apr 2017 18:28:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C5B70160B9B for ; Tue, 11 Apr 2017 20:28:50 +0200 (CEST) Received: (qmail 16816 invoked by uid 500); 11 Apr 2017 18:28:50 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 16712 invoked by uid 99); 11 Apr 2017 18:28:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Apr 2017 18:28:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D0A3CDFF5A; Tue, 11 Apr 2017 18:28:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jaimin@apache.org To: commits@ambari.apache.org Date: Tue, 11 Apr 2017 18:28:50 -0000 Message-Id: <31d23c7c566b4978a0ea459ed27ac011@git.apache.org> In-Reply-To: <388bf8c0c8fa498fb86300f4b197a863@git.apache.org> References: <388bf8c0c8fa498fb86300f4b197a863@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/50] [abbrv] ambari git commit: AMBARI-20573. Hive view 2.0 fails on LLAP (Gaurav Nagar via nitirajrathore) archived-at: Tue, 11 Apr 2017 18:28:51 -0000 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/1022fdbc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1022fdbc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1022fdbc Branch: refs/heads/ambari-rest-api-explorer Commit: 1022fdbc5a98b6f17d7a2745d2ca55c4b1fdba6d Parents: a1d58c1 Author: Nitiraj Singh Rathore Authored: Tue Apr 4 12:43:23 2017 +0530 Committer: Nitiraj Singh Rathore Committed: Tue Apr 4 12:43:23 2017 +0530 ---------------------------------------------------------------------- .../apache/ambari/server/view/ViewRegistry.java | 51 ++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/1022fdbc/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 roles) throws SystemException, ValidationException { + private void installAutoInstance(Long clusterId, String clusterName, Service service, ViewEntity viewEntity, String viewName, ViewConfig viewConfig, AutoInstanceConfig autoConfig, Collection 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 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 +