Class HDFSSynchronization
java.lang.Object
org.apache.beam.sdk.io.hadoop.format.HDFSSynchronization
- All Implemented Interfaces:
Serializable
,ExternalSynchronization
Implementation of
ExternalSynchronization
which registers locks in the HDFS.
Requires locksDir
to be specified. This directory MUST be different that directory
which is possibly stored under "mapreduce.output.fileoutputformat.outputdir"
key.
Otherwise setup of job will fail because the directory will exist before job setup.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHDFSSynchronization
(String locksDir) Creates instance ofHDFSSynchronization
. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.mapreduce.TaskAttemptID
acquireTaskAttemptIdLock
(org.apache.hadoop.conf.Configuration conf, int taskId) Creates uniqueTaskAttemptID
for given taskId.org.apache.hadoop.mapreduce.TaskID
acquireTaskIdLock
(org.apache.hadoop.conf.Configuration conf) CreatesTaskID
with unique id among given job.void
releaseJobIdLock
(org.apache.hadoop.conf.Configuration conf) Deletes lock ids bounded with given job if any exists.boolean
tryAcquireJobLock
(org.apache.hadoop.conf.Configuration conf) Tries to acquire lock for given job.
-
Constructor Details
-
HDFSSynchronization
Creates instance ofHDFSSynchronization
.- Parameters:
locksDir
- directory where locks will be stored. This directory MUST be different that directory which is possibly stored under"mapreduce.output.fileoutputformat.outputdir"
key. Otherwise setup of job will fail because the directory will exist before job setup.
-
-
Method Details
-
tryAcquireJobLock
public boolean tryAcquireJobLock(org.apache.hadoop.conf.Configuration conf) Description copied from interface:ExternalSynchronization
Tries to acquire lock for given job.- Specified by:
tryAcquireJobLock
in interfaceExternalSynchronization
- Parameters:
conf
- configuration bounded with given job.- Returns:
true
if the lock was acquired,false
otherwise.
-
releaseJobIdLock
public void releaseJobIdLock(org.apache.hadoop.conf.Configuration conf) Description copied from interface:ExternalSynchronization
Deletes lock ids bounded with given job if any exists.- Specified by:
releaseJobIdLock
in interfaceExternalSynchronization
- Parameters:
conf
- hadoop configuration of given job.
-
acquireTaskIdLock
public org.apache.hadoop.mapreduce.TaskID acquireTaskIdLock(org.apache.hadoop.conf.Configuration conf) Description copied from interface:ExternalSynchronization
CreatesTaskID
with unique id among given job.- Specified by:
acquireTaskIdLock
in interfaceExternalSynchronization
- Parameters:
conf
- hadoop configuration of given job.- Returns:
TaskID
with unique id among given job.
-
acquireTaskAttemptIdLock
public org.apache.hadoop.mapreduce.TaskAttemptID acquireTaskAttemptIdLock(org.apache.hadoop.conf.Configuration conf, int taskId) Description copied from interface:ExternalSynchronization
Creates uniqueTaskAttemptID
for given taskId.- Specified by:
acquireTaskAttemptIdLock
in interfaceExternalSynchronization
- Parameters:
conf
- configuration of given task and jobtaskId
- id of the task- Returns:
- Unique
TaskAttemptID
for given taskId.
-