Example usage for org.apache.hadoop.hdfs.protocol CacheDirectiveInfo getPath

List of usage examples for org.apache.hadoop.hdfs.protocol CacheDirectiveInfo getPath

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.protocol CacheDirectiveInfo getPath.

Prototype

public Path getPath() 

Source Link

Usage

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

/**
 * Add a new CacheDirective.//w w  w . j  av a  2 s . c o m
 * 
 * @param info
 *            Information about a directive to add.
 * @param flags
 *            {@link CacheFlag}s to use for this operation.
 * @return the ID of the directive that was created.
 * @throws IOException
 *             if the directive could not be added
 */
public long addCacheDirective(CacheDirectiveInfo info, EnumSet<CacheFlag> flags) throws IOException {
    Preconditions.checkNotNull(info.getPath());
    Path path = new Path(getPathName(fixRelativePart(info.getPath()))).makeQualified(getUri(),
            getWorkingDirectory());
    return dfs.addCacheDirective(new CacheDirectiveInfo.Builder(info).setPath(path).build(), flags);
}

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

/**
 * Modify a CacheDirective.//from ww  w  .  ja  v a2s  .  c om
 * 
 * @param info
 *            Information about the directive to modify. You must set the ID
 *            to indicate which CacheDirective you want to modify.
 * @param flags
 *            {@link CacheFlag}s to use for this operation.
 * @throws IOException
 *             if the directive could not be modified
 */
public void modifyCacheDirective(CacheDirectiveInfo info, EnumSet<CacheFlag> flags) throws IOException {
    if (info.getPath() != null) {
        info = new CacheDirectiveInfo.Builder(info)
                .setPath(new Path(getPathName(fixRelativePart(info.getPath()))).makeQualified(getUri(),
                        getWorkingDirectory()))
                .build();
    }
    dfs.modifyCacheDirective(info, flags);
}

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

/**
 * List cache directives. Incrementally fetches results from the server.
 * //ww w  .j  ava  2s. com
 * @param filter
 *            Filter parameters to use when listing the directives, null to
 *            list all directives visible to us.
 * @return A RemoteIterator which returns CacheDirectiveInfo objects.
 */
public RemoteIterator<CacheDirectiveEntry> listCacheDirectives(CacheDirectiveInfo filter) throws IOException {
    if (filter == null) {
        filter = new CacheDirectiveInfo.Builder().build();
    }
    if (filter.getPath() != null) {
        filter = new CacheDirectiveInfo.Builder(filter)
                .setPath(new Path(getPathName(fixRelativePart(filter.getPath())))).build();
    }
    final RemoteIterator<CacheDirectiveEntry> iter = dfs.listCacheDirectives(filter);
    return new RemoteIterator<CacheDirectiveEntry>() {
        @Override
        public boolean hasNext() throws IOException {
            return iter.hasNext();
        }

        @Override
        public CacheDirectiveEntry next() throws IOException {
            // Although the paths we get back from the NameNode should always be
            // absolute, we call makeQualified to add the scheme and authority of
            // this DistributedFilesystem.
            CacheDirectiveEntry desc = iter.next();
            CacheDirectiveInfo info = desc.getInfo();
            Path p = info.getPath().makeQualified(getUri(), getWorkingDirectory());
            return new CacheDirectiveEntry(new CacheDirectiveInfo.Builder(info).setPath(p).build(),
                    desc.getStats());
        }
    };
}