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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    Abstract method to be implemented 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 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:
      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 occurs.
      javax.servlet.ServletException - thrown if a servlet error occurs.
    • 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 - a filesystem instance.
    • getFileSystemAccess

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