HDFS-2564. Cleanup unnecessary exceptions thrown and unnecessary casts. Contributed by Hari Mankude
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1203950 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1f92266516
commit
b7cd8c0f86
@ -52,6 +52,8 @@ Trunk (unreleased changes)
|
|||||||
|
|
||||||
HDFS-2334. Add Closeable to JournalManager. (Ivan Kelly via jitendra)
|
HDFS-2334. Add Closeable to JournalManager. (Ivan Kelly via jitendra)
|
||||||
|
|
||||||
|
HDFS-2564. Cleanup unnecessary exceptions thrown and unnecessary casts.
|
||||||
|
(Hari Mankude via eli)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
HDFS-2477. Optimize computing the diff between a block report and the
|
HDFS-2477. Optimize computing the diff between a block report and the
|
||||||
|
@ -543,7 +543,7 @@ public synchronized int read(byte buf[], int off, int len) throws IOException {
|
|||||||
if (pos > blockEnd) {
|
if (pos > blockEnd) {
|
||||||
currentNode = blockSeekTo(pos);
|
currentNode = blockSeekTo(pos);
|
||||||
}
|
}
|
||||||
int realLen = (int) Math.min((long) len, (blockEnd - pos + 1L));
|
int realLen = (int) Math.min(len, (blockEnd - pos + 1L));
|
||||||
int result = readBuffer(buf, off, realLen, corruptedBlockMap);
|
int result = readBuffer(buf, off, realLen, corruptedBlockMap);
|
||||||
|
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
|
@ -239,8 +239,7 @@ public class DataNode extends Configured
|
|||||||
* Use {@link NetUtils#createSocketAddr(String)} instead.
|
* Use {@link NetUtils#createSocketAddr(String)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static InetSocketAddress createSocketAddr(String target
|
public static InetSocketAddress createSocketAddr(String target) {
|
||||||
) throws IOException {
|
|
||||||
return NetUtils.createSocketAddr(target);
|
return NetUtils.createSocketAddr(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,14 +333,14 @@ public Object run() throws Exception {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void joinAll() throws InterruptedException {
|
void joinAll() {
|
||||||
for (BPOfferService bpos: this.getAllNamenodeThreads()) {
|
for (BPOfferService bpos: this.getAllNamenodeThreads()) {
|
||||||
bpos.join();
|
bpos.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void refreshNamenodes(Configuration conf)
|
void refreshNamenodes(Configuration conf)
|
||||||
throws IOException, InterruptedException {
|
throws IOException {
|
||||||
LOG.info("Refresh request received for nameservices: "
|
LOG.info("Refresh request received for nameservices: "
|
||||||
+ conf.get(DFS_FEDERATION_NAMESERVICES));
|
+ conf.get(DFS_FEDERATION_NAMESERVICES));
|
||||||
List<InetSocketAddress> newAddresses =
|
List<InetSocketAddress> newAddresses =
|
||||||
@ -859,8 +858,7 @@ private void checkNNVersion(NamespaceInfo nsInfo)
|
|||||||
|
|
||||||
private void connectToNNAndHandshake() throws IOException {
|
private void connectToNNAndHandshake() throws IOException {
|
||||||
// get NN proxy
|
// get NN proxy
|
||||||
bpNamenode =
|
bpNamenode = (DatanodeProtocol)RPC.waitForProxy(DatanodeProtocol.class,
|
||||||
(DatanodeProtocol)RPC.waitForProxy(DatanodeProtocol.class,
|
|
||||||
DatanodeProtocol.versionID, nnAddr, dn.getConf());
|
DatanodeProtocol.versionID, nnAddr, dn.getConf());
|
||||||
|
|
||||||
// First phase of the handshake with NN - get the namespace
|
// First phase of the handshake with NN - get the namespace
|
||||||
@ -2120,7 +2118,7 @@ private class DataTransfer implements Runnable {
|
|||||||
* entire target list, the block, and the data.
|
* entire target list, the block, and the data.
|
||||||
*/
|
*/
|
||||||
DataTransfer(DatanodeInfo targets[], ExtendedBlock b, BlockConstructionStage stage,
|
DataTransfer(DatanodeInfo targets[], ExtendedBlock b, BlockConstructionStage stage,
|
||||||
final String clientname) throws IOException {
|
final String clientname) {
|
||||||
if (DataTransferProtocol.LOG.isDebugEnabled()) {
|
if (DataTransferProtocol.LOG.isDebugEnabled()) {
|
||||||
DataTransferProtocol.LOG.debug(getClass().getSimpleName() + ": "
|
DataTransferProtocol.LOG.debug(getClass().getSimpleName() + ": "
|
||||||
+ b + " (numBytes=" + b.getNumBytes() + ")"
|
+ b + " (numBytes=" + b.getNumBytes() + ")"
|
||||||
@ -2896,13 +2894,7 @@ public synchronized String getClusterId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshNamenodes(Configuration conf) throws IOException {
|
public void refreshNamenodes(Configuration conf) throws IOException {
|
||||||
try {
|
|
||||||
blockPoolManager.refreshNamenodes(conf);
|
blockPoolManager.refreshNamenodes(conf);
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
IOException eio = new IOException();
|
|
||||||
eio.initCause(ex);
|
|
||||||
throw eio;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override //ClientDatanodeProtocol
|
@Override //ClientDatanodeProtocol
|
||||||
|
@ -459,7 +459,7 @@ private long validateIntegrity(File blockFile, long genStamp) {
|
|||||||
long metaFileLen = metaFile.length();
|
long metaFileLen = metaFile.length();
|
||||||
int crcHeaderLen = DataChecksum.getChecksumHeaderSize();
|
int crcHeaderLen = DataChecksum.getChecksumHeaderSize();
|
||||||
if (!blockFile.exists() || blockFileLen == 0 ||
|
if (!blockFile.exists() || blockFileLen == 0 ||
|
||||||
!metaFile.exists() || metaFileLen < (long)crcHeaderLen) {
|
!metaFile.exists() || metaFileLen < crcHeaderLen) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
checksumIn = new DataInputStream(
|
checksumIn = new DataInputStream(
|
||||||
@ -578,7 +578,7 @@ long getBlockPoolUsed(String bpid) throws IOException {
|
|||||||
* reserved capacity.
|
* reserved capacity.
|
||||||
* @return the unreserved number of bytes left in this filesystem. May be zero.
|
* @return the unreserved number of bytes left in this filesystem. May be zero.
|
||||||
*/
|
*/
|
||||||
long getCapacity() throws IOException {
|
long getCapacity() {
|
||||||
long remaining = usage.getCapacity() - reserved;
|
long remaining = usage.getCapacity() - reserved;
|
||||||
return remaining > 0 ? remaining : 0;
|
return remaining > 0 ? remaining : 0;
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ private long getBlockPoolUsed(String bpid) throws IOException {
|
|||||||
return dfsUsed;
|
return dfsUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getCapacity() throws IOException {
|
private long getCapacity() {
|
||||||
long capacity = 0L;
|
long capacity = 0L;
|
||||||
for (FSVolume vol : volumes) {
|
for (FSVolume vol : volumes) {
|
||||||
capacity += vol.getCapacity();
|
capacity += vol.getCapacity();
|
||||||
@ -1667,7 +1667,7 @@ private void bumpReplicaGS(ReplicaInfo replicaInfo,
|
|||||||
}
|
}
|
||||||
if (!oldmeta.renameTo(newmeta)) {
|
if (!oldmeta.renameTo(newmeta)) {
|
||||||
replicaInfo.setGenerationStamp(oldGS); // restore old GS
|
replicaInfo.setGenerationStamp(oldGS); // restore old GS
|
||||||
throw new IOException("Block " + (Block)replicaInfo + " reopen failed. " +
|
throw new IOException("Block " + replicaInfo + " reopen failed. " +
|
||||||
" Unable to move meta file " + oldmeta +
|
" Unable to move meta file " + oldmeta +
|
||||||
" to " + newmeta);
|
" to " + newmeta);
|
||||||
}
|
}
|
||||||
@ -2018,7 +2018,7 @@ private boolean isValid(final ExtendedBlock b, final ReplicaState state) {
|
|||||||
/**
|
/**
|
||||||
* Find the file corresponding to the block and return it if it exists.
|
* Find the file corresponding to the block and return it if it exists.
|
||||||
*/
|
*/
|
||||||
File validateBlockFile(String bpid, Block b) throws IOException {
|
File validateBlockFile(String bpid, Block b) {
|
||||||
//Should we check for metadata file too?
|
//Should we check for metadata file too?
|
||||||
File f = getFile(bpid, b);
|
File f = getFile(bpid, b);
|
||||||
|
|
||||||
@ -2327,7 +2327,7 @@ public void checkAndUpdate(String bpid, long blockId, File diskFile,
|
|||||||
if (datanode.blockScanner != null) {
|
if (datanode.blockScanner != null) {
|
||||||
datanode.blockScanner.addBlock(new ExtendedBlock(bpid, diskBlockInfo));
|
datanode.blockScanner.addBlock(new ExtendedBlock(bpid, diskBlockInfo));
|
||||||
}
|
}
|
||||||
DataNode.LOG.warn("Added missing block to memory " + (Block)diskBlockInfo);
|
DataNode.LOG.warn("Added missing block to memory " + diskBlockInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -2600,7 +2600,7 @@ public synchronized void shutdownBlockPool(String bpid) {
|
|||||||
* get list of all bpids
|
* get list of all bpids
|
||||||
* @return list of bpids
|
* @return list of bpids
|
||||||
*/
|
*/
|
||||||
public String [] getBPIdlist() throws IOException {
|
public String [] getBPIdlist() {
|
||||||
return volumeMap.getBlockPoolList();
|
return volumeMap.getBlockPoolList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,7 +1421,7 @@ LocatedBlock appendFile(String src, String holder, String clientMachine)
|
|||||||
try {
|
try {
|
||||||
lb = startFileInternal(src, null, holder, clientMachine,
|
lb = startFileInternal(src, null, holder, clientMachine,
|
||||||
EnumSet.of(CreateFlag.APPEND),
|
EnumSet.of(CreateFlag.APPEND),
|
||||||
false, blockManager.maxReplication, (long)0);
|
false, blockManager.maxReplication, 0);
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
@ -1504,7 +1504,7 @@ LocatedBlock getAdditionalBlock(String src,
|
|||||||
fileLength = pendingFile.computeContentSummary().getLength();
|
fileLength = pendingFile.computeContentSummary().getLength();
|
||||||
blockSize = pendingFile.getPreferredBlockSize();
|
blockSize = pendingFile.getPreferredBlockSize();
|
||||||
clientNode = pendingFile.getClientNode();
|
clientNode = pendingFile.getClientNode();
|
||||||
replication = (int)pendingFile.getReplication();
|
replication = pendingFile.getReplication();
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
@ -2214,6 +2214,7 @@ boolean internalReleaseLease(Lease lease, String src,
|
|||||||
// If the penultimate block is not COMPLETE, then it must be COMMITTED.
|
// If the penultimate block is not COMPLETE, then it must be COMMITTED.
|
||||||
if(nrCompleteBlocks < nrBlocks - 2 ||
|
if(nrCompleteBlocks < nrBlocks - 2 ||
|
||||||
nrCompleteBlocks == nrBlocks - 2 &&
|
nrCompleteBlocks == nrBlocks - 2 &&
|
||||||
|
curBlock != null &&
|
||||||
curBlock.getBlockUCState() != BlockUCState.COMMITTED) {
|
curBlock.getBlockUCState() != BlockUCState.COMMITTED) {
|
||||||
final String message = "DIR* NameSystem.internalReleaseLease: "
|
final String message = "DIR* NameSystem.internalReleaseLease: "
|
||||||
+ "attempt to release a create lock on "
|
+ "attempt to release a create lock on "
|
||||||
@ -2299,7 +2300,7 @@ private Lease reassignLease(Lease lease, String src, String newHolder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Lease reassignLeaseInternal(Lease lease, String src, String newHolder,
|
Lease reassignLeaseInternal(Lease lease, String src, String newHolder,
|
||||||
INodeFileUnderConstruction pendingFile) throws IOException {
|
INodeFileUnderConstruction pendingFile) {
|
||||||
assert hasWriteLock();
|
assert hasWriteLock();
|
||||||
pendingFile.setClientName(newHolder);
|
pendingFile.setClientName(newHolder);
|
||||||
return leaseManager.reassignLease(lease, src, newHolder);
|
return leaseManager.reassignLease(lease, src, newHolder);
|
||||||
@ -2402,7 +2403,7 @@ void commitBlockSynchronization(ExtendedBlock lastblock,
|
|||||||
newtargets[i]);
|
newtargets[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (closeFile) {
|
if ((closeFile) && (descriptors != null)) {
|
||||||
// the file is getting closed. Insert block locations into blockManager.
|
// the file is getting closed. Insert block locations into blockManager.
|
||||||
// Otherwise fsck will report these blocks as MISSING, especially if the
|
// Otherwise fsck will report these blocks as MISSING, especially if the
|
||||||
// blocksReceived from Datanodes take a long time to arrive.
|
// blocksReceived from Datanodes take a long time to arrive.
|
||||||
@ -3088,7 +3089,7 @@ private synchronized void setBlockTotal(int total) {
|
|||||||
this.blockTotal = total;
|
this.blockTotal = total;
|
||||||
this.blockThreshold = (int) (blockTotal * threshold);
|
this.blockThreshold = (int) (blockTotal * threshold);
|
||||||
this.blockReplQueueThreshold =
|
this.blockReplQueueThreshold =
|
||||||
(int) (((double) blockTotal) * replQueueThreshold);
|
(int) (blockTotal * replQueueThreshold);
|
||||||
checkMode();
|
checkMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3098,7 +3099,7 @@ private synchronized void setBlockTotal(int total) {
|
|||||||
* @param replication current replication
|
* @param replication current replication
|
||||||
*/
|
*/
|
||||||
private synchronized void incrementSafeBlockCount(short replication) {
|
private synchronized void incrementSafeBlockCount(short replication) {
|
||||||
if ((int)replication == safeReplication)
|
if (replication == safeReplication)
|
||||||
this.blockSafe++;
|
this.blockSafe++;
|
||||||
checkMode();
|
checkMode();
|
||||||
}
|
}
|
||||||
@ -3230,6 +3231,7 @@ public String toString() {
|
|||||||
/**
|
/**
|
||||||
* Checks consistency of the class state.
|
* Checks consistency of the class state.
|
||||||
* This is costly and currently called only in assert.
|
* This is costly and currently called only in assert.
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private boolean isConsistent() throws IOException {
|
private boolean isConsistent() throws IOException {
|
||||||
if (blockTotal == -1 && blockSafe == -1) {
|
if (blockTotal == -1 && blockSafe == -1) {
|
||||||
|
@ -262,7 +262,8 @@ protected InetSocketAddress getServiceRpcServerAddress(Configuration conf)
|
|||||||
return NameNode.getServiceAddress(conf, false);
|
return NameNode.getServiceAddress(conf, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InetSocketAddress getRpcServerAddress(Configuration conf) throws IOException {
|
protected InetSocketAddress getRpcServerAddress(Configuration conf)
|
||||||
|
throws IOException {
|
||||||
return getAddress(conf);
|
return getAddress(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user