knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject knox git commit: KNOX-500 Rewriting Storm log URLs and added dispatch to allow cookie pass through
Date Thu, 05 Mar 2015 01:01:13 GMT
Repository: knox
Updated Branches:
  refs/heads/master 0a4fb9a7d -> 68416ccfd


KNOX-500 Rewriting Storm log URLs and added dispatch to allow cookie pass through


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

Branch: refs/heads/master
Commit: 68416ccfd14330c0a2f84472c9220feb6f127879
Parents: 0a4fb9a
Author: Sumit Gupta <sumit@apache.org>
Authored: Wed Mar 4 19:59:32 2015 -0500
Committer: Sumit Gupta <sumit@apache.org>
Committed: Wed Mar 4 19:59:32 2015 -0500

----------------------------------------------------------------------
 gateway-release/pom.xml                         |   4 +
 .../services/storm-logviewer/0.9.3/rewrite.xml  |  21 ++++
 .../services/storm-logviewer/0.9.3/services.xml |  21 ++++
 .../resources/services/storm/0.9.3/rewrite.xml  |  17 +++
 .../resources/services/storm/0.9.3/services.xml |   7 ++
 gateway-service-storm/pom.xml                   |  64 ++++++++++
 .../gateway/storm/StormHttpClientDispatch.java  |  35 ++++++
 .../hadoop/gateway/SpiGatewayMessages.java      |   3 +
 .../gateway/dispatch/GatewayDispatchFilter.java |  46 +++++++-
 .../gateway/dispatch/HttpClientDispatch.java    |  68 ++++++-----
 .../hadoop/gateway/GatewayBasicFuncTest.java    | 118 ++++++++++++++++++-
 .../falcon/instance-process-logs.json           |  77 ++++++++++++
 .../falcon/instance-status-process.json         |   1 +
 .../GatewayBasicFuncTest/storm/topology-id.json |   8 +-
 pom.xml                                         |   6 +
 15 files changed, 458 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-release/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-release/pom.xml b/gateway-release/pom.xml
index 5c2d174..adb7c52 100644
--- a/gateway-release/pom.xml
+++ b/gateway-release/pom.xml
@@ -168,6 +168,10 @@
         </dependency>
         <dependency>
             <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-service-storm</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${gateway-group}</groupId>
             <artifactId>gateway-service-tgs</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/rewrite.xml
b/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/rewrite.xml
new file mode 100644
index 0000000..848a20d
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/rewrite.xml
@@ -0,0 +1,21 @@
+<!--
+   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.
+-->
+<rules>
+    <rule dir="IN" name="STORM/storm/inbound" pattern="*://*:*/**/storm/logviewer/{path=**}?{**}">
+        <rewrite template="{$serviceUrl[STORM-LOGVIEWER]}/{path=**}?{**}"/>
+    </rule>
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/services.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/services.xml
b/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/services.xml
new file mode 100644
index 0000000..dd13e65
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/storm-logviewer/0.9.3/services.xml
@@ -0,0 +1,21 @@
+<!--
+   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.
+-->
+<service role="STORM-LOGVIEWER" name="storm-logviewer" version="0.9.3">
+    <routes>
+        <route path="/storm/logviewer/**"/>
+    </routes>
+</service>

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-service-definitions/src/main/resources/services/storm/0.9.3/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/storm/0.9.3/rewrite.xml
b/gateway-service-definitions/src/main/resources/services/storm/0.9.3/rewrite.xml
index 452d4eb..9015ebb 100644
--- a/gateway-service-definitions/src/main/resources/services/storm/0.9.3/rewrite.xml
+++ b/gateway-service-definitions/src/main/resources/services/storm/0.9.3/rewrite.xml
@@ -18,4 +18,21 @@
     <rule dir="IN" name="STORM/storm/inbound" pattern="*://*:*/**/storm/api/{path=**}?{**}">
         <rewrite template="{$serviceUrl[STORM]}/api/{path=**}?{**}"/>
     </rule>
