public final class HadoopDataSourceUtil extends Object
Modifier and Type | Field and Description |
---|---|
static Charset |
COMMENT_CHARSET
Charset for commit mark file comments.
|
static String |
DEFAULT_SYSTEM_DIR
The default system directory name.
|
static String |
KEY_LOCAL_TEMPDIR
The attribute key name of local tempdir.
|
static String |
KEY_PATH
The key name of path.
|
static String |
KEY_SYSTEM_DIR
The key name of system directory for this format.
|
static String |
PREFIX
The key prefix of data sources.
|
static String |
PREFIX_BEGIN_MARK
The file name prefix of transaction began mark.
|
static String |
PREFIX_COMMIT_MARK
The file name prefix of transaction committed mark.
|
static String |
TRANSACTION_INFO_DIR
The transaction directory name.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
contains(org.apache.hadoop.fs.Path parent,
org.apache.hadoop.fs.Path child)
Returns whether the parent path contains the child path, or not.
|
static OutputTransactionContext |
createContext(org.apache.hadoop.mapreduce.JobContext context,
String datasourceId)
Deprecated.
|
static OutputTransactionContext |
createContext(String executionId,
String datasourceId)
Creates output context from execution ID and datasource ID.
|
static OutputAttemptContext |
createContext(org.apache.hadoop.mapreduce.TaskAttemptContext context,
String datasourceId)
Deprecated.
|
static Collection<org.apache.hadoop.fs.FileStatus> |
findAllTransactionInfoFiles(org.apache.hadoop.conf.Configuration conf)
Returns the all transaction info files.
|
static org.apache.hadoop.fs.Path |
getCommitMarkPath(org.apache.hadoop.conf.Configuration conf,
String executionId)
Returns the commit mark path.
|
static org.apache.hadoop.fs.Path |
getLocalTemporaryDirectory(org.apache.hadoop.fs.LocalFileSystem localFileSystem)
Returns the local temporary directory.
|
static org.apache.hadoop.fs.Path |
getSystemDir(org.apache.hadoop.conf.Configuration conf)
Returns the system directory.
|
static org.apache.hadoop.fs.Path |
getSystemDir(org.apache.hadoop.conf.Configuration conf,
boolean resolve)
Returns the system directory.
|
static String |
getTransactionInfoExecutionId(org.apache.hadoop.fs.Path transactionInfoPath)
Extracts an execution ID from the transaction info.
|
static org.apache.hadoop.fs.Path |
getTransactionInfoPath(org.apache.hadoop.conf.Configuration conf,
String executionId)
Returns the transaction info path.
|
static boolean |
isLocalAttemptOutputDefined(org.apache.hadoop.fs.LocalFileSystem localFileSystem)
Returns whether the local attempt output directory is defined.
|
static List<DirectDataSourceProfile> |
loadProfiles(org.apache.hadoop.conf.Configuration conf)
Loads a profile list from the configuration.
|
static DirectDataSourceRepository |
loadRepository(org.apache.hadoop.conf.Configuration conf)
Loads
DirectDataSourceRepository from Configuration . |
static void |
move(Counter counter,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path from,
org.apache.hadoop.fs.Path to)
Moves all files in source directory into target directory.
|
static void |
move(Counter counter,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path from,
org.apache.hadoop.fs.Path to,
int threads)
Moves all files in source directory into target directory.
|
static void |
moveFromLocal(Counter counter,
org.apache.hadoop.fs.LocalFileSystem localFs,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path from,
org.apache.hadoop.fs.Path to)
Moves all files in source directory into target directory.
|
static List<org.apache.hadoop.fs.FileStatus> |
onlyMinimalCovered(List<org.apache.hadoop.fs.FileStatus> statList)
Returns only minimal covered files.
|
static List<org.apache.hadoop.fs.FileStatus> |
search(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path base,
FilePattern pattern)
Searches file/directories by pattern.
|
static <T> HadoopFileFormat<T> |
toHadoopFileFormat(org.apache.hadoop.conf.Configuration configuration,
DataFormat<T> format)
Converts
DataFormat into an equivalent HadoopFileFormat . |
public static final String PREFIX
public static final String KEY_PATH
public static final String KEY_SYSTEM_DIR
public static final String KEY_LOCAL_TEMPDIR
public static final String PREFIX_BEGIN_MARK
public static final String PREFIX_COMMIT_MARK
public static final String DEFAULT_SYSTEM_DIR
public static final String TRANSACTION_INFO_DIR
public static final Charset COMMENT_CHARSET
public static List<DirectDataSourceProfile> loadProfiles(org.apache.hadoop.conf.Configuration conf)
conf
- target configurationIllegalArgumentException
- if some parameters were null
public static DirectDataSourceRepository loadRepository(org.apache.hadoop.conf.Configuration conf)
DirectDataSourceRepository
from Configuration
.conf
- configuration objectIllegalArgumentException
- if some parameters were null
public static boolean isLocalAttemptOutputDefined(org.apache.hadoop.fs.LocalFileSystem localFileSystem)
localFileSystem
- current local file systemtrue
to defined, otherwise false
IllegalArgumentException
- if some parameters were null
public static org.apache.hadoop.fs.Path getLocalTemporaryDirectory(org.apache.hadoop.fs.LocalFileSystem localFileSystem) throws IOException
localFileSystem
- the local file systemnull
if not definedIOException
- if failed to compute the pathIllegalArgumentException
- if some parameters were null
public static OutputTransactionContext createContext(String executionId, String datasourceId)
executionId
- current execution IDdatasourceId
- target datasource IDIllegalArgumentException
- if some parameters were null
@Deprecated public static OutputTransactionContext createContext(org.apache.hadoop.mapreduce.JobContext context, String datasourceId)
BridgeOutputFormat.createContext(JobContext, String)
insteadcontext
- current context in HadoopdatasourceId
- datasource IDIllegalArgumentException
- if some parameters were null
@Deprecated public static OutputAttemptContext createContext(org.apache.hadoop.mapreduce.TaskAttemptContext context, String datasourceId)
BridgeOutputFormat.createContext(TaskAttemptContext, String)
insteadcontext
- current context in HadoopdatasourceId
- datasource IDIllegalArgumentException
- if some parameters were null
public static String getTransactionInfoExecutionId(org.apache.hadoop.fs.Path transactionInfoPath)
transactionInfoPath
- target pathnull
if is not a valid transaction infoIllegalArgumentException
- if some parameters were null
getCommitMarkPath(Configuration, String)
public static org.apache.hadoop.fs.Path getTransactionInfoPath(org.apache.hadoop.conf.Configuration conf, String executionId) throws IOException
conf
- the current configurationexecutionId
- target transaction IDIOException
- if failed to compute the path by I/O exceptionIllegalArgumentException
- if some parameters were null
public static org.apache.hadoop.fs.Path getCommitMarkPath(org.apache.hadoop.conf.Configuration conf, String executionId) throws IOException
conf
- the current configurationexecutionId
- target transaction IDIOException
- if failed to compute the path by I/O exceptionIllegalArgumentException
- if some parameters were null
public static Collection<org.apache.hadoop.fs.FileStatus> findAllTransactionInfoFiles(org.apache.hadoop.conf.Configuration conf) throws IOException
conf
- the current configurationIOException
- if failed to find files by I/O errorIllegalArgumentException
- if some parameters were null
public static org.apache.hadoop.fs.Path getSystemDir(org.apache.hadoop.conf.Configuration conf) throws IOException
conf
- the current configurationIOException
- if I/O error was occurredpublic static org.apache.hadoop.fs.Path getSystemDir(org.apache.hadoop.conf.Configuration conf, boolean resolve) throws IOException
conf
- the current configurationresolve
- true
to resolve the result path, otherwise false
IOException
- if I/O error was occurredpublic static List<org.apache.hadoop.fs.FileStatus> search(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path base, FilePattern pattern) throws IOException
fs
- target file systembase
- base pathpattern
- search patternIOException
- if failed to search by I/O errorIllegalArgumentException
- if some parameters were null
public static List<org.apache.hadoop.fs.FileStatus> onlyMinimalCovered(List<org.apache.hadoop.fs.FileStatus> statList)
statList
- target filespublic static boolean contains(org.apache.hadoop.fs.Path parent, org.apache.hadoop.fs.Path child)
false
.parent
- the parent pathchild
- the child pathtrue
if parent path strictly contains the child, otherwise false
IllegalArgumentException
- if some parameters were null
public static void move(Counter counter, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path from, org.apache.hadoop.fs.Path to) throws IOException
counter
- counter which accepts operations countfs
- file systemfrom
- path to source directoryto
- path to target directoryIOException
- if failed to move filesIllegalArgumentException
- if some parameters were null
public static void moveFromLocal(Counter counter, org.apache.hadoop.fs.LocalFileSystem localFs, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path from, org.apache.hadoop.fs.Path to) throws IOException
counter
- counter which accepts operations countlocalFs
- the local file systemfs
- the target file systemfrom
- path to source directory (must be on local file system)to
- path to target directoryIOException
- if failed to move filesIllegalArgumentException
- if some parameters were null
public static void move(Counter counter, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path from, org.apache.hadoop.fs.Path to, int threads) throws IOException, InterruptedException
counter
- counter which accepts operations countfs
- file systemfrom
- path to source directoryto
- path to target directorythreads
- the number of threads for moving each fileIOException
- if failed to move filesInterruptedException
- if interrupted while moving filesIllegalArgumentException
- if some parameters were null
public static <T> HadoopFileFormat<T> toHadoopFileFormat(org.apache.hadoop.conf.Configuration configuration, DataFormat<T> format) throws IOException
DataFormat
into an equivalent HadoopFileFormat
.T
- the data typeconfiguration
- the current configurationformat
- the target data formatIOException
- if the given DataFormat
is not supportedCopyright © 2011–2019 Asakusa Framework Team. All rights reserved.