Package org.apache.hadoop.lib.servlet
Class FileSystemReleaseFilter
java.lang.Object
org.apache.hadoop.lib.servlet.FileSystemReleaseFilter
- All Implemented Interfaces:
javax.servlet.Filter
- Direct Known Subclasses:
HttpFSReleaseFilter
@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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroys the filter.voiddoFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) It delegates the incoming request to theFilterChain, and at its completion (in a finally block) releases the filesystem instance back to theFileSystemAccessservice.protected abstract FileSystemAccessAbstract method to be implemented by concrete implementations of the filter that return theFileSystemAccessservice to which the filesystem will be returned to.voidinit(javax.servlet.FilterConfig filterConfig) Initializes the filter.static voidsetFileSystem(org.apache.hadoop.fs.FileSystem fs) Static method that sets theFileSystemto release back to theFileSystemAccessservice on servlet request completion.
-
Constructor Details
-
FileSystemReleaseFilter
public FileSystemReleaseFilter()
-
-
Method Details
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException Initializes the filter.This implementation is a NOP.
- Specified by:
initin interfacejavax.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 theFilterChain, and at its completion (in a finally block) releases the filesystem instance back to theFileSystemAccessservice.- Specified by:
doFilterin interfacejavax.servlet.Filter- Parameters:
servletRequest- servlet request.servletResponse- servlet response.filterChain- filter chain.- Throws:
IOException- thrown if an IO error occurs.javax.servlet.ServletException- thrown if a servlet error occurs.
-
destroy
public void destroy()Destroys the filter.This implementation is a NOP.
- Specified by:
destroyin interfacejavax.servlet.Filter
-
setFileSystem
public static void setFileSystem(org.apache.hadoop.fs.FileSystem fs) Static method that sets theFileSystemto release back to theFileSystemAccessservice on servlet request completion.- Parameters:
fs- a filesystem instance.
-
getFileSystemAccess
Abstract method to be implemented by concrete implementations of the filter that return theFileSystemAccessservice to which the filesystem will be returned to.- Returns:
- the FileSystemAccess service.
-