ctubbsii commented on code in PR #3436:
URL: https://github.com/apache/accumulo/pull/3436#discussion_r1212080076
##########
server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java:
##########
@@ -65,6 +65,8 @@ public class SimpleGarbageCollectorTest {
private SimpleGarbageCollector gc;
private ConfigurationCopy systemConfig;
private static SiteConfiguration siteConfig =
SiteConfiguration.empty().build();
+ @SuppressWarnings("removal")
+ private final Property p = Property.GC_TRASH_IGNORE;
Review Comment:
Can keep this name:
```suggestion
private final Property GC_TRASH_IGNORE = Property.GC_TRASH_IGNORE;
```
##########
server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java:
##########
@@ -97,7 +99,7 @@ private ConfigurationCopy createSystemConfig() {
conf.put(Property.GC_CYCLE_START.getKey(), "1");
conf.put(Property.GC_CYCLE_DELAY.getKey(), "20");
conf.put(Property.GC_DELETE_THREADS.getKey(), "2");
- conf.put(Property.GC_TRASH_IGNORE.getKey(), "false");
+ conf.put(p.getKey(), "false");
Review Comment:
```suggestion
conf.put(GC_TRASH_IGNORE.getKey(), "false");
```
##########
server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java:
##########
@@ -463,11 +463,15 @@ boolean inSafeMode() {
boolean moveToTrash(Path path) throws IOException {
final VolumeManager fs = context.getVolumeManager();
if (!isUsingTrash()) {
+ log.trace("Accumulo Trash is disabled.");
return false;
}
try {
- return fs.moveToTrash(path);
+ boolean success = fs.moveToTrash(path);
+ log.trace("Accumulo Trash enabled, moving to trash succeeded?: {}",
success);
+ return success;
} catch (FileNotFoundException ex) {
+ log.error("Error moving to trash", ex);
Review Comment:
```suggestion
log.error("Error moving {} to trash", path, ex);
```
##########
server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java:
##########
@@ -132,7 +134,7 @@ public void testMoveToTrash_UsingTrash_VolMgrFailure()
throws Exception {
@Test
public void testMoveToTrash_NotUsingTrash() throws Exception {
- systemConfig.set(Property.GC_TRASH_IGNORE.getKey(), "true");
+ systemConfig.set(p.getKey(), "true");
Review Comment:
```suggestion
systemConfig.set(GC_TRASH_IGNORE.getKey(), "true");
```
##########
server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java:
##########
@@ -354,7 +355,10 @@ public void bulkRename(Map<Path,Path> oldToNewPathMap, int
poolSize, String pool
@Override
public boolean moveToTrash(Path path) throws IOException {
FileSystem fs = getFileSystemByPath(path);
+ log.trace("fs.trash.interval: {}",
+ fs.getConf().get(CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY));
Trash trash = new Trash(fs, fs.getConf());
+ log.trace("Hadoop Trash is enabled: {}", trash.isEnabled());
Review Comment:
```suggestion
log.trace("Hadoop Trash is enabled for {}: {}", path, trash.isEnabled());
```
##########
test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashBase.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.metadata.StoredTabletFile;
+import org.apache.accumulo.core.metadata.TabletFile;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType;
+import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.test.util.Wait;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GarbageCollectorTrashBase extends ConfigurableMacBase {
Review Comment:
```suggestion
// base class for ITs that test our legacy trash flag and adoop's trash
policy with accumulo-gc
public class GarbageCollectorTrashBase extends ConfigurableMacBase {
```
##########
test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashBase.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.metadata.StoredTabletFile;
+import org.apache.accumulo.core.metadata.TabletFile;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType;
+import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.test.util.Wait;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GarbageCollectorTrashBase extends ConfigurableMacBase {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(GarbageCollectorTrashBase.class);
+
+ public ArrayList<StoredTabletFile> getFilesForTable(ServerContext ctx,
AccumuloClient client,
+ String tableName) {
+ String tid = client.tableOperations().tableIdMap().get(tableName);
+ TabletsMetadata tms =
+
ctx.getAmple().readTablets().forTable(TableId.of(tid)).fetch(ColumnType.FILES).build();
+ ArrayList<StoredTabletFile> files = new ArrayList<>();
+ tms.forEach(tm -> {
+ files.addAll(tm.getFiles());
+ });
+ LOG.debug("Tablet files: {}", files);
+ return files;
+ }
+
+ public ArrayList<StoredTabletFile> loadData(ServerContext ctx,
AccumuloClient client,
+ String tableName) throws Exception {
+ // create some files
+ for (int i = 0; i < 5; i++) {
+ ReadWriteIT.ingest(client, 10, 10, 10, 0, tableName);
+ client.tableOperations().flush(tableName);
+ }
+ return getFilesForTable(ctx, client, tableName);
+ }
+
+ public boolean userTrashDirExists(FileSystem fs) {
+ return !fs.getTrashRoots(false).isEmpty();
+ }
+
+ public void makeTrashDir(FileSystem fs) throws IOException {
+ if (!userTrashDirExists(fs)) {
+ Path homeDir = fs.getHomeDirectory();
+ Path trashDir = new Path(homeDir, ".Trash");
Review Comment:
This is okay so long as miniDFS is used. If LocalFileSystem or
RawLocalFileSystem is used, this is probably going to pollute the user's
`$HOME` instead of stay in the `/target/` directory.
##########
test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashEnabledCustomPolicyIT.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.admin.CompactionConfig;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.metadata.StoredTabletFile;
+import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.TrashPolicyDefault;
+import org.junit.jupiter.api.Test;
+
+public class GarbageCollectorTrashEnabledCustomPolicyIT extends
GarbageCollectorTrashBase {
Review Comment:
```suggestion
// verify trash is used if our legacy prop is set to not ignore it (the
default)
// and Hadoop is also configured to use a custom trash policy
public class GarbageCollectorTrashEnabledCustomPolicyIT extends
GarbageCollectorTrashBase {
```
##########
test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashDefaultIT.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.admin.CompactionConfig;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.metadata.StoredTabletFile;
+import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
+import org.apache.hadoop.fs.FileSystem;
+import org.junit.jupiter.api.Test;
+
+public class GarbageCollectorTrashDefaultIT extends GarbageCollectorTrashBase {
Review Comment:
```suggestion
// verify trash is not used using by Hadoop default when Hadoop isn't
configured
// to use it (even though our legacy prop set to use it, if configured)
public class GarbageCollectorTrashDefaultIT extends
GarbageCollectorTrashBase {
```
##########
test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashBase.java:
##########
Review Comment:
Methods can be protected instead of public on this base class
##########
server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java:
##########
@@ -354,7 +355,10 @@ public void bulkRename(Map<Path,Path> oldToNewPathMap, int
poolSize, String pool
@Override
public boolean moveToTrash(Path path) throws IOException {
FileSystem fs = getFileSystemByPath(path);
+ log.trace("fs.trash.interval: {}",
+ fs.getConf().get(CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY));
Review Comment:
```suggestion
String key = CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
log.trace("{}: {}", key, fs.getConf().get(key));
```
##########
test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashDisabledIT.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.admin.CompactionConfig;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.metadata.StoredTabletFile;
+import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
+import org.apache.hadoop.fs.FileSystem;
+import org.junit.jupiter.api.Test;
+
+public class GarbageCollectorTrashDisabledIT extends GarbageCollectorTrashBase
{
Review Comment:
```suggestion
// verify trash is ignored when Hadoop is configured to use it, because our
// legacy prop is set to ignore it
public class GarbageCollectorTrashDisabledIT extends
GarbageCollectorTrashBase {
```
##########
server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java:
##########
@@ -463,11 +463,15 @@ boolean inSafeMode() {
boolean moveToTrash(Path path) throws IOException {
final VolumeManager fs = context.getVolumeManager();
if (!isUsingTrash()) {
+ log.trace("Accumulo Trash is disabled.");
Review Comment:
```suggestion
log.trace("Accumulo Trash is disabled. Skipped for {}", path);
```
##########
test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashEnabledIT.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.admin.CompactionConfig;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.metadata.StoredTabletFile;
+import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
+import org.apache.hadoop.fs.FileSystem;
+import org.junit.jupiter.api.Test;
+
+public class GarbageCollectorTrashEnabledIT extends GarbageCollectorTrashBase {
Review Comment:
```suggestion
// verify trash is used with Hadoop's default trash policy when our legacy
prop
// is set to not ignore
public class GarbageCollectorTrashEnabledIT extends
GarbageCollectorTrashBase {
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]