You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2020/01/27 06:07:03 UTC
[GitHub] [hadoop] avijayanhwx opened a new pull request #1819: HDFS-14989.
Add a 'swapBlockList' operation to Namenode.
avijayanhwx opened a new pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819
This is the first patch HDFS-14989 for the In Place Erasure Coding Feature HDFS-14978.
Work Done
The swapBlockList takes two parameters, a source file and a destination file. This operation swaps the blocks belonging to the source and the destination atomically.
The namespace metadata of interest is the INodeFile class. A file (INodeFile) contains a header composed of PREFERRED_BLOCK_SIZE, BLOCK_LAYOUT_AND_REDUNDANCY and STORAGE_POLICY_ID. In addition, an INodeFile contains a list of blocks (BlockInfo[]). The operation will swap BLOCK_LAYOUT_AND_REDUNDANCY header bits and the block lists. But it will not touch other fields. To avoid complication, this operation will abort if either file is open (isUnderConstruction() == true)
Note : This patch is intentionally not exposing the client side API to use this operation. That will be handled in a separate JIRA where the client side API will involve using this operation to carry out EC conversion.
Added unit tests for the operation as well.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r372980350
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
+ fsd.writeLock();
+ try {
+ result = swapBlockList(fsd, srcIIP, dstIIP, genTimestamp);
+ } finally {
+ fsd.writeUnlock();
+ }
+ return result;
+ }
+
+ private static SwapBlockListResult swapBlockList(FSDirectory fsd,
+ final INodesInPath srcIIP,
+ final INodesInPath dstIIP,
+ long genTimestamp)
+ throws IOException {
+
+ assert fsd.hasWriteLock();
+ validateInode(srcIIP);
+ validateInode(dstIIP);
+ fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
+
+ final String src = srcIIP.getPath();
+ final String dst = dstIIP.getPath();
+ if (dst.equals(src)) {
+ throw new FileAlreadyExistsException("The source " + src +
+ " and destination " + dst + " are the same");
+ }
+
+ INodeFile srcINodeFile = (INodeFile) srcIIP.getLastINode();
+ INodeFile dstINodeFile = (INodeFile) dstIIP.getLastINode();
+
+ String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
+ String error = "Swap Block List destination file ";
+ BlockInfo lastBlock = dstINodeFile.getLastBlock();
+ if (lastBlock != null && lastBlock.getGenerationStamp() != genTimestamp) {
+ error += dstIIP.getPath() +
+ " has last block with different gen timestamp.";
+ NameNode.stateChangeLog.warn(errorPrefix + error);
+ throw new IOException(error);
+ }
+
+ long mtime = Time.now();
+ BlockInfo[] dstINodeFileBlocks = dstINodeFile.getBlocks();
+ dstINodeFile.replaceBlocks(srcINodeFile.getBlocks());
+ srcINodeFile.replaceBlocks(dstINodeFileBlocks);
Review comment:
I meant just refactor this too, srcINodeFile.getBlocks() as you did for dstINodeFile.getBlocks() into a variable, to match the code style with srcINodeFile.replaceBlocks(dstINodeFileBlocks);
Optional stuff, If you prefer to do. :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] hadoop-yetus commented on issue #1819: HDFS-14989. Add a
'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
hadoop-yetus commented on issue #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#issuecomment-578691591
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 30m 47s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | No case conflicting files found. |
| +1 :green_heart: | @author | 0m 0s | The patch does not contain any @author tags. |
| +1 :green_heart: | test4tests | 0m 0s | The patch appears to include 1 new or modified test files. |
||| _ HDFS-14978_ec_conversion Compile Tests _ |
| +0 :ok: | mvndep | 1m 8s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 21m 5s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | compile | 17m 45s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | checkstyle | 2m 55s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | mvnsite | 2m 43s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | shadedclient | 20m 48s | branch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 2m 55s | HDFS-14978_ec_conversion passed |
| +0 :ok: | spotbugs | 3m 6s | Used deprecated FindBugs config; considering switching to SpotBugs. |
| +1 :green_heart: | findbugs | 5m 8s | HDFS-14978_ec_conversion passed |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 20s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 1m 54s | the patch passed |
| +1 :green_heart: | compile | 17m 3s | the patch passed |
| +1 :green_heart: | javac | 17m 3s | the patch passed |
| +1 :green_heart: | checkstyle | 2m 51s | the patch passed |
| +1 :green_heart: | mvnsite | 2m 42s | the patch passed |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | shadedclient | 14m 0s | patch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 3m 1s | the patch passed |
| +1 :green_heart: | findbugs | 5m 39s | the patch passed |
||| _ Other Tests _ |
| +1 :green_heart: | unit | 9m 31s | hadoop-common in the patch passed. |
| -1 :x: | unit | 116m 15s | hadoop-hdfs in the patch failed. |
| +1 :green_heart: | asflicense | 0m 54s | The patch does not generate ASF License warnings. |
| | | 278m 35s | |
| Reason | Tests |
|-------:|:------|
| Failed junit tests | hadoop.hdfs.TestDeadNodeDetection |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | Client=19.03.5 Server=19.03.5 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/1/artifact/out/Dockerfile |
| GITHUB PR | https://github.com/apache/hadoop/pull/1819 |
| Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle |
| uname | Linux 05912709de22 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | personality/hadoop.sh |
| git revision | HDFS-14978_ec_conversion / 839e607 |
| Default Java | 1.8.0_232 |
| unit | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/1/artifact/out/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt |
| Test Results | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/1/testReport/ |
| Max. process+thread count | 2760 (vs. ulimit of 5500) |
| modules | C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs U: . |
| Console output | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/1/console |
| versions | git=2.7.4 maven=3.3.9 findbugs=3.1.0-RC1 |
| Powered by | Apache Yetus 0.11.1 https://yetus.apache.org |
This message was automatically generated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r373236453
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
##########
@@ -2667,4 +2667,15 @@ public Long getNextSPSPath() throws IOException {
}
return namesystem.getBlockManager().getSPSManager().getNextPathId();
}
+
+ public boolean swapBlockList(String src, String dst, long maxTimestamp)
+ throws IOException {
+ checkNNStartup();
+ if (stateChangeLog.isDebugEnabled()) {
+ stateChangeLog.debug("*DIR* NameNode.swapBlockList: {} and {}", src, dst);
+ }
+ namesystem.checkOperation(OperationCategory.WRITE);
Review comment:
Fixed this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r371323757
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
+ fsd.writeLock();
+ try {
+ result = swapBlockList(fsd, srcIIP, dstIIP, genTimestamp);
+ } finally {
+ fsd.writeUnlock();
+ }
+ return result;
+ }
+
+ private static SwapBlockListResult swapBlockList(FSDirectory fsd,
+ final INodesInPath srcIIP,
+ final INodesInPath dstIIP,
+ long genTimestamp)
+ throws IOException {
+
+ assert fsd.hasWriteLock();
+ validateInode(srcIIP);
+ validateInode(dstIIP);
+ fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
+
+ final String src = srcIIP.getPath();
+ final String dst = dstIIP.getPath();
+ if (dst.equals(src)) {
+ throw new FileAlreadyExistsException("The source " + src +
+ " and destination " + dst + " are the same");
+ }
+
+ INodeFile srcINodeFile = (INodeFile) srcIIP.getLastINode();
+ INodeFile dstINodeFile = (INodeFile) dstIIP.getLastINode();
+
+ String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
+ String error = "Swap Block List destination file ";
+ BlockInfo lastBlock = dstINodeFile.getLastBlock();
+ if (lastBlock != null && lastBlock.getGenerationStamp() != genTimestamp) {
+ error += dstIIP.getPath() +
+ " has last block with different gen timestamp.";
+ NameNode.stateChangeLog.warn(errorPrefix + error);
+ throw new IOException(error);
+ }
+
+ long mtime = Time.now();
+ BlockInfo[] dstINodeFileBlocks = dstINodeFile.getBlocks();
+ dstINodeFile.replaceBlocks(srcINodeFile.getBlocks());
+ srcINodeFile.replaceBlocks(dstINodeFileBlocks);
+
+ long srcHeader = srcINodeFile.getHeaderLong();
+ long dstHeader = dstINodeFile.getHeaderLong();
+
+ byte dstBlockLayoutPolicy =
+ HeaderFormat.getBlockLayoutPolicy(dstHeader);
+ byte srcBlockLayoutPolicy =
+ HeaderFormat.getBlockLayoutPolicy(srcHeader);
+
+ byte dstStoragePolicyID = HeaderFormat.getStoragePolicyID(dstHeader);
+ byte srcStoragePolicyID = HeaderFormat.getStoragePolicyID(srcHeader);
+
+ dstINodeFile.updateHeaderWithNewPolicy(srcBlockLayoutPolicy,
+ srcStoragePolicyID);
+ dstINodeFile.setModificationTime(mtime);
+
+ srcINodeFile.updateHeaderWithNewPolicy(dstBlockLayoutPolicy,
+ dstStoragePolicyID);
+ srcINodeFile.setModificationTime(mtime);
+
+ return new SwapBlockListResult(true,
+ fsd.getAuditFileInfo(srcIIP),
+ fsd.getAuditFileInfo(dstIIP));
+ }
+
+ private static void validateInode(INodesInPath srcIIP)
+ throws IOException {
+
+ String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
+ String error = "Swap Block List input ";
+ final INode srcInode = srcIIP.getLastINode();
+
+ // Check if INode is null.
+ if (srcInode == null) {
+ error += srcIIP.getPath() + " is not found.";
+ NameNode.stateChangeLog.warn(errorPrefix + error);
+ throw new FileNotFoundException(error);
+ }
Review comment:
Can use FsDirectory.resolveLastINode()
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r372649126
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
+ fsd.writeLock();
+ try {
+ result = swapBlockList(fsd, srcIIP, dstIIP, genTimestamp);
+ } finally {
+ fsd.writeUnlock();
+ }
+ return result;
+ }
+
+ private static SwapBlockListResult swapBlockList(FSDirectory fsd,
+ final INodesInPath srcIIP,
+ final INodesInPath dstIIP,
+ long genTimestamp)
+ throws IOException {
+
+ assert fsd.hasWriteLock();
+ validateInode(srcIIP);
+ validateInode(dstIIP);
+ fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
+
+ final String src = srcIIP.getPath();
+ final String dst = dstIIP.getPath();
+ if (dst.equals(src)) {
+ throw new FileAlreadyExistsException("The source " + src +
+ " and destination " + dst + " are the same");
+ }
+
+ INodeFile srcINodeFile = (INodeFile) srcIIP.getLastINode();
+ INodeFile dstINodeFile = (INodeFile) dstIIP.getLastINode();
+
+ String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
+ String error = "Swap Block List destination file ";
+ BlockInfo lastBlock = dstINodeFile.getLastBlock();
+ if (lastBlock != null && lastBlock.getGenerationStamp() != genTimestamp) {
+ error += dstIIP.getPath() +
+ " has last block with different gen timestamp.";
+ NameNode.stateChangeLog.warn(errorPrefix + error);
+ throw new IOException(error);
+ }
+
+ long mtime = Time.now();
+ BlockInfo[] dstINodeFileBlocks = dstINodeFile.getBlocks();
+ dstINodeFile.replaceBlocks(srcINodeFile.getBlocks());
+ srcINodeFile.replaceBlocks(dstINodeFileBlocks);
Review comment:
@ayushtkn I don't quite understand the issue here. I implemented a temp variable based swap mechanism. Could you explain it more?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r371322050
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
##########
@@ -2667,4 +2667,15 @@ public Long getNextSPSPath() throws IOException {
}
return namesystem.getBlockManager().getSPSManager().getNextPathId();
}
+
+ public boolean swapBlockList(String src, String dst, long maxTimestamp)
+ throws IOException {
+ checkNNStartup();
+ if (stateChangeLog.isDebugEnabled()) {
+ stateChangeLog.debug("*DIR* NameNode.swapBlockList: {} and {}", src, dst);
+ }
+ namesystem.checkOperation(OperationCategory.WRITE);
Review comment:
This isn't required, This would be redundant check, You are having the same check in FSNamesystem. Its required only twice, once before taking lock and once after...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r371334237
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
+ fsd.writeLock();
+ try {
+ result = swapBlockList(fsd, srcIIP, dstIIP, genTimestamp);
+ } finally {
+ fsd.writeUnlock();
+ }
+ return result;
+ }
+
+ private static SwapBlockListResult swapBlockList(FSDirectory fsd,
+ final INodesInPath srcIIP,
+ final INodesInPath dstIIP,
+ long genTimestamp)
+ throws IOException {
+
+ assert fsd.hasWriteLock();
+ validateInode(srcIIP);
+ validateInode(dstIIP);
+ fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
+
+ final String src = srcIIP.getPath();
+ final String dst = dstIIP.getPath();
+ if (dst.equals(src)) {
+ throw new FileAlreadyExistsException("The source " + src +
+ " and destination " + dst + " are the same");
+ }
+
+ INodeFile srcINodeFile = (INodeFile) srcIIP.getLastINode();
+ INodeFile dstINodeFile = (INodeFile) dstIIP.getLastINode();
+
+ String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
+ String error = "Swap Block List destination file ";
+ BlockInfo lastBlock = dstINodeFile.getLastBlock();
+ if (lastBlock != null && lastBlock.getGenerationStamp() != genTimestamp) {
+ error += dstIIP.getPath() +
+ " has last block with different gen timestamp.";
+ NameNode.stateChangeLog.warn(errorPrefix + error);
+ throw new IOException(error);
+ }
+
+ long mtime = Time.now();
+ BlockInfo[] dstINodeFileBlocks = dstINodeFile.getBlocks();
+ dstINodeFile.replaceBlocks(srcINodeFile.getBlocks());
+ srcINodeFile.replaceBlocks(dstINodeFileBlocks);
Review comment:
nit : Refactored dstInodeFIleBlocks and used only once, but didn't do for srcInodeFile. May be should keep same for both.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r373236481
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
Review comment:
Fixed this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r371324385
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
Review comment:
nit. My IDE complains that the null assignment is redundant. No need to assign null, it is already null.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r373236528
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
+ fsd.writeLock();
+ try {
+ result = swapBlockList(fsd, srcIIP, dstIIP, genTimestamp);
+ } finally {
+ fsd.writeUnlock();
+ }
+ return result;
+ }
+
+ private static SwapBlockListResult swapBlockList(FSDirectory fsd,
+ final INodesInPath srcIIP,
+ final INodesInPath dstIIP,
+ long genTimestamp)
+ throws IOException {
+
+ assert fsd.hasWriteLock();
+ validateInode(srcIIP);
+ validateInode(dstIIP);
+ fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
+
+ final String src = srcIIP.getPath();
+ final String dst = dstIIP.getPath();
+ if (dst.equals(src)) {
+ throw new FileAlreadyExistsException("The source " + src +
+ " and destination " + dst + " are the same");
+ }
+
+ INodeFile srcINodeFile = (INodeFile) srcIIP.getLastINode();
Review comment:
Fixed this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] hadoop-yetus commented on issue #1819: HDFS-14989. Add a
'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
hadoop-yetus commented on issue #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#issuecomment-580555055
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 34s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 0s | No case conflicting files found. |
| +1 :green_heart: | @author | 0m 0s | The patch does not contain any @author tags. |
| +1 :green_heart: | test4tests | 0m 0s | The patch appears to include 1 new or modified test files. |
||| _ HDFS-14978_ec_conversion Compile Tests _ |
| +0 :ok: | mvndep | 1m 7s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 18m 8s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | compile | 16m 46s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | checkstyle | 2m 40s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | mvnsite | 2m 47s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | shadedclient | 19m 34s | branch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 3m 5s | HDFS-14978_ec_conversion passed |
| +0 :ok: | spotbugs | 2m 59s | Used deprecated FindBugs config; considering switching to SpotBugs. |
| +1 :green_heart: | findbugs | 4m 58s | HDFS-14978_ec_conversion passed |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 24s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 1m 52s | the patch passed |
| +1 :green_heart: | compile | 15m 54s | the patch passed |
| +1 :green_heart: | javac | 15m 54s | the patch passed |
| +1 :green_heart: | checkstyle | 3m 30s | the patch passed |
| +1 :green_heart: | mvnsite | 2m 51s | the patch passed |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | shadedclient | 13m 26s | patch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 3m 7s | the patch passed |
| +1 :green_heart: | findbugs | 5m 19s | the patch passed |
||| _ Other Tests _ |
| +1 :green_heart: | unit | 9m 21s | hadoop-common in the patch passed. |
| -1 :x: | unit | 93m 54s | hadoop-hdfs in the patch failed. |
| +1 :green_heart: | asflicense | 1m 2s | The patch does not generate ASF License warnings. |
| | | 219m 48s | |
| Reason | Tests |
|-------:|:------|
| Failed junit tests | hadoop.hdfs.TestDecommissionWithBackoffMonitor |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | Client=19.03.5 Server=19.03.5 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/2/artifact/out/Dockerfile |
| GITHUB PR | https://github.com/apache/hadoop/pull/1819 |
| Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle |
| uname | Linux 92ad5cb4586f 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | personality/hadoop.sh |
| git revision | HDFS-14978_ec_conversion / 839e607 |
| Default Java | 1.8.0_232 |
| unit | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/2/artifact/out/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt |
| Test Results | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/2/testReport/ |
| Max. process+thread count | 4136 (vs. ulimit of 5500) |
| modules | C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs U: . |
| Console output | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/2/console |
| versions | git=2.7.4 maven=3.3.9 findbugs=3.1.0-RC1 |
| Powered by | Apache Yetus 0.11.1 https://yetus.apache.org |
This message was automatically generated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] hadoop-yetus commented on issue #1819: HDFS-14989. Add a
'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
hadoop-yetus commented on issue #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#issuecomment-580951570
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 46s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 0s | No case conflicting files found. |
| +1 :green_heart: | @author | 0m 0s | The patch does not contain any @author tags. |
| +1 :green_heart: | test4tests | 0m 0s | The patch appears to include 1 new or modified test files. |
||| _ HDFS-14978_ec_conversion Compile Tests _ |
| +0 :ok: | mvndep | 1m 13s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 23m 41s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | compile | 21m 43s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | checkstyle | 3m 25s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | mvnsite | 3m 15s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | shadedclient | 23m 42s | branch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 3m 12s | HDFS-14978_ec_conversion passed |
| +0 :ok: | spotbugs | 3m 33s | Used deprecated FindBugs config; considering switching to SpotBugs. |
| +1 :green_heart: | findbugs | 5m 55s | HDFS-14978_ec_conversion passed |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 26s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 2m 11s | the patch passed |
| -1 :x: | compile | 9m 32s | root in the patch failed. |
| -1 :x: | javac | 9m 32s | root in the patch failed. |
| +1 :green_heart: | checkstyle | 3m 14s | the patch passed |
| +1 :green_heart: | mvnsite | 2m 47s | the patch passed |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | shadedclient | 15m 38s | patch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 3m 2s | the patch passed |
| -1 :x: | findbugs | 0m 18s | hadoop-common in the patch failed. |
| -1 :x: | findbugs | 0m 34s | hadoop-hdfs in the patch failed. |
||| _ Other Tests _ |
| -1 :x: | unit | 0m 27s | hadoop-common in the patch failed. |
| -1 :x: | unit | 0m 17s | hadoop-hdfs in the patch failed. |
| +0 :ok: | asflicense | 0m 26s | ASF License check generated no output? |
| | | 123m 30s | |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | Client=19.03.5 Server=19.03.5 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/artifact/out/Dockerfile |
| GITHUB PR | https://github.com/apache/hadoop/pull/1819 |
| Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle |
| uname | Linux 24f7c44aa043 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | personality/hadoop.sh |
| git revision | HDFS-14978_ec_conversion / 839e607 |
| Default Java | 1.8.0_232 |
| compile | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/artifact/out/patch-compile-root.txt |
| javac | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/artifact/out/patch-compile-root.txt |
| findbugs | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/artifact/out/patch-findbugs-hadoop-common-project_hadoop-common.txt |
| findbugs | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/artifact/out/patch-findbugs-hadoop-hdfs-project_hadoop-hdfs.txt |
| unit | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/artifact/out/patch-unit-hadoop-common-project_hadoop-common.txt |
| unit | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/artifact/out/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt |
| Test Results | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/testReport/ |
| Max. process+thread count | 411 (vs. ulimit of 5500) |
| modules | C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs U: . |
| Console output | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/3/console |
| versions | git=2.7.4 maven=3.3.9 findbugs=3.1.0-RC1 |
| Powered by | Apache Yetus 0.11.1 https://yetus.apache.org |
This message was automatically generated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r373685220
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -130,15 +129,10 @@ private static void validateInode(INodesInPath srcIIP)
String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
String error = "Swap Block List input ";
- final INode srcInode = srcIIP.getLastINode();
- // Check if INode is null.
- if (srcInode == null) {
- error += srcIIP.getPath() + " is not found.";
- NameNode.stateChangeLog.warn(errorPrefix + error);
- throw new FileNotFoundException(error);
- }
+ FSDirectory.resolveLastINode(srcIIP);
+ final INode srcInode = srcIIP.getLastINode();
Review comment:
Thanks, good catch. Missed it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on issue #1819: HDFS-14989. Add a
'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on issue #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#issuecomment-582071905
Thank you for the review @ayushtkn.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r373237177
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
+ fsd.writeLock();
+ try {
+ result = swapBlockList(fsd, srcIIP, dstIIP, genTimestamp);
+ } finally {
+ fsd.writeUnlock();
+ }
+ return result;
+ }
+
+ private static SwapBlockListResult swapBlockList(FSDirectory fsd,
+ final INodesInPath srcIIP,
+ final INodesInPath dstIIP,
+ long genTimestamp)
+ throws IOException {
+
+ assert fsd.hasWriteLock();
+ validateInode(srcIIP);
+ validateInode(dstIIP);
+ fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
+
+ final String src = srcIIP.getPath();
+ final String dst = dstIIP.getPath();
+ if (dst.equals(src)) {
+ throw new FileAlreadyExistsException("The source " + src +
+ " and destination " + dst + " are the same");
+ }
+
+ INodeFile srcINodeFile = (INodeFile) srcIIP.getLastINode();
+ INodeFile dstINodeFile = (INodeFile) dstIIP.getLastINode();
+
+ String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
+ String error = "Swap Block List destination file ";
+ BlockInfo lastBlock = dstINodeFile.getLastBlock();
+ if (lastBlock != null && lastBlock.getGenerationStamp() != genTimestamp) {
+ error += dstIIP.getPath() +
+ " has last block with different gen timestamp.";
+ NameNode.stateChangeLog.warn(errorPrefix + error);
+ throw new IOException(error);
+ }
+
+ long mtime = Time.now();
+ BlockInfo[] dstINodeFileBlocks = dstINodeFile.getBlocks();
+ dstINodeFile.replaceBlocks(srcINodeFile.getBlocks());
+ srcINodeFile.replaceBlocks(dstINodeFileBlocks);
Review comment:
@ayushtkn I had to store dstINodeFile.getBlocks() into a variable because without that, after line 101, I would have lost the original dstINodeFile blocks. For scrInodeFile, I don't need that. So I left that out.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r371354584
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSwapBlockList.java
##########
@@ -0,0 +1,257 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.DFSTestUtil;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test SwapBlockListOp working.
+ */
+public class TestSwapBlockList {
+
+ private static final short REPLICATION = 3;
+
+ private static final long SEED = 0;
+ private final Path rootDir = new Path("/" + getClass().getSimpleName());
+
+ private final Path subDir1 = new Path(rootDir, "dir1");
+ private final Path file1 = new Path(subDir1, "file1");
+ private final Path file2 = new Path(subDir1, "file2");
+
+ private final Path subDir11 = new Path(subDir1, "dir11");
+ private final Path file3 = new Path(subDir11, "file3");
+
+ private final Path subDir2 = new Path(rootDir, "dir2");
+ private final Path file4 = new Path(subDir2, "file4");
+
+ private Configuration conf;
+ private MiniDFSCluster cluster;
+ private FSNamesystem fsn;
+ private FSDirectory fsdir;
+
+ private DistributedFileSystem hdfs;
+
+ @Before
+ public void setUp() throws Exception {
+ conf = new Configuration();
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAX_XATTRS_PER_INODE_KEY, 2);
+ cluster = new MiniDFSCluster.Builder(conf)
+ .numDataNodes(REPLICATION)
+ .build();
+ cluster.waitActive();
+
+ fsn = cluster.getNamesystem();
+ fsdir = fsn.getFSDirectory();
+
+ hdfs = cluster.getFileSystem();
+
+ hdfs.mkdirs(subDir2);
+
+ DFSTestUtil.createFile(hdfs, file1, 1024, REPLICATION, SEED);
+ DFSTestUtil.createFile(hdfs, file2, 1024, REPLICATION, SEED);
+ DFSTestUtil.createFile(hdfs, file3, 1024, REPLICATION, SEED);
+ DFSTestUtil.createFile(hdfs, file4, 1024, REPLICATION, SEED);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ }
+
+ @Test
+ public void testInputValidation() throws Exception {
+
+ // Source file not found.
+ try {
+ fsn.swapBlockList("/TestSwapBlockList/dir1/fileXYZ",
+ "/TestSwapBlockList/dir1/dir11/file3", 0L);
+ Assert.fail();
+ } catch (IOException ioEx) {
+ Assert.assertTrue(ioEx instanceof FileNotFoundException);
+ Assert.assertTrue(
+ ioEx.getMessage().contains("/TestSwapBlockList/dir1/fileXYZ"));
+ }
Review comment:
For the validations can use LambdaTestUtils, Like this
`
LambdaTestUtils.intercept(FileNotFoundException.class,
"/TestSwapBlockList/dir1/fileXYZ", () -> fsn
.swapBlockList("/TestSwapBlockList/dir1/fileXYZ",
"/TestSwapBlockList/dir1/dir11/file3", 0L));`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx merged pull request #1819: HDFS-14989. Add a
'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx merged pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] avijayanhwx commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
avijayanhwx commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r373236566
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSwapBlockList.java
##########
@@ -0,0 +1,257 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.DFSTestUtil;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test SwapBlockListOp working.
+ */
+public class TestSwapBlockList {
+
+ private static final short REPLICATION = 3;
+
+ private static final long SEED = 0;
+ private final Path rootDir = new Path("/" + getClass().getSimpleName());
+
+ private final Path subDir1 = new Path(rootDir, "dir1");
+ private final Path file1 = new Path(subDir1, "file1");
+ private final Path file2 = new Path(subDir1, "file2");
+
+ private final Path subDir11 = new Path(subDir1, "dir11");
+ private final Path file3 = new Path(subDir11, "file3");
+
+ private final Path subDir2 = new Path(rootDir, "dir2");
+ private final Path file4 = new Path(subDir2, "file4");
+
+ private Configuration conf;
+ private MiniDFSCluster cluster;
+ private FSNamesystem fsn;
+ private FSDirectory fsdir;
+
+ private DistributedFileSystem hdfs;
+
+ @Before
+ public void setUp() throws Exception {
+ conf = new Configuration();
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAX_XATTRS_PER_INODE_KEY, 2);
+ cluster = new MiniDFSCluster.Builder(conf)
+ .numDataNodes(REPLICATION)
+ .build();
+ cluster.waitActive();
+
+ fsn = cluster.getNamesystem();
+ fsdir = fsn.getFSDirectory();
+
+ hdfs = cluster.getFileSystem();
+
+ hdfs.mkdirs(subDir2);
+
+ DFSTestUtil.createFile(hdfs, file1, 1024, REPLICATION, SEED);
+ DFSTestUtil.createFile(hdfs, file2, 1024, REPLICATION, SEED);
+ DFSTestUtil.createFile(hdfs, file3, 1024, REPLICATION, SEED);
+ DFSTestUtil.createFile(hdfs, file4, 1024, REPLICATION, SEED);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ }
+
+ @Test
+ public void testInputValidation() throws Exception {
+
+ // Source file not found.
+ try {
+ fsn.swapBlockList("/TestSwapBlockList/dir1/fileXYZ",
+ "/TestSwapBlockList/dir1/dir11/file3", 0L);
+ Assert.fail();
+ } catch (IOException ioEx) {
+ Assert.assertTrue(ioEx instanceof FileNotFoundException);
+ Assert.assertTrue(
+ ioEx.getMessage().contains("/TestSwapBlockList/dir1/fileXYZ"));
+ }
Review comment:
Fixed this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r371331661
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.namenode;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile.HeaderFormat;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
+import org.apache.hadoop.util.Time;
+
+/**
+ * Class to carry out the operation of swapping blocks from one file to another.
+ * Along with swapping blocks, we can also optionally swap the block layout
+ * of a file header, which is useful for client operations like converting
+ * replicated to EC file.
+ */
+public final class SwapBlockListOp {
+
+ private SwapBlockListOp() {
+ }
+
+ static SwapBlockListResult swapBlocks(FSDirectory fsd, FSPermissionChecker pc,
+ String src, String dst, long genTimestamp)
+ throws IOException {
+
+ final INodesInPath srcIIP = fsd.resolvePath(pc, src, DirOp.WRITE);
+ final INodesInPath dstIIP = fsd.resolvePath(pc, dst, DirOp.WRITE);
+ if (fsd.isPermissionEnabled()) {
+ fsd.checkAncestorAccess(pc, srcIIP, FsAction.WRITE);
+ fsd.checkAncestorAccess(pc, dstIIP, FsAction.WRITE);
+ }
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
+ NameNode.stateChangeLog.debug("DIR* FSDirectory.swapBlockList: "
+ + srcIIP.getPath() + " and " + dstIIP.getPath());
+ }
+ SwapBlockListResult result = null;
+ fsd.writeLock();
+ try {
+ result = swapBlockList(fsd, srcIIP, dstIIP, genTimestamp);
+ } finally {
+ fsd.writeUnlock();
+ }
+ return result;
+ }
+
+ private static SwapBlockListResult swapBlockList(FSDirectory fsd,
+ final INodesInPath srcIIP,
+ final INodesInPath dstIIP,
+ long genTimestamp)
+ throws IOException {
+
+ assert fsd.hasWriteLock();
+ validateInode(srcIIP);
+ validateInode(dstIIP);
+ fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
+
+ final String src = srcIIP.getPath();
+ final String dst = dstIIP.getPath();
+ if (dst.equals(src)) {
+ throw new FileAlreadyExistsException("The source " + src +
+ " and destination " + dst + " are the same");
+ }
+
+ INodeFile srcINodeFile = (INodeFile) srcIIP.getLastINode();
Review comment:
Can use srcIIP.getLastINode().asFile(). Looks better. :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] hadoop-yetus commented on issue #1819: HDFS-14989. Add a
'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
hadoop-yetus commented on issue #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#issuecomment-581018534
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 32m 57s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | No case conflicting files found. |
| +1 :green_heart: | @author | 0m 0s | The patch does not contain any @author tags. |
| +1 :green_heart: | test4tests | 0m 0s | The patch appears to include 1 new or modified test files. |
||| _ HDFS-14978_ec_conversion Compile Tests _ |
| +0 :ok: | mvndep | 1m 8s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 20m 56s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | compile | 17m 41s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | checkstyle | 2m 54s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | mvnsite | 2m 37s | HDFS-14978_ec_conversion passed |
| +1 :green_heart: | shadedclient | 20m 42s | branch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 2m 53s | HDFS-14978_ec_conversion passed |
| +0 :ok: | spotbugs | 3m 1s | Used deprecated FindBugs config; considering switching to SpotBugs. |
| +1 :green_heart: | findbugs | 5m 1s | HDFS-14978_ec_conversion passed |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 20s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 1m 55s | the patch passed |
| +1 :green_heart: | compile | 19m 16s | the patch passed |
| +1 :green_heart: | javac | 19m 16s | the patch passed |
| +1 :green_heart: | checkstyle | 2m 51s | the patch passed |
| +1 :green_heart: | mvnsite | 2m 36s | the patch passed |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | shadedclient | 13m 59s | patch has no errors when building and testing our client artifacts. |
| +1 :green_heart: | javadoc | 2m 51s | the patch passed |
| +1 :green_heart: | findbugs | 5m 26s | the patch passed |
||| _ Other Tests _ |
| +1 :green_heart: | unit | 9m 27s | hadoop-common in the patch passed. |
| -1 :x: | unit | 113m 42s | hadoop-hdfs in the patch failed. |
| +1 :green_heart: | asflicense | 0m 52s | The patch does not generate ASF License warnings. |
| | | 279m 6s | |
| Reason | Tests |
|-------:|:------|
| Failed junit tests | hadoop.hdfs.server.namenode.TestAddOverReplicatedStripedBlocks |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | Client=19.03.5 Server=19.03.5 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/4/artifact/out/Dockerfile |
| GITHUB PR | https://github.com/apache/hadoop/pull/1819 |
| Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle |
| uname | Linux c66b3e70ecd9 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | personality/hadoop.sh |
| git revision | HDFS-14978_ec_conversion / 839e607 |
| Default Java | 1.8.0_242 |
| unit | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/4/artifact/out/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt |
| Test Results | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/4/testReport/ |
| Max. process+thread count | 3014 (vs. ulimit of 5500) |
| modules | C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs U: . |
| Console output | https://builds.apache.org/job/hadoop-multibranch/job/PR-1819/4/console |
| versions | git=2.7.4 maven=3.3.9 findbugs=3.1.0-RC1 |
| Powered by | Apache Yetus 0.11.1 https://yetus.apache.org |
This message was automatically generated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org
[GitHub] [hadoop] ayushtkn commented on a change in pull request #1819:
HDFS-14989. Add a 'swapBlockList' operation to Namenode.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on a change in pull request #1819: HDFS-14989. Add a 'swapBlockList' operation to Namenode.
URL: https://github.com/apache/hadoop/pull/1819#discussion_r373296427
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SwapBlockListOp.java
##########
@@ -130,15 +129,10 @@ private static void validateInode(INodesInPath srcIIP)
String errorPrefix = "DIR* FSDirectory.swapBlockList: ";
String error = "Swap Block List input ";
- final INode srcInode = srcIIP.getLastINode();
- // Check if INode is null.
- if (srcInode == null) {
- error += srcIIP.getPath() + " is not found.";
- NameNode.stateChangeLog.warn(errorPrefix + error);
- throw new FileNotFoundException(error);
- }
+ FSDirectory.resolveLastINode(srcIIP);
+ final INode srcInode = srcIIP.getLastINode();
Review comment:
Any reason for not assigning FSDirectory.resolveLastINode(srcIIP); to srcInode?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org