NIFI-221: Fixed shutdown of HandleHttpRequest and provided documentation

This commit is contained in:
Mark Payne 2015-02-28 14:55:56 -05:00
parent 2d48323878
commit c53b0f9d15
3 changed files with 368 additions and 0 deletions

View File

@ -397,6 +397,7 @@ public class HandleHttpRequest extends AbstractProcessor {
if ( server != null ) { if ( server != null ) {
getLogger().debug("Shutting down server"); getLogger().debug("Shutting down server");
server.stop(); server.stop();
server.destroy();
server.join(); server.join();
getLogger().info("Shut down {}", new Object[] {server}); getLogger().info("Shut down {}", new Object[] {server});
} }

View File

@ -0,0 +1,255 @@
<!DOCTYPE html>
<html lang="en">
<!--
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.
-->
<head>
<meta charset="utf-8" />
<title>HandleHttpRequest</title>
<link rel="stylesheet" href="../../css/component-usage.css" type="text/css" />
</head>
<body>
<!-- Processor Documentation ================================================== -->
<h2>Description:</h2>
<p>
This processor starts an HTTP server and creates a FlowFile for each HTTP Request that it receives. The Processor leaves
the HTTP Connection open and is intended to be used in conjunction with a
<a href="../org.apache.nifi.processors.standard.HandleHttpResponse/index.html">HandleHttpResponse</a> Processor.
</p>
<p>
The pairing of this Processor with a <a href="../org.apache.nifi.processors.standard.HandleHttpResponse/index.html">HandleHttpResponse</a> Processor
provides the ability to use NiFi to visually construct a web server that can carry out any functionality that is available
through the existing Processors. For example, one could construct a Web-based front end to an SFTP Server by constructing a
flow such as:
</p>
<p>
<a href="index.html">HandleHttpRequest</a> ->
<a href="../org.apache.nifi.processors.standard.PutSFTP/index.html">PutSFTP</a> ->
<a href="../org.apache.nifi.processors.standard.HandleHttpResponse/index.html">HandleHttpResponse</a>
</p>
<p>
The HandleHttpRequest Processor provides several Properties to configure which methods are supported, the paths that are
supported, and SSL configuration. The FlowFiles that are generated by this Processor have the following attributes added to
them, providing powerful routing capabilities and traceability of all data:
</p>
<table>
<thead>
<th>Attribute Name</th>
<th>Attribute Description</th>
</thead>
<tbody>
<tr>
<td>http.context.identifier</td>
<td>An identifier that allows the HandleHttpRequest and HandleHttpResponse to coordinate which FlowFile belongs
to which HTTP Request/Response.</td>
</tr>
<tr>
<td>mime.type</td>
<td>The MIME Type of the data, according to the HTTP Header "Content-Type"</td>
</tr>
<tr>
<td>http.servlet.path</td>
<td>The part of the request URL that is considered the Servlet Path</td>
</tr>
<tr>
<td>http.context.path</td>
<td>The part of the request URL that is considered to be the Context Path</td>
</tr>
<tr>
<td>http.method</td>
<td>The HTTP Method that was used for the request, such as GET or POST</td>
</tr>
<tr>
<td>http.query.string</td>
<td>The query string portion of hte Request URL</td>
</tr>
<tr>
<td>http.remote.host</td>
<td>The hostname of the requestor</td>
</tr>
<tr>
<td>http.remote.addr</td>
<td>The hostname:port combination of the requestor</td>
</tr>
<tr>
<td>http.remote.user</td>
<td>The username of the requestor</td>
</tr>
<tr>
<td>http.request.uri</td>
<td>The full Request URL</td>
</tr>
<tr>
<td>http.auth.type</td>
<td>The type of HTTP Authorization used</td>
</tr>
<tr>
<td>http.principal.name</td>
<td>The name of the authenticated user making the request</td>
</tr>
<tr>
<td>http.subject.dn</td>
<td>The Distinguished Name of the requestor. This value will not be populated unless the Processor is
configured to use an SSLContext Service</td>
</tr>
<tr>
<td>http.issuer.dn</td>
<td>The Distinguished Name of the entity that issued the Subject's certificate. This value will not be
populated unless the Processor is configured to use an SSLContext Service</td>
</tr>
<tr>
<td>http.headers.XXX</td>
<td>Each of the HTTP Headers that is received in the request will be added as an attribute, prefixed
with "http.headers." For example, if the request contains an HTTP Header named "x-my-header",
then the value will be added to an attribute named "http.headers.x-my-header"</td>
</tr>
</tbody>
</table>
<p>
<strong>Properties:</strong>
</p>
<p>
In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. If a property has a default value, it is indicated. If a property supports the use of the NiFi Expression Language (or simply, "expression language"), that is also indicated.
</p>
<ul>
<li><strong>Listening Port</strong>
<ul>
<li>The port to listen on for incoming HTTP Requests</li>
<li>Default value: no default</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li>Hostname
<ul>
<li>The Hostname to bind to. If not specified, will bind to all hosts</li>
<li>Default value: no default</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>HTTP Context Map</strong>
<ul>
<li>The HTTP Context Map Controller Service to use for caching the HTTP Request Information</li>
<li>Default value: no default</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li>SSL Context Service
<ul>
<li>The Controller Service to use for obtaining an SSL Context. The SSL Context controller service is a mechanism for providing all the security properties that allow for secure communications between NiFi extensions and other systems. See the User Guide or the Controller Services documentation via the "help" link in the upper-right corner of the GUI for more information about the StandardSSLContextService. The value for this property is the identifier name that is configured in the StandardSSLContextService.</li>
<li>Default value: no default</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Allowed Paths</strong>
<ul>
<li>A Regular Expression that specifies the valid HTTP Paths that are allowed in the incoming URL Requests. If this value is specified and the path of the HTTP Requests does not match this Regular Expression, the Processor will respond with a 404: NotFound</li>
<li>Default value: no default</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Allow GET</strong>
<ul>
<li>Specifies whether or not to allow HTTP GET Method</li>
<li>Default value: true</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Allow POST</strong>
<ul>
<li>Specifies whether or not to allow HTTP POST Method</li>
<li>Default value: true</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Allow PUT</strong>
<ul>
<li>Specifies whether or not to allow HTTP PUT Method</li>
<li>Default value: true</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Allow DELETE</strong>
<ul>
<li>Specifies whether or not to allow HTTP DELETE Method</li>
<li>Default value: true</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Allow HEAD</strong>
<ul>
<li>Specifies whether or not to allow HTTP HEAD Method</li>
<li>Default value: false</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Allow OPTIONS</strong>
<ul>
<li>Specifies whether or not to allow HTTP OPTIONS Method</li>
<li>Default value: false</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li>Additional HTTP Methods
<ul>
<li>A comma-separated list of non-standard HTTP Methods that should be allowed</li>
<li>Default value: no default</li>
<li>Supports expression language: false</li>
</ul>
</li>
<li><strong>Client Authentication</strong>
<ul>
<li>Specifies whether or not the Processor should authenticate clients. This value is ignored if the &lt;SSL Context Service&gt; Property is not specified or the SSL Context provided uses only a KeyStore and not a TrustStore.</li>
<li>
The following values are allowed:
<ul>
<li><b>No Authentication</b> - Processor will not authenticate clients. Anyone can communicate with this Processor anonymously</li>
<li><b>Want Authentication</b> - Processor will try to verify the client but if unable to verify will allow the client to communicate anonymously</li>
<li><b>Need Authentication</b> - Processor will reject communications from any client unless the client provides a certificate that is trusted by the TrustStore specified in the SSL Context Service</li>
</ul>
</li>
<li>Default value: No Authentication</li>
<li>Supports expression language: false</li>
</ul>
</li>
</ul>
<p>
<strong>Relationships:</strong>
</p>
<ul>
<li>success
<ul>
<li>All FlowFiles that are created are routed to this relationship.</li>
</ul>
</li>
</ul>
<p>
<strong>See Also:</strong><br />
<a href="../org.apache.nifi.processors.standard.HandleHttpResponse/index.html">HandleHttpResponse</a><br />
<a href="../org.apache.nifi.http.StandardHttpContextMap/index.html">StandardHttpContextMap</a><br />
<a href="../org.apache.nifi.ssl.StandardSSLContextService/index.html">StandardSSLContextService</a><br />
</p>
</body>
</html>

View File

@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="en">
<!--
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.
-->
<head>
<meta charset="utf-8" />
<title>HandleHttpResponse</title>
<link rel="stylesheet" href="../../css/component-usage.css" type="text/css" />
</head>
<body>
<!-- Processor Documentation ================================================== -->
<h2>Description:</h2>
<p>
This processor responds to an HTTP request that was received by the
<a href="../org.apache.nifi.processors.standard.HandleHttpRequest/index.html">HandleHttpRequest</a> Processor.
</p>
<p>
The pairing of this Processor with a <a href="../org.apache.nifi.processors.standard.HandleHttpRequest/index.html">HandleHttpRequest</a> Processor
provides the ability to use NiFi to visually construct a web server that can carry out any functionality that is available
through the existing Processors. For example, one could construct a Web-based front end to an SFTP Server by constructing a
flow such as:
</p>
<p>
<a href="../org.apache.nifi.processors.standard.HandleHttpRequest/index.html">HandleHttpRequest</a> ->
<a href="../org.apache.nifi.processors.standard.PutSFTP/index.html">PutSFTP</a> ->
<a href="index.html">HandleHttpResponse</a>
</p>
<p>
This Processor must be configured with the same &lt;HTTP Context Map&gt; service as the corresponding HandleHttpRequest Processor.
Otherwise, all FlowFiles will be routed to the 'failure' relationship.
</p>
<p>
All FlowFiles must have an attribute named <code>http.context.identifier</code>. The value of this attribute is used to lookup
the HTTP Response so that the proper message can be sent back to the requestor. If this attribute is missing, the FlowFile
will be routed to 'failure.'
</p>
<p>
<strong>Properties:</strong>
</p>
<p>
In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. If a property has a default value, it is indicated. If a property supports the use of the NiFi Expression Language (or simply, "expression language"), that is also indicated.
</p>
<ul>
<li><strong>HTTP Status Code</strong>
<ul>
<li>The HTTP Status Code to use when responding to the HTTP Request. See Section 10 of RFC 2616 for more information.</li>
<li>Default value: no default</li>
<li>Supports expression language: true</li>
</ul>
</li>
<li><strong>HTTP Context Map</strong>
<ul>
<li>The HTTP Context Map Controller Service to use for caching the HTTP Request Information</li>
<li>Default value: no default</li>
<li>Supports expression language: false</li>
</ul>
</li>
</ul>
<p>
<strong>Relationships:</strong>
</p>
<ul>
<li>success
<ul>
<li>If a message is successfully sent back to the requestor, the FlowFile is routed to this relationship.</li>
</ul>
</li>
<li>failure
<ul>
<li>
A FlowFile will be routed to failure under the following conditions:
<ul>
<li>The FlowFile does not have an <code>http.context.identifier</code> attribute</li>
<li>The <code>http.context.identifier</code> attribute has a value that cannot be found in the HTTP Context Map</li>
<li>The HTTP Status Code is not a number</li>
<li>There was a communications failure when attempting to write the response to the requestor</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>
<strong>See Also:</strong><br />
<a href="../org.apache.nifi.processors.standard.HandleHttpRequest/index.html">HandleHttpRequest</a><br />
<a href="../org.apache.nifi.http.StandardHttpContextMap/index.html">StandardHttpContextMap</a><br />
<a href="../org.apache.nifi.ssl.StandardSSLContextService/index.html">StandardSSLContextService</a><br />
</p>
</body>
</html>