Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 46427D997 for ; Tue, 16 Oct 2012 00:04:45 +0000 (UTC) Received: (qmail 19553 invoked by uid 500); 16 Oct 2012 00:04:44 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 19488 invoked by uid 500); 16 Oct 2012 00:04:44 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 19477 invoked by uid 99); 16 Oct 2012 00:04:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Oct 2012 00:04:44 +0000 X-ASF-Spam-Status: No, hits=-1998.0 required=5.0 tests=ALL_TRUSTED,FB_GET_MEDS X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Oct 2012 00:04:40 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3F48E2388A6E; Tue, 16 Oct 2012 00:03:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1398581 [5/14] - in /hadoop/common/branches/MR-3902/hadoop-common-project: hadoop-annotations/src/main/java/org/apache/hadoop/classification/tools/ hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/ hadoop-auth/src... Date: Tue, 16 Oct 2012 00:03:31 -0000 To: common-commits@hadoop.apache.org From: sseth@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121016000353.3F48E2388A6E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobFilter.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobFilter.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobFilter.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/GlobFilter.java Tue Oct 16 00:02:55 2012 @@ -31,6 +31,7 @@ import org.apache.hadoop.classification. @InterfaceStability.Evolving public class GlobFilter implements PathFilter { private final static PathFilter DEFAULT_FILTER = new PathFilter() { + @Override public boolean accept(Path file) { return true; } @@ -75,6 +76,7 @@ public class GlobFilter implements PathF return pattern.hasWildcard(); } + @Override public boolean accept(Path path) { return pattern.matches(path.getName()) && userFilter.accept(path); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java Tue Oct 16 00:02:55 2012 @@ -106,6 +106,7 @@ public class HarFileSystem extends Filte * har:///archivepath. This assumes the underlying filesystem * to be used in case not specified. */ + @Override public void initialize(URI name, Configuration conf) throws IOException { // decode the name URI underLyingURI = decodeHarURI(name, conf); @@ -247,6 +248,7 @@ public class HarFileSystem extends Filte /** * return the top level archive. */ + @Override public Path getWorkingDirectory() { return new Path(uri.toString()); } @@ -636,6 +638,7 @@ public class HarFileSystem extends Filte /** * @return null since no checksum algorithm is implemented. */ + @Override public FileChecksum getFileChecksum(Path f) { return null; } @@ -668,6 +671,7 @@ public class HarFileSystem extends Filte throw new IOException("Har: Create not allowed"); } + @Override public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, @@ -735,10 +739,12 @@ public class HarFileSystem extends Filte /** * return the top level archive path. */ + @Override public Path getHomeDirectory() { return new Path(uri.toString()); } + @Override public void setWorkingDirectory(Path newDir) { //does nothing. } @@ -746,6 +752,7 @@ public class HarFileSystem extends Filte /** * not implemented. */ + @Override public boolean mkdirs(Path f, FsPermission permission) throws IOException { throw new IOException("Har: mkdirs not allowed"); } @@ -753,6 +760,7 @@ public class HarFileSystem extends Filte /** * not implemented. */ + @Override public void copyFromLocalFile(boolean delSrc, Path src, Path dst) throws IOException { throw new IOException("Har: copyfromlocalfile not allowed"); @@ -761,6 +769,7 @@ public class HarFileSystem extends Filte /** * copies the file in the har filesystem to a local file. */ + @Override public void copyToLocalFile(boolean delSrc, Path src, Path dst) throws IOException { FileUtil.copy(this, src, getLocal(getConf()), dst, false, getConf()); @@ -769,6 +778,7 @@ public class HarFileSystem extends Filte /** * not implemented. */ + @Override public Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException { throw new IOException("Har: startLocalOutput not allowed"); @@ -777,6 +787,7 @@ public class HarFileSystem extends Filte /** * not implemented. */ + @Override public void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException { throw new IOException("Har: completeLocalOutput not allowed"); @@ -785,6 +796,7 @@ public class HarFileSystem extends Filte /** * not implemented. */ + @Override public void setOwner(Path p, String username, String groupname) throws IOException { throw new IOException("Har: setowner not allowed"); @@ -793,6 +805,7 @@ public class HarFileSystem extends Filte /** * Not implemented. */ + @Override public void setPermission(Path p, FsPermission permisssion) throws IOException { throw new IOException("Har: setPermission not allowed"); @@ -825,6 +838,7 @@ public class HarFileSystem extends Filte this.end = start + length; } + @Override public synchronized int available() throws IOException { long remaining = end - underLyingStream.getPos(); if (remaining > (long)Integer.MAX_VALUE) { @@ -833,6 +847,7 @@ public class HarFileSystem extends Filte return (int) remaining; } + @Override public synchronized void close() throws IOException { underLyingStream.close(); super.close(); @@ -847,15 +862,18 @@ public class HarFileSystem extends Filte /** * reset is not implemented */ + @Override public void reset() throws IOException { throw new IOException("reset not implemented."); } + @Override public synchronized int read() throws IOException { int ret = read(oneBytebuff, 0, 1); return (ret <= 0) ? -1: (oneBytebuff[0] & 0xff); } + @Override public synchronized int read(byte[] b) throws IOException { int ret = read(b, 0, b.length); if (ret != -1) { @@ -867,6 +885,7 @@ public class HarFileSystem extends Filte /** * */ + @Override public synchronized int read(byte[] b, int offset, int len) throws IOException { int newlen = len; @@ -882,6 +901,7 @@ public class HarFileSystem extends Filte return ret; } + @Override public synchronized long skip(long n) throws IOException { long tmpN = n; if (tmpN > 0) { @@ -895,10 +915,12 @@ public class HarFileSystem extends Filte return (tmpN < 0)? -1 : 0; } + @Override public synchronized long getPos() throws IOException { return (position - start); } + @Override public synchronized void seek(long pos) throws IOException { if (pos < 0 || (start + pos > end)) { throw new IOException("Failed to seek: EOF"); @@ -907,6 +929,7 @@ public class HarFileSystem extends Filte underLyingStream.seek(position); } + @Override public boolean seekToNewSource(long targetPos) throws IOException { //do not need to implement this // hdfs in itself does seektonewsource @@ -917,6 +940,7 @@ public class HarFileSystem extends Filte /** * implementing position readable. */ + @Override public int read(long pos, byte[] b, int offset, int length) throws IOException { int nlength = length; @@ -929,6 +953,7 @@ public class HarFileSystem extends Filte /** * position readable again. */ + @Override public void readFully(long pos, byte[] b, int offset, int length) throws IOException { if (start + length + pos > end) { @@ -937,6 +962,7 @@ public class HarFileSystem extends Filte underLyingStream.readFully(pos + start, b, offset, length); } + @Override public void readFully(long pos, byte[] b) throws IOException { readFully(pos, b, 0, b.length); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java Tue Oct 16 00:02:55 2012 @@ -265,6 +265,9 @@ public class LocalDirAllocator { private synchronized void confChanged(Configuration conf) throws IOException { String newLocalDirs = conf.get(contextCfgItemName); + if (null == newLocalDirs) { + throw new IOException(contextCfgItemName + " not configured"); + } if (!newLocalDirs.equals(savedLocalDirs)) { localDirs = StringUtils.getTrimmedStrings(newLocalDirs); localFS = FileSystem.getLocal(conf); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalFileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalFileSystem.java Tue Oct 16 00:02:55 2012 @@ -91,6 +91,7 @@ public class LocalFileSystem extends Che * Moves files to a bad file directory on the same device, so that their * storage will not be reused. */ + @Override public boolean reportChecksumFailure(Path p, FSDataInputStream in, long inPos, FSDataInputStream sums, long sumsPos) { Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocatedFileStatus.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocatedFileStatus.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocatedFileStatus.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocatedFileStatus.java Tue Oct 16 00:02:55 2012 @@ -94,6 +94,7 @@ public class LocatedFileStatus extends F * @throws ClassCastException if the specified object's is not of * type FileStatus */ + @Override public int compareTo(Object o) { return super.compareTo(o); } @@ -102,6 +103,7 @@ public class LocatedFileStatus extends F * @param o the object to be compared. * @return true if two file status has the same path name; false if not. */ + @Override public boolean equals(Object o) { return super.equals(o); } @@ -112,6 +114,7 @@ public class LocatedFileStatus extends F * * @return a hash code value for the path name. */ + @Override public int hashCode() { return super.hashCode(); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/MD5MD5CRC32FileChecksum.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/MD5MD5CRC32FileChecksum.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/MD5MD5CRC32FileChecksum.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/MD5MD5CRC32FileChecksum.java Tue Oct 16 00:02:55 2012 @@ -57,7 +57,7 @@ public class MD5MD5CRC32FileChecksum ext this.md5 = md5; } - /** {@inheritDoc} */ + @Override public String getAlgorithmName() { return "MD5-of-" + crcPerBlock + "MD5-of-" + bytesPerCRC + getCrcType().name(); @@ -73,11 +73,11 @@ public class MD5MD5CRC32FileChecksum ext throw new IOException("Unknown checksum type in " + algorithm); } - - /** {@inheritDoc} */ + + @Override public int getLength() {return LENGTH;} - - /** {@inheritDoc} */ + + @Override public byte[] getBytes() { return WritableUtils.toByteArray(this); } @@ -92,14 +92,14 @@ public class MD5MD5CRC32FileChecksum ext return new ChecksumOpt(getCrcType(), bytesPerCRC); } - /** {@inheritDoc} */ + @Override public void readFields(DataInput in) throws IOException { bytesPerCRC = in.readInt(); crcPerBlock = in.readLong(); md5 = MD5Hash.read(in); } - - /** {@inheritDoc} */ + + @Override public void write(DataOutput out) throws IOException { out.writeInt(bytesPerCRC); out.writeLong(crcPerBlock); @@ -133,7 +133,7 @@ public class MD5MD5CRC32FileChecksum ext try { // old versions don't support crcType. - if (crcType == null || crcType == "") { + if (crcType == null || crcType.equals("")) { finalCrcType = DataChecksum.Type.CRC32; } else { finalCrcType = DataChecksum.Type.valueOf(crcType); @@ -161,8 +161,8 @@ public class MD5MD5CRC32FileChecksum ext + ", md5=" + md5, e); } } - - /** {@inheritDoc} */ + + @Override public String toString() { return getAlgorithmName() + ":" + md5; } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java Tue Oct 16 00:02:55 2012 @@ -22,7 +22,6 @@ import org.apache.hadoop.classification. import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.util.DataChecksum; import org.apache.hadoop.util.Progressable; -import org.apache.hadoop.HadoopIllegalArgumentException; /** * This class contains options related to file system operations. Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java Tue Oct 16 00:02:55 2012 @@ -68,7 +68,7 @@ public class Path implements Comparable // Add a slash to parent's path so resolution is compatible with URI's URI parentUri = parent.uri; String parentPath = parentUri.getPath(); - if (!(parentPath.equals("/") || parentPath.equals(""))) { + if (!(parentPath.equals("/") || parentPath.isEmpty())) { try { parentUri = new URI(parentUri.getScheme(), parentUri.getAuthority(), parentUri.getPath()+"/", null, parentUri.getFragment()); @@ -261,6 +261,7 @@ public class Path implements Comparable return new Path(getParent(), getName()+suffix); } + @Override public String toString() { // we can't use uri.toString(), which escapes everything, because we want // illegal characters unescaped in the string, for glob processing, etc. @@ -289,6 +290,7 @@ public class Path implements Comparable return buffer.toString(); } + @Override public boolean equals(Object o) { if (!(o instanceof Path)) { return false; @@ -297,10 +299,12 @@ public class Path implements Comparable return this.uri.equals(that.uri); } + @Override public int hashCode() { return uri.hashCode(); } + @Override public int compareTo(Object o) { Path that = (Path)o; return this.uri.compareTo(that.uri); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java Tue Oct 16 00:02:55 2012 @@ -72,8 +72,10 @@ public class RawLocalFileSystem extends return new File(path.toUri().getPath()); } + @Override public URI getUri() { return NAME; } + @Override public void initialize(URI uri, Configuration conf) throws IOException { super.initialize(uri, conf); setConf(conf); @@ -84,6 +86,7 @@ public class RawLocalFileSystem extends super(f); } + @Override public int read() throws IOException { int result = super.read(); if (result != -1) { @@ -92,6 +95,7 @@ public class RawLocalFileSystem extends return result; } + @Override public int read(byte[] data) throws IOException { int result = super.read(data); if (result != -1) { @@ -100,6 +104,7 @@ public class RawLocalFileSystem extends return result; } + @Override public int read(byte[] data, int offset, int length) throws IOException { int result = super.read(data, offset, length); if (result != -1) { @@ -120,15 +125,18 @@ public class RawLocalFileSystem extends this.fis = new TrackingFileInputStream(pathToFile(f)); } + @Override public void seek(long pos) throws IOException { fis.getChannel().position(pos); this.position = pos; } + @Override public long getPos() throws IOException { return this.position; } + @Override public boolean seekToNewSource(long targetPos) throws IOException { return false; } @@ -136,11 +144,14 @@ public class RawLocalFileSystem extends /* * Just forward to the fis */ + @Override public int available() throws IOException { return fis.available(); } + @Override public void close() throws IOException { fis.close(); } @Override public boolean markSupported() { return false; } + @Override public int read() throws IOException { try { int value = fis.read(); @@ -153,6 +164,7 @@ public class RawLocalFileSystem extends } } + @Override public int read(byte[] b, int off, int len) throws IOException { try { int value = fis.read(b, off, len); @@ -165,6 +177,7 @@ public class RawLocalFileSystem extends } } + @Override public int read(long position, byte[] b, int off, int len) throws IOException { ByteBuffer bb = ByteBuffer.wrap(b, off, len); @@ -175,6 +188,7 @@ public class RawLocalFileSystem extends } } + @Override public long skip(long n) throws IOException { long value = fis.skip(n); if (value > 0) { @@ -189,6 +203,7 @@ public class RawLocalFileSystem extends } } + @Override public FSDataInputStream open(Path f, int bufferSize) throws IOException { if (!exists(f)) { throw new FileNotFoundException(f.toString()); @@ -210,8 +225,11 @@ public class RawLocalFileSystem extends /* * Just forward to the fos */ + @Override public void close() throws IOException { fos.close(); } + @Override public void flush() throws IOException { fos.flush(); } + @Override public void write(byte[] b, int off, int len) throws IOException { try { fos.write(b, off, len); @@ -220,6 +238,7 @@ public class RawLocalFileSystem extends } } + @Override public void write(int b) throws IOException { try { fos.write(b); @@ -229,7 +248,7 @@ public class RawLocalFileSystem extends } } - /** {@inheritDoc} */ + @Override public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException { if (!exists(f)) { @@ -242,7 +261,6 @@ public class RawLocalFileSystem extends new LocalFSFileOutputStream(f, true), bufferSize), statistics); } - /** {@inheritDoc} */ @Override public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) @@ -264,7 +282,6 @@ public class RawLocalFileSystem extends new LocalFSFileOutputStream(f, false), bufferSize), statistics); } - /** {@inheritDoc} */ @Override public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, @@ -276,7 +293,6 @@ public class RawLocalFileSystem extends return out; } - /** {@inheritDoc} */ @Override public FSDataOutputStream createNonRecursive(Path f, FsPermission permission, boolean overwrite, @@ -288,6 +304,7 @@ public class RawLocalFileSystem extends return out; } + @Override public boolean rename(Path src, Path dst) throws IOException { if (pathToFile(src).renameTo(pathToFile(dst))) { return true; @@ -302,6 +319,7 @@ public class RawLocalFileSystem extends * @return true if the file or directory and all its contents were deleted * @throws IOException if p is non-empty and recursive is false */ + @Override public boolean delete(Path p, boolean recursive) throws IOException { File f = pathToFile(p); if (f.isFile()) { @@ -319,6 +337,7 @@ public class RawLocalFileSystem extends * (Note: Returned list is not sorted in any given order, * due to reliance on Java's {@link File#list()} API.) */ + @Override public FileStatus[] listStatus(Path f) throws IOException { File localf = pathToFile(f); FileStatus[] results; @@ -356,6 +375,7 @@ public class RawLocalFileSystem extends * Creates the specified directory hierarchy. Does not * treat existence as an error. */ + @Override public boolean mkdirs(Path f) throws IOException { if(f == null) { throw new IllegalArgumentException("mkdirs path arg is null"); @@ -373,7 +393,6 @@ public class RawLocalFileSystem extends (p2f.mkdir() || p2f.isDirectory()); } - /** {@inheritDoc} */ @Override public boolean mkdirs(Path f, FsPermission permission) throws IOException { boolean b = mkdirs(f); @@ -418,7 +437,6 @@ public class RawLocalFileSystem extends return this.makeQualified(new Path(System.getProperty("user.dir"))); } - /** {@inheritDoc} */ @Override public FsStatus getStatus(Path p) throws IOException { File partition = pathToFile(p == null ? new Path("/") : p); @@ -430,29 +448,35 @@ public class RawLocalFileSystem extends } // In the case of the local filesystem, we can just rename the file. + @Override public void moveFromLocalFile(Path src, Path dst) throws IOException { rename(src, dst); } // We can write output directly to the final location + @Override public Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile) throws IOException { return fsOutputFile; } // It's in the right place - nothing to do. + @Override public void completeLocalOutput(Path fsWorkingFile, Path tmpLocalFile) throws IOException { } + @Override public void close() throws IOException { super.close(); } + @Override public String toString() { return "LocalFS"; } + @Override public FileStatus getFileStatus(Path f) throws IOException { File path = pathToFile(f); if (path.exists()) { @@ -468,7 +492,7 @@ public class RawLocalFileSystem extends * onwer.equals(""). */ private boolean isPermissionLoaded() { - return !super.getOwner().equals(""); + return !super.getOwner().isEmpty(); } RawLocalFileStatus(File f, long defaultBlockSize, FileSystem fs) { Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java Tue Oct 16 00:02:55 2012 @@ -68,8 +68,26 @@ public class Trash extends Configured { public static boolean moveToAppropriateTrash(FileSystem fs, Path p, Configuration conf) throws IOException { Path fullyResolvedPath = fs.resolvePath(p); - Trash trash = new Trash(FileSystem.get(fullyResolvedPath.toUri(), conf), conf); - boolean success = trash.moveToTrash(fullyResolvedPath); + FileSystem fullyResolvedFs = + FileSystem.get(fullyResolvedPath.toUri(), conf); + // If the trash interval is configured server side then clobber this + // configuration so that we always respect the server configuration. + try { + long trashInterval = fullyResolvedFs.getServerDefaults( + fullyResolvedPath).getTrashInterval(); + if (0 != trashInterval) { + Configuration confCopy = new Configuration(conf); + confCopy.setLong(CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY, + trashInterval); + conf = confCopy; + } + } catch (Exception e) { + // If we can not determine that trash is enabled server side then + // bail rather than potentially deleting a file when trash is enabled. + throw new IOException("Failed to get server trash configuration", e); + } + Trash trash = new Trash(fullyResolvedFs, conf); + boolean success = trash.moveToTrash(fullyResolvedPath); if (success) { System.out.println("Moved: '" + p + "' to trash at: " + trash.getCurrentTrashDir() ); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java Tue Oct 16 00:02:55 2012 @@ -61,6 +61,9 @@ public class TrashPolicyDefault extends new FsPermission(FsAction.ALL, FsAction.NONE, FsAction.NONE); private static final DateFormat CHECKPOINT = new SimpleDateFormat("yyMMddHHmmss"); + /** Format of checkpoint directories used prior to Hadoop 0.23. */ + private static final DateFormat OLD_CHECKPOINT = + new SimpleDateFormat("yyMMddHHmm"); private static final int MSECS_PER_MINUTE = 60*1000; private Path current; @@ -69,8 +72,9 @@ public class TrashPolicyDefault extends public TrashPolicyDefault() { } - private TrashPolicyDefault(Path home, Configuration conf) throws IOException { - initialize(conf, home.getFileSystem(conf), home); + private TrashPolicyDefault(FileSystem fs, Path home, Configuration conf) + throws IOException { + initialize(conf, fs, home); } @Override @@ -79,24 +83,9 @@ public class TrashPolicyDefault extends this.trash = new Path(home, TRASH); this.homesParent = home.getParent(); this.current = new Path(trash, CURRENT); - long trashInterval = 0; - try { - trashInterval = fs.getServerDefaults(home).getTrashInterval(); - } catch (IOException ioe) { - LOG.warn("Unable to get server defaults", ioe); - } - // If the trash interval is not configured or is disabled on the - // server side then check the config which may be client side. - if (0 == trashInterval) { - this.deletionInterval = (long)(conf.getFloat( - FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT) - * MSECS_PER_MINUTE); - } else { - this.deletionInterval = trashInterval * MSECS_PER_MINUTE; - } - // For the checkpoint interval use the given config instead of - // checking the server as it's OK if a client starts an emptier - // with a different interval than the server. + this.deletionInterval = (long)(conf.getFloat( + FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT) + * MSECS_PER_MINUTE); this.emptierInterval = (long)(conf.getFloat( FS_TRASH_CHECKPOINT_INTERVAL_KEY, FS_TRASH_CHECKPOINT_INTERVAL_DEFAULT) * MSECS_PER_MINUTE); @@ -217,9 +206,7 @@ public class TrashPolicyDefault extends long time; try { - synchronized (CHECKPOINT) { - time = CHECKPOINT.parse(name).getTime(); - } + time = getTimeFromCheckpoint(name); } catch (ParseException e) { LOG.warn("Unexpected item in trash: "+dir+". Ignoring."); continue; @@ -263,6 +250,7 @@ public class TrashPolicyDefault extends } } + @Override public void run() { if (emptierInterval == 0) return; // trash disabled @@ -292,7 +280,8 @@ public class TrashPolicyDefault extends if (!home.isDirectory()) continue; try { - TrashPolicyDefault trash = new TrashPolicyDefault(home.getPath(), conf); + TrashPolicyDefault trash = new TrashPolicyDefault( + fs, home.getPath(), conf); trash.deleteCheckpoint(); trash.createCheckpoint(); } catch (IOException e) { @@ -318,4 +307,22 @@ public class TrashPolicyDefault extends return (time / interval) * interval; } } + + private long getTimeFromCheckpoint(String name) throws ParseException { + long time; + + try { + synchronized (CHECKPOINT) { + time = CHECKPOINT.parse(name).getTime(); + } + } catch (ParseException pe) { + // Check for old-style checkpoint directories left over + // after an upgrade from Hadoop 1.x + synchronized (OLD_CHECKPOINT) { + time = OLD_CHECKPOINT.parse(name).getTime(); + } + } + + return time; + } } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java Tue Oct 16 00:02:55 2012 @@ -262,6 +262,7 @@ public class FTPFileSystem extends FileS } /** This optional operation is not yet supported. */ + @Override public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException { throw new IOException("Not supported"); @@ -487,7 +488,7 @@ public class FTPFileSystem extends FileS if (created) { String parentDir = parent.toUri().getPath(); client.changeWorkingDirectory(parentDir); - created = created & client.makeDirectory(pathName); + created = created && client.makeDirectory(pathName); } } else if (isFile(client, absolute)) { throw new IOException(String.format( Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPInputStream.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPInputStream.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPInputStream.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPInputStream.java Tue Oct 16 00:02:55 2012 @@ -51,19 +51,23 @@ public class FTPInputStream extends FSIn this.closed = false; } + @Override public long getPos() throws IOException { return pos; } // We don't support seek. + @Override public void seek(long pos) throws IOException { throw new IOException("Seek not supported"); } + @Override public boolean seekToNewSource(long targetPos) throws IOException { throw new IOException("Seek not supported"); } + @Override public synchronized int read() throws IOException { if (closed) { throw new IOException("Stream closed"); @@ -73,12 +77,13 @@ public class FTPInputStream extends FSIn if (byteRead >= 0) { pos++; } - if (stats != null & byteRead >= 0) { + if (stats != null && byteRead >= 0) { stats.incrementBytesRead(1); } return byteRead; } + @Override public synchronized int read(byte buf[], int off, int len) throws IOException { if (closed) { throw new IOException("Stream closed"); @@ -88,13 +93,14 @@ public class FTPInputStream extends FSIn if (result > 0) { pos += result; } - if (stats != null & result > 0) { + if (stats != null && result > 0) { stats.incrementBytesRead(result); } return result; } + @Override public synchronized void close() throws IOException { if (closed) { throw new IOException("Stream closed"); @@ -116,14 +122,17 @@ public class FTPInputStream extends FSIn // Not supported. + @Override public boolean markSupported() { return false; } + @Override public void mark(int readLimit) { // Do nothing } + @Override public void reset() throws IOException { throw new IOException("Mark not supported"); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/local/RawLocalFs.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/local/RawLocalFs.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/local/RawLocalFs.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/local/RawLocalFs.java Tue Oct 16 00:02:55 2012 @@ -128,7 +128,7 @@ public class RawLocalFs extends Delegate try { FileStatus fs = getFileStatus(f); // If f refers to a regular file or directory - if ("".equals(target)) { + if (target.isEmpty()) { return fs; } // Otherwise f refers to a symlink @@ -150,7 +150,7 @@ public class RawLocalFs extends Delegate * the readBasicFileAttributes method in java.nio.file.attributes * when available. */ - if (!"".equals(target)) { + if (!target.isEmpty()) { return new FileStatus(0, false, 0, 0, 0, 0, FsPermission.getDefault(), "", "", new Path(target), f); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java Tue Oct 16 00:02:55 2012 @@ -40,6 +40,7 @@ public class FsPermission implements Wri private static final Log LOG = LogFactory.getLog(FsPermission.class); static final WritableFactory FACTORY = new WritableFactory() { + @Override public Writable newInstance() { return new FsPermission(); } }; static { // register a ctor @@ -124,12 +125,12 @@ public class FsPermission implements Wri set(v[(n >>> 6) & 7], v[(n >>> 3) & 7], v[n & 7], (((n >>> 9) & 1) == 1) ); } - /** {@inheritDoc} */ + @Override public void write(DataOutput out) throws IOException { out.writeShort(toShort()); } - /** {@inheritDoc} */ + @Override public void readFields(DataInput in) throws IOException { fromShort(in.readShort()); } @@ -155,7 +156,7 @@ public class FsPermission implements Wri return (short)s; } - /** {@inheritDoc} */ + @Override public boolean equals(Object obj) { if (obj instanceof FsPermission) { FsPermission that = (FsPermission)obj; @@ -167,10 +168,10 @@ public class FsPermission implements Wri return false; } - /** {@inheritDoc} */ + @Override public int hashCode() {return toShort();} - /** {@inheritDoc} */ + @Override public String toString() { String str = useraction.SYMBOL + groupaction.SYMBOL + otheraction.SYMBOL; if(stickyBit) { @@ -300,9 +301,11 @@ public class FsPermission implements Wri public ImmutableFsPermission(short permission) { super(permission); } + @Override public FsPermission applyUMask(FsPermission umask) { throw new UnsupportedOperationException(); } + @Override public void readFields(DataInput in) throws IOException { throw new UnsupportedOperationException(); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/PermissionStatus.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/PermissionStatus.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/PermissionStatus.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/PermissionStatus.java Tue Oct 16 00:02:55 2012 @@ -32,6 +32,7 @@ import java.io.IOException; @InterfaceStability.Unstable public class PermissionStatus implements Writable { static final WritableFactory FACTORY = new WritableFactory() { + @Override public Writable newInstance() { return new PermissionStatus(); } }; static { // register a ctor @@ -42,9 +43,11 @@ public class PermissionStatus implements public static PermissionStatus createImmutable( String user, String group, FsPermission permission) { return new PermissionStatus(user, group, permission) { + @Override public PermissionStatus applyUMask(FsPermission umask) { throw new UnsupportedOperationException(); } + @Override public void readFields(DataInput in) throws IOException { throw new UnsupportedOperationException(); } @@ -82,14 +85,14 @@ public class PermissionStatus implements return this; } - /** {@inheritDoc} */ + @Override public void readFields(DataInput in) throws IOException { username = Text.readString(in, Text.DEFAULT_MAX_LEN); groupname = Text.readString(in, Text.DEFAULT_MAX_LEN); permission = FsPermission.read(in); } - /** {@inheritDoc} */ + @Override public void write(DataOutput out) throws IOException { write(out, username, groupname, permission); } @@ -115,7 +118,7 @@ public class PermissionStatus implements permission.write(out); } - /** {@inheritDoc} */ + @Override public String toString() { return username + ":" + groupname + ":" + permission; } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java Tue Oct 16 00:02:55 2012 @@ -83,6 +83,7 @@ class Jets3tFileSystemStore implements F private static final Log LOG = LogFactory.getLog(Jets3tFileSystemStore.class.getName()); + @Override public void initialize(URI uri, Configuration conf) throws IOException { this.conf = conf; @@ -108,6 +109,7 @@ class Jets3tFileSystemStore implements F ); } + @Override public String getVersion() throws IOException { return FILE_SYSTEM_VERSION_VALUE; } @@ -123,14 +125,17 @@ class Jets3tFileSystemStore implements F } } + @Override public void deleteINode(Path path) throws IOException { delete(pathToKey(path)); } + @Override public void deleteBlock(Block block) throws IOException { delete(blockToKey(block)); } + @Override public boolean inodeExists(Path path) throws IOException { InputStream in = get(pathToKey(path), true); if (in == null) { @@ -140,6 +145,7 @@ class Jets3tFileSystemStore implements F return true; } + @Override public boolean blockExists(long blockId) throws IOException { InputStream in = get(blockToKey(blockId), false); if (in == null) { @@ -203,10 +209,12 @@ class Jets3tFileSystemStore implements F } } + @Override public INode retrieveINode(Path path) throws IOException { return INode.deserialize(get(pathToKey(path), true)); } + @Override public File retrieveBlock(Block block, long byteRangeStart) throws IOException { File fileBlock = null; @@ -249,6 +257,7 @@ class Jets3tFileSystemStore implements F return result; } + @Override public Set listSubPaths(Path path) throws IOException { try { String prefix = pathToKey(path); @@ -270,6 +279,7 @@ class Jets3tFileSystemStore implements F } } + @Override public Set listDeepSubPaths(Path path) throws IOException { try { String prefix = pathToKey(path); @@ -311,10 +321,12 @@ class Jets3tFileSystemStore implements F } } + @Override public void storeINode(Path path, INode inode) throws IOException { put(pathToKey(path), inode.serialize(), inode.getSerializedLength(), true); } + @Override public void storeBlock(Block block, File file) throws IOException { BufferedInputStream in = null; try { @@ -354,6 +366,7 @@ class Jets3tFileSystemStore implements F return blockToKey(block.getId()); } + @Override public void purge() throws IOException { try { S3Object[] objects = s3Service.listObjects(bucket); @@ -368,6 +381,7 @@ class Jets3tFileSystemStore implements F } } + @Override public void dump() throws IOException { StringBuilder sb = new StringBuilder("S3 Filesystem, "); sb.append(bucket.getName()).append("\n"); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/MigrationTool.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/MigrationTool.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/MigrationTool.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/MigrationTool.java Tue Oct 16 00:02:55 2012 @@ -61,6 +61,7 @@ public class MigrationTool extends Confi System.exit(res); } + @Override public int run(String[] args) throws Exception { if (args.length == 0) { @@ -195,6 +196,7 @@ public class MigrationTool extends Confi class UnversionedStore implements Store { + @Override public Set listAllPaths() throws IOException { try { String prefix = urlEncode(Path.SEPARATOR); @@ -212,6 +214,7 @@ public class MigrationTool extends Confi } } + @Override public void deleteINode(Path path) throws IOException { delete(pathToKey(path)); } @@ -227,6 +230,7 @@ public class MigrationTool extends Confi } } + @Override public INode retrieveINode(Path path) throws IOException { return INode.deserialize(get(pathToKey(path))); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java Tue Oct 16 00:02:55 2012 @@ -206,6 +206,7 @@ public class S3FileSystem extends FileSy } /** This optional operation is not yet supported. */ + @Override public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException { throw new IOException("Not supported"); @@ -298,6 +299,7 @@ public class S3FileSystem extends FileSy return true; } + @Override public boolean delete(Path path, boolean recursive) throws IOException { Path absolutePath = makeAbsolute(path); INode inode = store.retrieveINode(absolutePath); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3InputStream.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3InputStream.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3InputStream.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3/S3InputStream.java Tue Oct 16 00:02:55 2012 @@ -113,7 +113,7 @@ class S3InputStream extends FSInputStrea pos++; } } - if (stats != null & result >= 0) { + if (stats != null && result >= 0) { stats.incrementBytesRead(1); } return result; Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/Jets3tNativeFileSystemStore.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/Jets3tNativeFileSystemStore.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/Jets3tNativeFileSystemStore.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/Jets3tNativeFileSystemStore.java Tue Oct 16 00:02:55 2012 @@ -49,6 +49,7 @@ class Jets3tNativeFileSystemStore implem private S3Service s3Service; private S3Bucket bucket; + @Override public void initialize(URI uri, Configuration conf) throws IOException { S3Credentials s3Credentials = new S3Credentials(); s3Credentials.initialize(uri, conf); @@ -63,6 +64,7 @@ class Jets3tNativeFileSystemStore implem bucket = new S3Bucket(uri.getHost()); } + @Override public void storeFile(String key, File file, byte[] md5Hash) throws IOException { @@ -90,6 +92,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public void storeEmptyFile(String key) throws IOException { try { S3Object object = new S3Object(key); @@ -102,6 +105,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public FileMetadata retrieveMetadata(String key) throws IOException { try { S3Object object = s3Service.getObjectDetails(bucket, key); @@ -117,6 +121,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public InputStream retrieve(String key) throws IOException { try { S3Object object = s3Service.getObject(bucket, key); @@ -127,6 +132,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public InputStream retrieve(String key, long byteRangeStart) throws IOException { try { @@ -139,11 +145,13 @@ class Jets3tNativeFileSystemStore implem } } + @Override public PartialListing list(String prefix, int maxListingLength) throws IOException { return list(prefix, maxListingLength, null, false); } + @Override public PartialListing list(String prefix, int maxListingLength, String priorLastKey, boolean recurse) throws IOException { @@ -175,6 +183,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public void delete(String key) throws IOException { try { s3Service.deleteObject(bucket, key); @@ -183,6 +192,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public void copy(String srcKey, String dstKey) throws IOException { try { s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(), @@ -192,6 +202,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public void purge(String prefix) throws IOException { try { S3Object[] objects = s3Service.listObjects(bucket, prefix, null); @@ -203,6 +214,7 @@ class Jets3tNativeFileSystemStore implem } } + @Override public void dump() throws IOException { StringBuilder sb = new StringBuilder("S3 Native Filesystem, "); sb.append(bucket.getName()).append("\n"); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/s3native/NativeS3FileSystem.java Tue Oct 16 00:02:55 2012 @@ -300,7 +300,7 @@ public class NativeS3FileSystem extends } private static String pathToKey(Path path) { - if (path.toUri().getScheme() != null && "".equals(path.toUri().getPath())) { + if (path.toUri().getScheme() != null && path.toUri().getPath().isEmpty()) { // allow uris without trailing slash after bucket to refer to root, // like s3n://mybucket return ""; Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Command.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Command.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Command.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Command.java Tue Oct 16 00:02:55 2012 @@ -44,12 +44,12 @@ import org.apache.hadoop.util.StringUtil @InterfaceStability.Evolving abstract public class Command extends Configured { - /** default name of the command */ - public static String NAME; - /** the command's usage switches and arguments format */ - public static String USAGE; - /** the command's long description */ - public static String DESCRIPTION; + /** field name indicating the default name of the command */ + public static final String COMMAND_NAME_FIELD = "NAME"; + /** field name indicating the command's usage switches and arguments format */ + public static final String COMMAND_USAGE_FIELD = "USAGE"; + /** field name indicating the command's long description */ + public static final String COMMAND_DESCRIPTION_FIELD = "DESCRIPTION"; protected String[] args; protected String name; @@ -397,7 +397,7 @@ abstract public class Command extends Co */ public String getName() { return (name == null) - ? getCommandField("NAME") + ? getCommandField(COMMAND_NAME_FIELD) : name.startsWith("-") ? name.substring(1) : name; } @@ -415,7 +415,7 @@ abstract public class Command extends Co */ public String getUsage() { String cmd = "-" + getName(); - String usage = isDeprecated() ? "" : getCommandField("USAGE"); + String usage = isDeprecated() ? "" : getCommandField(COMMAND_USAGE_FIELD); return usage.isEmpty() ? cmd : cmd + " " + usage; } @@ -426,7 +426,7 @@ abstract public class Command extends Co public String getDescription() { return isDeprecated() ? "(DEPRECATED) Same as '" + getReplacementCommand() + "'" - : getCommandField("DESCRIPTION"); + : getCommandField(COMMAND_DESCRIPTION_FIELD); } /** Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandFormat.java Tue Oct 16 00:02:55 2012 @@ -150,6 +150,7 @@ public class CommandFormat { actual = got; } + @Override public String getMessage() { return "expected " + expected + " but got " + actual; } @@ -165,6 +166,7 @@ public class CommandFormat { super(expected, actual); } + @Override public String getMessage() { return "Too many arguments: " + super.getMessage(); } @@ -180,6 +182,7 @@ public class CommandFormat { super(expected, actual); } + @Override public String getMessage() { return "Not enough arguments: " + super.getMessage(); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java Tue Oct 16 00:02:55 2012 @@ -114,6 +114,7 @@ class Delete { static class Rmr extends Rm { public static final String NAME = "rmr"; + @Override protected void processOptions(LinkedList args) throws IOException { args.addFirst("-r"); super.processOptions(args); @@ -136,6 +137,7 @@ class Delete { private boolean ignoreNonEmpty = false; + @Override protected void processOptions(LinkedList args) throws IOException { CommandFormat cf = new CommandFormat( 1, Integer.MAX_VALUE, "-ignore-fail-on-non-empty"); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java Tue Oct 16 00:02:55 2012 @@ -17,11 +17,21 @@ */ package org.apache.hadoop.fs.shell; -import java.io.IOException; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.InputStream; +import java.io.IOException; import java.util.LinkedList; import java.util.zip.GZIPInputStream; +import org.apache.avro.file.DataFileReader; +import org.apache.avro.file.FileReader; +import org.apache.avro.generic.GenericDatumReader; +import org.apache.avro.generic.GenericDatumWriter; +import org.apache.avro.io.DatumWriter; +import org.apache.avro.io.EncoderFactory; +import org.apache.avro.io.JsonEncoder; +import org.apache.avro.Schema; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -37,6 +47,10 @@ import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.compress.CompressionCodecFactory; import org.apache.hadoop.util.ReflectionUtils; +import org.codehaus.jackson.JsonEncoding; +import org.codehaus.jackson.JsonFactory; +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.util.MinimalPrettyPrinter; /** * Display contents of files @@ -95,14 +109,14 @@ class Display extends FsCommand { /** * Same behavior as "-cat", but handles zip and TextRecordInputStream - * encodings. + * and Avro encodings. */ public static class Text extends Cat { public static final String NAME = "text"; public static final String USAGE = Cat.USAGE; public static final String DESCRIPTION = "Takes a source file and outputs the file in text format.\n" + - "The allowed formats are zip and TextRecordInputStream."; + "The allowed formats are zip and TextRecordInputStream and Avro."; @Override protected InputStream getInputStream(PathData item) throws IOException { @@ -128,10 +142,18 @@ class Display extends FsCommand { CompressionCodecFactory cf = new CompressionCodecFactory(getConf()); CompressionCodec codec = cf.getCodec(item.path); if (codec != null) { + i.seek(0); return codec.createInputStream(i); } break; } + case 0x4f62: { // 'O' 'b' + if (i.readByte() == 'j') { + i.close(); + return new AvroFileInputStream(item.stat); + } + break; + } } // File is non-compressed, or not a file container we know. @@ -161,6 +183,7 @@ class Display extends FsCommand { outbuf = new DataOutputBuffer(); } + @Override public int read() throws IOException { int ret; if (null == inbuf || -1 == (ret = inbuf.read())) { @@ -180,9 +203,74 @@ class Display extends FsCommand { return ret; } + @Override public void close() throws IOException { r.close(); super.close(); } } + + /** + * This class transforms a binary Avro data file into an InputStream + * with data that is in a human readable JSON format. + */ + protected static class AvroFileInputStream extends InputStream { + private int pos; + private byte[] buffer; + private ByteArrayOutputStream output; + private FileReader fileReader; + private DatumWriter writer; + private JsonEncoder encoder; + + public AvroFileInputStream(FileStatus status) throws IOException { + pos = 0; + buffer = new byte[0]; + GenericDatumReader reader = new GenericDatumReader(); + fileReader = + DataFileReader.openReader(new File(status.getPath().toUri()), reader); + Schema schema = fileReader.getSchema(); + writer = new GenericDatumWriter(schema); + output = new ByteArrayOutputStream(); + JsonGenerator generator = + new JsonFactory().createJsonGenerator(output, JsonEncoding.UTF8); + MinimalPrettyPrinter prettyPrinter = new MinimalPrettyPrinter(); + prettyPrinter.setRootValueSeparator(System.getProperty("line.separator")); + generator.setPrettyPrinter(prettyPrinter); + encoder = EncoderFactory.get().jsonEncoder(schema, generator); + } + + /** + * Read a single byte from the stream. + */ + @Override + public int read() throws IOException { + if (pos < buffer.length) { + return buffer[pos++]; + } + if (!fileReader.hasNext()) { + return -1; + } + writer.write(fileReader.next(), encoder); + encoder.flush(); + if (!fileReader.hasNext()) { + // Write a new line after the last Avro record. + output.write(System.getProperty("line.separator").getBytes()); + output.flush(); + } + pos = 0; + buffer = output.toByteArray(); + output.reset(); + return read(); + } + + /** + * Close the stream. + */ + @Override + public void close() throws IOException { + fileReader.close(); + output.close(); + super.close(); + } + } } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsCommand.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsCommand.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsCommand.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsCommand.java Tue Oct 16 00:02:55 2012 @@ -73,6 +73,7 @@ abstract public class FsCommand extends // abstract method that normally is invoked by runall() which is // overridden below + @Override protected void run(Path path) throws IOException { throw new RuntimeException("not supposed to get here"); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/PathData.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/PathData.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/PathData.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/PathData.java Tue Oct 16 00:02:55 2012 @@ -380,6 +380,7 @@ public class PathData implements Compara * as given on the commandline, or the full path * @return String of the path */ + @Override public String toString() { String scheme = uri.getScheme(); // No interpretation of symbols. Just decode % escaped chars. Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java Tue Oct 16 00:02:55 2012 @@ -89,7 +89,11 @@ class ChRootedFileSystem extends FilterF public ChRootedFileSystem(final URI uri, Configuration conf) throws IOException { super(FileSystem.get(uri, conf)); - chRootPathPart = new Path(uri.getPath()); + String pathString = uri.getPath(); + if (pathString.isEmpty()) { + pathString = "/"; + } + chRootPathPart = new Path(pathString); chRootPathPartString = chRootPathPart.toUri().getPath(); myUri = uri; workingDir = getHomeDirectory(); @@ -102,6 +106,7 @@ class ChRootedFileSystem extends FilterF * for this FileSystem * @param conf the configuration */ + @Override public void initialize(final URI name, final Configuration conf) throws IOException { super.initialize(name, conf); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/NotInMountpointException.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/NotInMountpointException.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/NotInMountpointException.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/NotInMountpointException.java Tue Oct 16 00:02:55 2012 @@ -20,10 +20,6 @@ package org.apache.hadoop.fs.viewfs; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; - import org.apache.hadoop.fs.Path; /** Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java Tue Oct 16 00:02:55 2012 @@ -164,6 +164,7 @@ public class ViewFileSystem extends File * this FileSystem * @param conf the configuration */ + @Override public void initialize(final URI theUri, final Configuration conf) throws IOException { super.initialize(theUri, conf); @@ -706,7 +707,7 @@ public class ViewFileSystem extends File @Override public boolean mkdirs(Path dir, FsPermission permission) throws AccessControlException, FileAlreadyExistsException { - if (theInternalDir.isRoot & dir == null) { + if (theInternalDir.isRoot && dir == null) { throw new FileAlreadyExistsException("/ already exits"); } // Note dir starts with / Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java Tue Oct 16 00:02:55 2012 @@ -205,9 +205,13 @@ public class ViewFs extends AbstractFile protected AbstractFileSystem getTargetFileSystem(final URI uri) throws URISyntaxException, UnsupportedFileSystemException { + String pathString = uri.getPath(); + if (pathString.isEmpty()) { + pathString = "/"; + } return new ChRootedFs( AbstractFileSystem.createFileSystem(uri, config), - new Path(uri.getPath())); + new Path(pathString)); } @Override @@ -750,7 +754,7 @@ public class ViewFs extends AbstractFile public void mkdir(final Path dir, final FsPermission permission, final boolean createParent) throws AccessControlException, FileAlreadyExistsException { - if (theInternalDir.isRoot & dir == null) { + if (theInternalDir.isRoot && dir == null) { throw new FileAlreadyExistsException("/ already exits"); } throw readOnlyMountTable("mkdir", dir); Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFsFileStatus.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFsFileStatus.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFsFileStatus.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFsFileStatus.java Tue Oct 16 00:02:55 2012 @@ -42,7 +42,8 @@ class ViewFsFileStatus extends FileStatu return super.equals(o); } - public int hashCode() { + @Override + public int hashCode() { return super.hashCode(); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java Tue Oct 16 00:02:55 2012 @@ -276,7 +276,7 @@ public class ActiveStandbyElector implem String pathParts[] = znodeWorkingDir.split("/"); Preconditions.checkArgument(pathParts.length >= 1 && - "".equals(pathParts[0]), + pathParts[0].isEmpty(), "Invalid path: %s", znodeWorkingDir); StringBuilder sb = new StringBuilder(); @@ -892,6 +892,7 @@ public class ActiveStandbyElector implem final List acl, final CreateMode mode) throws InterruptedException, KeeperException { return zkDoWithRetries(new ZKAction() { + @Override public String run() throws KeeperException, InterruptedException { return zkClient.create(path, data, acl, mode); } @@ -901,6 +902,7 @@ public class ActiveStandbyElector implem private byte[] getDataWithRetries(final String path, final boolean watch, final Stat stat) throws InterruptedException, KeeperException { return zkDoWithRetries(new ZKAction() { + @Override public byte[] run() throws KeeperException, InterruptedException { return zkClient.getData(path, watch, stat); } @@ -910,6 +912,7 @@ public class ActiveStandbyElector implem private Stat setDataWithRetries(final String path, final byte[] data, final int version) throws InterruptedException, KeeperException { return zkDoWithRetries(new ZKAction() { + @Override public Stat run() throws KeeperException, InterruptedException { return zkClient.setData(path, data, version); } @@ -919,6 +922,7 @@ public class ActiveStandbyElector implem private void deleteWithRetries(final String path, final int version) throws KeeperException, InterruptedException { zkDoWithRetries(new ZKAction() { + @Override public Void run() throws KeeperException, InterruptedException { zkClient.delete(path, version); return null; Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceProtocol.java Tue Oct 16 00:02:55 2012 @@ -56,6 +56,7 @@ public interface HAServiceProtocol { this.name = name; } + @Override public String toString() { return name; } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/NodeFencer.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/NodeFencer.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/NodeFencer.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/NodeFencer.java Tue Oct 16 00:02:55 2012 @@ -184,6 +184,7 @@ public class NodeFencer { this.arg = arg; } + @Override public String toString() { return method.getClass().getCanonicalName() + "(" + arg + ")"; } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java Tue Oct 16 00:02:55 2012 @@ -241,7 +241,7 @@ public class SshFenceByTcpPort extends C sshPort = DEFAULT_SSH_PORT; // Parse optional user and ssh port - if (arg != null && !"".equals(arg)) { + if (arg != null && !arg.isEmpty()) { Matcher m = USER_PORT_RE.matcher(arg); if (!m.matches()) { throw new BadFencingConfigurationException( @@ -274,6 +274,7 @@ public class SshFenceByTcpPort extends C static final Log LOG = LogFactory.getLog( SshFenceByTcpPort.class.getName() + ".jsch"); + @Override public boolean isEnabled(int level) { switch (level) { case com.jcraft.jsch.Logger.DEBUG: @@ -291,6 +292,7 @@ public class SshFenceByTcpPort extends C } } + @Override public void log(int level, String message) { switch (level) { case com.jcraft.jsch.Logger.DEBUG: Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFCRpcServer.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFCRpcServer.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFCRpcServer.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFCRpcServer.java Tue Oct 16 00:02:55 2012 @@ -55,11 +55,10 @@ public class ZKFCRpcServer implements ZK new ZKFCProtocolServerSideTranslatorPB(this); BlockingService service = ZKFCProtocolService .newReflectiveBlockingService(translator); - this.server = RPC.getServer( - ZKFCProtocolPB.class, - service, bindAddr.getHostName(), - bindAddr.getPort(), HANDLER_COUNT, false, conf, - null /*secretManager*/); + this.server = new RPC.Builder(conf).setProtocol(ZKFCProtocolPB.class) + .setInstance(service).setBindAddress(bindAddr.getHostName()) + .setPort(bindAddr.getPort()).setNumHandlers(HANDLER_COUNT) + .setVerbose(false).build(); // set service-level authorization security policy if (conf.getBoolean( Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java Tue Oct 16 00:02:55 2012 @@ -330,6 +330,12 @@ public class HttpServer implements Filte Context logContext = new Context(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(AdminAuthorizedServlet.class, "/*"); + if (conf.getBoolean( + CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES, + CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) { + logContext.getInitParams().put( + "org.mortbay.jetty.servlet.Default.aliases", "true"); + } logContext.setDisplayName("logs"); setContextAttributes(logContext, conf); defaultContexts.put(logContext, true); @@ -468,7 +474,7 @@ public class HttpServer implements Filte } } - /** {@inheritDoc} */ + @Override public void addFilter(String name, String classname, Map parameters) { @@ -488,7 +494,7 @@ public class HttpServer implements Filte filterNames.add(name); } - /** {@inheritDoc} */ + @Override public void addGlobalFilter(String name, String classname, Map parameters) { final String[] ALL_URLS = { "/*" }; @@ -671,6 +677,15 @@ public class HttpServer implements Filte "Problem in starting http server. Server handlers failed"); } } + // Make sure there are no errors initializing the context. + Throwable unavailableException = webAppContext.getUnavailableException(); + if (unavailableException != null) { + // Have to stop the webserver, or else its non-daemon threads + // will hang forever. + webServer.stop(); + throw new IOException("Unable to initialize WebAppContext", + unavailableException); + } } catch (IOException e) { throw e; } catch (InterruptedException e) { Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java Tue Oct 16 00:02:55 2012 @@ -164,16 +164,18 @@ public abstract class AbstractMapWritabl } /** @return the conf */ + @Override public Configuration getConf() { return conf.get(); } /** @param conf the conf to set */ + @Override public void setConf(Configuration conf) { this.conf.set(conf); } - /** {@inheritDoc} */ + @Override public void write(DataOutput out) throws IOException { // First write out the size of the class table and any classes that are @@ -187,7 +189,7 @@ public abstract class AbstractMapWritabl } } - /** {@inheritDoc} */ + @Override public void readFields(DataInput in) throws IOException { // Get the number of "unknown" classes Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ArrayWritable.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ArrayWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ArrayWritable.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ArrayWritable.java Tue Oct 16 00:02:55 2012 @@ -88,6 +88,7 @@ public class ArrayWritable implements Wr public Writable[] get() { return values; } + @Override public void readFields(DataInput in) throws IOException { values = new Writable[in.readInt()]; // construct values for (int i = 0; i < values.length; i++) { @@ -97,6 +98,7 @@ public class ArrayWritable implements Wr } } + @Override public void write(DataOutput out) throws IOException { out.writeInt(values.length); // write values for (int i = 0; i < values.length; i++) { Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/BooleanWritable.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/BooleanWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/BooleanWritable.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/BooleanWritable.java Tue Oct 16 00:02:55 2012 @@ -57,12 +57,14 @@ public class BooleanWritable implements /** */ + @Override public void readFields(DataInput in) throws IOException { value = in.readBoolean(); } /** */ + @Override public void write(DataOutput out) throws IOException { out.writeBoolean(value); } Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteWritable.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff ============================================================================== --- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteWritable.java (original) +++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteWritable.java Tue Oct 16 00:02:55 2012 @@ -39,10 +39,12 @@ public class ByteWritable implements Wri /** Return the value of this ByteWritable. */ public byte get() { return value; } + @Override public void readFields(DataInput in) throws IOException { value = in.readByte(); } + @Override public void write(DataOutput out) throws IOException { out.writeByte(value); }