Repository: ambari
Updated Branches:
  refs/heads/trunk 04a539279 -> 1f68c6e84


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/1f68c6e8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1f68c6e8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1f68c6e8

Branch: refs/heads/trunk
Commit: 1f68c6e845a5f9b9909e539c6c3ffc4fda198c35
Parents: 04a5392
Author: Bob Nettleton <rnettle...@hortonworks.com>
Authored: Tue Apr 25 13:11:50 2017 -0400
Committer: Bob Nettleton <rnettle...@hortonworks.com>
Committed: Tue Apr 25 13:11:50 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/1f68c6e8/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 2b1b04a..0db8853 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
@@ -100,6 +100,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;
@@ -383,6 +385,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/1f68c6e8/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 b24500f..1221518 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 = 
EasyMock.newCapture();
 
     
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());
@@ -335,6 +338,7 @@ public class LoggingRequestHelperImplTest {
     Capture<HttpURLConnection> captureURLConnectionForAuthentication = 
EasyMock.newCapture();
 
     
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();
 
@@ -362,6 +366,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());
@@ -417,6 +423,7 @@ public class LoggingRequestHelperImplTest {
     Capture<HttpURLConnection> captureURLConnectionForAuthentication = new 
Capture<>();
 
     
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();
 
@@ -444,6 +451,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