Configurablepublic abstract class CopyCommandWithMultiThread extends FsCommand
| Modifier and Type | Field | Description |
|---|---|---|
static int |
DEFAULT_QUEUE_SIZE |
|
protected PathData |
dst |
|
protected static org.slf4j.Logger |
LOG |
|
static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
loopLocator |
args, COMMAND_DESCRIPTION_FIELD, COMMAND_NAME_FIELD, COMMAND_USAGE_FIELD, err, exceptions, exitCode, name, numErrors, out, recursive| Constructor | Description |
|---|---|
CopyCommandWithMultiThread() |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
copyFileToTarget(PathData src,
PathData target) |
Copies the source file to the target.
|
protected void |
copyStreamToTarget(java.io.InputStream in,
PathData target) |
If direct write is disabled ,copies the stream contents to a temporary
file "target._COPYING_".
|
protected java.util.concurrent.ThreadPoolExecutor |
getExecutor() |
|
protected void |
getLocalDestination(java.util.LinkedList<java.lang.String> args) |
The last arg is expected to be a local path, if only one argument is
given then the destination will be the current directory
|
protected void |
getRemoteDestination(java.util.LinkedList<java.lang.String> args) |
The last arg is expected to be a remote path, if only one argument is
given then the destination will be the remote user's directory
|
protected PathData |
getTargetPath(PathData src) |
|
protected int |
getThreadCount() |
|
protected int |
getThreadPoolQueueSize() |
|
protected boolean |
isMultiThreadNecessary(java.util.LinkedList<PathData> args) |
|
protected void |
preserve(org.apache.hadoop.fs.shell.CommandWithDestination.FileAttribute fileAttribute) |
Add file attributes that need to be preserved.
|
protected void |
preserveAttributes(PathData src,
PathData target,
boolean preserveRawXAttrs) |
Preserve the attributes of the source to the target.
|
protected void |
processArguments(java.util.LinkedList<PathData> args) |
Processes the command's list of expanded arguments.
|
protected void |
processPath(PathData src) |
Hook for commands to implement an operation to be applied on each
path for the command.
|
protected void |
processPath(PathData src,
PathData dst) |
Called with a source and target destination pair
|
protected void |
processPathArgument(PathData src) |
This is the last chance to modify an argument before going into the
(possibly) recursive
Command.processPaths(PathData, PathData...)
-> Command.processPath(PathData) loop. |
protected void |
recursePath(PathData src) |
Gets the directory listing for a path and invokes
Command.processPaths(PathData, PathData...) |
protected void |
setDirectWrite(boolean flag) |
|
protected void |
setKeepLinks(boolean flag) |
|
protected void |
setLazyPersist(boolean flag) |
|
protected void |
setOverwrite(boolean flag) |
This method is used to enable the force(-f) option while copying the files.
|
protected void |
setPreserve(boolean preserve) |
If true, the last modified time, last access time,
owner, group and permission information of the source
file will be preserved as far as target
FileSystem
implementation allows. |
protected void |
setThreadCount(java.lang.String optValue) |
set thread count by option value, if the value less than 1,
use 1 instead.
|
protected void |
setThreadPoolQueueSize(java.lang.String optValue) |
set thread pool queue size by option value, if the value less than 1,
use DEFAULT_QUEUE_SIZE instead.
|
protected void |
setVerifyChecksum(boolean flag) |
|
protected void |
setWriteChecksum(boolean flag) |
getCommandName, processRawArguments, registerCommands, run, runAlldisplayError, displayError, displayWarning, exitCodeForError, expandArgument, expandArguments, getCommandFactory, getDepth, getDescription, getListingGroupSize, getName, getReplacementCommand, getUsage, isDeprecated, isPathRecursable, isRecursive, isSorted, postProcessPath, processArgument, processNonexistentPath, processOptions, processPaths, processPaths, run, run, setCommandFactory, setName, setRecursivegetConf, setConfpublic static final int DEFAULT_QUEUE_SIZE
protected static final org.slf4j.Logger LOG
protected PathData dst
public static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> loopLocator
protected void setThreadCount(java.lang.String optValue)
optValue - option valueprotected void setThreadPoolQueueSize(java.lang.String optValue)
optValue - option value@VisibleForTesting protected int getThreadCount()
@VisibleForTesting protected int getThreadPoolQueueSize()
@VisibleForTesting protected java.util.concurrent.ThreadPoolExecutor getExecutor()
protected void processArguments(java.util.LinkedList<PathData> args) throws java.io.IOException
CommandCommand.processArgument(PathData) will be invoked with each item
in the list. The loop catches IOExceptions, increments the error
count, and displays the exception.args - a list of PathData to processjava.io.IOException - if anything goes wrong...@VisibleForTesting protected boolean isMultiThreadNecessary(java.util.LinkedList<PathData> args) throws java.io.IOException
java.io.IOExceptionprotected void copyFileToTarget(PathData src, PathData target) throws java.io.IOException
src - item to copytarget - where to copy the itemjava.io.IOException - if copy failsprotected void setOverwrite(boolean flag)
flag - true/falseprotected void setLazyPersist(boolean flag)
protected void setVerifyChecksum(boolean flag)
protected void setWriteChecksum(boolean flag)
protected void setDirectWrite(boolean flag)
protected void setKeepLinks(boolean flag)
protected void setPreserve(boolean preserve)
FileSystem
implementation allows.preserve - preserve.protected void preserve(org.apache.hadoop.fs.shell.CommandWithDestination.FileAttribute fileAttribute)
fileAttribute - - Attribute to add, one at a timeprotected void getLocalDestination(java.util.LinkedList<java.lang.String> args)
throws java.io.IOException
args - is the list of argumentsjava.io.IOException - raised on errors performing I/O.protected void getRemoteDestination(java.util.LinkedList<java.lang.String> args)
throws java.io.IOException
args - is the list of argumentsPathIOException - if path doesn't exist or matches too many timesjava.io.IOExceptionprotected void processPathArgument(PathData src) throws java.io.IOException
CommandCommand.processPaths(PathData, PathData...)
-> Command.processPath(PathData) loop. Ex. ls and du use
this to expand out directories.processPathArgument in class Commandsrc - a PathData representing a path which existsjava.io.IOException - if anything goes wrong...protected void processPath(PathData src) throws java.io.IOException
CommandprocessPath in class Commandsrc - a PathData objectjava.io.IOException - if anything else goes wrong in the user-implementationprotected void processPath(PathData src, PathData dst) throws java.io.IOException
src - for the operationdst - for the operationjava.io.IOException - if anything goes wrongprotected void recursePath(PathData src) throws java.io.IOException
CommandCommand.processPaths(PathData, PathData...)recursePath in class Commandsrc - PathData for directory to recurse intojava.io.IOException - if anything goes wrong...protected PathData getTargetPath(PathData src) throws java.io.IOException
java.io.IOExceptionprotected void copyStreamToTarget(java.io.InputStream in,
PathData target)
throws java.io.IOException
in - the input stream for the copytarget - where to store the contents of the streamjava.io.IOException - if copy failsprotected void preserveAttributes(PathData src, PathData target, boolean preserveRawXAttrs) throws java.io.IOException
shouldPreserve(FileAttribute) to check what
attribute to preserve.src - source to preservetarget - where to preserve attributespreserveRawXAttrs - true if raw.* xattrs should be preservedjava.io.IOException - if fails to preserve attributesCopyright © 2008–2025 Apache Software Foundation. All rights reserved.