Spring for Apache Hadoop

org.springframework.data.hadoop.fs
Class FileSystemFactoryBean

java.lang.Object
  extended by org.springframework.data.hadoop.fs.FileSystemFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<org.apache.hadoop.fs.FileSystem>, org.springframework.beans.factory.InitializingBean

public class FileSystemFactoryBean
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<org.apache.hadoop.fs.FileSystem>

FactoryBean for creating Hadoop FileSystem instances. Useful for interacting with HDFS from outside a Map Reduce job. If no parameter is given, a file system using the installed Hadoop defaults will be created.

Author:
Costin Leau

Constructor Summary
FileSystemFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 org.apache.hadoop.fs.FileSystem getObject()
           
 java.lang.Class<?> getObjectType()
           
 boolean isSingleton()
           
 void setClose(boolean close)
          Indicates whether the Hadoop file systems should be closed once this factory is destroyed.
 void setCloseAll(boolean closeAll)
          Indicates whether all the Hadoop file systems should be closed once this factory is destroyed.
 void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
          Sets the Hadoop configuration for this file system.
 void setUri(java.net.URI uri)
          Sets the URI (if available) for this file system.
 void setUser(java.lang.String user)
          Sets the user impersonation (optional) for creating this file-system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemFactoryBean

public FileSystemFactoryBean()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

getObject

public org.apache.hadoop.fs.FileSystem getObject()
                                          throws java.lang.Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<org.apache.hadoop.fs.FileSystem>
Throws:
java.lang.Exception

getObjectType

public java.lang.Class<?> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<org.apache.hadoop.fs.FileSystem>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<org.apache.hadoop.fs.FileSystem>

setConfiguration

public void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
Sets the Hadoop configuration for this file system.

Parameters:
configuration - The configuration to set.

setUri

public void setUri(java.net.URI uri)
Sets the URI (if available) for this file system.

Parameters:
uri - The uri to set.

setUser

public void setUser(java.lang.String user)
Sets the user impersonation (optional) for creating this file-system. Should be used when running against a Hadoop Kerberos cluster.

Parameters:
user - user/group information

setCloseAll

public void setCloseAll(boolean closeAll)
Indicates whether all the Hadoop file systems should be closed once this factory is destroyed. False by default - should be turned on as a safety measure when the app controls the entire lifecycle of Hadoop inside a JVM.

Parameters:
closeAll - the close all
See Also:
FileSystem.closeAll()

setClose

public void setClose(boolean close)
Indicates whether the Hadoop file systems should be closed once this factory is destroyed. True by default - should be turned off when running 'embedded' or if long running operations outlive the application context.

Parameters:
close -
See Also:
FileSystem.close()

Spring for Apache Hadoop