ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgerg...@apache.org
Subject ambari git commit: AMBARI-20006 Log Search should not hide external Solr button even if it's mandatory (mgergely)
Date Wed, 15 Feb 2017 11:40:50 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 1966459d7 -> b705866ed


AMBARI-20006 Log Search should not hide external Solr button even if it's mandatory (mgergely)

Change-Id: Id937f704d01bc89e94ce6adf9068370c58f3307e


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

Branch: refs/heads/branch-2.5
Commit: b705866ed153627730940491db57bb48696c50cc
Parents: 1966459
Author: Miklos Gergely <mgergely@hortonworks.com>
Authored: Wed Feb 15 12:40:37 2017 +0100
Committer: Miklos Gergely <mgergely@hortonworks.com>
Committed: Wed Feb 15 12:40:37 2017 +0100

----------------------------------------------------------------------
 .../org/apache/ambari/logsearch/LogSearch.java  | 51 ++-------------
 .../ambari/logsearch/conf/ApiDocConfig.java     |  1 -
 .../ambari/logsearch/conf/SecurityConfig.java   |  1 -
 .../logsearch/conf/SolrAuditLogPropsConfig.java |  1 -
 .../conf/SolrServiceLogPropsConfig.java         |  3 -
 .../apache/ambari/logsearch/util/WebUtil.java   | 65 ++++++++++++++++++++
 .../LogsearchKRBAuthenticationFilter.java       |  7 +--
 ...LogsearchSecurityContextFormationFilter.java |  1 -
 ...rchUsernamePasswordAuthenticationFilter.java |  2 -
 .../stacks/HDP/2.2/services/stack_advisor.py    |  1 -
 10 files changed, 72 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java
index 70053d2..b75da0e 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java
@@ -18,18 +18,16 @@
  */
 package org.apache.ambari.logsearch;
 
-import java.io.IOException;
 import java.net.MalformedURLException;
-import java.net.ServerSocket;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.EnumSet;
 
 import org.apache.ambari.logsearch.common.ManageStartEndTime;
 import org.apache.ambari.logsearch.common.PropertiesHelper;
 import org.apache.ambari.logsearch.conf.ApplicationConfig;
 import org.apache.ambari.logsearch.util.SSLUtil;
