浏览代码

ZOOKEEPER-3411: Remove deprecated ls2 and rmr command

Removed Ls2Command.java, DeleteAllCommand.printdeprecatedwarning(), statements creating new objects for ls2 and rmr in ZookeeperMain.java. Updated zookeeperCLI.md and ZookeeperTest.java.

Please do let me know if any additional changes are needed

Author: ravowlga123 <ravowlga@gmail.com>

Reviewers: andor@apache.org

Closes #1175 from ravowlga123/ZOOKEEPER-3411
ravowlga123 5 年之前
父节点
当前提交
27b92caefd

+ 0 - 19
zookeeper-docs/src/main/resources/markdown/zookeeperCLI.md

@@ -48,13 +48,11 @@ ZooKeeper -server host:port cmd args
 	history
 	listquota path
 	ls [-s] [-w] [-R] path
-	ls2 path [watch]
 	printwatches on|off
 	quit
 	reconfig [-s] [-v version] [[-file path] | [-members serverID=host:port1:port2;port3[,...]*]] | [-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*]
 	redo cmdno
 	removewatches path [-c|-d|-a] [-l]
-	rmr path
 	set [-s] [-v version] path data
 	setAcl [-s] [-v version] [-R] path acl
 	setquota -n|-b val path
@@ -324,15 +322,6 @@ Listing the child nodes of one path
 	WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/brokers
 ```
 
-## ls2
-
-'ls2' has been deprecated. Please use 'ls [-s] path' instead.
-
-```bash
-[zkshell: 7] ls2 /
-	'ls2' has been deprecated. Please use 'ls [-s] path' instead.
-```
-
 ## printwatches
 A switch to turn on/off whether printing watches or not.
 
@@ -422,14 +411,6 @@ Remove the watches under a node.
 
 ```
 
-## rmr
-The command 'rmr' has been deprecated. Please use 'deleteall' instead.
-
-```bash
-[zkshell: 4] rmr /zk-latencies4
-	The command 'rmr' has been deprecated. Please use 'deleteall' instead
-```
-
 ## set
 Set/update the data on a path.
 

+ 0 - 4
zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeperMain.java

@@ -53,7 +53,6 @@ import org.apache.zookeeper.cli.GetCommand;
 import org.apache.zookeeper.cli.GetConfigCommand;
 import org.apache.zookeeper.cli.GetEphemeralsCommand;
 import org.apache.zookeeper.cli.ListQuotaCommand;
-import org.apache.zookeeper.cli.Ls2Command;
 import org.apache.zookeeper.cli.LsCommand;
 import org.apache.zookeeper.cli.MalformedCommandException;
 import org.apache.zookeeper.cli.ReconfigCommand;
@@ -105,12 +104,9 @@ public class ZooKeeperMain {
         new CreateCommand().addToMap(commandMapCli);
         new DeleteCommand().addToMap(commandMapCli);
         new DeleteAllCommand().addToMap(commandMapCli);
-        // Depricated: rmr
-        new DeleteAllCommand("rmr").addToMap(commandMapCli);
         new SetCommand().addToMap(commandMapCli);
         new GetCommand().addToMap(commandMapCli);
         new LsCommand().addToMap(commandMapCli);
-        new Ls2Command().addToMap(commandMapCli);
         new GetAclCommand().addToMap(commandMapCli);
         new SetAclCommand().addToMap(commandMapCli);
         new StatCommand().addToMap(commandMapCli);

+ 0 - 7
zookeeper-server/src/main/java/org/apache/zookeeper/cli/DeleteAllCommand.java

@@ -66,7 +66,6 @@ public class DeleteAllCommand extends CliCommand {
 
     @Override
     public boolean exec() throws CliException {
-        printDeprecatedWarning();
         int batchSize;
         try {
             batchSize = cl.hasOption("b") ? Integer.parseInt(cl.getOptionValue("b")) : 1000;
@@ -88,10 +87,4 @@ public class DeleteAllCommand extends CliCommand {
         return false;
     }
 
-    private void printDeprecatedWarning() {
-        if ("rmr".equals(args[0])) {
-            err.println("The command 'rmr' has been deprecated. " + "Please use 'deleteall' instead.");
-        }
-    }
-
 }

+ 0 - 77
zookeeper-server/src/main/java/org/apache/zookeeper/cli/Ls2Command.java

@@ -1,77 +0,0 @@
-/*
- * 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.zookeeper.cli;
-
-import java.util.List;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.Parser;
-import org.apache.commons.cli.PosixParser;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.Stat;
-
-/**
- * ls2 command for cli
- */
-public class Ls2Command extends CliCommand {
-
-    private static Options options = new Options();
-    private String[] args;
-
-    public Ls2Command() {
-        super("ls2", "path [watch]");
-    }
-
-    @Override
-    public CliCommand parse(String[] cmdArgs) throws CliParseException {
-        Parser parser = new PosixParser();
-        CommandLine cl;
-        try {
-            cl = parser.parse(options, cmdArgs);
-        } catch (ParseException ex) {
-            throw new CliParseException(ex);
-        }
-        args = cl.getArgs();
-        if (args.length < 2) {
-            throw new CliParseException(getUsageStr());
-        }
-
-        return this;
-    }
-
-    @Override
-    public boolean exec() throws CliException {
-        err.println("'ls2' has been deprecated. " + "Please use 'ls [-s] path' instead.");
-        String path = args[1];
-        boolean watch = args.length > 2;
-        Stat stat = new Stat();
-        List<String> children;
-        try {
-            children = zk.getChildren(path, watch, stat);
-        } catch (IllegalArgumentException ex) {
-            throw new MalformedPathException(ex.getMessage());
-        } catch (KeeperException | InterruptedException ex) {
-            throw new CliWrapperException(ex);
-        }
-        out.println(children);
-        new StatPrinter(out).print(stat);
-        return watch;
-    }
-
-}

+ 0 - 6
zookeeper-server/src/test/java/org/apache/zookeeper/ZooKeeperTest.java

@@ -154,13 +154,7 @@ public class ZooKeeperTest extends ClientBase {
         assertTrue(children.contains("c"));
 
         ZooKeeperMain zkMain = new ZooKeeperMain(zk);
-        // 'rmr' is deprecated, so the test here is just for backwards
-        // compatibility.
-        String cmdstring0 = "rmr /a/b/v";
         String cmdstring1 = "deleteall /a";
-        zkMain.cl.parseCommand(cmdstring0);
-        assertFalse(zkMain.processZKCmd(zkMain.cl));
-        assertEquals(null, zk.exists("/a/b/v", null));
         zkMain.cl.parseCommand(cmdstring1);
         assertFalse(zkMain.processZKCmd(zkMain.cl));
         assertNull(zk.exists("/a", null));