|
@@ -1545,8 +1545,9 @@ public class DataNode extends Configured
|
|
|
|
|
|
/** Recover a block */
|
|
|
private LocatedBlock recoverBlock(Block block, boolean keepLength,
|
|
|
- DatanodeID[] datanodeids, boolean closeFile) throws IOException {
|
|
|
+ DatanodeInfo[] targets, boolean closeFile) throws IOException {
|
|
|
|
|
|
+ DatanodeID[] datanodeids = (DatanodeID[])targets;
|
|
|
// If the block is already being recovered, then skip recovering it.
|
|
|
// This can happen if the namenode and client start recovering the same
|
|
|
// file at the same time.
|
|
@@ -1600,7 +1601,7 @@ public class DataNode extends Configured
|
|
|
if (!keepLength) {
|
|
|
block.setNumBytes(minlength);
|
|
|
}
|
|
|
- return syncBlock(block, syncList, closeFile);
|
|
|
+ return syncBlock(block, syncList, targets, closeFile);
|
|
|
} finally {
|
|
|
synchronized (ongoingRecovery) {
|
|
|
ongoingRecovery.remove(block);
|
|
@@ -1610,7 +1611,7 @@ public class DataNode extends Configured
|
|
|
|
|
|
/** Block synchronization */
|
|
|
private LocatedBlock syncBlock(Block block, List<BlockRecord> syncList,
|
|
|
- boolean closeFile) throws IOException {
|
|
|
+ DatanodeInfo[] targets, boolean closeFile) throws IOException {
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug("block=" + block + ", (length=" + block.getNumBytes()
|
|
|
+ "), syncList=" + syncList + ", closeFile=" + closeFile);
|
|
@@ -1621,7 +1622,13 @@ public class DataNode extends Configured
|
|
|
if (syncList.isEmpty()) {
|
|
|
namenode.commitBlockSynchronization(block, 0, 0, closeFile, true,
|
|
|
DatanodeID.EMPTY_ARRAY);
|
|
|
- return null;
|
|
|
+ //always return a new access token even if everything else stays the same
|
|
|
+ LocatedBlock b = new LocatedBlock(block, targets);
|
|
|
+ if (isAccessTokenEnabled) {
|
|
|
+ b.setAccessToken(accessTokenHandler.generateToken(null, b.getBlock()
|
|
|
+ .getBlockId(), EnumSet.of(AccessTokenHandler.AccessMode.WRITE)));
|
|
|
+ }
|
|
|
+ return b;
|
|
|
}
|
|
|
|
|
|
List<DatanodeID> successList = new ArrayList<DatanodeID>();
|
|
@@ -1649,7 +1656,14 @@ public class DataNode extends Configured
|
|
|
for (int i = 0; i < nlist.length; i++) {
|
|
|
info[i] = new DatanodeInfo(nlist[i]);
|
|
|
}
|
|
|
- return new LocatedBlock(newblock, info); // success
|
|
|
+ LocatedBlock b = new LocatedBlock(newblock, info); // success
|
|
|
+ // should have used client ID to generate access token, but since
|
|
|
+ // owner ID is not checked, we simply pass null for now.
|
|
|
+ if (isAccessTokenEnabled) {
|
|
|
+ b.setAccessToken(accessTokenHandler.generateToken(null, b.getBlock()
|
|
|
+ .getBlockId(), EnumSet.of(AccessTokenHandler.AccessMode.WRITE)));
|
|
|
+ }
|
|
|
+ return b;
|
|
|
}
|
|
|
|
|
|
//failed
|