org.apache.hadoop.lib.servlet
Class FileSystemReleaseFilter

java.lang.Object
  extended by org.apache.hadoop.lib.servlet.FileSystemReleaseFilter
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
HttpFSReleaseFilter

@InterfaceAudience.Private
public abstract class FileSystemReleaseFilter
extends Object
implements javax.servlet.Filter

The FileSystemReleaseFilter releases back to the FileSystemAccess service a FileSystem instance.

This filter is useful in situations where a servlet request is streaming out HDFS data and the corresponding filesystem instance have to be closed after the streaming completes.


Constructor Summary
FileSystemReleaseFilter()
           
 
Method Summary
 void destroy()
          Destroys the filter.
 void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)
          It delegates the incoming request to the FilterChain, and at its completion (in a finally block) releases the filesystem instance back to the FileSystemAccess service.
protected abstract  FileSystemAccess getFileSystemAccess()
          Abstract method to be implemetned by concrete implementations of the filter that return the FileSystemAccess service to which the filesystem will be returned to.
 void init(javax.servlet.FilterConfig filterConfig)
          Initializes the filter.
static void setFileSystem(org.apache.hadoop.fs.FileSystem fs)
          Static method that sets the FileSystem to release back to the FileSystemAccess service on servlet request completion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemReleaseFilter

public FileSystemReleaseFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Initializes the filter.

This implementation is a NOP.

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - filter configuration.
Throws:
javax.servlet.ServletException - thrown if the filter could not be initialized.

doFilter

public void doFilter(javax.servlet.ServletRequest servletRequest,
                     javax.servlet.ServletResponse servletResponse,
                     javax.servlet.FilterChain filterChain)
              throws IOException,
                     javax.servlet.ServletException
It delegates the incoming request to the FilterChain, and at its completion (in a finally block) releases the filesystem instance back to the FileSystemAccess service.

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
servletRequest - servlet request.
servletResponse - servlet response.
filterChain - filter chain.
Throws:
IOException - thrown if an IO error occurrs.
javax.servlet.ServletException - thrown if a servet error occurrs.

destroy

public void destroy()
Destroys the filter.

This implementation is a NOP.

Specified by:
destroy in interface javax.servlet.Filter

setFileSystem

public static void setFileSystem(org.apache.hadoop.fs.FileSystem fs)
Static method that sets the FileSystem to release back to the FileSystemAccess service on servlet request completion.

Parameters:
fs - fileystem instance.

getFileSystemAccess

protected abstract FileSystemAccess getFileSystemAccess()
Abstract method to be implemetned by concrete implementations of the filter that return the FileSystemAccess service to which the filesystem will be returned to.

Returns:
the FileSystemAccess service.


Copyright © 2014 Apache Software Foundation. All Rights Reserved.