(CommandLine cli)
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public void runImpl(CommandLine cli) throws Exception { |
| 56 | String zkHost = CLIUtils.getZkHost(cli); |
| 57 | |
| 58 | String target = cli.getArgs()[0]; |
| 59 | boolean recursive = cli.hasOption(CommonCLIOptions.RECURSIVE_OPTION); |
| 60 | |
| 61 | String znode = target; |
| 62 | if (target.toLowerCase(Locale.ROOT).startsWith("zk:")) { |
| 63 | znode = target.substring(3); |
| 64 | } |
| 65 | if (znode.equals("/")) { |
| 66 | throw new SolrServerException("You may not remove the root ZK node ('/')!"); |
| 67 | } |
| 68 | echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ..."); |
| 69 | try (SolrZkClient zkClient = CLIUtils.getSolrZkClient(cli, zkHost)) { |
| 70 | if (!recursive && !zkClient.getChildren(znode, null).isEmpty()) { |
| 71 | throw new SolrServerException( |
| 72 | "ZooKeeper node " + znode + " has children and recursive has NOT been specified."); |
| 73 | } |
| 74 | echo( |
| 75 | "Removing ZooKeeper node " |
| 76 | + znode |
| 77 | + " from ZooKeeper at " |
| 78 | + zkHost |
| 79 | + " recursive: " |
| 80 | + recursive); |
| 81 | zkClient.clean(znode); |
| 82 | } catch (Exception e) { |
| 83 | log.error("Could not complete rm operation for reason: ", e); |
| 84 | throw (e); |
| 85 | } |
| 86 | } |
| 87 | } |
nothing calls this directly
no test coverage detected