+    <rule dir="OUT" name="STORM/storm/url/outbound">
+        <match pattern="*://*:*/{**}?{**}"/>
+        <rewrite template="{$frontend[url]}/storm/logviewer/{**}?{**}"/>
+    </rule>
+    <filter name="STORM/storm/logs/outbound">
+        <content type="*/json">
+            <buffer path="$.executorStats[*]">
+                <apply path="$.workerLogLink" rule="STORM/storm/url/outbound"/>
+            </buffer>
+            <buffer path="$.spouts[*]">
+                <apply path="$.errorWorkerLogLink" rule="STORM/storm/url/outbound"/>
+            </buffer>
+            <buffer path="$.bolts[*]">
+                <apply path="$.errorWorkerLogLink" rule="STORM/storm/url/outbound"/>
+            </buffer>
+        </content>
+    </filter>
 </rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-service-definitions/src/main/resources/services/storm/0.9.3/services.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/storm/0.9.3/services.xml
b/gateway-service-definitions/src/main/resources/services/storm/0.9.3/services.xml
index 94d4bee..c813265 100644
--- a/gateway-service-definitions/src/main/resources/services/storm/0.9.3/services.xml
+++ b/gateway-service-definitions/src/main/resources/services/storm/0.9.3/services.xml
@@ -17,5 +17,12 @@
 <service role="STORM" name="storm" version="0.9.3">
     <routes>
         <route path="/storm/api/**"/>
+        <route path="/storm/api/v1/topology/*">
+            <rewrite apply="STORM/storm/logs/outbound" to="response.body"/>
+        </route>
+        <route path="/storm/api/v1/topology/**/component/**?**">
+            <rewrite apply="STORM/storm/logs/outbound" to="response.body"/>
+        </route>
     </routes>
