private void loadNext() throws IOException { if (files == null || fileIdx >= files.length) { CorruptFileBlocks cfb = dfs.listCorruptFileBlocks(path, cookie); files = cfb.getFiles(); cookie = cfb.getCookie(); fileIdx = 0; callsMade++; } if (fileIdx >= files.length) { // received an empty response // there are no more corrupt file blocks nextPath = null; } else { nextPath = string2Path(files[fileIdx]); fileIdx++; } }
/** Version based list corrupt file blocks */ private CorruptFileBlocks versionBasedListCorruptFileBlocks(String path, String cookie) throws IOException { if (namenodeVersion < ClientProtocol.LIST_CORRUPT_FILEBLOCKS_VERSION) { LOG.info("NameNode version is " + namenodeVersion + " Using older version of getCorruptFiles."); if (cookie != null ) { return new CorruptFileBlocks(new String[0], ""); } ArrayList<String> str = new ArrayList<String>(); for (FileStatus stat : namenode.getCorruptFiles()) { String filename = stat.getPath().toUri().getPath(); if (filename.startsWith(path)) { str.add(filename); } } return new CorruptFileBlocks(str.toArray(new String[str.size()]), ""); } return namenode.listCorruptFileBlocks(path, cookie); }
/** Method based listCorruptFileBlocks */ private CorruptFileBlocks methodBasedListCorruptFileBlocks(String path, String cookie) throws IOException { if (!namenodeProtocolProxy.isMethodSupported("listCorruptFileBlocks", String.class, String.class)) { LOG.info("NameNode version is " + namenodeVersion + " Using older version of getCorruptFiles."); if (cookie != null ) { return new CorruptFileBlocks(new String[0], ""); } ArrayList<String> str = new ArrayList<String>(); for (FileStatus stat : namenode.getCorruptFiles()) { String filename = stat.getPath().toUri().getPath(); if (filename.startsWith(path)) { str.add(filename); } } return new CorruptFileBlocks(str.toArray(new String[str.size()]), ""); } return namenode.listCorruptFileBlocks(path, cookie); }
/** * @return a list in which each entry describes a corrupt file/block * @throws IOException */ public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) throws IOException { checkOpen(); TraceScope scope = getPathTraceScope("listCorruptFileBlocks", path); try { return namenode.listCorruptFileBlocks(path, cookie); } finally { scope.close(); } }
@Override // ClientProtocol public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) throws IOException { checkNNStartup(); String[] cookieTab = new String[] { cookie }; Collection<FSNamesystem.CorruptFileBlockInfo> fbs = namesystem.listCorruptFileBlocks(path, cookieTab); String[] files = new String[fbs.size()]; int i = 0; for(FSNamesystem.CorruptFileBlockInfo fb: fbs) { files[i++] = fb.path; } return new CorruptFileBlocks(files, cookieTab[0]); }
public static CorruptFileBlocks convert(CorruptFileBlocksProto c) { if (c == null) return null; List<String> fileList = c.getFilesList(); return new CorruptFileBlocks(fileList.toArray(new String[fileList.size()]), c.getCookie()); }
public static CorruptFileBlocksProto convert(CorruptFileBlocks c) { if (c == null) return null; return CorruptFileBlocksProto.newBuilder(). addAllFiles(Arrays.asList(c.getFiles())). setCookie(c.getCookie()). build(); }
@Override public ListCorruptFileBlocksResponseProto listCorruptFileBlocks( RpcController controller, ListCorruptFileBlocksRequestProto req) throws ServiceException { try { CorruptFileBlocks result = server.listCorruptFileBlocks( req.getPath(), req.hasCookie() ? req.getCookie(): null); return ListCorruptFileBlocksResponseProto.newBuilder() .setCorrupt(PBHelper.convert(result)) .build(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) throws IOException { ListCorruptFileBlocksRequestProto.Builder req = ListCorruptFileBlocksRequestProto.newBuilder().setPath(path); if (cookie != null) req.setCookie(cookie); try { return PBHelper.convert( rpcProxy.listCorruptFileBlocks(null, req.build()).getCorrupt()); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } }
/** * @return a list in which each entry describes a corrupt file/block * @throws IOException */ public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) throws IOException { checkOpen(); try (TraceScope ignored = newPathTraceScope("listCorruptFileBlocks", path)) { return namenode.listCorruptFileBlocks(path, cookie); } }
@Override public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) throws IOException { ListCorruptFileBlocksRequestProto.Builder req = ListCorruptFileBlocksRequestProto.newBuilder().setPath(path); if (cookie != null) req.setCookie(cookie); try { return PBHelperClient.convert( rpcProxy.listCorruptFileBlocks(null, req.build()).getCorrupt()); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); } }
@Override public ListCorruptFileBlocksResponseProto listCorruptFileBlocks( RpcController controller, ListCorruptFileBlocksRequestProto req) throws ServiceException { try { CorruptFileBlocks result = server.listCorruptFileBlocks( req.getPath(), req.hasCookie() ? req.getCookie(): null); return ListCorruptFileBlocksResponseProto.newBuilder() .setCorrupt(PBHelperClient.convert(result)) .build(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) throws IOException { try { AuthorizationProvider.beginClientOp(); return server.listCorruptFileBlocks(path, cookie); } finally { AuthorizationProvider.endClientOp(); } }