neils-dev commented on code in PR #4246: URL: https://github.com/apache/ozone/pull/4246#discussion_r1173251987
########## hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneFsDelete.java: ########## @@ -0,0 +1,206 @@ +/* + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.fs.ozone; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URI; +import java.util.LinkedList; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.fs.ContentSummary; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.PathIOException; +import org.apache.hadoop.fs.PathIsDirectoryException; +import org.apache.hadoop.fs.PathNotFoundException; +import org.apache.hadoop.fs.Trash; +import org.apache.hadoop.fs.shell.CommandFactory; +import org.apache.hadoop.fs.shell.CommandFormat; +import org.apache.hadoop.fs.shell.FsCommand; +import org.apache.hadoop.fs.shell.PathData; +import org.apache.hadoop.util.ToolRunner; +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_SAFELY_DELETE_LIMIT_NUM_FILES; +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_SAFELY_DELETE_LIMIT_NUM_FILES_DEFAULT; +import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER; + +/** + * Classes that delete paths. + */ [email protected] [email protected] + +public final class OzoneFsDelete { + + private OzoneFsDelete() { + } + + public static void registerCommands(CommandFactory factory) { + factory.addClass(OzoneFsDelete.Rm.class, "-rm"); + factory.addClass(OzoneFsDelete.Rmr.class, "-rmr"); + } + + /** remove non-directory paths. */ + public static class Rm extends FsCommand { Review Comment: > Can this Rm extend Delete.Rm? After repackaging under the hadoop fs shell package, `org.apache.hadoop.fs.shell`, it is possible to extend `Delete.Rm` to a certain extent, however many of the properties and methods used in the subclass overriden methods are private in the base class. The private props and methods include all of the parsed command arguments (private variables in base class), and the garbage collection trash routines needed in the subclass override for `processPath` , The resulting subclass redefines those private methods to an extent and limits code reuse. It does not appear to be advantageous. This `FsCommand` does not lend itself to subclassing. Our ozone command handler `OzoneFsDelete` appears to be flexible and cleaner. We can open a jira to follow-up on looking into this further if it looks worth pursuing, Thoughts? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
