|
@@ -2808,7 +2808,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
* @param src the path of the file to start lease recovery
|
|
* @param src the path of the file to start lease recovery
|
|
* @param holder the lease holder's name
|
|
* @param holder the lease holder's name
|
|
* @param clientMachine the client machine's name
|
|
* @param clientMachine the client machine's name
|
|
- * @return true if the file is already closed
|
|
|
|
|
|
+ * @return true if the file is already closed or
|
|
|
|
+ * if the lease can be released and the file can be closed.
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
boolean recoverLease(String src, String holder, String clientMachine)
|
|
boolean recoverLease(String src, String holder, String clientMachine)
|
|
@@ -2835,7 +2836,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
dir.checkPathAccess(pc, iip, FsAction.WRITE);
|
|
dir.checkPathAccess(pc, iip, FsAction.WRITE);
|
|
}
|
|
}
|
|
|
|
|
|
- recoverLeaseInternal(RecoverLeaseOp.RECOVER_LEASE,
|
|
|
|
|
|
+ return recoverLeaseInternal(RecoverLeaseOp.RECOVER_LEASE,
|
|
iip, src, holder, clientMachine, true);
|
|
iip, src, holder, clientMachine, true);
|
|
} catch (StandbyException se) {
|
|
} catch (StandbyException se) {
|
|
skipSync = true;
|
|
skipSync = true;
|
|
@@ -2848,7 +2849,6 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
getEditLog().logSync();
|
|
getEditLog().logSync();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private enum RecoverLeaseOp {
|
|
private enum RecoverLeaseOp {
|
|
@@ -2864,12 +2864,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void recoverLeaseInternal(RecoverLeaseOp op, INodesInPath iip,
|
|
|
|
|
|
+ boolean recoverLeaseInternal(RecoverLeaseOp op, INodesInPath iip,
|
|
String src, String holder, String clientMachine, boolean force)
|
|
String src, String holder, String clientMachine, boolean force)
|
|
throws IOException {
|
|
throws IOException {
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
INodeFile file = iip.getLastINode().asFile();
|
|
INodeFile file = iip.getLastINode().asFile();
|
|
- if (file != null && file.isUnderConstruction()) {
|
|
|
|
|
|
+ if (file.isUnderConstruction()) {
|
|
//
|
|
//
|
|
// If the file is under construction , then it must be in our
|
|
// If the file is under construction , then it must be in our
|
|
// leases. Find the appropriate lease record.
|
|
// leases. Find the appropriate lease record.
|
|
@@ -2902,7 +2902,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
// close only the file src
|
|
// close only the file src
|
|
LOG.info("recoverLease: " + lease + ", src=" + src +
|
|
LOG.info("recoverLease: " + lease + ", src=" + src +
|
|
" from client " + clientName);
|
|
" from client " + clientName);
|
|
- internalReleaseLease(lease, src, iip, holder);
|
|
|
|
|
|
+ return internalReleaseLease(lease, src, iip, holder);
|
|
} else {
|
|
} else {
|
|
assert lease.getHolder().equals(clientName) :
|
|
assert lease.getHolder().equals(clientName) :
|
|
"Current lease holder " + lease.getHolder() +
|
|
"Current lease holder " + lease.getHolder() +
|
|
@@ -2914,11 +2914,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
if (lease.expiredSoftLimit()) {
|
|
if (lease.expiredSoftLimit()) {
|
|
LOG.info("startFile: recover " + lease + ", src=" + src + " client "
|
|
LOG.info("startFile: recover " + lease + ", src=" + src + " client "
|
|
+ clientName);
|
|
+ clientName);
|
|
- boolean isClosed = internalReleaseLease(lease, src, iip, null);
|
|
|
|
- if(!isClosed)
|
|
|
|
|
|
+ if (internalReleaseLease(lease, src, iip, null)) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
throw new RecoveryInProgressException(
|
|
throw new RecoveryInProgressException(
|
|
op.getExceptionMessage(src, holder, clientMachine,
|
|
op.getExceptionMessage(src, holder, clientMachine,
|
|
"lease recovery is in progress. Try again later."));
|
|
"lease recovery is in progress. Try again later."));
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
final BlockInfoContiguous lastBlock = file.getLastBlock();
|
|
final BlockInfoContiguous lastBlock = file.getLastBlock();
|
|
if (lastBlock != null
|
|
if (lastBlock != null
|
|
@@ -2935,7 +2937,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|