List of usage examples for org.apache.hadoop.fs FileContext util
Util util
To view the source code for org.apache.hadoop.fs FileContext util.
Click Source Link
From source file:org.elasticsearch.repositories.hdfs.HdfsBlobContainer.java
License:Apache License
@Override public boolean blobExists(String blobName) { try {// w w w .j a v a2s . c om return store.execute(new Operation<Boolean>() { @Override public Boolean run(FileContext fileContext) throws IOException { return fileContext.util().exists(new Path(path, blobName)); } }); } catch (Exception e) { return false; } }
From source file:org.elasticsearch.repositories.hdfs.HdfsBlobContainer.java
License:Apache License
@Override public Map<String, BlobMetaData> listBlobsByPrefix(@Nullable final String prefix) throws IOException { FileStatus[] files = store.execute(new Operation<FileStatus[]>() { @Override/* ww w .j a v a 2 s . co m*/ public FileStatus[] run(FileContext fileContext) throws IOException { return (fileContext.util().listStatus(path, new PathFilter() { @Override public boolean accept(Path path) { return prefix == null || path.getName().startsWith(prefix); } })); } }); Map<String, BlobMetaData> map = new LinkedHashMap<String, BlobMetaData>(); for (FileStatus file : files) { map.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen())); } return Collections.unmodifiableMap(map); }