[GitHub] [hbase] ndimiduk commented on a change in pull request #1791: HBASE-23202 ExportSnapshot (import) will fail if copying files to roo…

2020-06-09 Thread GitBox


ndimiduk commented on a change in pull request #1791:
URL: https://github.com/apache/hbase/pull/1791#discussion_r437717024



##
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCacheWithDifferentWorkingDir.java
##
@@ -0,0 +1,64 @@
+/**
+ * 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.hbase.master.snapshot;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.UUID;
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Test that we correctly reload the cache, filter directories, etc.
+ * while the temporary directory is on a different file system than the root 
directory
+ */
+@Category({MasterTests.class, LargeTests.class})
+public class TestSnapshotFileCacheWithDifferentWorkingDir extends 
TestSnapshotFileCache {

Review comment:
   Yep, no problem. Thanks for addressing my other concerns :)





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:
us...@infra.apache.org




[GitHub] [hbase] ndimiduk commented on a change in pull request #1791: HBASE-23202 ExportSnapshot (import) will fail if copying files to roo…

2020-06-04 Thread GitBox


ndimiduk commented on a change in pull request #1791:
URL: https://github.com/apache/hbase/pull/1791#discussion_r435577323



##
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java
##
@@ -85,32 +106,34 @@ public void cleanupFiles() throws Exception {
 
   @Test
   public void testLoadAndDelete() throws IOException {
-SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, PERIOD, 
1000,
-"test-snapshot-file-cache-refresh", new SnapshotFiles());
+SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, workingFs, 
workingDir, PERIOD,
+  1000, "test-snapshot-file-cache-refresh", new SnapshotFiles());
 
 createAndTestSnapshotV1(cache, "snapshot1a", false, true, false);
+createAndTestSnapshotV1(cache, "snapshot1b", true, true, false);
 
 createAndTestSnapshotV2(cache, "snapshot2a", false, true, false);
+createAndTestSnapshotV2(cache, "snapshot2b", true, true, false);
   }
 
   @Test
   public void testReloadModifiedDirectory() throws IOException {
-SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, PERIOD, 
1000,
-"test-snapshot-file-cache-refresh", new SnapshotFiles());
+SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, workingFs, 
workingDir, PERIOD,
+  1000, "test-snapshot-file-cache-refresh", new SnapshotFiles());
 
-createAndTestSnapshotV1(cache, "snapshot1", false, true, false);
+createAndTestSnapshotV1(cache, "snapshot1v1", false, true, false);
 // now delete the snapshot and add a file with a different name
-createAndTestSnapshotV1(cache, "snapshot1", false, false, false);
+createAndTestSnapshotV1(cache, "snapshot1v2", false, false, false);

Review comment:
   I missed the reason for changing this test parameter. By the comment 
there between method invocations, it seems repetition of the name, a.k.a, the 
directory, "snapshot1" was intentional. Why have two different parameters? 
Doesn't that negate the purpose of this test?

##
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCacheWithDifferentWorkingDir.java
##
@@ -0,0 +1,64 @@
+/**
+ * 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.hbase.master.snapshot;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.UUID;
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Test that we correctly reload the cache, filter directories, etc.
+ * while the temporary directory is on a different file system than the root 
directory
+ */
+@Category({MasterTests.class, LargeTests.class})
+public class TestSnapshotFileCacheWithDifferentWorkingDir extends 
TestSnapshotFileCache {
+
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+
HBaseClassTestRule.forClass(TestSnapshotFileCacheWithDifferentWorkingDir.class);
+
+  protected static String TEMP_DIR =
+Paths.get("").toAbsolutePath().toString() + Path.SEPARATOR + 
UUID.randomUUID().toString();

Review comment:
   nit: you're mixing `java.nio` and Hadoop APIs for building this path. 
I'm not quite sure, but maybe you want something like `Paths.get(".", 
UUID.randomUUID().toString()).toAbsolutePath().toString()`? I'm not sure where 
`Paths.get("")` would drop you, but I assume it's the same as `pwd`.

##
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCacheWithDifferentWorkingDir.java
##
@@ -0,0 +1,64 @@
+/**
+ * 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 

[GitHub] [hbase] ndimiduk commented on a change in pull request #1791: HBASE-23202 ExportSnapshot (import) will fail if copying files to roo…

2020-05-27 Thread GitBox


ndimiduk commented on a change in pull request #1791:
URL: https://github.com/apache/hbase/pull/1791#discussion_r431486691



##
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotFileCache.java
##
@@ -251,6 +260,25 @@ private void refreshCache() throws IOException {
 this.snapshots.putAll(newSnapshots);
   }
 
+  @VisibleForTesting
+  List getSnapshotsInProgress() throws IOException {
+List snapshotInProgress = Lists.newArrayList();
+// only add those files to the cache, but not to the known snapshots
+FileStatus[] snapshotsInProgress = CommonFSUtils.listStatus(fs,
+  new Path(snapshotDir, SnapshotDescriptionUtils.SNAPSHOT_TMP_DIR_NAME));
+
+if (!ArrayUtils.isEmpty(snapshotsInProgress)) {
+  for (FileStatus snapshot : snapshotsInProgress) {
+try {
+  
snapshotInProgress.addAll(fileInspector.filesUnderSnapshot(snapshot.getPath()));
+} catch (CorruptedSnapshotException cse) {
+  LOG.debug("Corrupted in-progress snapshot file exception, ignored.", 
cse);

Review comment:
   `CorruptedSnapshotException` contains a copy of `SnapshotDescription`. 
Where this is logged, instead of logging the exception, it can grab the snaps 
tho info out of the description field to build a more meaningful log message.
   
   I don't know about the log level. I guess it depends on if you think this is 
a really severe problem or not. If not, `debug` is fine. If it's the only sign 
an operator has of a bad problem, or it should be `info` or `warn`.





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:
us...@infra.apache.org




[GitHub] [hbase] ndimiduk commented on a change in pull request #1791: HBASE-23202 ExportSnapshot (import) will fail if copying files to roo…

2020-05-27 Thread GitBox


ndimiduk commented on a change in pull request #1791:
URL: https://github.com/apache/hbase/pull/1791#discussion_r431403678



##
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotFileCache.java
##
@@ -251,6 +260,25 @@ private void refreshCache() throws IOException {
 this.snapshots.putAll(newSnapshots);
   }
 
+  @VisibleForTesting
+  List getSnapshotsInProgress() throws IOException {
+List snapshotInProgress = Lists.newArrayList();
+// only add those files to the cache, but not to the known snapshots
+FileStatus[] snapshotsInProgress = CommonFSUtils.listStatus(fs,
+  new Path(snapshotDir, SnapshotDescriptionUtils.SNAPSHOT_TMP_DIR_NAME));
+
+if (!ArrayUtils.isEmpty(snapshotsInProgress)) {
+  for (FileStatus snapshot : snapshotsInProgress) {
+try {
+  
snapshotInProgress.addAll(fileInspector.filesUnderSnapshot(snapshot.getPath()));
+} catch (CorruptedSnapshotException cse) {
+  LOG.debug("Corrupted in-progress snapshot file exception, ignored.", 
cse);

Review comment:
   Could this be handled better? It seems that in the event of an 
exception, the entirety of the in-progress snapshot would excluded.
   
   Logging the exception doesn't tell us anything useful because the 
`SnapshotDescription` isn't party to the message. Maybe we should log the 
snapshot name and table name. At WARN level?





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:
us...@infra.apache.org