Java 类org.apache.hadoop.hdfs.protocol.CachePoolEntry 实例源码

项目:hadoop    文件:FSNamesystem.java   
BatchedListEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  BatchedListEntries<CachePoolEntry> results;
  checkOperation(OperationCategory.READ);
  boolean success = false;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  try {
    checkOperation(OperationCategory.READ);
    results = FSNDNCacheOp.listCachePools(this, cacheManager, prevKey);
    success = true;
  } finally {
    readUnlock();
    logAuditEvent(success, "listCachePools", null, null, null);
  }
  return results;
}
项目:hadoop    文件:CacheManager.java   
public BatchedListEntries<CachePoolEntry>
    listCachePools(FSPermissionChecker pc, String prevKey) {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  ArrayList<CachePoolEntry> results = 
      new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false);
  int numListed = 0;
  for (Entry<String, CachePool> cur : tailMap.entrySet()) {
    if (numListed++ >= maxListCachePoolsResponses) {
      return new BatchedListEntries<CachePoolEntry>(results, true);
    }
    results.add(cur.getValue().getEntry(pc));
  }
  return new BatchedListEntries<CachePoolEntry>(results, false);
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public ListCachePoolsResponseProto listCachePools(RpcController controller,
    ListCachePoolsRequestProto request) throws ServiceException {
  try {
    BatchedEntries<CachePoolEntry> entries =
      server.listCachePools(request.getPrevPoolName());
    ListCachePoolsResponseProto.Builder responseBuilder =
      ListCachePoolsResponseProto.newBuilder();
    responseBuilder.setHasMore(entries.hasMore());
    for (int i=0, n=entries.size(); i<n; i++) {
      responseBuilder.addEntries(PBHelper.convert(entries.get(i)));
    }
    return responseBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop    文件:TestRetryCacheWithHA.java   
@SuppressWarnings("unchecked")
private void listCachePools(
    HashSet<String> poolNames, int active) throws Exception {
  HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
  RemoteIterator<CachePoolEntry> pools = dfs.listCachePools();
  int poolCount = poolNames.size();
  for (int i=0; i<poolCount; i++) {
    CachePoolEntry pool = pools.next();
    String pollName = pool.getInfo().getPoolName();
    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());
}
项目:aliyun-oss-hadoop-fs    文件:FSNamesystem.java   
BatchedListEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  BatchedListEntries<CachePoolEntry> results;
  checkOperation(OperationCategory.READ);
  boolean success = false;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  try {
    checkOperation(OperationCategory.READ);
    results = FSNDNCacheOp.listCachePools(this, cacheManager, prevKey);
    success = true;
  } finally {
    readUnlock();
    logAuditEvent(success, "listCachePools", null, null, null);
  }
  return results;
}
项目:aliyun-oss-hadoop-fs    文件:CacheManager.java   
public BatchedListEntries<CachePoolEntry>
    listCachePools(FSPermissionChecker pc, String prevKey) {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  ArrayList<CachePoolEntry> results = 
      new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false);
  int numListed = 0;
  for (Entry<String, CachePool> cur : tailMap.entrySet()) {
    if (numListed++ >= maxListCachePoolsResponses) {
      return new BatchedListEntries<CachePoolEntry>(results, true);
    }
    results.add(cur.getValue().getEntry(pc));
  }
  return new BatchedListEntries<CachePoolEntry>(results, false);
}
项目:aliyun-oss-hadoop-fs    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public ListCachePoolsResponseProto listCachePools(RpcController controller,
    ListCachePoolsRequestProto request) throws ServiceException {
  try {
    BatchedEntries<CachePoolEntry> entries =
      server.listCachePools(request.getPrevPoolName());
    ListCachePoolsResponseProto.Builder responseBuilder =
      ListCachePoolsResponseProto.newBuilder();
    responseBuilder.setHasMore(entries.hasMore());
    for (int i=0, n=entries.size(); i<n; i++) {
      responseBuilder.addEntries(PBHelperClient.convert(entries.get(i)));
    }
    return responseBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestRetryCacheWithHA.java   
@SuppressWarnings("unchecked")
private void listCachePools(
    HashSet<String> poolNames, int active) throws Exception {
  HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
  RemoteIterator<CachePoolEntry> pools = dfs.listCachePools();
  int poolCount = poolNames.size();
  for (int i=0; i<poolCount; i++) {
    CachePoolEntry pool = pools.next();
    String pollName = pool.getInfo().getPoolName();
    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());
}
项目:nnproxy    文件:CacheRegistry.java   
List<CachePoolEntry> getAllCachePools(UpstreamManager.Upstream upstream) throws IOException {
    String prevPool = "";
    List<CachePoolEntry> pools = new ArrayList<>();

    while (true) {
        BatchedRemoteIterator.BatchedEntries<CachePoolEntry> it = upstream.protocol.listCachePools(prevPool);
        if (it.size() == 0) {
            break;
        }
        for (int i = 0; i < it.size(); i++) {
            CachePoolEntry entry = it.get(i);
            prevPool = entry.getInfo().getPoolName();
            pools.add(entry);
        }
    }
    return pools;
}
项目:big-c    文件:FSNamesystem.java   
BatchedListEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  BatchedListEntries<CachePoolEntry> results;
  checkOperation(OperationCategory.READ);
  boolean success = false;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  try {
    checkOperation(OperationCategory.READ);
    results = FSNDNCacheOp.listCachePools(this, cacheManager, prevKey);
    success = true;
  } finally {
    readUnlock();
    logAuditEvent(success, "listCachePools", null, null, null);
  }
  return results;
}
项目:big-c    文件:CacheManager.java   
public BatchedListEntries<CachePoolEntry>
    listCachePools(FSPermissionChecker pc, String prevKey) {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  ArrayList<CachePoolEntry> results = 
      new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false);
  int numListed = 0;
  for (Entry<String, CachePool> cur : tailMap.entrySet()) {
    if (numListed++ >= maxListCachePoolsResponses) {
      return new BatchedListEntries<CachePoolEntry>(results, true);
    }
    results.add(cur.getValue().getEntry(pc));
  }
  return new BatchedListEntries<CachePoolEntry>(results, false);
}
项目:big-c    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public ListCachePoolsResponseProto listCachePools(RpcController controller,
    ListCachePoolsRequestProto request) throws ServiceException {
  try {
    BatchedEntries<CachePoolEntry> entries =
      server.listCachePools(request.getPrevPoolName());
    ListCachePoolsResponseProto.Builder responseBuilder =
      ListCachePoolsResponseProto.newBuilder();
    responseBuilder.setHasMore(entries.hasMore());
    for (int i=0, n=entries.size(); i<n; i++) {
      responseBuilder.addEntries(PBHelper.convert(entries.get(i)));
    }
    return responseBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:big-c    文件:TestRetryCacheWithHA.java   
@SuppressWarnings("unchecked")
private void listCachePools(
    HashSet<String> poolNames, int active) throws Exception {
  HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
  RemoteIterator<CachePoolEntry> pools = dfs.listCachePools();
  int poolCount = poolNames.size();
  for (int i=0; i<poolCount; i++) {
    CachePoolEntry pool = pools.next();
    String pollName = pool.getInfo().getPoolName();
    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());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:FSNamesystem.java   
public BatchedListEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  final FSPermissionChecker pc =
      isPermissionEnabled ? getPermissionChecker() : null;
  BatchedListEntries<CachePoolEntry> results;
  checkOperation(OperationCategory.READ);
  boolean success = false;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  try {
    checkOperation(OperationCategory.READ);
    results = cacheManager.listCachePools(pc, prevKey);
    success = true;
  } finally {
    readUnlock();
    if (isAuditEnabled() && isExternalInvocation()) {
      logAuditEvent(success, "listCachePools", null, null, null);
    }
  }
  return results;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:CacheManager.java   
public BatchedListEntries<CachePoolEntry>
    listCachePools(FSPermissionChecker pc, String prevKey) {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  ArrayList<CachePoolEntry> results = 
      new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false);
  int numListed = 0;
  for (Entry<String, CachePool> cur : tailMap.entrySet()) {
    if (numListed++ >= maxListCachePoolsResponses) {
      return new BatchedListEntries<CachePoolEntry>(results, true);
    }
    results.add(cur.getValue().getEntry(pc));
  }
  return new BatchedListEntries<CachePoolEntry>(results, false);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public ListCachePoolsResponseProto listCachePools(RpcController controller,
    ListCachePoolsRequestProto request) throws ServiceException {
  try {
    BatchedEntries<CachePoolEntry> entries =
      server.listCachePools(request.getPrevPoolName());
    ListCachePoolsResponseProto.Builder responseBuilder =
      ListCachePoolsResponseProto.newBuilder();
    responseBuilder.setHasMore(entries.hasMore());
    for (int i=0, n=entries.size(); i<n; i++) {
      responseBuilder.addEntries(PBHelper.convert(entries.get(i)));
    }
    return responseBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestRetryCacheWithHA.java   
@SuppressWarnings("unchecked")
private void listCachePools(
    HashSet<String> poolNames, int active) throws Exception {
  HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
  RemoteIterator<CachePoolEntry> pools = dfs.listCachePools();
  int poolCount = poolNames.size();
  for (int i=0; i<poolCount; i++) {
    CachePoolEntry pool = pools.next();
    String pollName = pool.getInfo().getPoolName();
    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());
}
项目:FlexMap    文件:FSNamesystem.java   
public BatchedListEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  final FSPermissionChecker pc =
      isPermissionEnabled ? getPermissionChecker() : null;
  BatchedListEntries<CachePoolEntry> results;
  checkOperation(OperationCategory.READ);
  boolean success = false;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  try {
    checkOperation(OperationCategory.READ);
    results = cacheManager.listCachePools(pc, prevKey);
    success = true;
  } finally {
    readUnlock();
    if (isAuditEnabled() && isExternalInvocation()) {
      logAuditEvent(success, "listCachePools", null, null, null);
    }
  }
  return results;
}
项目:FlexMap    文件:CacheManager.java   
public BatchedListEntries<CachePoolEntry>
    listCachePools(FSPermissionChecker pc, String prevKey) {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  ArrayList<CachePoolEntry> results = 
      new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false);
  int numListed = 0;
  for (Entry<String, CachePool> cur : tailMap.entrySet()) {
    if (numListed++ >= maxListCachePoolsResponses) {
      return new BatchedListEntries<CachePoolEntry>(results, true);
    }
    results.add(cur.getValue().getEntry(pc));
  }
  return new BatchedListEntries<CachePoolEntry>(results, false);
}
项目:FlexMap    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public ListCachePoolsResponseProto listCachePools(RpcController controller,
    ListCachePoolsRequestProto request) throws ServiceException {
  try {
    BatchedEntries<CachePoolEntry> entries =
      server.listCachePools(request.getPrevPoolName());
    ListCachePoolsResponseProto.Builder responseBuilder =
      ListCachePoolsResponseProto.newBuilder();
    responseBuilder.setHasMore(entries.hasMore());
    for (int i=0, n=entries.size(); i<n; i++) {
      responseBuilder.addEntries(PBHelper.convert(entries.get(i)));
    }
    return responseBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:FlexMap    文件:TestRetryCacheWithHA.java   
@SuppressWarnings("unchecked")
private void listCachePools(
    HashSet<String> poolNames, int active) throws Exception {
  HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
  RemoteIterator<CachePoolEntry> pools = dfs.listCachePools();
  int poolCount = poolNames.size();
  for (int i=0; i<poolCount; i++) {
    CachePoolEntry pool = pools.next();
    String pollName = pool.getInfo().getPoolName();
    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());
}
项目:hadoop-on-lustre2    文件:FSNamesystem.java   
public BatchedListEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  final FSPermissionChecker pc =
      isPermissionEnabled ? getPermissionChecker() : null;
  BatchedListEntries<CachePoolEntry> results;
  checkOperation(OperationCategory.READ);
  boolean success = false;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  try {
    checkOperation(OperationCategory.READ);
    results = cacheManager.listCachePools(pc, prevKey);
    success = true;
  } finally {
    readUnlock();
    if (isAuditEnabled() && isExternalInvocation()) {
      logAuditEvent(success, "listCachePools", null, null, null);
    }
  }
  return results;
}
项目:hadoop-on-lustre2    文件:CacheManager.java   
public BatchedListEntries<CachePoolEntry>
    listCachePools(FSPermissionChecker pc, String prevKey) {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  ArrayList<CachePoolEntry> results = 
      new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  SortedMap<String, CachePool> tailMap = cachePools.tailMap(prevKey, false);
  int numListed = 0;
  for (Entry<String, CachePool> cur : tailMap.entrySet()) {
    if (numListed++ >= maxListCachePoolsResponses) {
      return new BatchedListEntries<CachePoolEntry>(results, true);
    }
    results.add(cur.getValue().getEntry(pc));
  }
  return new BatchedListEntries<CachePoolEntry>(results, false);
}
项目:hadoop-on-lustre2    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public ListCachePoolsResponseProto listCachePools(RpcController controller,
    ListCachePoolsRequestProto request) throws ServiceException {
  try {
    BatchedEntries<CachePoolEntry> entries =
      server.listCachePools(request.getPrevPoolName());
    ListCachePoolsResponseProto.Builder responseBuilder =
      ListCachePoolsResponseProto.newBuilder();
    responseBuilder.setHasMore(entries.hasMore());
    for (int i=0, n=entries.size(); i<n; i++) {
      responseBuilder.addEntries(PBHelper.convert(entries.get(i)));
    }
    return responseBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-on-lustre2    文件:TestRetryCacheWithHA.java   
@SuppressWarnings("unchecked")
private void listCachePools(
    HashSet<String> poolNames, int active) throws Exception {
  HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
  RemoteIterator<CachePoolEntry> pools = dfs.listCachePools();
  int poolCount = poolNames.size();
  for (int i=0; i<poolCount; i++) {
    CachePoolEntry pool = pools.next();
    String pollName = pool.getInfo().getPoolName();
    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());
}
项目:hadoop    文件:CachePool.java   
/**
 * Returns a CachePoolInfo describing this CachePool based on the permissions
 * of the calling user. Unprivileged users will see only minimal descriptive
 * information about the pool.
 * 
 * @param pc Permission checker to be used to validate the user's permissions,
 *          or null
 * @return CachePoolEntry describing this CachePool
 */
public CachePoolEntry getEntry(FSPermissionChecker pc) {
  boolean hasPermission = true;
  if (pc != null) {
    try {
      pc.checkPermission(this, FsAction.READ);
    } catch (AccessControlException e) {
      hasPermission = false;
    }
  }
  return new CachePoolEntry(getInfo(hasPermission), 
      hasPermission ? getStats() : new CachePoolStats.Builder().build());
}
项目:hadoop    文件:ClientNamenodeProtocolTranslatorPB.java   
@Override
public BatchedEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  try {
    return new BatchedCachePoolEntries(
      rpcProxy.listCachePools(null,
        ListCachePoolsRequestProto.newBuilder().
          setPrevPoolName(prevKey).build()));
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
项目:hadoop    文件:TestRetryCacheWithHA.java   
@Override
boolean checkNamenodeBeforeReturn() throws Exception {
  for (int i = 0; i < CHECKTIMES; i++) {
    RemoteIterator<CachePoolEntry> iter = dfs.listCachePools();
    if (iter.hasNext()) {
      return true;
    }
    Thread.sleep(1000);
  }
  return false;
}
项目:hadoop    文件:TestRetryCacheWithHA.java   
@Override
boolean checkNamenodeBeforeReturn() throws Exception {
  for (int i = 0; i < CHECKTIMES; i++) {
    RemoteIterator<CachePoolEntry> iter = dfs.listCachePools();
    if (iter.hasNext() && iter.next().getInfo().getLimit() == 99) {
      return true;
    }
    Thread.sleep(1000);
  }
  return false;
}
项目:hadoop    文件:TestRetryCacheWithHA.java   
@Override
boolean checkNamenodeBeforeReturn() throws Exception {
  for (int i = 0; i < CHECKTIMES; i++) {
    RemoteIterator<CachePoolEntry> iter = dfs.listCachePools();
    if (!iter.hasNext()) {
      return true;
    }
    Thread.sleep(1000);
  }
  return false;
}
项目:hadoop    文件:TestCacheDirectives.java   
@Test(timeout=60000)
public void testListCachePoolPermissions() throws Exception {
  final UserGroupInformation myUser = UserGroupInformation
      .createRemoteUser("myuser");
  final DistributedFileSystem myDfs = 
      (DistributedFileSystem)DFSTestUtil.getFileSystemAs(myUser, conf);
  final String poolName = "poolparty";
  dfs.addCachePool(new CachePoolInfo(poolName)
      .setMode(new FsPermission((short)0700)));
  // Should only see partial info
  RemoteIterator<CachePoolEntry> it = myDfs.listCachePools();
  CachePoolInfo info = it.next().getInfo();
  assertFalse(it.hasNext());
  assertEquals("Expected pool name", poolName, info.getPoolName());
  assertNull("Unexpected owner name", info.getOwnerName());
  assertNull("Unexpected group name", info.getGroupName());
  assertNull("Unexpected mode", info.getMode());
  assertNull("Unexpected limit", info.getLimit());
  // Modify the pool so myuser is now the owner
  final long limit = 99;
  dfs.modifyCachePool(new CachePoolInfo(poolName)
      .setOwnerName(myUser.getShortUserName())
      .setLimit(limit));
  // Should see full info
  it = myDfs.listCachePools();
  info = it.next().getInfo();
  assertFalse(it.hasNext());
  assertEquals("Expected pool name", poolName, info.getPoolName());
  assertEquals("Mismatched owner name", myUser.getShortUserName(),
      info.getOwnerName());
  assertNotNull("Expected group name", info.getGroupName());
  assertEquals("Mismatched mode", (short) 0700,
      info.getMode().toShort());
  assertEquals("Mismatched limit", limit, (long)info.getLimit());
}
项目:aliyun-oss-hadoop-fs    文件:ClientNamenodeProtocolTranslatorPB.java   
@Override
public BatchedEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  try {
    return new BatchedCachePoolEntries(
        rpcProxy.listCachePools(null,
            ListCachePoolsRequestProto.newBuilder().
                setPrevPoolName(prevKey).build()));
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
项目:aliyun-oss-hadoop-fs    文件:CachePool.java   
/**
 * Returns a CachePoolInfo describing this CachePool based on the permissions
 * of the calling user. Unprivileged users will see only minimal descriptive
 * information about the pool.
 * 
 * @param pc Permission checker to be used to validate the user's permissions,
 *          or null
 * @return CachePoolEntry describing this CachePool
 */
public CachePoolEntry getEntry(FSPermissionChecker pc) {
  boolean hasPermission = true;
  if (pc != null) {
    try {
      pc.checkPermission(this, FsAction.READ);
    } catch (AccessControlException e) {
      hasPermission = false;
    }
  }
  return new CachePoolEntry(getInfo(hasPermission), 
      hasPermission ? getStats() : new CachePoolStats.Builder().build());
}
项目:aliyun-oss-hadoop-fs    文件:TestRetryCacheWithHA.java   
@Override
boolean checkNamenodeBeforeReturn() throws Exception {
  for (int i = 0; i < CHECKTIMES; i++) {
    RemoteIterator<CachePoolEntry> iter = dfs.listCachePools();
    if (iter.hasNext()) {
      return true;
    }
    Thread.sleep(1000);
  }
  return false;
}
项目:aliyun-oss-hadoop-fs    文件:TestRetryCacheWithHA.java   
@Override
boolean checkNamenodeBeforeReturn() throws Exception {
  for (int i = 0; i < CHECKTIMES; i++) {
    RemoteIterator<CachePoolEntry> iter = dfs.listCachePools();
    if (iter.hasNext() && iter.next().getInfo().getLimit() == 99) {
      return true;
    }
    Thread.sleep(1000);
  }
  return false;
}
项目:aliyun-oss-hadoop-fs    文件:TestRetryCacheWithHA.java   
@Override
boolean checkNamenodeBeforeReturn() throws Exception {
  for (int i = 0; i < CHECKTIMES; i++) {
    RemoteIterator<CachePoolEntry> iter = dfs.listCachePools();
    if (!iter.hasNext()) {
      return true;
    }
    Thread.sleep(1000);
  }
  return false;
}
项目:aliyun-oss-hadoop-fs    文件:TestCacheDirectives.java   
@Test(timeout=60000)
public void testListCachePoolPermissions() throws Exception {
  final UserGroupInformation myUser = UserGroupInformation
      .createRemoteUser("myuser");
  final DistributedFileSystem myDfs = 
      (DistributedFileSystem)DFSTestUtil.getFileSystemAs(myUser, conf);
  final String poolName = "poolparty";
  dfs.addCachePool(new CachePoolInfo(poolName)
      .setMode(new FsPermission((short)0700)));
  // Should only see partial info
  RemoteIterator<CachePoolEntry> it = myDfs.listCachePools();
  CachePoolInfo info = it.next().getInfo();
  assertFalse(it.hasNext());
  assertEquals("Expected pool name", poolName, info.getPoolName());
  assertNull("Unexpected owner name", info.getOwnerName());
  assertNull("Unexpected group name", info.getGroupName());
  assertNull("Unexpected mode", info.getMode());
  assertNull("Unexpected limit", info.getLimit());
  // Modify the pool so myuser is now the owner
  final long limit = 99;
  dfs.modifyCachePool(new CachePoolInfo(poolName)
      .setOwnerName(myUser.getShortUserName())
      .setLimit(limit));
  // Should see full info
  it = myDfs.listCachePools();
  info = it.next().getInfo();
  assertFalse(it.hasNext());
  assertEquals("Expected pool name", poolName, info.getPoolName());
  assertEquals("Mismatched owner name", myUser.getShortUserName(),
      info.getOwnerName());
  assertNotNull("Expected group name", info.getGroupName());
  assertEquals("Mismatched mode", (short) 0700,
      info.getMode().toShort());
  assertEquals("Mismatched limit", limit, (long)info.getLimit());
}
项目:nnproxy    文件:CacheRegistry.java   
public BatchedRemoteIterator.BatchedListEntries<CachePoolEntry> listCachePools(String prevKey) {
    final int NUM_PRE_ALLOCATED_ENTRIES = 16;
    ArrayList<CachePoolEntry> results =
            new ArrayList<CachePoolEntry>(NUM_PRE_ALLOCATED_ENTRIES);
    SortedMap<String, CachePoolEntry> tailMap = cachePools.tailMap(prevKey, false);
    int numListed = 0;
    for (Map.Entry<String, CachePoolEntry> cur : tailMap.entrySet()) {
        if (numListed++ >= maxListCachePoolsResponses) {
            return new BatchedRemoteIterator.BatchedListEntries<>(results, true);
        }
        results.add(cur.getValue());
    }
    return new BatchedRemoteIterator.BatchedListEntries<>(results, false);
}
项目:big-c    文件:CachePool.java   
/**
 * Returns a CachePoolInfo describing this CachePool based on the permissions
 * of the calling user. Unprivileged users will see only minimal descriptive
 * information about the pool.
 * 
 * @param pc Permission checker to be used to validate the user's permissions,
 *          or null
 * @return CachePoolEntry describing this CachePool
 */
public CachePoolEntry getEntry(FSPermissionChecker pc) {
  boolean hasPermission = true;
  if (pc != null) {
    try {
      pc.checkPermission(this, FsAction.READ);
    } catch (AccessControlException e) {
      hasPermission = false;
    }
  }
  return new CachePoolEntry(getInfo(hasPermission), 
      hasPermission ? getStats() : new CachePoolStats.Builder().build());
}
项目:big-c    文件:ClientNamenodeProtocolTranslatorPB.java   
@Override
public BatchedEntries<CachePoolEntry> listCachePools(String prevKey)
    throws IOException {
  try {
    return new BatchedCachePoolEntries(
      rpcProxy.listCachePools(null,
        ListCachePoolsRequestProto.newBuilder().
          setPrevPoolName(prevKey).build()));
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}