Search in sources :

Example 11 with CacheDirectiveEntry

use of org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry in project hadoop by apache.

the class TestRetryCacheWithHA method listCacheDirectives.

@SuppressWarnings("unchecked")
private void listCacheDirectives(HashSet<String> poolNames, int active) throws Exception {
    HashSet<String> tmpNames = (HashSet<String>) poolNames.clone();
    RemoteIterator<CacheDirectiveEntry> directives = dfs.listCacheDirectives(null);
    int poolCount = poolNames.size();
    for (int i = 0; i < poolCount; i++) {
        CacheDirectiveEntry directive = directives.next();
        String pollName = directive.getInfo().getPool();
        assertTrue("The pool name should be expected", tmpNames.remove(pollName));
        if (i % 2 == 0) {
            int standby = active;
            active = (standby == 0) ? 1 : 0;
            cluster.transitionToStandby(standby);
            cluster.transitionToActive(active);
            cluster.waitActive(active);
        }
    }
    assertTrue("All pools must be found", tmpNames.isEmpty());
}
Also used : CacheDirectiveEntry(org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry) HashSet(java.util.HashSet)

Example 12 with CacheDirectiveEntry

use of org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry in project SSM by Intel-bigdata.

the class CacheFileAction method isCached.

public boolean isCached(String fileName) throws Exception {
    CacheDirectiveInfo.Builder filterBuilder = new CacheDirectiveInfo.Builder();
    filterBuilder.setPath(new Path(fileName));
    CacheDirectiveInfo filter = filterBuilder.build();
    RemoteIterator<CacheDirectiveEntry> directiveEntries = dfsClient.listCacheDirectives(filter);
    return directiveEntries.hasNext();
}
Also used : Path(org.apache.hadoop.fs.Path) CacheDirectiveInfo(org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo) CacheDirectiveEntry(org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry)

Aggregations

CacheDirectiveEntry (org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry)12 CacheDirectiveInfo (org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo)10 Path (org.apache.hadoop.fs.Path)8 CachePoolInfo (org.apache.hadoop.hdfs.protocol.CachePoolInfo)6 Test (org.junit.Test)6 InvalidRequestException (org.apache.hadoop.fs.InvalidRequestException)4 IOException (java.io.IOException)3 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 RemoteIterator (org.apache.hadoop.fs.RemoteIterator)2 FsPermission (org.apache.hadoop.fs.permission.FsPermission)2 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)2 CachePoolEntry (org.apache.hadoop.hdfs.protocol.CachePoolEntry)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 ServiceException (com.google.protobuf.ServiceException)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 BatchedListEntries (org.apache.hadoop.fs.BatchedRemoteIterator.BatchedListEntries)1 CacheFlag (org.apache.hadoop.fs.CacheFlag)1 FileSystemTestHelper (org.apache.hadoop.fs.FileSystemTestHelper)1