+import org.apache.ambari.logsearch.util.WebUtil;
 import org.apache.ambari.logsearch.web.listener.LogSearchSessionListener;
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.jetty.server.Connector;
@@ -68,7 +66,6 @@ public class LogSearch {
   private static final String HTTPS_PORT = "61889";
   private static final String HTTP_PORT = "61888";
 
-  private static final String WEB_RESOURCE_FOLDER = "webapps/app";
   private static final String ROOT_CONTEXT = "/";
   private static final Integer SESSION_TIMEOUT = 60 * 30;
 
@@ -112,7 +109,7 @@ public class LogSearch {
     if (HTTPS_PROTOCOL.equals(protcolProperty) && SSLUtil.isKeyStoreSpecified())
{
       LOG.info("Building https server...........");
       port = portSpecified ? argv[0] : HTTPS_PORT;
-      checkPort(Integer.parseInt(port));
+      WebUtil.checkPort(Integer.parseInt(port));
       httpConfiguration.addCustomizer(new SecureRequestCustomizer());
       SslContextFactory sslContextFactory = SSLUtil.getSslContextFactory();
       ServerConnector sslConnector = new ServerConnector(server,
@@ -123,7 +120,7 @@ public class LogSearch {
     } else {
       LOG.info("Building http server...........");
       port = portSpecified ? argv[0] : HTTP_PORT;
-      checkPort(Integer.parseInt(port));
+      WebUtil.checkPort(Integer.parseInt(port));
       ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
       connector.setPort(Integer.parseInt(port));
       server.setConnectors(new Connector[] { connector });
@@ -134,7 +131,7 @@ public class LogSearch {
   }
 
   private WebAppContext createBaseWebappContext() throws MalformedURLException {
-    URI webResourceBase = findWebResourceBase();
+    URI webResourceBase = WebUtil.findWebResourceBase();
     WebAppContext context = new WebAppContext();
     context.setBaseResource(Resource.newResource(webResourceBase));
     context.setContextPath(ROOT_CONTEXT);
@@ -176,44 +173,4 @@ public class LogSearch {
     context.setHandler(resourceHandler);
     return context;
   }
-
-  private URI findWebResourceBase() {
-    URL fileCompleteUrl = Thread.currentThread().getContextClassLoader()
-        .getResource(WEB_RESOURCE_FOLDER);
-    String errorMessage = "Web Resource Folder " + WEB_RESOURCE_FOLDER + " not found in classpath";
-    if (fileCompleteUrl != null) {
-      try {
-        return fileCompleteUrl.toURI().normalize();
-      } catch (URISyntaxException e) {
-        LOG.error(errorMessage, e);
-        System.exit(1);
-      }
-    } else {
-      LOG.error(errorMessage);
-      System.exit(1);
-    }
-    throw new IllegalStateException(errorMessage);
-  }
-
-  private void checkPort(int port) {
-    ServerSocket serverSocket = null;
-    boolean portBusy = false;
-    try {
-      serverSocket = new ServerSocket(port);
-    } catch (IOException ex) {
-      portBusy = true;
-      LOG.error(ex.getLocalizedMessage() + " PORT :" + port);
-    } finally {
-      if (serverSocket != null) {
-        try {
-          serverSocket.close();
-        } catch (Exception exception) {
-          // ignore
-        }
-      }
-      if (portBusy) {
-        System.exit(1);
-      }
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java
index 86c1edd..4a8fdea 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java
@@ -25,7 +25,6 @@ import io.swagger.jaxrs.listing.SwaggerSerializers;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import java.net.InetAddress;
 import java.net.UnknownHostException;
 
 @Configuration

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
index b15ae43..2f9cba4 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
@@ -47,7 +47,6 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
 
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.servlet.Filter;
 import java.util.List;
 
 import static org.apache.ambari.logsearch.common.LogSearchConstants.LOGSEARCH_SESSION_ID;

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
index ace278f..5981bcc 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogPropsConfig.java
@@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 
 import java.util.List;
-import java.util.Map;
 
 @Configuration
 public class SolrAuditLogPropsConfig implements SolrPropsConfig {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
index 81935d4..482438a 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
@@ -21,9 +21,6 @@ package org.apache.ambari.logsearch.conf;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 
-import java.util.List;
-import java.util.Map;
-
 @Configuration
 public class SolrServiceLogPropsConfig extends SolrConnectionPropsConfig {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/WebUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/WebUtil.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/WebUtil.java
new file mode 100644
index 0000000..36865ad
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/WebUtil.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ambari.logsearch.util;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WebUtil {
+  private static final Logger LOG = LoggerFactory.getLogger(WebUtil.class);
+
+  private static final String WEB_RESOURCE_FOLDER = "webapps/app";
+
+  private WebUtil() {
+    throw new UnsupportedOperationException();
+  }
+
+  public static URI findWebResourceBase() {
+    URL fileCompleteUrl = Thread.currentThread().getContextClassLoader().getResource(WEB_RESOURCE_FOLDER);
+    String errorMessage = "Web Resource Folder " + WEB_RESOURCE_FOLDER + " not found in classpath";
+    if (fileCompleteUrl != null) {
+      try {
+        return fileCompleteUrl.toURI().normalize();
+      } catch (URISyntaxException e) {
+        LOG.error(errorMessage, e);
+        System.exit(1);
+      }
+    } else {
+      LOG.error(errorMessage);
+      System.exit(1);
+    }
+    throw new IllegalStateException(errorMessage);
+  }
+
+  public static void checkPort(int port) {
+    try (ServerSocket serverSocket = new ServerSocket(port)) {
+    } catch (IOException ex) {
+      LOG.error(ex.getLocalizedMessage() + " PORT :" + port);
+      System.exit(1);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
index fdda542..1b77753 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchKRBAuthenticationFilter.java
@@ -246,8 +246,7 @@ public class LogsearchKRBAuthenticationFilter extends LogsearchKrbFilter
{
   private Authentication getGrantedAuthority(Authentication authentication) {
     UsernamePasswordAuthenticationToken result = null;
     if (authentication != null && authentication.isAuthenticated()) {
-      final List<GrantedAuthority> grantedAuths = getAuthorities(authentication
-          .getName().toString());
+      final List<GrantedAuthority> grantedAuths = getAuthorities();
       final UserDetails userDetails = new User(authentication.getName()
           .toString(), authentication.getCredentials().toString(), grantedAuths);
       result = new UsernamePasswordAuthenticationToken(userDetails,
@@ -258,7 +257,7 @@ public class LogsearchKRBAuthenticationFilter extends LogsearchKrbFilter
{
     return authentication;
   }
 
-  private List<GrantedAuthority> getAuthorities(String username) {
+  private List<GrantedAuthority> getAuthorities() {
     final List<GrantedAuthority> grantedAuths = new ArrayList<>();
     grantedAuths.add(new SimpleGrantedAuthority(DEFAULT_USER_ROLE));
     return grantedAuths;
@@ -275,7 +274,7 @@ public class LogsearchKRBAuthenticationFilter extends LogsearchKrbFilter
{
     org.apache.ambari.logsearch.web.model.User user = new org.apache.ambari.logsearch.web.model.User();
     user.setUsername(username);
     authentication = new UsernamePasswordAuthenticationToken(username,
-        password, getAuthorities(username));
+        password, getAuthorities());
     return authentication;
   }
   

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
index b427749..fed86e8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
@@ -38,7 +38,6 @@ import org.apache.log4j.Logger;
 import org.springframework.security.authentication.AnonymousAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.stereotype.Component;
 import org.springframework.web.filter.GenericFilterBean;
 
 public class LogsearchSecurityContextFormationFilter extends GenericFilterBean {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUsernamePasswordAuthenticationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUsernamePasswordAuthenticationFilter.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUsernamePasswordAuthenticationFilter.java
index 24ec2d4..e20c0fa 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUsernamePasswordAuthenticationFilter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchUsernamePasswordAuthenticationFilter.java
@@ -20,13 +20,11 @@ package org.apache.ambari.logsearch.web.filters;
 
 import java.io.IOException;
 
-import javax.inject.Inject;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.log4j.Logger;
-import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.RememberMeServices;
 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

http://git-wip-us.apache.org/repos/asf/ambari/blob/b705866e/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
index 0bdf319..5e0fa5e 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
@@ -1030,7 +1030,6 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
       recommendedMaxShards = 100
       
       putLogsearchCommonEnvProperty('logsearch_use_external_solr', 'true')
-      putLogsearchCommonEnvAttribute('logsearch_use_external_solr', 'visible', 'false')
 
     # recommend number of shard
     putLogsearchAttribute('logsearch.collection.service.logs.numshards', 'minimum', recommendedMinShards)


Mime
View raw message