Merge branch '1.6.1-SNAPSHOT'

Conflicts:
        
core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
        core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cf18632c
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cf18632c
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cf18632c

Branch: refs/heads/master
Commit: cf18632cd24eb2f97b2d6a895c317d09e9dac71a
Parents: e7451ff f7cfb25
Author: Bill Havanki <bhava...@cloudera.com>
Authored: Tue Jul 15 15:52:49 2014 -0400
Committer: Bill Havanki <bhava...@cloudera.com>
Committed: Tue Jul 15 15:52:49 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/conf/AccumuloConfiguration.java       | 12 ------------
 .../apache/accumulo/core/conf/SiteConfiguration.java    |  3 +++
 .../org/apache/accumulo/core/file/rfile/PrintInfo.java  |  5 +++--
 .../accumulo/core/file/rfile/bcfile/PrintInfo.java      |  5 +++--
 .../org/apache/accumulo/shell/commands/FateCommand.java |  5 +++--
 .../java/org/apache/accumulo/test/util/CertUtils.java   |  7 +++----
 6 files changed, 15 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/cf18632c/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
----------------------------------------------------------------------
diff --cc 
core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
index e0b6b32,cddd3be..813633c
--- 
a/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
@@@ -348,27 -213,6 +348,15 @@@ public abstract class AccumuloConfigura
      return DefaultConfiguration.getInstance();
    }
    
 +  /**
-    * Gets a site configuration parented by a default configuration. Only here
-    * for shell option-free start-up.
-    *
-    * @return configuration
-    * @deprecated not for client use
-    */
-   @Deprecated
-   public static synchronized AccumuloConfiguration getSiteConfiguration() {
-     return SiteConfiguration.getInstance(getDefaultConfiguration());
-   }
-   
-   /**
 +   * Gets the configuration specific to a table.
 +   *
 +   * @param conn connector (used to find table name)
 +   * @param tableId table ID
 +   * @return configuration containing table properties
 +   * @throws TableNotFoundException if the table is not found
 +   * @throws AccumuloException if there is a problem communicating to Accumulo
 +   */
    public static AccumuloConfiguration getTableConfiguration(Connector conn, 
String tableId) throws TableNotFoundException, AccumuloException {
      String tableName = Tables.getTableName(conn.getInstance(), tableId);
      return new 
ConfigurationCopy(conn.tableOperations().getProperties(tableName));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/cf18632c/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
----------------------------------------------------------------------
diff --cc 
core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index 9fcc4fb,997df64..9875cdb
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@@ -23,15 -23,10 +23,18 @@@ import org.apache.hadoop.conf.Configura
  import org.apache.log4j.Logger;
  
  /**
 - * A configuration drawn from an XML configuration file specified by the 
system property
 - * org.apache.accumulo.config.file, which points to the file as a resource. 
The default value is
 - * "accumulo-site.xml". <b>Note</b>: Client code should not use this class, 
and it may be deprecated in the
 - * future.
 + * An {@link AccumuloConfiguration} which loads properties from an XML file,
 + * usually accumulo-site.xml. This implementation supports defaulting 
undefined
 + * property values to a parent configuration's definitions.
 + * <p>
 + * The system property "org.apache.accumulo.config.file" can be used to 
specify
 + * the location of the XML configuration file on the classpath. If the system
 + * property is not defined, it defaults to "accumulo-site.xml".
 + * <p>
 + * This class is a singleton.
++ * <p>
++ * <b>Note</b>: Client code should not use this class, and it may be 
deprecated
++ * in the future.
   */
  public class SiteConfiguration extends AccumuloConfiguration {
    private static final Logger log = Logger.getLogger(SiteConfiguration.class);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/cf18632c/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
----------------------------------------------------------------------
diff --cc 
shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
index eae1ec8,0000000..4d7a43f
mode 100644,000000..100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
@@@ -1,180 -1,0 +1,181 @@@
 +/*
 + * 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.shell.commands;
 +
 +import java.io.IOException;
 +import java.util.Collections;
 +import java.util.EnumSet;
 +import java.util.Formatter;
 +import java.util.HashSet;
 +import java.util.Set;
 +
 +import org.apache.accumulo.core.Constants;
 +import org.apache.accumulo.core.client.Instance;
 +import org.apache.accumulo.core.conf.AccumuloConfiguration;
++import org.apache.accumulo.core.conf.DefaultConfiguration;
++import org.apache.accumulo.core.conf.SiteConfiguration;
 +import org.apache.accumulo.core.conf.Property;
 +import org.apache.accumulo.core.zookeeper.ZooUtil;
 +import org.apache.accumulo.fate.AdminUtil;
 +import org.apache.accumulo.fate.ReadOnlyTStore.TStatus;
 +import org.apache.accumulo.fate.ZooStore;
 +import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 +import org.apache.accumulo.fate.zookeeper.ZooReaderWriter;
 +import org.apache.accumulo.shell.Shell;
 +import org.apache.accumulo.shell.Shell.Command;
 +import org.apache.commons.cli.CommandLine;
 +import org.apache.commons.cli.Option;
 +import org.apache.commons.cli.Options;
 +import org.apache.commons.cli.ParseException;
 +import org.apache.zookeeper.KeeperException;
 +
 +/**
 + * Manage FATE transactions
 + * 
 + */
 +public class FateCommand extends Command {
 +  
 +  private static final String SCHEME = "digest";
 +  
 +  private static final String USER = "accumulo";
 +  
 +  private Option secretOption;
 +  private Option statusOption;
 +  
 +  @Override
 +  public int execute(final String fullCommand, final CommandLine cl, final 
Shell shellState) throws ParseException, KeeperException, InterruptedException,
 +      IOException {
 +    Instance instance = shellState.getInstance();
 +    String[] args = cl.getArgs();
 +    if (args.length <= 0) {
 +      throw new ParseException("Must provide a command to execute");
 +    }
 +    String cmd = args[0];
 +    boolean failedCommand = false;
 +    
 +    AdminUtil<FateCommand> admin = new AdminUtil<FateCommand>(false);
 +    
 +    String path = ZooUtil.getRoot(instance) + Constants.ZFATE;
 +    String masterPath = ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK;
 +    IZooReaderWriter zk = getZooReaderWriter(shellState.getInstance(), 
cl.getOptionValue(secretOption.getOpt()));
 +    ZooStore<FateCommand> zs = new ZooStore<FateCommand>(path, zk);
 +    
 +    if ("fail".equals(cmd)) {
 +      if (args.length <= 1) {
 +        throw new ParseException("Must provide transaction ID");
 +      }
 +      for (int i = 1; i < args.length; i++) {
 +        if (!admin.prepFail(zs, zk, masterPath, args[i])) {
 +          System.out.printf("Could not fail transaction: %s%n", args[i]);
 +          failedCommand = true;
 +        }
 +      }
 +    } else if ("delete".equals(cmd)) {
 +      if (args.length <= 1) {
 +        throw new ParseException("Must provide transaction ID");
 +      }
 +      for (int i = 1; i < args.length; i++) {
 +        if (admin.prepDelete(zs, zk, masterPath, args[i])) {
 +          admin.deleteLocks(zs, zk, ZooUtil.getRoot(instance) + 
Constants.ZTABLE_LOCKS, args[i]);
 +        } else {
 +          System.out.printf("Could not delete transaction: %s%n", args[i]);
 +          failedCommand = true;
 +        }
 +      }
 +    } else if ("list".equals(cmd) || "print".equals(cmd)) {
 +      // Parse transaction ID filters for print display
 +      Set<Long> filterTxid = null;
 +      if (args.length >= 2) {
 +        filterTxid = new HashSet<Long>(args.length);
 +        for (int i = 1; i < args.length; i++) {
 +          try {
 +            Long val = Long.parseLong(args[i], 16);
 +            filterTxid.add(val);
 +          } catch (NumberFormatException nfe) {
 +            // Failed to parse, will exit instead of displaying everything 
since the intention was to potentially filter some data
 +            System.out.printf("Invalid transaction ID format: %s%n", args[i]);
 +            return 1;
 +          }
 +        }
 +      }
 +      
 +      // Parse TStatus filters for print display
 +      EnumSet<TStatus> filterStatus = null;
 +      if (cl.hasOption(statusOption.getOpt())) {
 +        filterStatus = EnumSet.noneOf(TStatus.class);
 +        String[] tstat = cl.getOptionValues(statusOption.getOpt());
 +        for (int i = 0; i < tstat.length; i++) {
 +          try {
 +            filterStatus.add(TStatus.valueOf(tstat[i]));
 +          } catch (IllegalArgumentException iae) {
 +            System.out.printf("Invalid transaction status name: %s%n", 
tstat[i]);
 +            return 1;
 +          }
 +        }
 +      }
 +      
 +      StringBuilder buf = new StringBuilder(8096);
 +      Formatter fmt = new Formatter(buf);
 +      admin.print(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, 
fmt, filterTxid, filterStatus);
 +      
shellState.printLines(Collections.singletonList(buf.toString()).iterator(), 
true);
 +    } else {
 +      throw new ParseException("Invalid command option");
 +    }
 +    
 +    return failedCommand ? 1 : 0;
 +  }
 +  
 +  protected synchronized IZooReaderWriter getZooReaderWriter(Instance 
instance, String secret) {
 +    
 +    if (secret == null) {
-       @SuppressWarnings("deprecation")
-       AccumuloConfiguration conf = 
AccumuloConfiguration.getSiteConfiguration();
++      AccumuloConfiguration conf = 
SiteConfiguration.getInstance(DefaultConfiguration.getInstance());
 +      secret = conf.get(Property.INSTANCE_SECRET);
 +    }
 +    
 +    return new ZooReaderWriter(instance.getZooKeepers(), 
instance.getZooKeepersSessionTimeOut(), SCHEME, (USER + ":" + 
secret).getBytes());
 +  }
 +  
 +  @Override
 +  public String description() {
 +    return "manage FATE transactions";
 +  }
 +  
 +  @Override
 +  public String usage() {
 +    return getName() + " fail <txid>... | delete <txid>... | print 
[<txid>...]";
 +  }
 +  
 +  @Override
 +  public Options getOptions() {
 +    final Options o = new Options();
 +    secretOption = new Option("s", "secret", true, "specify the instance 
secret to use");
 +    secretOption.setOptionalArg(false);
 +    o.addOption(secretOption);
 +    statusOption = new Option("t", "status-type", true,
 +        "filter 'print' on the transaction status type(s) {NEW, IN_PROGRESS, 
FAILED_IN_PROGRESS, FAILED, SUCCESSFUL}");
 +    statusOption.setArgs(Option.UNLIMITED_VALUES);
 +    statusOption.setOptionalArg(false);
 +    o.addOption(statusOption);
 +    return o;
 +  }
 +  
 +  @Override
 +  public int numArgs() {
 +    // Arg length varies between 1 to n
 +    return -1;
 +  }
 +}

Reply via email to