本文整理汇总了Java中org.apache.hadoop.fs.Path.isAbsolute方法的典型用法代码示例。如果您正苦于以下问题:Java Path.isAbsolute方法的具体用法?Java Path.isAbsolute怎么用?Java Path.isAbsolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.fs.Path
的用法示例。
在下文中一共展示了Path.isAbsolute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeRelative
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* Make a path relative with respect to a root path.
* absPath is always assumed to descend from root.
* Otherwise returned path is null.
*/
static String makeRelative(Path root, Path absPath) {
if (!absPath.isAbsolute()) {
throw new IllegalArgumentException("!absPath.isAbsolute(), absPath="
+ absPath);
}
String p = absPath.toUri().getPath();
StringTokenizer pathTokens = new StringTokenizer(p, "/");
for(StringTokenizer rootTokens = new StringTokenizer(
root.toUri().getPath(), "/"); rootTokens.hasMoreTokens(); ) {
if (!rootTokens.nextToken().equals(pathTokens.nextToken())) {
return null;
}
}
StringBuilder sb = new StringBuilder();
for(; pathTokens.hasMoreTokens(); ) {
sb.append(pathTokens.nextToken());
if (pathTokens.hasMoreTokens()) { sb.append(Path.SEPARATOR); }
}
return sb.length() == 0? ".": sb.toString();
}
示例2: parse
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* The parse method parses the command-line options and creates a corresponding Options object.
*
* @param args Command-line arguments
* @return The Options object, corresponding to the specified command-line.
* @throws IllegalArgumentException Thrown if the parse fails.
*/
public S3MapReduceCpOptions parse(String... args) throws IllegalArgumentException {
try {
jCommander.parse(args);
} catch (Exception e) {
throw new IllegalArgumentException("Unable to parse arguments: " + Arrays.toString(args), e);
}
if (options.isHelp()) {
return options;
}
for (Path source : options.getSources()) {
if (!source.isAbsolute()) {
throw new IllegalArgumentException("Source paths must be absolute: " + Arrays.toString(args));
}
}
if (!options.getTarget().isAbsolute()) {
throw new IllegalArgumentException("Destination URI must be absolute: " + Arrays.toString(args));
}
if (options.getCredentialsProvider() != null && !options.getCredentialsProvider().isAbsolute()) {
throw new IllegalArgumentException("Credentials provider URI must be absolute: " + Arrays.toString(args));
}
if (options.getMaxMaps() <= 0) {
options.setMaxMaps(1);
}
if (options.getLogPath() != null && !options.getLogPath().isAbsolute()) {
throw new IllegalArgumentException("Log path must be absolute: " + Arrays.toString(args));
}
return options;
}
示例3: symlink
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
public final void symlink(Path src, Path dst) throws IOException {
if (!src.isAbsolute()) {
throw new IOException("Source must be absolute");
}
if (dst.isAbsolute()) {
throw new IOException("Destination must be relative");
}
if (dst.toUri().getPath().indexOf('/') != -1) {
mkdir(dst.getParent());
}
link(src, dst);
}
示例4: makeAbsolute
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* Get the absolute version of the path (fully qualified).
* This is public for testing purposes.
*
* @param path
* @return fully qualified path
*/
@VisibleForTesting
public Path makeAbsolute(Path path) {
if (path.isAbsolute()) {
return path;
}
return new Path(workingDir, path);
}
示例5: toAbsolutePath
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path toAbsolutePath(Path p) {
if (p.isAbsolute()) {
return p;
}
return new Path(workingDirectory, p);
}
示例6: makeAbsolute
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/**
* Makes path absolute
*
* @param path path to file
* @return absolute path
*/
protected Path makeAbsolute(Path path) {
if (path.isAbsolute()) {
return path;
}
return new Path(workingDir, path);
}
示例7: pathToKey
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private static String pathToKey(Path path) {
if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) {
// allow uris without trailing slash after bucket to refer to root,
// like s3n://mybucket
return "";
}
if (!path.isAbsolute()) {
throw new IllegalArgumentException("Path must be absolute: " + path);
}
String ret = path.toUri().getPath().substring(1); // remove initial slash
if (ret.endsWith("/") && (ret.indexOf("/") != ret.length() - 1)) {
ret = ret.substring(0, ret.length() -1);
}
return ret;
}
示例8: normalize
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path normalize(Path path) {
if (!path.isAbsolute()) {
throw new IllegalArgumentException("Path must be absolute: " + path);
}
return new Path(path.toUri().getPath());
}
示例9: setWorkingDirectory
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
@Override
public void setWorkingDirectory(final Path new_dir) {
workingDir = new_dir.isAbsolute() ? new_dir : new Path(workingDir, new_dir);
}
示例10: confChanged
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
/** This method gets called everytime before any read/write to make sure
* that any change to localDirs is reflected immediately.
*/
private synchronized void confChanged(Configuration conf)
throws IOException {
String newLocalDirs = conf.get(contextCfgItemName);
if (!newLocalDirs.equals(savedLocalDirs)) {
localDirs = StringUtils.getTrimmedStrings(newLocalDirs);
localFS = FileSystem.getLocal(conf);
int numDirs = localDirs.length;
ArrayList<String> dirs = new ArrayList<String>(numDirs);
ArrayList<DF> dfList = new ArrayList<DF>(numDirs);
for (int i = 0; i < numDirs; i++) {
try {
// filter problematic directories
Path tmpDir = new Path(localDirs[i]);
if(localFS.mkdirs(tmpDir)|| localFS.exists(tmpDir)) {
try {
File tmpFile = tmpDir.isAbsolute()
? new File(localFS.makeQualified(tmpDir).toUri())
: new File(localDirs[i]);
DiskChecker.checkDir(tmpFile);
dirs.add(tmpFile.getPath());
dfList.add(new DF(tmpFile, 30000));
} catch (DiskErrorException de) {
LOG.warn( localDirs[i] + " is not writable\n", de);
}
} else {
LOG.warn( "Failed to create " + localDirs[i]);
}
} catch (IOException ie) {
LOG.warn( "Failed to create " + localDirs[i] + ": " +
ie.getMessage() + "\n", ie);
} //ignore
}
localDirs = dirs.toArray(new String[dirs.size()]);
dirDF = dfList.toArray(new DF[dirs.size()]);
savedLocalDirs = newLocalDirs;
// randomize the first disk picked in the round-robin selection
dirNumLastAccessed = dirIndexRandomizer.nextInt(dirs.size());
}
}
示例11: makeAbsolute
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path makeAbsolute(final Path f) {
return f.isAbsolute() ? f : new Path(workingDir, f);
}
示例12: makeAbsolute
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path makeAbsolute(Path f) {
return f.isAbsolute()? f: new Path(workingDir, f);
}
示例13: makeAbsolute
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private Path makeAbsolute(Path path) {
if (path.isAbsolute()) {
return path;
}
return new Path(workingDir, path);
}
示例14: pathToKey
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private String pathToKey(Path path) {
if (!path.isAbsolute()) {
throw new IllegalArgumentException("Path must be absolute: " + path);
}
return path.toUri().getPath();
}
示例15: pathToKey
import org.apache.hadoop.fs.Path; //导入方法依赖的package包/类
private String pathToKey(Path path) {
if (!path.isAbsolute()) {
throw new IllegalArgumentException("Path must be absolute: " + path);
}
return urlEncode(path.toUri().getPath());
}