HDDS-905. Create informative landing page for Ozone S3 gateway.
Contributed by Elek, Marton.
This commit is contained in:
parent
5b55f3538c
commit
506bd02c63
34
hadoop-ozone/dist/src/main/smoketest/s3/webui.robot
vendored
Normal file
34
hadoop-ozone/dist/src/main/smoketest/s3/webui.robot
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
*** Settings ***
|
||||||
|
Documentation S3 gateway web ui test
|
||||||
|
Library OperatingSystem
|
||||||
|
Library String
|
||||||
|
Resource ../commonlib.robot
|
||||||
|
Resource ./commonawslib.robot
|
||||||
|
Suite Setup Setup s3 tests
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${ENDPOINT_URL} http://s3g:9878
|
||||||
|
${BUCKET} generated
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
|
||||||
|
File upload and directory list
|
||||||
|
${result} = Execute curl -v ${ENDPOINT_URL}
|
||||||
|
Should contain ${result} HTTP/1.1 307 Temporary Redirect
|
||||||
|
${result} = Execute curl -v ${ENDPOINT_URL}/static/
|
||||||
|
Should contain ${result} Apache Hadoop Ozone S3
|
@ -30,12 +30,6 @@
|
|||||||
<downloadSources>true</downloadSources>
|
<downloadSources>true</downloadSources>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
@ -185,4 +179,42 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-common-html</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>unpack</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactItems>
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>org.apache.hadoop</groupId>
|
||||||
|
<artifactId>hadoop-hdds-server-framework</artifactId>
|
||||||
|
<outputDirectory>${project.build.outputDirectory}
|
||||||
|
</outputDirectory>
|
||||||
|
<includes>webapps/static/**/*.*</includes>
|
||||||
|
</artifactItem>
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>org.apache.hadoop</groupId>
|
||||||
|
<artifactId>hadoop-hdds-docs</artifactId>
|
||||||
|
<outputDirectory>
|
||||||
|
${project.build.outputDirectory}/webapps/static
|
||||||
|
</outputDirectory>
|
||||||
|
<includes>docs/**/*.*</includes>
|
||||||
|
</artifactItem>
|
||||||
|
</artifactItems>
|
||||||
|
<overWriteSnapshots>true</overWriteSnapshots>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.Response.Status;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -27,6 +29,7 @@
|
|||||||
import org.apache.hadoop.ozone.client.OzoneVolume;
|
import org.apache.hadoop.ozone.client.OzoneVolume;
|
||||||
import org.apache.hadoop.ozone.s3.commontypes.BucketMetadata;
|
import org.apache.hadoop.ozone.s3.commontypes.BucketMetadata;
|
||||||
import org.apache.hadoop.ozone.s3.exception.OS3Exception;
|
import org.apache.hadoop.ozone.s3.exception.OS3Exception;
|
||||||
|
import org.apache.hadoop.ozone.s3.header.AuthenticationHeaderParser;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -47,12 +50,20 @@ public class RootEndpoint extends EndpointBase {
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
public ListBucketResponse get()
|
public Response get()
|
||||||
throws OS3Exception, IOException {
|
throws OS3Exception, IOException {
|
||||||
OzoneVolume volume;
|
OzoneVolume volume;
|
||||||
ListBucketResponse response = new ListBucketResponse();
|
ListBucketResponse response = new ListBucketResponse();
|
||||||
|
|
||||||
String userName = getAuthenticationHeaderParser().getAccessKeyID();
|
AuthenticationHeaderParser authenticationHeaderParser =
|
||||||
|
getAuthenticationHeaderParser();
|
||||||
|
|
||||||
|
if (!authenticationHeaderParser.doesAuthenticationInfoExists()) {
|
||||||
|
return Response.status(Status.TEMPORARY_REDIRECT)
|
||||||
|
.header("Location", "/static/")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
String userName = authenticationHeaderParser.getAccessKeyID();
|
||||||
Iterator<? extends OzoneBucket> bucketIterator = listS3Buckets(userName,
|
Iterator<? extends OzoneBucket> bucketIterator = listS3Buckets(userName,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
@ -65,6 +76,6 @@ public ListBucketResponse get()
|
|||||||
response.addBucket(bucketMetadata);
|
response.addBucket(bucketMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return Response.ok(response).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,10 @@ public void parse() throws OS3Exception {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean doesAuthenticationInfoExists() {
|
||||||
|
return authHeader != null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAccessKeyID() throws OS3Exception {
|
public String getAccessKeyID() throws OS3Exception {
|
||||||
parse();
|
parse();
|
||||||
return accessKeyID;
|
return accessKeyID;
|
||||||
|
@ -21,10 +21,6 @@
|
|||||||
<param-name>javax.ws.rs.Application</param-name>
|
<param-name>javax.ws.rs.Application</param-name>
|
||||||
<param-value>org.apache.hadoop.ozone.s3.GatewayApplication</param-value>
|
<param-value>org.apache.hadoop.ozone.s3.GatewayApplication</param-value>
|
||||||
</init-param>
|
</init-param>
|
||||||
<init-param>
|
|
||||||
<param-name>jersey.config.servlet.filter.staticContentRegex</param-name>
|
|
||||||
<param-value>/static/images/*.ico</param-value>
|
|
||||||
</init-param>
|
|
||||||
<load-on-startup>1</load-on-startup>
|
<load-on-startup>1</load-on-startup>
|
||||||
</servlet>
|
</servlet>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||||
|
<meta name="description" content="Apache Hadoop Ozone S3 gateway">
|
||||||
|
|
||||||
|
<title>S3 gateway -- Apache Hadoop Ozone</title>
|
||||||
|
|
||||||
|
<link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="hadoop.css" rel="stylesheet">
|
||||||
|
<link href="ozone.css" rel="stylesheet">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle collapsed"
|
||||||
|
data-toggle="collapse" data-target="#navbar"
|
||||||
|
aria-expanded="false" aria-controls="navbar">
|
||||||
|
<span class="sr-only">Toggle navigation</span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="#">Ozone S3G</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="collapse navbar-collapse">
|
||||||
|
<ul class="nav navbar-nav" id="ui-tabs">
|
||||||
|
<li><a href="docs">Documentation</a></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div><!--/.nav-collapse -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container-fluid" style="margin: 12pt">
|
||||||
|
|
||||||
|
<h1>S3 gateway</h1>
|
||||||
|
|
||||||
|
<p>This is an endpoint of Apache Hadoop Ozone S3 gateway. Use it with any
|
||||||
|
AWS S3 compatible tool
|
||||||
|
with setting this url as an endpoint</p>
|
||||||
|
|
||||||
|
<p>For example with aws-cli:</p>
|
||||||
|
|
||||||
|
<pre>aws s3api --endpoint <script>document.write(window.location.href).replace("static/", "")</script> create-bucket --bucket=wordcount</pre>
|
||||||
|
|
||||||
|
<p>For more information, please check the <a href="docs">documentation.</a>
|
||||||
|
</p>
|
||||||
|
</div><!-- /.container -->
|
||||||
|
|
||||||
|
<script src="static/bootstrap-3.3.7/js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -58,14 +58,14 @@ public void setup() throws Exception {
|
|||||||
public void testListBucket() throws Exception {
|
public void testListBucket() throws Exception {
|
||||||
|
|
||||||
// List operation should succeed even there is no bucket.
|
// List operation should succeed even there is no bucket.
|
||||||
ListBucketResponse response = rootEndpoint.get();
|
ListBucketResponse response = (ListBucketResponse) rootEndpoint.get().getEntity();
|
||||||
assertEquals(0, response.getBucketsNum());
|
assertEquals(0, response.getBucketsNum());
|
||||||
|
|
||||||
String bucketBaseName = "bucket-" + getClass().getName();
|
String bucketBaseName = "bucket-" + getClass().getName();
|
||||||
for(int i = 0; i < 10; i++) {
|
for(int i = 0; i < 10; i++) {
|
||||||
objectStoreStub.createS3Bucket(userName, bucketBaseName + i);
|
objectStoreStub.createS3Bucket(userName, bucketBaseName + i);
|
||||||
}
|
}
|
||||||
response = rootEndpoint.get();
|
response = (ListBucketResponse) rootEndpoint.get().getEntity();
|
||||||
assertEquals(10, response.getBucketsNum());
|
assertEquals(10, response.getBucketsNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user