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; }
@Override public ListCacheDirectivesResponseProto listCacheDirectives( RpcController controller, ListCacheDirectivesRequestProto request) throws ServiceException { try { CacheDirectiveInfo filter = PBHelper.convert(request.getFilter()); BatchedEntries<CacheDirectiveEntry> entries = server.listCacheDirectives(request.getPrevId(), filter); ListCacheDirectivesResponseProto.Builder builder = ListCacheDirectivesResponseProto.newBuilder(); builder.setHasMore(entries.hasMore()); for (int i=0, n=entries.size(); i<n; i++) { builder.addElements(PBHelper.convert(entries.get(i))); } return builder.build(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public BatchedEntries<CacheDirectiveEntry> listCacheDirectives(long prevId, CacheDirectiveInfo filter) throws IOException { if (filter == null) { filter = new CacheDirectiveInfo.Builder().build(); } try { return new BatchedCacheEntries( rpcProxy.listCacheDirectives(null, ListCacheDirectivesRequestProto.newBuilder(). setPrevId(prevId). setFilter(PBHelper.convert(filter)). build())); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } }
@Override boolean checkNamenodeBeforeReturn() throws Exception { for (int i = 0; i < CHECKTIMES; i++) { RemoteIterator<CacheDirectiveEntry> iter = dfs.listCacheDirectives( new CacheDirectiveInfo.Builder(). setPool(directive.getPool()). setPath(directive.getPath()). build()); if (iter.hasNext()) { return true; } Thread.sleep(1000); } return false; }
@Override boolean checkNamenodeBeforeReturn() throws Exception { for (int i = 0; i < CHECKTIMES; i++) { RemoteIterator<CacheDirectiveEntry> iter = dfs.listCacheDirectives( new CacheDirectiveInfo.Builder(). setPool(directive.getPool()). setPath(directive.getPath()). build()); while (iter.hasNext()) { CacheDirectiveInfo result = iter.next().getInfo(); if ((result.getId() == id) && (result.getReplication().shortValue() == newReplication)) { return true; } } Thread.sleep(1000); } return false; }
@Override boolean checkNamenodeBeforeReturn() throws Exception { for (int i = 0; i < CHECKTIMES; i++) { RemoteIterator<CacheDirectiveEntry> iter = dfs.listCacheDirectives( new CacheDirectiveInfo.Builder(). setPool(directive.getPool()). setPath(directive.getPath()). build()); if (!iter.hasNext()) { return true; } Thread.sleep(1000); } return false; }
@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()); }
@Override public BatchedEntries<CacheDirectiveEntry> listCacheDirectives(long prevId, CacheDirectiveInfo filter) throws IOException { if (filter == null) { filter = new CacheDirectiveInfo.Builder().build(); } try { return new BatchedCacheEntries( rpcProxy.listCacheDirectives(null, ListCacheDirectivesRequestProto.newBuilder(). setPrevId(prevId). setFilter(PBHelperClient.convert(filter)). build())); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } }
@Override public ListCacheDirectivesResponseProto listCacheDirectives( RpcController controller, ListCacheDirectivesRequestProto request) throws ServiceException { try { CacheDirectiveInfo filter = PBHelperClient.convert(request.getFilter()); BatchedEntries<CacheDirectiveEntry> entries = server.listCacheDirectives(request.getPrevId(), filter); ListCacheDirectivesResponseProto.Builder builder = ListCacheDirectivesResponseProto.newBuilder(); builder.setHasMore(entries.hasMore()); for (int i=0, n=entries.size(); i<n; i++) { builder.addElements(PBHelperClient.convert(entries.get(i))); } return builder.build(); } catch (IOException e) { throw new ServiceException(e); } }
List<CacheDirectiveEntry> getAllCacheDirectives(UpstreamManager.Upstream upstream) throws IOException { CacheDirectiveInfo filter = new CacheDirectiveInfo.Builder().build(); List<CacheDirectiveEntry> directives = new ArrayList<>(); long prevId = -1; while (true) { BatchedRemoteIterator.BatchedEntries<CacheDirectiveEntry> it = upstream.protocol.listCacheDirectives(prevId, filter); if (it.size() == 0) { break; } for (int i = 0; i < it.size(); i++) { CacheDirectiveEntry entry = it.get(i); prevId = entry.getInfo().getId(); directives.add(entry); } } return directives; }
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; }
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; }