List of usage examples for org.apache.hadoop.fs Path isAbsolute
public boolean isAbsolute()
From source file:org.springframework.data.hadoop.store.input.AbstractDataStreamReader.java
License:Apache License
/** * Gets the input.//from www . j av a 2 s . com * * @param inputPath the input path * @return the input * @throws IOException Signals that an I/O exception has occurred. */ protected StreamsHolder<InputStream> getInput(Path inputPath) throws IOException { log.info("Creating new InputStream"); StreamsHolder<InputStream> holder = new StreamsHolder<InputStream>(); final FileSystem fs = getPath().getFileSystem(getConfiguration()); Path p = inputPath.isAbsolute() ? inputPath : new Path(getPath(), inputPath); if (!fs.exists(p)) { throw new StoreException("Path " + p + " does not exist"); } if (!isCompressed()) { InputStream input = fs.open(p); holder.setStream(input); } else { // TODO: will isCompressed() really guard for npe against getCodec() Class<?> clazz = ClassUtils.resolveClassName(getCodec().getCodecClass(), getClass().getClassLoader()); CompressionCodec compressionCodec = (CompressionCodec) ReflectionUtils.newInstance(clazz, getConfiguration()); Decompressor decompressor = CodecPool.getDecompressor(compressionCodec); FSDataInputStream winput = fs.open(p); InputStream input = compressionCodec.createInputStream(winput, decompressor); holder.setWrappedStream(winput); holder.setStream(input); } return holder; }
From source file:org.xtreemfs.common.clients.hadoop.XtreemFSFileSystem.java
License:BSD License
private Path makeAbsolute(Path p) { if (p.isAbsolute()) { return p; } else {//w w w.j ava 2 s . c o m return new Path(workingDirectory, p); } }
From source file:ras.test.hadoop.fs.InMemoryFileSystem.java
License:Apache License
private Path makeAbsolute(Path path) { Validate.notNull(path, "path == null not allowed!"); if (path.isAbsolute()) { return path; }/*w ww . j a v a 2s . c om*/ return new Path(workingDirectory, path); }
From source file:ras.test.hadoop.fs.InMemoryFileSystemUnitTest.java
License:Apache License
private void expectPathMustExistIOException(Path path) { thrown.expect(IOException.class); String absoluteChar = (path.isAbsolute()) ? "" : "/"; thrown.expectMessage(equalTo("'" + absoluteChar + path + "' not found!")); }
From source file:tachyon.hadoop.AbstractTFS.java
License:Apache License
@Override public void setWorkingDirectory(Path path) { LOG.info("setWorkingDirectory(" + path + ")"); if (path.isAbsolute()) { mWorkingDir = path;/*from w w w . j a v a 2s .c o m*/ } else { mWorkingDir = new Path(mWorkingDir, path); } }