Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 8a7bba3e4 -> 2daa20e1f


AMBARI-20845. Include cluster filter in every Log Search request in Ambari 
server. (rnettleton)


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

Branch: refs/heads/branch-2.5
Commit: 2daa20e1f6f8a7101b569f0c59b8fe6f79c079bb
Parents: 8a7bba3
Author: Bob Nettleton <[email protected]>
Authored: Tue Apr 25 14:33:15 2017 -0400
Committer: Bob Nettleton <[email protected]>
Committed: Tue Apr 25 14:33:15 2017 -0400

----------------------------------------------------------------------
 .../server/controller/logging/LoggingRequestHelperImpl.java | 6 ++++++
 .../controller/logging/LoggingRequestHelperImplTest.java    | 9 +++++++++
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2daa20e1/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
index 0c47fc5..6cee4b7 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java
@@ -99,6 +99,8 @@ public class LoggingRequestHelperImpl implements 
LoggingRequestHelper {
 
   private static final int DEFAULT_LOGSEARCH_READ_TIMEOUT_IN_MILLISECONDS = 
5000;
 
+  private static final String LOGSEARCH_CLUSTERS_QUERY_PARAMETER_NAME = 
"clusters";
+
   private static AtomicInteger errorLogCounterForLogSearchConnectionExceptions 
= new AtomicInteger(0);
 
   private final String hostName;
@@ -382,6 +384,10 @@ public class LoggingRequestHelperImpl implements 
LoggingRequestHelper {
     URIBuilder uriBuilder = createBasicURI(scheme);
     uriBuilder.setPath(LOGSEARCH_QUERY_PATH);
 
+    // set the current cluster name, in case this LogSearch service supports 
data
+    // for multiple clusters
+    uriBuilder.addParameter(LOGSEARCH_CLUSTERS_QUERY_PARAMETER_NAME, 
cluster.getClusterName());
+
     // add any query strings specified
     for (String key : queryParameters.keySet()) {
       uriBuilder.addParameter(key, queryParameters.get(key));

http://git-wip-us.apache.org/repos/asf/ambari/blob/2daa20e1/ambari-server/src/test/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImplTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImplTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImplTest.java
index 2e7020f..c8157a4 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImplTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImplTest.java
@@ -154,6 +154,7 @@ public class LoggingRequestHelperImplTest {
     Capture<HttpURLConnection> captureURLConnectionForAuthentication = new 
Capture<HttpURLConnection>();
 
     
expect(clusterMock.getDesiredConfigByType("logsearch-admin-json")).andReturn(adminPropertiesConfigMock).atLeastOnce();
+    expect(clusterMock.getClusterName()).andReturn("clusterone").atLeastOnce();
     
expect(adminPropertiesConfigMock.getProperties()).andReturn(testConfigProperties).atLeastOnce();
     
expect(networkConnectionMock.readQueryResponseFromServer(capture(captureURLConnection))).andReturn(new
 StringBuffer(TEST_JSON_INPUT_TWO_LIST_ENTRIES)).atLeastOnce();
 
@@ -181,6 +182,8 @@ public class LoggingRequestHelperImplTest {
       "http", httpURLConnection.getURL().getProtocol());
     assertEquals("URLConnection did not have the expected method set",
       "GET", httpURLConnection.getRequestMethod());
+    assertTrue("URLConnection's URL did not have the expected query parameter 
string",
+      httpURLConnection.getURL().getQuery().contains("clusters=clusterone"));
 
     assertSame("HttpUrlConnection instances passed into NetworkConnection mock 
should have been the same instance",
       httpURLConnection, captureURLConnectionForAuthentication.getValue());
@@ -426,6 +429,7 @@ public class LoggingRequestHelperImplTest {
     Capture<HttpURLConnection> captureURLConnectionForAuthentication = new 
Capture<HttpURLConnection>();
 
     
expect(clusterMock.getDesiredConfigByType("logsearch-admin-json")).andReturn(adminPropertiesConfigMock).atLeastOnce();
+    expect(clusterMock.getClusterName()).andReturn("clusterone").atLeastOnce();
     
expect(adminPropertiesConfigMock.getProperties()).andReturn(testConfigProperties).atLeastOnce();
     
expect(networkConnectionMock.readQueryResponseFromServer(capture(captureURLConnection))).andReturn(new
 StringBuffer(TEST_JSON_INPUT_TWO_LIST_ENTRIES)).atLeastOnce();
 
@@ -453,6 +457,8 @@ public class LoggingRequestHelperImplTest {
       "http", httpURLConnection.getURL().getProtocol());
     assertEquals("URLConnection did not have the expected method set",
       "GET", httpURLConnection.getRequestMethod());
+    assertTrue("URLConnection's URL did not have the expected query parameter 
string",
+      httpURLConnection.getURL().getQuery().contains("clusters=clusterone"));
 
     assertSame("HttpUrlConnection instances passed into NetworkConnection mock 
should have been the same instance",
       httpURLConnection, captureURLConnectionForAuthentication.getValue());
@@ -508,6 +514,7 @@ public class LoggingRequestHelperImplTest {
     Capture<HttpURLConnection> captureURLConnectionForAuthentication = new 
Capture<HttpURLConnection>();
 
     
expect(clusterMock.getDesiredConfigByType("logsearch-admin-json")).andReturn(adminPropertiesConfigMock).atLeastOnce();
+    expect(clusterMock.getClusterName()).andReturn("clusterone").atLeastOnce();
     
expect(adminPropertiesConfigMock.getProperties()).andReturn(testConfigProperties).atLeastOnce();
     
expect(networkConnectionMock.readQueryResponseFromServer(capture(captureURLConnection))).andReturn(new
 StringBuffer(TEST_JSON_INPUT_NULL_LOG_LIST)).atLeastOnce();
 
@@ -535,6 +542,8 @@ public class LoggingRequestHelperImplTest {
       "http", httpURLConnection.getURL().getProtocol());
     assertEquals("URLConnection did not have the expected method set",
       "GET", httpURLConnection.getRequestMethod());
+    assertTrue("URLConnection's URL did not have the expected query parameter 
string",
+              
httpURLConnection.getURL().getQuery().contains("clusters=clusterone"));
 
     assertSame("HttpUrlConnection instances passed into NetworkConnection mock 
should have been the same instance",
       httpURLConnection, captureURLConnectionForAuthentication.getValue());

Reply via email to