public abstract class AbstractResourceLocalizer extends java.lang.Object implements SmartResourceLocalizer
ResourceLocalizer
.Constructor and Description |
---|
AbstractResourceLocalizer(org.apache.hadoop.conf.Configuration configuration)
Instantiates a new abstract resource localizer.
|
AbstractResourceLocalizer(org.apache.hadoop.conf.Configuration configuration,
org.apache.hadoop.fs.Path stagingDirectory)
Instantiates a new abstract resource localizer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
clean()
Cleans all leftovers what has been created during
the distribute process.
|
void |
copy()
If resource localizer has knowledge to copy files
into file system, calling this method effectively
should do all tasks for that specific functionality.
|
protected boolean |
deleteStagingEntries()
Delete staging entries.
|
void |
distribute()
If underlying implementation needs to do operations
on file system or any other preparation work,
calling of this method should make implementation
ready to return resources from
ResourceLocalizer.getResources()
command. |
protected abstract void |
doFileCopy(org.apache.hadoop.fs.FileSystem fs)
Do file copy.
|
protected abstract java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> |
doFileTransfer(org.apache.hadoop.fs.FileSystem fs)
Do file transfer.
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
Gets the hadoop configuration.
|
java.util.concurrent.locks.ReentrantLock |
getLock()
Gets the lock.
|
java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> |
getResources()
Gets a map of
LocalResource instances. |
protected boolean |
isCopied()
Checks if is copied.
|
protected boolean |
isDistributed()
Checks if is distributed.
|
void |
resolve()
Manually resolve resources before distribution process
is initiated.
|
protected org.apache.hadoop.fs.Path |
resolveStagingDirectory()
Resolve runtime staging directory.
|
protected void |
setCopied(boolean copied)
Sets the copied.
|
protected void |
setDistributed(boolean distributed)
Sets the distributed.
|
void |
setStagingDirectory(org.apache.hadoop.fs.Path stagingDirectory)
Sets the staging directory.
|
void |
setStagingId(java.lang.String stagingId)
Sets the staging id.
|
public AbstractResourceLocalizer(org.apache.hadoop.conf.Configuration configuration)
configuration
- the configurationpublic AbstractResourceLocalizer(org.apache.hadoop.conf.Configuration configuration, org.apache.hadoop.fs.Path stagingDirectory)
configuration
- the configurationstagingDirectory
- the staging directorypublic java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> getResources()
ResourceLocalizer
LocalResource
instances. Underlying
instances of LocalResource
s needs to be fully
initialised including resource size and timestamp.
Calling this method should do all needed preparation work
needed to return LocalResource
s.
getResources
in interface ResourceLocalizer
LocalResource
instancespublic void copy()
SmartResourceLocalizer
copy
in interface SmartResourceLocalizer
public void distribute()
SmartResourceLocalizer
ResourceLocalizer.getResources()
command.
Effectively result of calling this method should be same as calling both SmartResourceLocalizer.copy() and SmartResourceLocalizer.resolve() methods manually.
distribute
in interface SmartResourceLocalizer
public void resolve()
SmartResourceLocalizer
resolve
in interface SmartResourceLocalizer
public boolean clean()
SmartResourceLocalizer
clean
in interface SmartResourceLocalizer
public void setStagingDirectory(org.apache.hadoop.fs.Path stagingDirectory)
SmartResourceLocalizer
setStagingDirectory
in interface SmartResourceLocalizer
stagingDirectory
- the new staging directorypublic void setStagingId(java.lang.String stagingId)
SmartResourceLocalizer
Path
set in SmartResourceLocalizer.setStagingDirectory(Path)
to post fix unique
runtime staging path. If not set simultaneous instances of
same application may override files.setStagingId
in interface SmartResourceLocalizer
stagingId
- the new staging idpublic org.apache.hadoop.conf.Configuration getConfiguration()
public java.util.concurrent.locks.ReentrantLock getLock()
protected abstract void doFileCopy(org.apache.hadoop.fs.FileSystem fs) throws java.lang.Exception
fs
- the fsjava.lang.Exception
- the exceptionprotected abstract java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> doFileTransfer(org.apache.hadoop.fs.FileSystem fs) throws java.lang.Exception
fs
- the fsjava.lang.Exception
- the exceptionprotected boolean isDistributed()
protected void setDistributed(boolean distributed)
distributed
- the new distributedprotected boolean isCopied()
protected void setCopied(boolean copied)
copied
- the new copiedprotected org.apache.hadoop.fs.Path resolveStagingDirectory()
protected boolean deleteStagingEntries()