HADOOP-10482. Fix various findbugs warnings in hadoop-common. Contributed by Haohui Mai.
This commit is contained in:
parent
2e98ad34ce
commit
bbd6a32776
|
@ -558,6 +558,8 @@ Release 2.7.0 - UNRELEASED
|
||||||
HADOOP-11381. Fix findbugs warnings in hadoop-distcp, hadoop-aws,
|
HADOOP-11381. Fix findbugs warnings in hadoop-distcp, hadoop-aws,
|
||||||
hadoop-azure, and hadoop-openstack. (Li Lu via wheat9)
|
hadoop-azure, and hadoop-openstack. (Li Lu via wheat9)
|
||||||
|
|
||||||
|
HADOOP-10482. Fix various findbugs warnings in hadoop-common. (wheat9)
|
||||||
|
|
||||||
Release 2.6.0 - 2014-11-18
|
Release 2.6.0 - 2014-11-18
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -241,6 +241,16 @@
|
||||||
<Method name="writeVLong" />
|
<Method name="writeVLong" />
|
||||||
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
|
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
|
||||||
</Match>
|
</Match>
|
||||||
|
<Match>
|
||||||
|
<Class name="org.apache.hadoop.io.Text" />
|
||||||
|
<Method name="bytesToCodePoint" />
|
||||||
|
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
|
||||||
|
</Match>
|
||||||
|
<Match>
|
||||||
|
<Class name="org.apache.hadoop.util.PureJavaCrc32C" />
|
||||||
|
<Method name="update" />
|
||||||
|
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
|
||||||
|
</Match>
|
||||||
<!--
|
<!--
|
||||||
The switch condition fall through is intentional and for performance
|
The switch condition fall through is intentional and for performance
|
||||||
purposes.
|
purposes.
|
||||||
|
|
|
@ -1487,11 +1487,8 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
|
||||||
* @param pattern new value
|
* @param pattern new value
|
||||||
*/
|
*/
|
||||||
public void setPattern(String name, Pattern pattern) {
|
public void setPattern(String name, Pattern pattern) {
|
||||||
if (null == pattern) {
|
assert pattern != null : "Pattern cannot be null";
|
||||||
set(name, null);
|
set(name, pattern.pattern());
|
||||||
} else {
|
|
||||||
set(name, pattern.pattern());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -144,13 +144,8 @@ public class JavaKeyStoreProvider extends KeyProvider {
|
||||||
// Provided Password file does not exist
|
// Provided Password file does not exist
|
||||||
throw new IOException("Password file does not exists");
|
throw new IOException("Password file does not exists");
|
||||||
}
|
}
|
||||||
if (pwdFile != null) {
|
try (InputStream is = pwdFile.openStream()) {
|
||||||
InputStream is = pwdFile.openStream();
|
password = IOUtils.toString(is).trim().toCharArray();
|
||||||
try {
|
|
||||||
password = IOUtils.toString(is).trim().toCharArray();
|
|
||||||
} finally {
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2618,9 +2618,6 @@ public abstract class FileSystem extends Configured implements Closeable {
|
||||||
private static FileSystem createFileSystem(URI uri, Configuration conf
|
private static FileSystem createFileSystem(URI uri, Configuration conf
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
Class<?> clazz = getFileSystemClass(uri.getScheme(), conf);
|
Class<?> clazz = getFileSystemClass(uri.getScheme(), conf);
|
||||||
if (clazz == null) {
|
|
||||||
throw new IOException("No FileSystem for scheme: " + uri.getScheme());
|
|
||||||
}
|
|
||||||
FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
|
FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
|
||||||
fs.initialize(uri, conf);
|
fs.initialize(uri, conf);
|
||||||
return fs;
|
return fs;
|
||||||
|
|
|
@ -220,12 +220,7 @@ public class HarFileSystem extends FileSystem {
|
||||||
return FileSystem.getDefaultUri(conf);
|
return FileSystem.getDefaultUri(conf);
|
||||||
}
|
}
|
||||||
String authority = rawURI.getAuthority();
|
String authority = rawURI.getAuthority();
|
||||||
if (authority == null) {
|
|
||||||
throw new IOException("URI: " + rawURI
|
|
||||||
+ " is an invalid Har URI since authority==null."
|
|
||||||
+ " Expecting har://<scheme>-<host>/<path>.");
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = authority.indexOf('-');
|
int i = authority.indexOf('-');
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
throw new IOException("URI: " + rawURI
|
throw new IOException("URI: " + rawURI
|
||||||
|
@ -489,19 +484,12 @@ public class HarFileSystem extends FileSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Store {
|
static class Store {
|
||||||
public Store() {
|
public Store(long begin, long end) {
|
||||||
begin = end = startHash = endHash = 0;
|
|
||||||
}
|
|
||||||
public Store(long begin, long end, int startHash, int endHash) {
|
|
||||||
this.begin = begin;
|
this.begin = begin;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.startHash = startHash;
|
|
||||||
this.endHash = endHash;
|
|
||||||
}
|
}
|
||||||
public long begin;
|
public long begin;
|
||||||
public long end;
|
public long end;
|
||||||
public int startHash;
|
|
||||||
public int endHash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -594,7 +582,7 @@ public class HarFileSystem extends FileSystem {
|
||||||
public HarStatus(String harString) throws UnsupportedEncodingException {
|
public HarStatus(String harString) throws UnsupportedEncodingException {
|
||||||
String[] splits = harString.split(" ");
|
String[] splits = harString.split(" ");
|
||||||
this.name = decodeFileName(splits[0]);
|
this.name = decodeFileName(splits[0]);
|
||||||
this.isDir = "dir".equals(splits[1]) ? true: false;
|
this.isDir = "dir".equals(splits[1]);
|
||||||
// this is equal to "none" if its a directory
|
// this is equal to "none" if its a directory
|
||||||
this.partName = splits[2];
|
this.partName = splits[2];
|
||||||
this.startIndex = Long.parseLong(splits[3]);
|
this.startIndex = Long.parseLong(splits[3]);
|
||||||
|
@ -1167,11 +1155,8 @@ public class HarFileSystem extends FileSystem {
|
||||||
int b = lin.readLine(line);
|
int b = lin.readLine(line);
|
||||||
read += b;
|
read += b;
|
||||||
readStr = line.toString().split(" ");
|
readStr = line.toString().split(" ");
|
||||||
int startHash = Integer.parseInt(readStr[0]);
|
|
||||||
int endHash = Integer.parseInt(readStr[1]);
|
|
||||||
stores.add(new Store(Long.parseLong(readStr[2]),
|
stores.add(new Store(Long.parseLong(readStr[2]),
|
||||||
Long.parseLong(readStr[3]), startHash,
|
Long.parseLong(readStr[3])));
|
||||||
endHash));
|
|
||||||
line.clear();
|
line.clear();
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
|
|
@ -372,7 +372,7 @@ public class LocalDirAllocator {
|
||||||
// Keep rolling the wheel till we get a valid path
|
// Keep rolling the wheel till we get a valid path
|
||||||
Random r = new java.util.Random();
|
Random r = new java.util.Random();
|
||||||
while (numDirsSearched < numDirs && returnPath == null) {
|
while (numDirsSearched < numDirs && returnPath == null) {
|
||||||
long randomPosition = Math.abs(r.nextLong()) % totalAvailable;
|
long randomPosition = (r.nextLong() >>> 1) % totalAvailable;
|
||||||
int dir = 0;
|
int dir = 0;
|
||||||
while (randomPosition > availableOnDisk[dir]) {
|
while (randomPosition > availableOnDisk[dir]) {
|
||||||
randomPosition -= availableOnDisk[dir];
|
randomPosition -= availableOnDisk[dir];
|
||||||
|
|
|
@ -143,13 +143,13 @@ public class MD5MD5CRC32FileChecksum extends FileChecksum {
|
||||||
switch (finalCrcType) {
|
switch (finalCrcType) {
|
||||||
case CRC32:
|
case CRC32:
|
||||||
return new MD5MD5CRC32GzipFileChecksum(
|
return new MD5MD5CRC32GzipFileChecksum(
|
||||||
Integer.valueOf(bytesPerCRC),
|
Integer.parseInt(bytesPerCRC),
|
||||||
Integer.valueOf(crcPerBlock),
|
Integer.parseInt(crcPerBlock),
|
||||||
new MD5Hash(md5));
|
new MD5Hash(md5));
|
||||||
case CRC32C:
|
case CRC32C:
|
||||||
return new MD5MD5CRC32CastagnoliFileChecksum(
|
return new MD5MD5CRC32CastagnoliFileChecksum(
|
||||||
Integer.valueOf(bytesPerCRC),
|
Integer.parseInt(bytesPerCRC),
|
||||||
Integer.valueOf(crcPerBlock),
|
Integer.parseInt(crcPerBlock),
|
||||||
new MD5Hash(md5));
|
new MD5Hash(md5));
|
||||||
default:
|
default:
|
||||||
// we should never get here since finalCrcType will
|
// we should never get here since finalCrcType will
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.io.InputStream;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.commons.net.ftp.FTP;
|
import org.apache.commons.net.ftp.FTP;
|
||||||
|
@ -101,17 +102,12 @@ public class FTPFileSystem extends FileSystem {
|
||||||
if (userAndPassword == null) {
|
if (userAndPassword == null) {
|
||||||
userAndPassword = (conf.get("fs.ftp.user." + host, null) + ":" + conf
|
userAndPassword = (conf.get("fs.ftp.user." + host, null) + ":" + conf
|
||||||
.get("fs.ftp.password." + host, null));
|
.get("fs.ftp.password." + host, null));
|
||||||
if (userAndPassword == null) {
|
|
||||||
throw new IOException("Invalid user/passsword specified");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
String[] userPasswdInfo = userAndPassword.split(":");
|
String[] userPasswdInfo = userAndPassword.split(":");
|
||||||
|
Preconditions.checkState(userPasswdInfo.length > 1,
|
||||||
|
"Invalid username / password");
|
||||||
conf.set(FS_FTP_USER_PREFIX + host, userPasswdInfo[0]);
|
conf.set(FS_FTP_USER_PREFIX + host, userPasswdInfo[0]);
|
||||||
if (userPasswdInfo.length > 1) {
|
conf.set(FS_FTP_PASSWORD_PREFIX + host, userPasswdInfo[1]);
|
||||||
conf.set(FS_FTP_PASSWORD_PREFIX + host, userPasswdInfo[1]);
|
|
||||||
} else {
|
|
||||||
conf.set(FS_FTP_PASSWORD_PREFIX + host, null);
|
|
||||||
}
|
|
||||||
setConf(conf);
|
setConf(conf);
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +289,8 @@ public class FTPFileSystem extends FileSystem {
|
||||||
*/
|
*/
|
||||||
private boolean exists(FTPClient client, Path file) throws IOException {
|
private boolean exists(FTPClient client, Path file) throws IOException {
|
||||||
try {
|
try {
|
||||||
return getFileStatus(client, file) != null;
|
getFileStatus(client, file);
|
||||||
|
return true;
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -333,10 +330,8 @@ public class FTPFileSystem extends FileSystem {
|
||||||
if (dirEntries != null && dirEntries.length > 0 && !(recursive)) {
|
if (dirEntries != null && dirEntries.length > 0 && !(recursive)) {
|
||||||
throw new IOException("Directory: " + file + " is not empty.");
|
throw new IOException("Directory: " + file + " is not empty.");
|
||||||
}
|
}
|
||||||
if (dirEntries != null) {
|
for (FileStatus dirEntry : dirEntries) {
|
||||||
for (int i = 0; i < dirEntries.length; i++) {
|
delete(client, new Path(absolute, dirEntry.getPath()), recursive);
|
||||||
delete(client, new Path(absolute, dirEntries[i].getPath()), recursive);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return client.removeDirectory(pathName);
|
return client.removeDirectory(pathName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Ls extends FsCommand {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected static final SimpleDateFormat dateFormat =
|
protected final SimpleDateFormat dateFormat =
|
||||||
new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
|
|
||||||
protected int maxRepl = 3, maxLen = 10, maxOwner = 0, maxGroup = 0;
|
protected int maxRepl = 3, maxLen = 10, maxOwner = 0, maxGroup = 0;
|
||||||
|
|
|
@ -55,8 +55,8 @@ class Stat extends FsCommand {
|
||||||
"in the specified format. Format accepts filesize in blocks (%b), group name of owner(%g), " +
|
"in the specified format. Format accepts filesize in blocks (%b), group name of owner(%g), " +
|
||||||
"filename (%n), block size (%o), replication (%r), user name of owner(%u), modification date (%y, %Y)\n";
|
"filename (%n), block size (%o), replication (%r), user name of owner(%u), modification date (%y, %Y)\n";
|
||||||
|
|
||||||
protected static final SimpleDateFormat timeFmt;
|
protected final SimpleDateFormat timeFmt;
|
||||||
static {
|
{
|
||||||
timeFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
timeFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
timeFmt.setTimeZone(TimeZone.getTimeZone("UTC"));
|
timeFmt.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@ class Test extends FsCommand {
|
||||||
case 'z':
|
case 'z':
|
||||||
test = (item.stat.getLen() == 0);
|
test = (item.stat.getLen() == 0);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!test) exitCode = 1;
|
if (!test) exitCode = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,12 +168,6 @@ public abstract class HAAdmin extends Configured implements Tool {
|
||||||
private boolean isOtherTargetNodeActive(String targetNodeToActivate, boolean forceActive)
|
private boolean isOtherTargetNodeActive(String targetNodeToActivate, boolean forceActive)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Collection<String> targetIds = getTargetIds(targetNodeToActivate);
|
Collection<String> targetIds = getTargetIds(targetNodeToActivate);
|
||||||
if(targetIds == null) {
|
|
||||||
errOut.println("transitionToActive: No target node in the "
|
|
||||||
+ "current configuration");
|
|
||||||
printUsage(errOut, "-transitionToActive");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
targetIds.remove(targetNodeToActivate);
|
targetIds.remove(targetNodeToActivate);
|
||||||
for(String targetId : targetIds) {
|
for(String targetId : targetIds) {
|
||||||
HAServiceTarget target = resolveTarget(targetId);
|
HAServiceTarget target = resolveTarget(targetId);
|
||||||
|
|
|
@ -310,6 +310,8 @@ public class SshFenceByTcpPort extends Configured
|
||||||
case com.jcraft.jsch.Logger.FATAL:
|
case com.jcraft.jsch.Logger.FATAL:
|
||||||
LOG.fatal(message);
|
LOG.fatal(message);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,11 @@ public class LongWritable implements WritableComparable<LongWritable> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(WritableComparable a, WritableComparable b) {
|
public int compare(WritableComparable a, WritableComparable b) {
|
||||||
return -super.compare(a, b);
|
return super.compare(b, a);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
|
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
|
||||||
return -super.compare(b1, s1, l1, b2, s2, l2);
|
return super.compare(b2, s2, l2, b1, s1, l1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -584,6 +584,8 @@ public class Text extends BinaryComparable
|
||||||
state = TRAIL_BYTE;
|
state = TRAIL_BYTE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
} // switch (state)
|
} // switch (state)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class DecompressorStream extends CompressionInputStream {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
super(in);
|
super(in);
|
||||||
|
|
||||||
if (in == null || decompressor == null) {
|
if (decompressor == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
} else if (bufferSize <= 0) {
|
} else if (bufferSize <= 0) {
|
||||||
throw new IllegalArgumentException("Illegal bufferSize");
|
throw new IllegalArgumentException("Illegal bufferSize");
|
||||||
|
|
|
@ -665,7 +665,7 @@ public abstract class Server {
|
||||||
assert !running;
|
assert !running;
|
||||||
readSelector.wakeup();
|
readSelector.wakeup();
|
||||||
try {
|
try {
|
||||||
join();
|
super.join();
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
|
@ -1119,7 +1119,8 @@ public abstract class Server {
|
||||||
private ByteBuffer data;
|
private ByteBuffer data;
|
||||||
private ByteBuffer dataLengthBuffer;
|
private ByteBuffer dataLengthBuffer;
|
||||||
private LinkedList<Call> responseQueue;
|
private LinkedList<Call> responseQueue;
|
||||||
private volatile int rpcCount = 0; // number of outstanding rpcs
|
// number of outstanding rpcs
|
||||||
|
private AtomicInteger rpcCount = new AtomicInteger();
|
||||||
private long lastContact;
|
private long lastContact;
|
||||||
private int dataLength;
|
private int dataLength;
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
|
@ -1207,17 +1208,17 @@ public abstract class Server {
|
||||||
|
|
||||||
/* Return true if the connection has no outstanding rpc */
|
/* Return true if the connection has no outstanding rpc */
|
||||||
private boolean isIdle() {
|
private boolean isIdle() {
|
||||||
return rpcCount == 0;
|
return rpcCount.get() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the outstanding RPC count */
|
/* Decrement the outstanding RPC count */
|
||||||
private void decRpcCount() {
|
private void decRpcCount() {
|
||||||
rpcCount--;
|
rpcCount.decrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment the outstanding RPC count */
|
/* Increment the outstanding RPC count */
|
||||||
private void incRpcCount() {
|
private void incRpcCount() {
|
||||||
rpcCount++;
|
rpcCount.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserGroupInformation getAuthorizedUgi(String authorizedId)
|
private UserGroupInformation getAuthorizedUgi(String authorizedId)
|
||||||
|
@ -2068,9 +2069,9 @@ public abstract class Server {
|
||||||
LOG.debug("Ignoring socket shutdown exception", e);
|
LOG.debug("Ignoring socket shutdown exception", e);
|
||||||
}
|
}
|
||||||
if (channel.isOpen()) {
|
if (channel.isOpen()) {
|
||||||
try {channel.close();} catch(Exception e) {}
|
IOUtils.cleanup(null, channel);
|
||||||
}
|
}
|
||||||
try {socket.close();} catch(Exception e) {}
|
IOUtils.cleanup(null, socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,11 +86,6 @@ public class GangliaContext31 extends GangliaContext {
|
||||||
value + " from hostname" + hostName);
|
value + " from hostname" + hostName);
|
||||||
|
|
||||||
String units = getUnits(name);
|
String units = getUnits(name);
|
||||||
if (units == null) {
|
|
||||||
LOG.warn("Metric name " + name + ", value " + value
|
|
||||||
+ " had 'null' units");
|
|
||||||
units = "";
|
|
||||||
}
|
|
||||||
int slope = getSlope(name);
|
int slope = getSlope(name);
|
||||||
int tmax = getTmax(name);
|
int tmax = getTmax(name);
|
||||||
int dmax = getDmax(name);
|
int dmax = getDmax(name);
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class CompositeContext extends AbstractMetricsContext {
|
||||||
int nKids;
|
int nKids;
|
||||||
try {
|
try {
|
||||||
String sKids = getAttribute(ARITY_LABEL);
|
String sKids = getAttribute(ARITY_LABEL);
|
||||||
nKids = Integer.valueOf(sKids);
|
nKids = Integer.parseInt(sKids);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Unable to initialize composite metric " + contextName +
|
LOG.error("Unable to initialize composite metric " + contextName +
|
||||||
": could not init arity", e);
|
": could not init arity", e);
|
||||||
|
|
|
@ -23,23 +23,24 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.metrics2.MetricsInfo;
|
import org.apache.hadoop.metrics2.MetricsInfo;
|
||||||
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mutable int counter for implementing metrics sources
|
* A mutable int counter for implementing metrics sources
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class MutableCounterInt extends MutableCounter {
|
public class MutableCounterInt extends MutableCounter {
|
||||||
private volatile int value;
|
private AtomicInteger value = new AtomicInteger();
|
||||||
|
|
||||||
MutableCounterInt(MetricsInfo info, int initValue) {
|
MutableCounterInt(MetricsInfo info, int initValue) {
|
||||||
super(info);
|
super(info);
|
||||||
this.value = initValue;
|
this.value.set(initValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void incr() {
|
public void incr() {
|
||||||
++value;
|
incr(1);
|
||||||
setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,18 +48,18 @@ public class MutableCounterInt extends MutableCounter {
|
||||||
* @param delta of the increment
|
* @param delta of the increment
|
||||||
*/
|
*/
|
||||||
public synchronized void incr(int delta) {
|
public synchronized void incr(int delta) {
|
||||||
value += delta;
|
value.addAndGet(delta);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int value() {
|
public int value() {
|
||||||
return value;
|
return value.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
||||||
if (all || changed()) {
|
if (all || changed()) {
|
||||||
builder.addCounter(info(), value);
|
builder.addCounter(info(), value());
|
||||||
clearChanged();
|
clearChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.metrics2.MetricsInfo;
|
import org.apache.hadoop.metrics2.MetricsInfo;
|
||||||
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mutable long counter
|
* A mutable long counter
|
||||||
*/
|
*/
|
||||||
|
@ -30,36 +32,35 @@ import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class MutableCounterLong extends MutableCounter {
|
public class MutableCounterLong extends MutableCounter {
|
||||||
|
|
||||||
private volatile long value;
|
private AtomicLong value = new AtomicLong();
|
||||||
|
|
||||||
MutableCounterLong(MetricsInfo info, long initValue) {
|
MutableCounterLong(MetricsInfo info, long initValue) {
|
||||||
super(info);
|
super(info);
|
||||||
this.value = initValue;
|
this.value.set(initValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void incr() {
|
public void incr() {
|
||||||
++value;
|
incr(1);
|
||||||
setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment the value by a delta
|
* Increment the value by a delta
|
||||||
* @param delta of the increment
|
* @param delta of the increment
|
||||||
*/
|
*/
|
||||||
public synchronized void incr(long delta) {
|
public void incr(long delta) {
|
||||||
value += delta;
|
value.addAndGet(delta);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long value() {
|
public long value() {
|
||||||
return value;
|
return value.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
||||||
if (all || changed()) {
|
if (all || changed()) {
|
||||||
builder.addCounter(info(), value);
|
builder.addCounter(info(), value());
|
||||||
clearChanged();
|
clearChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.metrics2.MetricsInfo;
|
import org.apache.hadoop.metrics2.MetricsInfo;
|
||||||
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mutable int gauge
|
* A mutable int gauge
|
||||||
*/
|
*/
|
||||||
|
@ -30,44 +32,42 @@ import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class MutableGaugeInt extends MutableGauge {
|
public class MutableGaugeInt extends MutableGauge {
|
||||||
|
|
||||||
private volatile int value;
|
private AtomicInteger value = new AtomicInteger();
|
||||||
|
|
||||||
MutableGaugeInt(MetricsInfo info, int initValue) {
|
MutableGaugeInt(MetricsInfo info, int initValue) {
|
||||||
super(info);
|
super(info);
|
||||||
this.value = initValue;
|
this.value.set(initValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int value() {
|
public int value() {
|
||||||
return value;
|
return value.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void incr() {
|
public void incr() {
|
||||||
++value;
|
incr(1);
|
||||||
setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment by delta
|
* Increment by delta
|
||||||
* @param delta of the increment
|
* @param delta of the increment
|
||||||
*/
|
*/
|
||||||
public synchronized void incr(int delta) {
|
public void incr(int delta) {
|
||||||
value += delta;
|
value.addAndGet(delta);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void decr() {
|
public void decr() {
|
||||||
--value;
|
decr(1);
|
||||||
setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* decrement by delta
|
* decrement by delta
|
||||||
* @param delta of the decrement
|
* @param delta of the decrement
|
||||||
*/
|
*/
|
||||||
public synchronized void decr(int delta) {
|
public void decr(int delta) {
|
||||||
value -= delta;
|
value.addAndGet(-delta);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,14 +76,14 @@ public class MutableGaugeInt extends MutableGauge {
|
||||||
* @param value to set
|
* @param value to set
|
||||||
*/
|
*/
|
||||||
public void set(int value) {
|
public void set(int value) {
|
||||||
this.value = value;
|
this.value.set(value);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
||||||
if (all || changed()) {
|
if (all || changed()) {
|
||||||
builder.addGauge(info(), value);
|
builder.addGauge(info(), value());
|
||||||
clearChanged();
|
clearChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.metrics2.MetricsInfo;
|
import org.apache.hadoop.metrics2.MetricsInfo;
|
||||||
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mutable long gauge
|
* A mutable long gauge
|
||||||
*/
|
*/
|
||||||
|
@ -30,44 +32,42 @@ import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class MutableGaugeLong extends MutableGauge {
|
public class MutableGaugeLong extends MutableGauge {
|
||||||
|
|
||||||
private volatile long value;
|
private AtomicLong value = new AtomicLong();
|
||||||
|
|
||||||
MutableGaugeLong(MetricsInfo info, long initValue) {
|
MutableGaugeLong(MetricsInfo info, long initValue) {
|
||||||
super(info);
|
super(info);
|
||||||
this.value = initValue;
|
this.value.set(initValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long value() {
|
public long value() {
|
||||||
return value;
|
return value.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void incr() {
|
public void incr() {
|
||||||
++value;
|
incr(1);
|
||||||
setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment by delta
|
* Increment by delta
|
||||||
* @param delta of the increment
|
* @param delta of the increment
|
||||||
*/
|
*/
|
||||||
public synchronized void incr(long delta) {
|
public void incr(long delta) {
|
||||||
value += delta;
|
value.addAndGet(delta);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void decr() {
|
public void decr() {
|
||||||
--value;
|
decr(1);
|
||||||
setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* decrement by delta
|
* decrement by delta
|
||||||
* @param delta of the decrement
|
* @param delta of the decrement
|
||||||
*/
|
*/
|
||||||
public synchronized void decr(long delta) {
|
public void decr(long delta) {
|
||||||
value -= delta;
|
value.addAndGet(-delta);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,14 +76,14 @@ public class MutableGaugeLong extends MutableGauge {
|
||||||
* @param value to set
|
* @param value to set
|
||||||
*/
|
*/
|
||||||
public void set(long value) {
|
public void set(long value) {
|
||||||
this.value = value;
|
this.value.set(value);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
||||||
if (all || changed()) {
|
if (all || changed()) {
|
||||||
builder.addGauge(info(), value);
|
builder.addGauge(info(), value());
|
||||||
clearChanged();
|
clearChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ public class NetUtils {
|
||||||
if (fqHost == null) {
|
if (fqHost == null) {
|
||||||
try {
|
try {
|
||||||
fqHost = SecurityUtil.getByName(host).getHostName();
|
fqHost = SecurityUtil.getByName(host).getHostName();
|
||||||
// slight race condition, but won't hurt
|
// slight race condition, but won't hurt
|
||||||
canonicalizedHostCache.put(host, fqHost);
|
canonicalizedHostCache.put(host, fqHost);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
fqHost = host;
|
fqHost = host;
|
||||||
|
|
|
@ -171,8 +171,7 @@ public class ScriptBasedMappingWithDependency extends ScriptBasedMapping
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + ", " + dependencyScriptName != null ?
|
return "dependency script " + dependencyScriptName;
|
||||||
("dependency script " + dependencyScriptName) : NO_SCRIPT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,10 +367,8 @@ public class LdapGroupsMapping
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader reader = null;
|
try (Reader reader = new FileReader(pwFile)) {
|
||||||
try {
|
|
||||||
StringBuilder password = new StringBuilder();
|
StringBuilder password = new StringBuilder();
|
||||||
reader = new FileReader(pwFile);
|
|
||||||
int c = reader.read();
|
int c = reader.read();
|
||||||
while (c > -1) {
|
while (c > -1) {
|
||||||
password.append((char)c);
|
password.append((char)c);
|
||||||
|
@ -379,8 +377,6 @@ public class LdapGroupsMapping
|
||||||
return password.toString().trim();
|
return password.toString().trim();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new RuntimeException("Could not read password file: " + pwFile, ioe);
|
throw new RuntimeException("Could not read password file: " + pwFile, ioe);
|
||||||
} finally {
|
|
||||||
IOUtils.cleanup(LOG, reader);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,6 +195,8 @@ public class ComparableVersion
|
||||||
case 'm':
|
case 'm':
|
||||||
value = "milestone";
|
value = "milestone";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.value = ALIASES.getProperty( value , value );
|
this.value = ALIASES.getProperty( value , value );
|
||||||
|
|
|
@ -34,16 +34,13 @@ public class PrintJarMainClass {
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try (JarFile jar_file = new JarFile(args[0])) {
|
||||||
JarFile jar_file = new JarFile(args[0]);
|
Manifest manifest = jar_file.getManifest();
|
||||||
if (jar_file != null) {
|
if (manifest != null) {
|
||||||
Manifest manifest = jar_file.getManifest();
|
String value = manifest.getMainAttributes().getValue("Main-Class");
|
||||||
if (manifest != null) {
|
if (value != null) {
|
||||||
String value = manifest.getMainAttributes().getValue("Main-Class");
|
System.out.println(value.replaceAll("/", "."));
|
||||||
if (value != null) {
|
return;
|
||||||
System.out.println(value.replaceAll("/", "."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
|
@ -70,14 +70,14 @@ public class ServletUtil {
|
||||||
throw new IOException("Invalid request has no " + param + " parameter");
|
throw new IOException("Invalid request has no " + param + " parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Long.valueOf(paramStr);
|
return Long.parseLong(paramStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String HTML_TAIL = "<hr />\n"
|
public static final String HTML_TAIL = "<hr />\n"
|
||||||
+ "<a href='http://hadoop.apache.org/core'>Hadoop</a>, "
|
+ "<a href='http://hadoop.apache.org/core'>Hadoop</a>, "
|
||||||
+ Calendar.getInstance().get(Calendar.YEAR) + ".\n"
|
+ Calendar.getInstance().get(Calendar.YEAR) + ".\n"
|
||||||
+ "</body></html>";
|
+ "</body></html>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML footer to be added in the jsps.
|
* HTML footer to be added in the jsps.
|
||||||
* @return the HTML footer.
|
* @return the HTML footer.
|
||||||
|
|
Loading…
Reference in New Issue