+    <dispatch classname="org.apache.hadoop.gateway.storm.StormHttpClientDispatch"/>
 </service>

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-service-storm/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-service-storm/pom.xml b/gateway-service-storm/pom.xml
new file mode 100644
index 0000000..3111f79
--- /dev/null
+++ b/gateway-service-storm/pom.xml
@@ -0,0 +1,64 @@
+<!--
+   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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.knox</groupId>
+        <artifactId>gateway</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>gateway-service-storm</artifactId>
+
+    <name>gateway-service-storm</name>
+    <description>The extension to the gateway for supporting Storm.</description>
+
+    <licenses>
+        <license>
+            <name>The Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <dependencies>
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-spi</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-provider-rewrite</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-test-utils</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-service-storm/src/main/java/org/apache/hadoop/gateway/storm/StormHttpClientDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-storm/src/main/java/org/apache/hadoop/gateway/storm/StormHttpClientDispatch.java
b/gateway-service-storm/src/main/java/org/apache/hadoop/gateway/storm/StormHttpClientDispatch.java
new file mode 100644
index 0000000..889c427
--- /dev/null
+++ b/gateway-service-storm/src/main/java/org/apache/hadoop/gateway/storm/StormHttpClientDispatch.java
@@ -0,0 +1,35 @@
+/**
+ * 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.hadoop.gateway.storm;
+
+import org.apache.hadoop.gateway.dispatch.HttpClientDispatch;
+
+import java.util.Set;
+
+/**
+ * This specialized dispatch provides Storm specific features to the
+ * default HttpClientDispatch.
+ */
+public class StormHttpClientDispatch extends HttpClientDispatch {
+
+  @Override
+  public Set<String> getOutboundResponseExcludeHeaders() {
+    return null;
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-spi/src/main/java/org/apache/hadoop/gateway/SpiGatewayMessages.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/SpiGatewayMessages.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/SpiGatewayMessages.java
index 9b575e3..5ff8a86 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/SpiGatewayMessages.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/SpiGatewayMessages.java
@@ -48,4 +48,7 @@ public interface SpiGatewayMessages {
   
   @Message( level = MessageLevel.ERROR, text = "Failed Knox->Hadoop SPNegotiation authentication
for URL: {0}" )
   void failedSPNegoAuthn(String uri);
+
+  @Message( level = MessageLevel.WARN, text = "Error occurred when closing HTTP client :
{0}" )
+  void errorClosingHttpClient(@StackTrace(level=MessageLevel.WARN) Exception e);
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
index f359568..897d5de 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
@@ -17,7 +17,11 @@
  */
 package org.apache.hadoop.gateway.dispatch;
 
+import org.apache.hadoop.gateway.SpiGatewayMessages;
 import org.apache.hadoop.gateway.filter.AbstractGatewayFilter;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
+import org.apache.http.client.CookieStore;
+import org.apache.http.cookie.Cookie;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 
@@ -30,7 +34,9 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import static org.apache.hadoop.gateway.config.ConfigurationInjectorBuilder.configuration;
@@ -39,8 +45,12 @@ public class GatewayDispatchFilter extends AbstractGatewayFilter {
 
   private static Map<String, Adapter> METHOD_ADAPTERS = createMethodAdapters();
 
+  protected static SpiGatewayMessages LOG = MessagesFactory.get(SpiGatewayMessages.class);
+
   private Dispatch dispatch;
 
+  private CloseableHttpClient httpClient;
+
   private static Map<String, Adapter> createMethodAdapters() {
     Map<String, Adapter> map = new HashMap<String, Adapter>();
     map.put("GET", new GetAdapter());
@@ -57,12 +67,22 @@ public class GatewayDispatchFilter extends AbstractGatewayFilter {
     String dispatchImpl = filterConfig.getInitParameter("dispatch-impl");
     dispatch = newDispatch(dispatchImpl);
     configuration().target(dispatch).source(filterConfig).inject();
-    CloseableHttpClient client = HttpClients.createSystem();
+    httpClient = HttpClients.custom().setDefaultCookieStore(new NoCookieStore()).build();
     //[sumit] this can perhaps be stashed in the servlet context to increase sharing of the
client
-    dispatch.setHttpClient(client);
+    dispatch.setHttpClient(httpClient);
     dispatch.init();
   }
 
+  @Override
+  public void destroy() {
+    dispatch.destroy();
+    try {
+      httpClient.close();
+    } catch ( IOException e ) {
+      LOG.errorClosingHttpClient(e);
+    }
+  }
+
   public Dispatch getDispatch() {
     return dispatch;
   }
@@ -149,4 +169,26 @@ public class GatewayDispatchFilter extends AbstractGatewayFilter {
       throw new ServletException(e);
     }
   }
+
+  private class NoCookieStore implements CookieStore {
+    @Override
+    public void addCookie(Cookie cookie) {
+      //no op
+    }
+
+    @Override
+    public List<Cookie> getCookies() {
+      return Collections.EMPTY_LIST;
+    }
+
+    @Override
+    public boolean clearExpired(Date date) {
+      return true;
+    }
+
+    @Override
+    public void clear() {
+      //no op
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/HttpClientDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/HttpClientDispatch.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/HttpClientDispatch.java
index 45e2480..7f4d27c 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/HttpClientDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/HttpClientDispatch.java
@@ -52,6 +52,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  *
@@ -75,10 +77,14 @@ public class HttpClientDispatch extends AbstractGatewayDispatch {
   protected AppCookieManager appCookieManager;
 
   private int replayBufferSize = 0;
+  private Set<String> outboundResponseExcludeHeaders;
 
   @Override
   public void init() {
     setAppCookieManager(new AppCookieManager());
+    outboundResponseExcludeHeaders = new HashSet<String>();
+    outboundResponseExcludeHeaders.add(SET_COOKIE);
+    outboundResponseExcludeHeaders.add(WWW_AUTHENTICATE);
   }
 
   @Override
@@ -144,35 +150,40 @@ public class HttpClientDispatch extends AbstractGatewayDispatch {
       return inboundResponse;
    }
 
-   protected void writeOutboundResponse(HttpUriRequest outboundRequest, HttpServletRequest
inboundRequest, HttpServletResponse outboundResponse, HttpResponse inboundResponse) throws
IOException {
-      // Copy the client respond header to the server respond.
-      outboundResponse.setStatus(inboundResponse.getStatusLine().getStatusCode());
-      Header[] headers = inboundResponse.getAllHeaders();
-      for (Header header : headers) {
-         String name = header.getName();
-         if (name.equals(SET_COOKIE) || name.equals(WWW_AUTHENTICATE)) {
-            continue;
-         }
-         String value = header.getValue();
-         outboundResponse.addHeader(name, value);
+  protected void writeOutboundResponse(HttpUriRequest outboundRequest, HttpServletRequest
inboundRequest, HttpServletResponse outboundResponse, HttpResponse inboundResponse) throws
IOException {
+    // Copy the client respond header to the server respond.
+    outboundResponse.setStatus(inboundResponse.getStatusLine().getStatusCode());
+    Header[] headers = inboundResponse.getAllHeaders();
+    Set<String> excludeHeaders = getOutboundResponseExcludeHeaders();
+    boolean hasExcludeHeaders = false;
+    if ((excludeHeaders != null) && !(excludeHeaders.isEmpty())) {
+      hasExcludeHeaders = true;
+    }
+    for ( Header header : headers ) {
+      String name = header.getName();
+      if (hasExcludeHeaders && excludeHeaders.contains(name)) {
+        continue;
       }
-
-      HttpEntity entity = inboundResponse.getEntity();
-      if (entity != null) {
-         Header contentType = entity.getContentType();
-         if (contentType != null) {
-            outboundResponse.setContentType(contentType.getValue());
-         }
-         //KM[ If this is set here it ends up setting the content length to the content returned
from the server.
-         // This length might not match if the the content is rewritten.
-         //      long contentLength = entity.getContentLength();
-         //      if( contentLength <= Integer.MAX_VALUE ) {
-         //        outboundResponse.setContentLength( (int)contentLength );
-         //      }
-         //]
-         writeResponse(inboundRequest, outboundResponse, entity.getContent());
+      String value = header.getValue();
+      outboundResponse.addHeader(name, value);
+    }
+
+    HttpEntity entity = inboundResponse.getEntity();
+    if ( entity != null ) {
+      Header contentType = entity.getContentType();
+      if ( contentType != null ) {
+        outboundResponse.setContentType(contentType.getValue());
       }
-   }
+      //KM[ If this is set here it ends up setting the content length to the content returned
from the server.
+      // This length might not match if the the content is rewritten.
+      //      long contentLength = entity.getContentLength();
+      //      if( contentLength <= Integer.MAX_VALUE ) {
+      //        outboundResponse.setContentLength( (int)contentLength );
+      //      }
+      //]
+      writeResponse(inboundRequest, outboundResponse, entity.getContent());
+    }
+  }
 
    /**
     * This method provides a hook for specialized credential propagation
@@ -301,4 +312,7 @@ public class HttpClientDispatch extends AbstractGatewayDispatch {
       replayBufferSize = size;
    }
 
+  public Set<String> getOutboundResponseExcludeHeaders() {
+    return outboundResponseExcludeHeaders;
+  }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
index c6847ea..7e830ea 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
@@ -142,6 +142,7 @@ public class GatewayBasicFuncTest {
     driver.setupService( "RESOURCEMANAGER", "http://" + TEST_HOST + ":8088/ws", "/cluster/resourcemanager",
USE_MOCK_SERVICES );
     driver.setupService( "FALCON", "http://" + TEST_HOST + ":15000", "/cluster/falcon", USE_MOCK_SERVICES
);
     driver.setupService( "STORM", "http://" + TEST_HOST + ":8477", "/cluster/storm", USE_MOCK_SERVICES
);
+    driver.setupService( "STORM-LOGVIEWER", "http://" + TEST_HOST + ":8477", "/cluster/storm",
USE_MOCK_SERVICES );
     driver.setupGateway( config, "cluster", createTopology(), USE_GATEWAY );
   }
 
@@ -237,6 +238,9 @@ public class GatewayBasicFuncTest {
         .addTag( "service" )
             .addTag( "role" ).addText( "STORM" )
             .addTag( "url" ).addText( driver.getRealUrl( "STORM" ) ).gotoParent()
+        .addTag( "service" )
+            .addTag( "role" ).addText( "STORM-LOGVIEWER" )
+            .addTag( "url" ).addText( driver.getRealUrl( "STORM-LOGVIEWER" ) ).gotoParent()
         .gotoRoot();
 //     System.out.println( "GATEWAY=" + xml.toString() );
     return xml;
@@ -2870,6 +2874,10 @@ public class GatewayBasicFuncTest {
     resourceName = "falcon/instance-params-process";
     path = "/api/instance/params/process/cleanseEmailProcess";
     testGetFalconResource(resourceName, path, ContentType.JSON);
+
+    resourceName = "falcon/instance-status-process";
+    path = "/api/instance/status/process/cleanseEmailProcess";
+    testGetFalconResource(resourceName, path, ContentType.JSON);
   }
 
   @Test
@@ -3076,13 +3084,86 @@ public class GatewayBasicFuncTest {
     path = "/api/v1/topology/summary";
     testGetStormResource(resourceName, path);
 
+    String username = "hdfs";
+    String password = "hdfs-password";
+
+    InetSocketAddress gatewayAddress = driver.gateway.getAddresses()[0];
+    String gatewayHostName = gatewayAddress.getHostName();
+    String gatewayAddrName = InetAddress.getByName( gatewayHostName ).getHostAddress();
+
     resourceName = "storm/topology-id.json";
     path = "/api/v1/topology/WordCount-1-1424792039";
-    testGetStormResource(resourceName, path);
+    String gatewayPath = driver.getUrl( "STORM" ) + path;
+    driver.getMock("STORM")
+        .expect()
+        .method("GET")
+        .pathInfo(path)
+        .queryParam("user.name", username)
+        .respond()
+        .status(HttpStatus.SC_OK)
+        .content(driver.getResourceBytes(resourceName))
+        .contentType(ContentType.JSON.toString());
+
+    Response response = given()
+        .auth().preemptive().basic(username, password)
+        .header("X-XSRF-Header", "jksdhfkhdsf")
+        .header("Accept", ContentType.JSON.toString())
+        .expect()
+        .statusCode(HttpStatus.SC_OK)
+        .contentType( ContentType.JSON.toString() )
+        .when().get( gatewayPath );
+
+    String link = response.getBody().jsonPath().getString("spouts[0].errorWorkerLogLink");
+    MatcherAssert.assertThat(link, anyOf(
+        startsWith("http://" + gatewayHostName + ":" + gatewayAddress.getPort() + "/"),
+        startsWith("http://" + gatewayAddrName + ":" + gatewayAddress.getPort() + "/")));
+    MatcherAssert.assertThat( link, containsString("/storm/logviewer") );
+
+    driver.assertComplete();
 
     resourceName = "storm/topology-component-id.json";
     path = "/api/v1/topology/WordCount-1-1424792039/component/spout";
-    testGetStormResource(resourceName, path);
+    gatewayPath = driver.getUrl( "STORM" ) + path;
+    driver.getMock("STORM")
+        .expect()
+        .method("GET")
+        .pathInfo(path)
+        .queryParam("user.name", username)
+        .respond()
+        .status(HttpStatus.SC_OK)
+        .content(driver.getResourceBytes(resourceName))
+        .contentType(ContentType.JSON.toString());
+
+    response = given()
+        .auth().preemptive().basic(username, password)
+        .header("X-XSRF-Header", "jksdhfkhdsf")
+        .header("Accept", ContentType.JSON.toString())
+        .expect()
+//        .log().all()
+        .statusCode(HttpStatus.SC_OK)
+        .contentType( ContentType.JSON.toString() )
+        .when().get( gatewayPath );
+
+
+    link = response.getBody().jsonPath().getString("executorStats[0].workerLogLink");
+    MatcherAssert.assertThat(link, anyOf(
+        startsWith("http://" + gatewayHostName + ":" + gatewayAddress.getPort() + "/"),
+        startsWith("http://" + gatewayAddrName + ":" + gatewayAddress.getPort() + "/")));
+    MatcherAssert.assertThat( link, containsString("/storm/logviewer") );
+
+    driver.assertComplete();
+
+    path = "/api/v1/topology/WordCount-1-1424792039/activate";
+    testPostStormResource(path);
+
+    path = "/api/v1/topology/WordCount-1-1424792039/deactivate";
+    testPostStormResource(path);
+
+    path = "/api/v1/topology/WordCount-1-1424792039/rebalance/20";
+    testPostStormResource(path);
+
+    path = "/api/v1/topology/WordCount-1-1424792039/kill/20";
+    testPostStormResource(path);
 
   }
 
@@ -3106,13 +3187,40 @@ public class GatewayBasicFuncTest {
         .header("X-XSRF-Header", "jksdhfkhdsf")
         .header("Accept", ContentType.JSON.toString())
         .expect()
-//       .log().all()
+//        .log().all()
         .statusCode(HttpStatus.SC_OK)
         .contentType( ContentType.JSON.toString() )
         .when().get( gatewayPath );
 
-    MatcherAssert.assertThat( response.getBody().asString(),
-            sameJSONAs( driver.getResourceString( resourceName, UTF8 ) ) );
+    MatcherAssert.assertThat(response.getBody().asString(),
+        sameJSONAs(driver.getResourceString(resourceName, UTF8)));
+    driver.assertComplete();
+  }
+
+    private void testPostStormResource(String path) throws IOException {
+    String username = "hdfs";
+    String password = "hdfs-password";
+    String gatewayPath = driver.getUrl( "STORM" ) + path;
+
+    driver.getMock("STORM")
+        .expect()
+        .method("POST")
+        .pathInfo(path)
+        .queryParam("user.name", username)
+        .respond()
+        .status(HttpStatus.SC_MOVED_TEMPORARILY)
+        .contentType(ContentType.JSON.toString());
+
+    Response response = given()
+        .auth().preemptive().basic(username, password)
+        .header("X-XSRF-Header", "jksdhfkhdsf")
+        .header("X-CSRF-Token", "H/8xIWCYQo4ZDWLvV9k0FAkjD0omWI8beVTp2mEPRxCbJmWBTYhRMhIV9LGIY3E51OAj+s6T7eQChpGJ")
+        .header("Accept", ContentType.JSON.toString())
+        .expect()
+        .statusCode(HttpStatus.SC_MOVED_TEMPORARILY)
+        .contentType( ContentType.JSON.toString() )
+        .when().post( gatewayPath );
+
     driver.assertComplete();
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-process-logs.json
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-process-logs.json
b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-process-logs.json
new file mode 100644
index 0000000..f2073c7
--- /dev/null
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-process-logs.json
@@ -0,0 +1,77 @@
+{
+  "status": "SUCCEEDED",
+  "message": "default/STATUS\n",
+  "requestId": "default/null\n",
+  "instances": [
+    {
+      "instance": "2014-03-07T11:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T10:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T09:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T08:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T07:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T06:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T05:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T04:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T03:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    },
+    {
+      "instance": "2014-03-07T02:00Z",
+      "status": "WAITING",
+      "logFile": "-",
+      "cluster": "primaryCluster",
+      "details": ""
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-status-process.json
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-status-process.json
b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-status-process.json
new file mode 100644
index 0000000..ea21a22
--- /dev/null
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/falcon/instance-status-process.json
@@ -0,0 +1 @@
+{"status":"SUCCEEDED","message":"default/STATUS\n","requestId":"default/null\n"}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/storm/topology-id.json
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/storm/topology-id.json
b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/storm/topology-id.json
index e21cd1a..9f48f98 100644
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/storm/topology-id.json
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayBasicFuncTest/storm/topology-id.json
@@ -11,9 +11,9 @@
       "errorPort": "",
       "spoutId": "spout",
       "tasks": 5,
-      "errorHost": "",
+      "errorHost": "sandbox.hortonworks.com",
       "lastError": "",
-      "errorWorkerLogLink": "http://:8005/log?file=WordCount-1-1424792039-worker-.log",
+      "errorWorkerLogLink": "http://sandbox.hortonworks.com:8005/log?file=WordCount-1-1424792039-worker-.log",
       "failed": 0
     }
   ],
@@ -256,9 +256,9 @@
       "executed": 3985560,
       "processLatency": "0.107",
       "boltId": "count",
-      "errorHost": "",
+      "errorHost": "sandbox.hortonworks.com",
       "lastError": "",
-      "errorWorkerLogLink": "http://:8005/log?file=WordCount-1-1424792039-worker-.log",
+      "errorWorkerLogLink": "http://sandbox.hortonworks.com:8005/log?file=WordCount-1-1424792039-worker-.log",
       "capacity": "0.000",
       "failed": 0
     },

http://git-wip-us.apache.org/repos/asf/knox/blob/68416ccf/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 56064b6..2dcffea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,6 +67,7 @@
         <module>gateway-service-hive</module>
         <module>gateway-service-webhdfs</module>
         <module>gateway-service-tgs</module>
+        <module>gateway-service-storm</module>
         <module>gateway-service-definitions</module>
         <module>gateway-shell</module>
         <module>gateway-shell-launcher</module>
@@ -490,6 +491,11 @@
             </dependency>
             <dependency>
                 <groupId>${gateway-group}</groupId>
+                <artifactId>gateway-service-storm</artifactId>
+                <version>${gateway-version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${gateway-group}</groupId>
                 <artifactId>gateway-service-definitions</artifactId>
                 <version>${gateway-version}</version>
             </dependency>


Mime
View raw message