Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2EEA5172D5 for ; Fri, 23 Jan 2015 22:26:48 +0000 (UTC) Received: (qmail 62033 invoked by uid 500); 23 Jan 2015 22:26:48 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 61930 invoked by uid 500); 23 Jan 2015 22:26:48 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 61752 invoked by uid 99); 23 Jan 2015 22:26:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jan 2015 22:26:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 74094E0E12; Fri, 23 Jan 2015 22:26:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ctubbsii@apache.org To: commits@accumulo.apache.org Date: Fri, 23 Jan 2015 22:26:57 -0000 Message-Id: <38a70d4bec644aac8526f6ed68194b9b@git.apache.org> In-Reply-To: <2fd3de3e6f9c4fa8afb303e9501c9f02@git.apache.org> References: <2fd3de3e6f9c4fa8afb303e9501c9f02@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/12] accumulo git commit: Merge branch '1.5' into 1.6 Merge branch '1.5' into 1.6 Conflicts: server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/69ca8c9c Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/69ca8c9c Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/69ca8c9c Branch: refs/heads/1.6 Commit: 69ca8c9c0b1d4b069df82e47fba5b823e18f503e Parents: 9f2fcf4 145f83a Author: Christopher Tubbs Authored: Fri Jan 23 17:24:26 2015 -0500 Committer: Christopher Tubbs Committed: Fri Jan 23 17:24:26 2015 -0500 ---------------------------------------------------------------------- .../accumulo/core/file/rfile/SplitLarge.java | 3 +-- .../org/apache/accumulo/server/util/ZooZap.java | 18 ++++++------- .../apache/accumulo/master/util/FateAdmin.java | 28 +++++++++++++------- 3 files changed, 28 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/69ca8c9c/core/src/main/java/org/apache/accumulo/core/file/rfile/SplitLarge.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/69ca8c9c/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java ---------------------------------------------------------------------- diff --cc server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java index fe1cc3c,0000000..f9bb208 mode 100644,000000..100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java @@@ -1,110 -1,0 +1,108 @@@ +/* + * 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.accumulo.server.util; + +import java.util.List; + +import org.apache.accumulo.core.Constants; +import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; +import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy; +import org.apache.accumulo.server.cli.ClientOpts; +import org.apache.accumulo.server.zookeeper.ZooLock; +import org.apache.accumulo.server.zookeeper.ZooReaderWriter; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; + +public class ZooZap { + - static boolean verbose = false; - - private static void message(String msg) { - if (verbose) ++ private static void message(String msg, Opts opts) { ++ if (opts.verbose) + System.out.println(msg); + } + + static class Opts extends ClientOpts { + @Parameter(names = "-master", description = "remove master locks") + boolean zapMaster = false; + @Parameter(names = "-tservers", description = "remove tablet server locks") + boolean zapTservers = false; + @Parameter(names = "-tracers", description = "remove tracer locks") + boolean zapTracers = false; + @Parameter(names = "-verbose", description = "print out messages about progress") + boolean verbose = false; + } + + public static void main(String[] args) { + Opts opts = new Opts(); + opts.parseArgs(ZooZap.class.getName(), args); + + if (!opts.zapMaster && !opts.zapTservers && !opts.zapTracers) { + new JCommander(opts).usage(); + return; + } + + String iid = opts.getInstance().getInstanceID(); + IZooReaderWriter zoo = ZooReaderWriter.getInstance(); + + if (opts.zapMaster) { + String masterLockPath = Constants.ZROOT + "/" + iid + Constants.ZMASTER_LOCK; + - zapDirectory(zoo, masterLockPath); ++ zapDirectory(zoo, masterLockPath, opts); + } + + if (opts.zapTservers) { + String tserversPath = Constants.ZROOT + "/" + iid + Constants.ZTSERVERS; + try { + List children = zoo.getChildren(tserversPath); + for (String child : children) { - message("Deleting " + tserversPath + "/" + child + " from zookeeper"); ++ message("Deleting " + tserversPath + "/" + child + " from zookeeper", opts); + + if (opts.zapMaster) + ZooReaderWriter.getInstance().recursiveDelete(tserversPath + "/" + child, NodeMissingPolicy.SKIP); + else { + String path = tserversPath + "/" + child; + if (zoo.getChildren(path).size() > 0) { + if (!ZooLock.deleteLock(path, "tserver")) { - message("Did not delete " + tserversPath + "/" + child); ++ message("Did not delete " + tserversPath + "/" + child, opts); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (opts.zapTracers) { + String path = Constants.ZROOT + "/" + iid + Constants.ZTRACERS; - zapDirectory(zoo, path); ++ zapDirectory(zoo, path, opts); + } + + } + - private static void zapDirectory(IZooReaderWriter zoo, String path) { ++ private static void zapDirectory(IZooReaderWriter zoo, String path, Opts opts) { + try { + List children = zoo.getChildren(path); + for (String child : children) { - message("Deleting " + path + "/" + child + " from zookeeper"); ++ message("Deleting " + path + "/" + child + " from zookeeper", opts); + zoo.recursiveDelete(path + "/" + child, NodeMissingPolicy.SKIP); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/69ca8c9c/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java ---------------------------------------------------------------------- diff --cc server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java index 5ab5d75,0000000..953d630 mode 100644,000000..100644 --- a/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java +++ b/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java @@@ -1,94 -1,0 +1,104 @@@ +/* + * 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.accumulo.master.util; + +import java.util.ArrayList; ++import java.util.LinkedHashMap; +import java.util.List; ++import java.util.Map.Entry; + +import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.cli.Help; +import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.zookeeper.ZooUtil; +import org.apache.accumulo.fate.AdminUtil; +import org.apache.accumulo.fate.ReadOnlyStore; +import org.apache.accumulo.fate.ZooStore; +import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; +import org.apache.accumulo.master.Master; +import org.apache.accumulo.server.client.HdfsZooInstance; +import org.apache.accumulo.server.zookeeper.ZooReaderWriter; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +/** + * A utility to administer FATE operations + */ +public class FateAdmin { + + static class TxOpts { - @Parameter(description = "", required = true) - List args = new ArrayList(); ++ @Parameter(description = "...", required = true) ++ List txids = new ArrayList(); + } + + @Parameters(commandDescription = "Stop an existing FATE by transaction id") + static class FailOpts extends TxOpts {} + + @Parameters(commandDescription = "Delete an existing FATE by transaction id") + static class DeleteOpts extends TxOpts {} + + @Parameters(commandDescription = "List the existing FATE transactions") + static class PrintOpts {} + + public static void main(String[] args) throws Exception { + Help opts = new Help(); + JCommander jc = new JCommander(opts); + jc.setProgramName(FateAdmin.class.getName()); - jc.addCommand("fail", new FailOpts()); - jc.addCommand("delete", new DeleteOpts()); ++ LinkedHashMap txOpts = new LinkedHashMap(2); ++ txOpts.put("fail", new FailOpts()); ++ txOpts.put("delete", new DeleteOpts()); ++ for (Entry entry : txOpts.entrySet()) { ++ jc.addCommand(entry.getKey(), entry.getValue()); ++ } + jc.addCommand("print", new PrintOpts()); + jc.parse(args); + if (opts.help || jc.getParsedCommand() == null) { + jc.usage(); + System.exit(1); + } + + System.err + .printf("This tool has been deprecated%nFATE administration now available within 'accumulo shell'%n$ fate fail ... | delete ... | print [...]%n%n"); + + AdminUtil admin = new AdminUtil(); + + Instance instance = HdfsZooInstance.getInstance(); + String path = ZooUtil.getRoot(instance) + Constants.ZFATE; + String masterPath = ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK; + IZooReaderWriter zk = ZooReaderWriter.getInstance(); + ZooStore zs = new ZooStore(path, zk); + + if (jc.getParsedCommand().equals("fail")) { - if (!admin.prepFail(zs, zk, masterPath, args[1])) { - System.exit(1); ++ for (String txid : txOpts.get(jc.getParsedCommand()).txids) { ++ if (!admin.prepFail(zs, zk, masterPath, txid)) { ++ System.exit(1); ++ } + } + } else if (jc.getParsedCommand().equals("delete")) { - if (!admin.prepDelete(zs, zk, masterPath, args[1])) { - System.exit(1); ++ for (String txid : txOpts.get(jc.getParsedCommand()).txids) { ++ if (!admin.prepDelete(zs, zk, masterPath, txid)) { ++ System.exit(1); ++ } ++ admin.deleteLocks(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, txid); + } - admin.deleteLocks(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, args[1]); + } else if (jc.getParsedCommand().equals("print")) { + admin.print(new ReadOnlyStore(zs), zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS); + } + } +}