本文整理汇总了Java中org.apache.hadoop.fs.PathNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java PathNotFoundException类的具体用法?Java PathNotFoundException怎么用?Java PathNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathNotFoundException类属于org.apache.hadoop.fs包,在下文中一共展示了PathNotFoundException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRemoteDestination
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
/**
* 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
* @param args is the list of arguments
* @throws PathIOException if path doesn't exist or matches too many times
*/
protected void getRemoteDestination(LinkedList<String> args)
throws IOException {
if (args.size() < 2) {
dst = new PathData(Path.CUR_DIR, getConf());
} else {
String pathString = args.removeLast();
// if the path is a glob, then it must match one and only one path
PathData[] items = PathData.expandAsGlob(pathString, getConf());
switch (items.length) {
case 0:
throw new PathNotFoundException(pathString);
case 1:
dst = items[0];
break;
default:
throw new PathIOException(pathString, "Too many matches");
}
}
}
示例2: processArguments
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
// if more than one arg, the destination must be a directory
// if one arg, the dst must not exist or must be a directory
if (args.size() > 1) {
if (!dst.exists) {
throw new PathNotFoundException(dst.toString());
}
if (!dst.stat.isDirectory()) {
throw new PathIsNotDirectoryException(dst.toString());
}
} else if (dst.exists) {
if (!dst.stat.isDirectory() && !overwrite) {
throw new PathExistsException(dst.toString());
}
} else if (!dst.parentExists()) {
throw new PathNotFoundException(dst.toString());
}
super.processArguments(args);
}
示例3: cleanUp
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
@AfterClass
public static void cleanUp() {
System.gc();
Configuration configuration = new Configuration();
FileSystem fileSystem = null;
try {
fileSystem = FileSystem.get(configuration);
Path deletingFilePath = new Path("testData/MetaData/");
if (!fileSystem.exists(deletingFilePath)) {
throw new PathNotFoundException(deletingFilePath.toString());
} else {
boolean isDeleted = fileSystem.delete(deletingFilePath, true);
if (isDeleted) {
fileSystem.deleteOnExit(deletingFilePath);
}
}
fileSystem.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例4: parentOf
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
/**
* Get the parent of a path
* @param path path to look at
* @return the parent path
* @throws PathNotFoundException if the path was at root.
*/
public static String parentOf(String path) throws PathNotFoundException {
List<String> elements = split(path);
int size = elements.size();
if (size == 0) {
throw new PathNotFoundException("No parent of " + path);
}
if (size == 1) {
return "/";
}
elements.remove(size - 1);
StringBuilder parent = new StringBuilder(path.length());
for (String element : elements) {
parent.append("/");
parent.append(element);
}
return parent.toString();
}
示例5: statChildren
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
/**
* List children of a directory and retrieve their
* {@link RegistryPathStatus} values.
* <p>
* This is not an atomic operation; A child may be deleted
* during the iteration through the child entries. If this happens,
* the <code>PathNotFoundException</code> is caught and that child
* entry ommitted.
*
* @param path path
* @return a possibly empty map of child entries listed by
* their short name.
* @throws PathNotFoundException path is not in the registry.
* @throws InvalidPathnameException the path is invalid.
* @throws IOException Any other IO Exception
*/
public static Map<String, RegistryPathStatus> statChildren(
RegistryOperations registryOperations,
String path)
throws PathNotFoundException,
InvalidPathnameException,
IOException {
List<String> childNames = registryOperations.list(path);
Map<String, RegistryPathStatus> results =
new HashMap<String, RegistryPathStatus>();
for (String childName : childNames) {
String child = join(path, childName);
try {
RegistryPathStatus stat = registryOperations.stat(child);
results.put(childName, stat);
} catch (PathNotFoundException pnfe) {
if (LOG.isDebugEnabled()) {
LOG.debug("stat failed on {}: moved? {}", child, pnfe, pnfe);
}
// and continue
}
}
return results;
}
示例6: zkStat
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
/**
* Stat the file
* @param path path of operation
* @return a curator stat entry
* @throws IOException on a failure
* @throws PathNotFoundException if the path was not found
*/
public Stat zkStat(String path) throws IOException {
checkServiceLive();
String fullpath = createFullPath(path);
Stat stat;
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Stat {}", fullpath);
}
stat = curator.checkExists().forPath(fullpath);
} catch (Exception e) {
throw operationFailure(fullpath, "read()", e);
}
if (stat == null) {
throw new PathNotFoundException(path);
}
return stat;
}
示例7: zkGetACLS
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
/**
* Get the ACLs of a path
* @param path path of operation
* @return a possibly empty list of ACLs
* @throws IOException
*/
public List<ACL> zkGetACLS(String path) throws IOException {
checkServiceLive();
String fullpath = createFullPath(path);
List<ACL> acls;
try {
if (LOG.isDebugEnabled()) {
LOG.debug("GetACLS {}", fullpath);
}
acls = curator.getACL().forPath(fullpath);
} catch (Exception e) {
throw operationFailure(fullpath, "read()", e);
}
if (acls == null) {
throw new PathNotFoundException(path);
}
return acls;
}
示例8: transaction
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
@Override
public ConfigDiff transaction(ConfigSource config,
InputPlugin.Control control)
{
PluginTask task = config.loadConfig(PluginTask.class);
configureParquetLogger(task);
Path rootPath = new Path(task.getPath());
try (PluginClassLoaderScope ignored = new PluginClassLoaderScope()) {
Configuration conf = ConfigurationFactory.create(task);
FileSystem fs = FileSystem.get(rootPath.toUri(), conf);
List<FileStatus> statusList = listFileStatuses(fs, rootPath);
if (statusList.isEmpty()) {
throw new PathNotFoundException(rootPath.toString());
}
for (FileStatus status : statusList) {
logger.debug("embulk-input-parquet_hadoop: Loading paths: {}, length: {}",
status.getPath(), status.getLen());
}
List<String> files = Lists.transform(statusList, new Function<FileStatus, String>() {
@Nullable
@Override
public String apply(@Nullable FileStatus input)
{
return input.getPath().toString();
}
});
task.setFiles(files);
}
catch (IOException e) {
throw Throwables.propagate(e);
}
Schema schema = newSchema();
int taskCount = task.getFiles().size();
return resume(task.dump(), schema, taskCount, control);
}
示例9: throwException
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
/**
* Translates HDFS specific Exceptions to Pravega-equivalent Exceptions and re-throws them as such.
*
* @param segmentName Name of the stream segment on which the exception occurs.
* @param e The exception to be translated.
* @return Nothing. This method always throws.
*/
static <T> T throwException(String segmentName, Throwable e) throws StreamSegmentException {
if (e instanceof RemoteException) {
e = ((RemoteException) e).unwrapRemoteException();
}
if (e instanceof PathNotFoundException || e instanceof FileNotFoundException) {
throw new StreamSegmentNotExistsException(segmentName, e);
}
if (e instanceof FileAlreadyExistsException) {
throw new StreamSegmentExistsException(segmentName, e);
}
if (e instanceof AclException) {
throw new StreamSegmentSealedException(segmentName, e);
}
throw Lombok.sneakyThrow(e);
}
示例10: processArguments
import org.apache.hadoop.fs.PathNotFoundException; //导入依赖的package包/类
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
// if more than one arg, the destination must be a directory
// if one arg, the dst must not exist or must be a directory
if (args.size() > 1) {
if (!dst.exists) {
throw new PathNotFoundException(dst.toString());
}
if (!dst.stat.isDirectory()) {
throw new PathIsNotDirectoryException(dst.toString());
}
} else if (dst.exists) {
if (!dst.stat.isDirectory() && !overwrite) {
throw new PathExistsException(dst.toString());
}
} else if (!dst.parentExists()) {
throw new PathNotFoundException(dst.toString())
.withFullyQualifiedPath(dst.path.toUri().toString());
}
super.processArguments(args);
}