public boolean isConcatAvailable() throws IOException { if(namenodeProtocolProxy == null) { if(namenodeVersion >= ClientProtocol.CONCAT_VERSION) return true; } else { return namenodeProtocolProxy.isMethodSupported( "concat", String.class, String[].class); } return false; }
public static boolean isMetaInfoSuppoted(ProtocolProxy<ClientProtocol> proxy) throws IOException { return proxy != null && proxy.isMethodSupported( "openAndFetchMetaInfo", String.class, long.class, long.class); }
public String getClusterName() throws IOException { if (namenodeProtocolProxy.isMethodSupported( "getClusterName")) { return namenode.getClusterName(); } else { return null; } }
/** Re-populate the namespace and diskspace count of every node with quota */ public void recount() throws IOException { if (namenodeProtocolProxy.isMethodSupported("recount")) { namenode.recount(); } } /**
private boolean closeFileOnNameNode(String src, long fileLen, Block lastBlockId) throws IOException { boolean fileComplete; if (namenodeProtocolProxy != null && namenodeProtocolProxy.isMethodSupported("complete", String.class, String.class, long.class, Block.class)) { fileComplete = namenode.complete(src, clientName, fileLen, lastBlockId); } else if (namenodeProtocolProxy != null && namenodeProtocolProxy.isMethodSupported("complete", String.class, String.class, long.class)) { fileComplete = namenode.complete(src, clientName, fileLen); } else { fileComplete = namenode.complete(src, clientName); } return fileComplete; }
/** List a directory with location based on method */ private RemoteIterator<LocatedFileStatus> methodBasedListPathWithLocation( final String src) throws IOException { if (namenodeProtocolProxy.isMethodSupported( "getLocatedPartialListing", String.class, byte[].class)) { return iteratorListing(src); } else { return arrayListing(src); } }
/** Method-based save namespace */ private void methodBasedSaveNamespace(boolean force, boolean uncompressed) throws AccessControlException, IOException { if (namenodeProtocolProxy.isMethodSupported( "saveNamespace", boolean.class, boolean.class)) { namenode.saveNamespace(force, uncompressed); } else { namenode.saveNamespace(); } }
/** 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); }
private FileStatus[] methodBasedListPath(String src) throws IOException { if (namenodeProtocolProxy.isMethodSupported( "getPartialListing", String.class, byte[].class)) { return iterativeListing(src); } else if (namenodeProtocolProxy.isMethodSupported( "getHdfsListing", String.class)) { HdfsFileStatus[] hdfsStats = namenode.getHdfsListing(src); if (hdfsStats == null) { return null; } FileStatus[] stats = new FileStatus[hdfsStats.length]; for (int i=0; i<stats.length; i++) { stats[i] = toFileStatus(hdfsStats[i], src); } return stats; } else { return namenode.getListing(src); } }
/** Get file info: decide which rpc to call based on server methods*/ private FileStatus methodBasedGetFileInfo(String src) throws IOException { if (namenodeProtocolProxy.isMethodSupported( "getHdfsFileInfo", String.class)) { return toFileStatus(namenode.getHdfsFileInfo(src), src); } else { return namenode.getFileInfo(src); } }
public int echo(int value) throws IOException, NumberFormatException { if (serverInfo.isMethodSupported("echo", int.class)) { System.out.println("echo int is supported"); return -value; // use version 3 echo long } else { // server is version 2 System.out.println("echo int is NOT supported"); return Integer.parseInt(proxy2.echo(String.valueOf(value))); } }
public int echo(int value) throws IOException, NumberFormatException { if (serverInfo.isMethodSupported("echo", int.class)) { System.out.println("echo int is supported"); return -value; // use version 3 echo long } else { // server is version 2 System.out.println("echo int is NOT supported"); return Integer.parseInt(proxy2.echo(String.valueOf(value))); } }
while (true) { try { if (dstNamenodeProtocolProxy.isMethodSupported( "addBlockAndFetchMetaInfo", String.class, String.class, DatanodeInfo[].class, DatanodeInfo[].class, long.class)) { favoredNodes, startPos); destinationLocatedBlock = dstLocatedBlockWithMetaInfo; } else if (dstNamenodeProtocolProxy.isMethodSupported( "addBlockAndFetchMetaInfo", String.class, String.class, DatanodeInfo[].class, DatanodeInfo[].class)) {
/** * Move blocks from src to trg and delete src * See {@link ClientProtocol#concat(String, String [])}. */ public void concat(String trg, String[] srcs, boolean restricted) throws IOException { checkOpen(); try { if (namenodeProtocolProxy != null && namenodeProtocolProxy.isMethodSupported("concat", String.class, String[].class, boolean.class)) { namenode.concat(trg, srcs, restricted); } else if (!restricted){ throw new UnsupportedOperationException( "Namenode does not support variable length blocks"); } else { namenode.concat(trg, srcs); } } catch(RemoteException re) { throw re.unwrapRemoteException(AccessControlException.class, NSQuotaExceededException.class, DSQuotaExceededException.class); } }
throws IOException { if (namenodeProtocolProxy.isMethodSupported( "closeRecoverLease", String.class, String.class, boolean.class)) { try { else if (namenodeProtocolProxy.isMethodSupported( "closeRecoverLease", String.class, String.class)) { try { if (namenodeProtocolProxy.isMethodSupported( "recoverLease", String.class, String.class)) { try {
if (datanode.isMethodSupported("getBlockPathInfo", int.class, Block.class)) { pathinfo = datanode.getProxy().getBlockPathInfo(namespaceid, blk); } else {
namenodeProtocolProxy.isMethodSupported("create", String.class, FsPermission.class, String.class, boolean.class, boolean.class, short.class, long.class)) {
if (cdp.isMethodSupported("getBlockInfo", int.class, Block.class)) { newBlock = cdp.getProxy().getBlockInfo( namespaceId, locatedblock.getBlock());
try { if (namenodeProtocolProxy != null && namenodeProtocolProxy.isMethodSupported("openAndFetchMetaInfo", String.class, long.class, long.class)) { LocatedBlocksWithMetaInfo locs = return locs; } else if (namenodeProtocolProxy != null && namenodeProtocolProxy.isMethodSupported("open", String.class, long.class, long.class)) { VersionedLocatedBlocks locs = namenode.open(src, start, length);
stat = getFileInfo(src); if (namenodeProtocolProxy != null && namenodeProtocolProxy.isMethodSupported( "appendAndFetchMetaInfo", String.class, String.class)) { LocatedBlockWithMetaInfo loc = namenode.appendAndFetchMetaInfo(src,