Java 类org.apache.hadoop.fs.BatchedRemoteIterator.BatchedListEntries 实例源码

项目:hadoop    文件:FSNamesystem.java   
BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    long startId, CacheDirectiveInfo filter) throws IOException {
  checkOperation(OperationCategory.READ);
  BatchedListEntries<CacheDirectiveEntry> results;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  boolean success = false;
  try {
    checkOperation(OperationCategory.READ);
    results = FSNDNCacheOp.listCacheDirectives(this, cacheManager, startId,
        filter);
    success = true;
  } finally {
    readUnlock();
    logAuditEvent(success, "listCacheDirectives", filter.toString(), null,
        null);
  }
  return results;
}
项目: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    文件:FSNamesystem.java   
BatchedListEntries<EncryptionZone> listEncryptionZones(long prevId)
    throws IOException {
  boolean success = false;
  checkSuperuserPrivilege();
  checkOperation(OperationCategory.READ);
  readLock();
  try {
    checkSuperuserPrivilege();
    checkOperation(OperationCategory.READ);
    final BatchedListEntries<EncryptionZone> ret =
        dir.listEncryptionZones(prevId);
    success = true;
    return ret;
  } finally {
    readUnlock();
    logAuditEvent(success, "listEncryptionZones", null);
  }
}
项目: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);
}
项目:aliyun-oss-hadoop-fs    文件:FSNamesystem.java   
BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    long startId, CacheDirectiveInfo filter) throws IOException {
  checkOperation(OperationCategory.READ);
  BatchedListEntries<CacheDirectiveEntry> results;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  boolean success = false;
  try {
    checkOperation(OperationCategory.READ);
    results = FSNDNCacheOp.listCacheDirectives(this, cacheManager, startId,
        filter);
    success = true;
  } finally {
    readUnlock();
    logAuditEvent(success, "listCacheDirectives", filter.toString(), null,
        null);
  }
  return results;
}
项目: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    文件:FSNamesystem.java   
BatchedListEntries<EncryptionZone> listEncryptionZones(long prevId)
    throws IOException {
  boolean success = false;
  checkSuperuserPrivilege();
  checkOperation(OperationCategory.READ);
  readLock();
  try {
    checkSuperuserPrivilege();
    checkOperation(OperationCategory.READ);
    final BatchedListEntries<EncryptionZone> ret =
        FSDirEncryptionZoneOp.listEncryptionZones(dir, prevId);
    success = true;
    return ret;
  } finally {
    readUnlock();
    logAuditEvent(success, "listEncryptionZones", null);
  }
}
项目: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);
}
项目:big-c    文件:FSNamesystem.java   
BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    long startId, CacheDirectiveInfo filter) throws IOException {
  checkOperation(OperationCategory.READ);
  BatchedListEntries<CacheDirectiveEntry> results;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  boolean success = false;
  try {
    checkOperation(OperationCategory.READ);
    results = FSNDNCacheOp.listCacheDirectives(this, cacheManager, startId,
        filter);
    success = true;
  } finally {
    readUnlock();
    logAuditEvent(success, "listCacheDirectives", filter.toString(), null,
        null);
  }
  return results;
}
项目: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    文件:FSNamesystem.java   
BatchedListEntries<EncryptionZone> listEncryptionZones(long prevId)
    throws IOException {
  boolean success = false;
  checkSuperuserPrivilege();
  checkOperation(OperationCategory.READ);
  readLock();
  try {
    checkSuperuserPrivilege();
    checkOperation(OperationCategory.READ);
    final BatchedListEntries<EncryptionZone> ret =
        dir.listEncryptionZones(prevId);
    success = true;
    return ret;
  } finally {
    readUnlock();
    logAuditEvent(success, "listEncryptionZones", null);
  }
}
项目: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);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:FSNamesystem.java   
BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    long startId, CacheDirectiveInfo filter) throws IOException {
  checkOperation(OperationCategory.READ);
  final FSPermissionChecker pc = isPermissionEnabled ?
      getPermissionChecker() : null;
  BatchedListEntries<CacheDirectiveEntry> results;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  boolean success = false;
  try {
    checkOperation(OperationCategory.READ);
    results =
        cacheManager.listCacheDirectives(startId, filter, pc);
    success = true;
  } finally {
    readUnlock();
    if (isAuditEnabled() && isExternalInvocation()) {
      logAuditEvent(success, "listCacheDirectives", filter.toString(), null,
          null);
    }
  }
  return results;
}
项目: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    文件:FSNamesystem.java   
BatchedListEntries<EncryptionZone> listEncryptionZones(long prevId)
    throws IOException {
  boolean success = false;
  checkSuperuserPrivilege();
  checkOperation(OperationCategory.READ);
  readLock();
  try {
    checkSuperuserPrivilege();
    checkOperation(OperationCategory.READ);
    final BatchedListEntries<EncryptionZone> ret =
        dir.listEncryptionZones(prevId);
    success = true;
    return ret;
  } finally {
    readUnlock();
    logAuditEvent(success, "listEncryptionZones", null);
  }
}
项目: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);
}
项目:FlexMap    文件:FSNamesystem.java   
BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    long startId, CacheDirectiveInfo filter) throws IOException {
  checkOperation(OperationCategory.READ);
  final FSPermissionChecker pc = isPermissionEnabled ?
      getPermissionChecker() : null;
  BatchedListEntries<CacheDirectiveEntry> results;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  boolean success = false;
  try {
    checkOperation(OperationCategory.READ);
    results =
        cacheManager.listCacheDirectives(startId, filter, pc);
    success = true;
  } finally {
    readUnlock();
    if (isAuditEnabled() && isExternalInvocation()) {
      logAuditEvent(success, "listCacheDirectives", filter.toString(), null,
          null);
    }
  }
  return results;
}
项目: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    文件:FSNamesystem.java   
BatchedListEntries<EncryptionZone> listEncryptionZones(long prevId)
    throws IOException {
  boolean success = false;
  checkSuperuserPrivilege();
  checkOperation(OperationCategory.READ);
  readLock();
  try {
    checkSuperuserPrivilege();
    checkOperation(OperationCategory.READ);
    final BatchedListEntries<EncryptionZone> ret =
        dir.listEncryptionZones(prevId);
    success = true;
    return ret;
  } finally {
    readUnlock();
    logAuditEvent(success, "listEncryptionZones", null);
  }
}
项目: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);
}
项目:hadoop-on-lustre2    文件:FSNamesystem.java   
BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    long startId, CacheDirectiveInfo filter) throws IOException {
  checkOperation(OperationCategory.READ);
  final FSPermissionChecker pc = isPermissionEnabled ?
      getPermissionChecker() : null;
  BatchedListEntries<CacheDirectiveEntry> results;
  cacheManager.waitForRescanIfNeeded();
  readLock();
  boolean success = false;
  try {
    checkOperation(OperationCategory.READ);
    results =
        cacheManager.listCacheDirectives(startId, filter, pc);
    success = true;
  } finally {
    readUnlock();
    if (isAuditEnabled() && isExternalInvocation()) {
      logAuditEvent(success, "listCacheDirectives", null, null,
          null);
    }
  }
  return results;
}
项目: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);
}
项目:aliyun-oss-hadoop-fs    文件:FSDirEncryptionZoneOp.java   
static BatchedListEntries<EncryptionZone> listEncryptionZones(
    final FSDirectory fsd, final long prevId) throws IOException {
  fsd.readLock();
  try {
    return fsd.ezManager.listEncryptionZones(prevId);
  } finally {
    fsd.readUnlock();
  }
}
项目:hadoop    文件:FSNDNCacheOp.java   
static BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    FSNamesystem fsn, CacheManager cacheManager,
    long startId, CacheDirectiveInfo filter) throws IOException {
  final FSPermissionChecker pc = getFsPermissionChecker(fsn);
  return cacheManager.listCacheDirectives(startId, filter, pc);
}
项目:hadoop    文件:FSNDNCacheOp.java   
static BatchedListEntries<CachePoolEntry> listCachePools(
    FSNamesystem fsn, CacheManager cacheManager, String prevKey)
    throws IOException {
  final FSPermissionChecker pc = getFsPermissionChecker(fsn);
  return cacheManager.listCachePools(pc, prevKey);
}
项目:hadoop    文件:CacheManager.java   
public BatchedListEntries<CacheDirectiveEntry> 
      listCacheDirectives(long prevId,
          CacheDirectiveInfo filter,
          FSPermissionChecker pc) throws IOException {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  String filterPath = null;
  if (filter.getPath() != null) {
    filterPath = validatePath(filter);
  }
  if (filter.getReplication() != null) {
    throw new InvalidRequestException(
        "Filtering by replication is unsupported.");
  }

  // Querying for a single ID
  final Long id = filter.getId();
  if (id != null) {
    if (!directivesById.containsKey(id)) {
      throw new InvalidRequestException("Did not find requested id " + id);
    }
    // Since we use a tailMap on directivesById, setting prev to id-1 gets
    // us the directive with the id (if present)
    prevId = id - 1;
  }

  ArrayList<CacheDirectiveEntry> replies =
      new ArrayList<CacheDirectiveEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  int numReplies = 0;
  SortedMap<Long, CacheDirective> tailMap =
    directivesById.tailMap(prevId + 1);
  for (Entry<Long, CacheDirective> cur : tailMap.entrySet()) {
    if (numReplies >= maxListCacheDirectivesNumResponses) {
      return new BatchedListEntries<CacheDirectiveEntry>(replies, true);
    }
    CacheDirective curDirective = cur.getValue();
    CacheDirectiveInfo info = cur.getValue().toInfo();

    // If the requested ID is present, it should be the first item.
    // Hitting this case means the ID is not present, or we're on the second
    // item and should break out.
    if (id != null &&
        !(info.getId().equals(id))) {
      break;
    }
    if (filter.getPool() != null && 
        !info.getPool().equals(filter.getPool())) {
      continue;
    }
    if (filterPath != null &&
        !info.getPath().toUri().getPath().equals(filterPath)) {
      continue;
    }
    boolean hasPermission = true;
    if (pc != null) {
      try {
        pc.checkPermission(curDirective.getPool(), FsAction.READ);
      } catch (AccessControlException e) {
        hasPermission = false;
      }
    }
    if (hasPermission) {
      replies.add(new CacheDirectiveEntry(info, cur.getValue().toStats()));
      numReplies++;
    }
  }
  return new BatchedListEntries<CacheDirectiveEntry>(replies, false);
}
项目:aliyun-oss-hadoop-fs    文件:FSNDNCacheOp.java   
static BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    FSNamesystem fsn, CacheManager cacheManager,
    long startId, CacheDirectiveInfo filter) throws IOException {
  final FSPermissionChecker pc = getFsPermissionChecker(fsn);
  return cacheManager.listCacheDirectives(startId, filter, pc);
}
项目:aliyun-oss-hadoop-fs    文件:FSNDNCacheOp.java   
static BatchedListEntries<CachePoolEntry> listCachePools(
    FSNamesystem fsn, CacheManager cacheManager, String prevKey)
    throws IOException {
  final FSPermissionChecker pc = getFsPermissionChecker(fsn);
  return cacheManager.listCachePools(pc, prevKey);
}
项目:aliyun-oss-hadoop-fs    文件:CacheManager.java   
public BatchedListEntries<CacheDirectiveEntry> 
      listCacheDirectives(long prevId,
          CacheDirectiveInfo filter,
          FSPermissionChecker pc) throws IOException {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  String filterPath = null;
  if (filter.getPath() != null) {
    filterPath = validatePath(filter);
  }
  if (filter.getReplication() != null) {
    throw new InvalidRequestException(
        "Filtering by replication is unsupported.");
  }

  // Querying for a single ID
  final Long id = filter.getId();
  if (id != null) {
    if (!directivesById.containsKey(id)) {
      throw new InvalidRequestException("Did not find requested id " + id);
    }
    // Since we use a tailMap on directivesById, setting prev to id-1 gets
    // us the directive with the id (if present)
    prevId = id - 1;
  }

  ArrayList<CacheDirectiveEntry> replies =
      new ArrayList<CacheDirectiveEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  int numReplies = 0;
  SortedMap<Long, CacheDirective> tailMap =
    directivesById.tailMap(prevId + 1);
  for (Entry<Long, CacheDirective> cur : tailMap.entrySet()) {
    if (numReplies >= maxListCacheDirectivesNumResponses) {
      return new BatchedListEntries<CacheDirectiveEntry>(replies, true);
    }
    CacheDirective curDirective = cur.getValue();
    CacheDirectiveInfo info = cur.getValue().toInfo();

    // If the requested ID is present, it should be the first item.
    // Hitting this case means the ID is not present, or we're on the second
    // item and should break out.
    if (id != null &&
        !(info.getId().equals(id))) {
      break;
    }
    if (filter.getPool() != null && 
        !info.getPool().equals(filter.getPool())) {
      continue;
    }
    if (filterPath != null &&
        !info.getPath().toUri().getPath().equals(filterPath)) {
      continue;
    }
    boolean hasPermission = true;
    if (pc != null) {
      try {
        pc.checkPermission(curDirective.getPool(), FsAction.READ);
      } catch (AccessControlException e) {
        hasPermission = false;
      }
    }
    if (hasPermission) {
      replies.add(new CacheDirectiveEntry(info, cur.getValue().toStats()));
      numReplies++;
    }
  }
  return new BatchedListEntries<CacheDirectiveEntry>(replies, false);
}
项目:big-c    文件:FSNDNCacheOp.java   
static BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
    FSNamesystem fsn, CacheManager cacheManager,
    long startId, CacheDirectiveInfo filter) throws IOException {
  final FSPermissionChecker pc = getFsPermissionChecker(fsn);
  return cacheManager.listCacheDirectives(startId, filter, pc);
}
项目:big-c    文件:FSNDNCacheOp.java   
static BatchedListEntries<CachePoolEntry> listCachePools(
    FSNamesystem fsn, CacheManager cacheManager, String prevKey)
    throws IOException {
  final FSPermissionChecker pc = getFsPermissionChecker(fsn);
  return cacheManager.listCachePools(pc, prevKey);
}
项目:big-c    文件:CacheManager.java   
public BatchedListEntries<CacheDirectiveEntry> 
      listCacheDirectives(long prevId,
          CacheDirectiveInfo filter,
          FSPermissionChecker pc) throws IOException {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  String filterPath = null;
  if (filter.getPath() != null) {
    filterPath = validatePath(filter);
  }
  if (filter.getReplication() != null) {
    throw new InvalidRequestException(
        "Filtering by replication is unsupported.");
  }

  // Querying for a single ID
  final Long id = filter.getId();
  if (id != null) {
    if (!directivesById.containsKey(id)) {
      throw new InvalidRequestException("Did not find requested id " + id);
    }
    // Since we use a tailMap on directivesById, setting prev to id-1 gets
    // us the directive with the id (if present)
    prevId = id - 1;
  }

  ArrayList<CacheDirectiveEntry> replies =
      new ArrayList<CacheDirectiveEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  int numReplies = 0;
  SortedMap<Long, CacheDirective> tailMap =
    directivesById.tailMap(prevId + 1);
  for (Entry<Long, CacheDirective> cur : tailMap.entrySet()) {
    if (numReplies >= maxListCacheDirectivesNumResponses) {
      return new BatchedListEntries<CacheDirectiveEntry>(replies, true);
    }
    CacheDirective curDirective = cur.getValue();
    CacheDirectiveInfo info = cur.getValue().toInfo();

    // If the requested ID is present, it should be the first item.
    // Hitting this case means the ID is not present, or we're on the second
    // item and should break out.
    if (id != null &&
        !(info.getId().equals(id))) {
      break;
    }
    if (filter.getPool() != null && 
        !info.getPool().equals(filter.getPool())) {
      continue;
    }
    if (filterPath != null &&
        !info.getPath().toUri().getPath().equals(filterPath)) {
      continue;
    }
    boolean hasPermission = true;
    if (pc != null) {
      try {
        pc.checkPermission(curDirective.getPool(), FsAction.READ);
      } catch (AccessControlException e) {
        hasPermission = false;
      }
    }
    if (hasPermission) {
      replies.add(new CacheDirectiveEntry(info, cur.getValue().toStats()));
      numReplies++;
    }
  }
  return new BatchedListEntries<CacheDirectiveEntry>(replies, false);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:CacheManager.java   
public BatchedListEntries<CacheDirectiveEntry> 
      listCacheDirectives(long prevId,
          CacheDirectiveInfo filter,
          FSPermissionChecker pc) throws IOException {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  String filterPath = null;
  if (filter.getPath() != null) {
    filterPath = validatePath(filter);
  }
  if (filter.getReplication() != null) {
    throw new InvalidRequestException(
        "Filtering by replication is unsupported.");
  }

  // Querying for a single ID
  final Long id = filter.getId();
  if (id != null) {
    if (!directivesById.containsKey(id)) {
      throw new InvalidRequestException("Did not find requested id " + id);
    }
    // Since we use a tailMap on directivesById, setting prev to id-1 gets
    // us the directive with the id (if present)
    prevId = id - 1;
  }

  ArrayList<CacheDirectiveEntry> replies =
      new ArrayList<CacheDirectiveEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  int numReplies = 0;
  SortedMap<Long, CacheDirective> tailMap =
    directivesById.tailMap(prevId + 1);
  for (Entry<Long, CacheDirective> cur : tailMap.entrySet()) {
    if (numReplies >= maxListCacheDirectivesNumResponses) {
      return new BatchedListEntries<CacheDirectiveEntry>(replies, true);
    }
    CacheDirective curDirective = cur.getValue();
    CacheDirectiveInfo info = cur.getValue().toInfo();

    // If the requested ID is present, it should be the first item.
    // Hitting this case means the ID is not present, or we're on the second
    // item and should break out.
    if (id != null &&
        !(info.getId().equals(id))) {
      break;
    }
    if (filter.getPool() != null && 
        !info.getPool().equals(filter.getPool())) {
      continue;
    }
    if (filterPath != null &&
        !info.getPath().toUri().getPath().equals(filterPath)) {
      continue;
    }
    boolean hasPermission = true;
    if (pc != null) {
      try {
        pc.checkPermission(curDirective.getPool(), FsAction.READ);
      } catch (AccessControlException e) {
        hasPermission = false;
      }
    }
    if (hasPermission) {
      replies.add(new CacheDirectiveEntry(info, cur.getValue().toStats()));
      numReplies++;
    }
  }
  return new BatchedListEntries<CacheDirectiveEntry>(replies, false);
}
项目:FlexMap    文件:CacheManager.java   
public BatchedListEntries<CacheDirectiveEntry> 
      listCacheDirectives(long prevId,
          CacheDirectiveInfo filter,
          FSPermissionChecker pc) throws IOException {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  String filterPath = null;
  if (filter.getPath() != null) {
    filterPath = validatePath(filter);
  }
  if (filter.getReplication() != null) {
    throw new InvalidRequestException(
        "Filtering by replication is unsupported.");
  }

  // Querying for a single ID
  final Long id = filter.getId();
  if (id != null) {
    if (!directivesById.containsKey(id)) {
      throw new InvalidRequestException("Did not find requested id " + id);
    }
    // Since we use a tailMap on directivesById, setting prev to id-1 gets
    // us the directive with the id (if present)
    prevId = id - 1;
  }

  ArrayList<CacheDirectiveEntry> replies =
      new ArrayList<CacheDirectiveEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  int numReplies = 0;
  SortedMap<Long, CacheDirective> tailMap =
    directivesById.tailMap(prevId + 1);
  for (Entry<Long, CacheDirective> cur : tailMap.entrySet()) {
    if (numReplies >= maxListCacheDirectivesNumResponses) {
      return new BatchedListEntries<CacheDirectiveEntry>(replies, true);
    }
    CacheDirective curDirective = cur.getValue();
    CacheDirectiveInfo info = cur.getValue().toInfo();

    // If the requested ID is present, it should be the first item.
    // Hitting this case means the ID is not present, or we're on the second
    // item and should break out.
    if (id != null &&
        !(info.getId().equals(id))) {
      break;
    }
    if (filter.getPool() != null && 
        !info.getPool().equals(filter.getPool())) {
      continue;
    }
    if (filterPath != null &&
        !info.getPath().toUri().getPath().equals(filterPath)) {
      continue;
    }
    boolean hasPermission = true;
    if (pc != null) {
      try {
        pc.checkPermission(curDirective.getPool(), FsAction.READ);
      } catch (AccessControlException e) {
        hasPermission = false;
      }
    }
    if (hasPermission) {
      replies.add(new CacheDirectiveEntry(info, cur.getValue().toStats()));
      numReplies++;
    }
  }
  return new BatchedListEntries<CacheDirectiveEntry>(replies, false);
}
项目:hadoop-on-lustre2    文件:CacheManager.java   
public BatchedListEntries<CacheDirectiveEntry> 
      listCacheDirectives(long prevId,
          CacheDirectiveInfo filter,
          FSPermissionChecker pc) throws IOException {
  assert namesystem.hasReadLock();
  final int NUM_PRE_ALLOCATED_ENTRIES = 16;
  String filterPath = null;
  if (filter.getId() != null) {
    throw new IOException("Filtering by ID is unsupported.");
  }
  if (filter.getPath() != null) {
    filterPath = validatePath(filter);
  }
  if (filter.getReplication() != null) {
    throw new IOException("Filtering by replication is unsupported.");
  }
  ArrayList<CacheDirectiveEntry> replies =
      new ArrayList<CacheDirectiveEntry>(NUM_PRE_ALLOCATED_ENTRIES);
  int numReplies = 0;
  SortedMap<Long, CacheDirective> tailMap =
    directivesById.tailMap(prevId + 1);
  for (Entry<Long, CacheDirective> cur : tailMap.entrySet()) {
    if (numReplies >= maxListCacheDirectivesNumResponses) {
      return new BatchedListEntries<CacheDirectiveEntry>(replies, true);
    }
    CacheDirective curDirective = cur.getValue();
    CacheDirectiveInfo info = cur.getValue().toInfo();
    if (filter.getPool() != null && 
        !info.getPool().equals(filter.getPool())) {
      continue;
    }
    if (filterPath != null &&
        !info.getPath().toUri().getPath().equals(filterPath)) {
      continue;
    }
    boolean hasPermission = true;
    if (pc != null) {
      try {
        pc.checkPermission(curDirective.getPool(), FsAction.READ);
      } catch (AccessControlException e) {
        hasPermission = false;
      }
    }
    if (hasPermission) {
      replies.add(new CacheDirectiveEntry(info, cur.getValue().toStats()));
      numReplies++;
    }
  }
  return new BatchedListEntries<CacheDirectiveEntry>(replies, false);
}