accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [56/64] [abbrv] Merge branch '1.5.2-SNAPSHOT' into 1.6.0-SNAPSHOT
Date Wed, 09 Apr 2014 17:58:27 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
index 5c7b857,0000000..53abbbe
mode 100644,000000..100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
@@@ -1,690 -1,0 +1,689 @@@
 +/*
 + * 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.core.client.mapreduce;
 +
 +import java.io.IOException;
 +import java.lang.reflect.Method;
 +import java.net.InetAddress;
 +import java.util.ArrayList;
 +import java.util.Collection;
 +import java.util.HashMap;
 +import java.util.Iterator;
 +import java.util.LinkedList;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Random;
 +
 +import org.apache.accumulo.core.client.AccumuloException;
 +import org.apache.accumulo.core.client.AccumuloSecurityException;
 +import org.apache.accumulo.core.client.ClientConfiguration;
 +import org.apache.accumulo.core.client.ClientSideIteratorScanner;
 +import org.apache.accumulo.core.client.Connector;
 +import org.apache.accumulo.core.client.Instance;
 +import org.apache.accumulo.core.client.IsolatedScanner;
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.client.Scanner;
 +import org.apache.accumulo.core.client.TableDeletedException;
 +import org.apache.accumulo.core.client.TableNotFoundException;
 +import org.apache.accumulo.core.client.TableOfflineException;
 +import org.apache.accumulo.core.client.impl.OfflineScanner;
 +import org.apache.accumulo.core.client.impl.ScannerImpl;
 +import org.apache.accumulo.core.client.impl.Tables;
 +import org.apache.accumulo.core.client.impl.TabletLocator;
 +import org.apache.accumulo.core.client.mapreduce.lib.util.InputConfigurator;
 +import org.apache.accumulo.core.client.mock.MockInstance;
 +import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.KeyExtent;
 +import org.apache.accumulo.core.data.Range;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.core.master.state.tables.TableState;
 +import org.apache.accumulo.core.security.Authorizations;
 +import org.apache.accumulo.core.security.Credentials;
 +import org.apache.accumulo.core.util.Pair;
 +import org.apache.accumulo.core.util.UtilWaitThread;
 +import org.apache.hadoop.conf.Configuration;
 +import org.apache.hadoop.io.Text;
 +import org.apache.hadoop.mapreduce.InputFormat;
 +import org.apache.hadoop.mapreduce.InputSplit;
 +import org.apache.hadoop.mapreduce.Job;
 +import org.apache.hadoop.mapreduce.JobContext;
 +import org.apache.hadoop.mapreduce.RecordReader;
 +import org.apache.hadoop.mapreduce.TaskAttemptContext;
 +import org.apache.log4j.Level;
 +import org.apache.log4j.Logger;
 +
 +/**
 + * An abstract input format to provide shared methods common to all other input format classes. At the very least, any classes inheriting from this class will
 + * need to define their own {@link RecordReader}.
 + */
 +public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V> {
 +
 +  protected static final Class<?> CLASS = AccumuloInputFormat.class;
 +  protected static final Logger log = Logger.getLogger(CLASS);
 +
 +  /**
 +   * Sets the connector information needed to communicate with Accumulo in this job.
 +   * 
 +   * <p>
 +   * <b>WARNING:</b> The serialized token is stored in the configuration and shared with all MapReduce tasks. It is BASE64 encoded to provide a charset safe
 +   * conversion to a string, and is not intended to be secure.
 +   * 
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param principal
 +   *          a valid Accumulo user name (user must have Table.CREATE permission)
 +   * @param token
 +   *          the user's password
-    * @throws org.apache.accumulo.core.client.AccumuloSecurityException
 +   * @since 1.5.0
 +   */
 +  public static void setConnectorInfo(Job job, String principal, AuthenticationToken token) throws AccumuloSecurityException {
 +    InputConfigurator.setConnectorInfo(CLASS, job.getConfiguration(), principal, token);
 +  }
 +
 +  /**
 +   * Sets the connector information needed to communicate with Accumulo in this job.
 +   * 
 +   * <p>
 +   * Stores the password in a file in HDFS and pulls that into the Distributed Cache in an attempt to be more secure than storing it in the Configuration.
 +   * 
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param principal
 +   *          a valid Accumulo user name (user must have Table.CREATE permission)
 +   * @param tokenFile
 +   *          the path to the token file
-    * @throws AccumuloSecurityException
 +   * @since 1.6.0
 +   */
 +  public static void setConnectorInfo(Job job, String principal, String tokenFile) throws AccumuloSecurityException {
 +    InputConfigurator.setConnectorInfo(CLASS, job.getConfiguration(), principal, tokenFile);
 +  }
 +
 +  /**
 +   * Determines if the connector has been configured.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @return true if the connector has been configured, false otherwise
 +   * @since 1.5.0
 +   * @see #setConnectorInfo(Job, String, AuthenticationToken)
 +   */
 +  protected static Boolean isConnectorInfoSet(JobContext context) {
 +    return InputConfigurator.isConnectorInfoSet(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * Gets the user name from the configuration.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @return the user name
 +   * @since 1.5.0
 +   * @see #setConnectorInfo(Job, String, AuthenticationToken)
 +   */
 +  protected static String getPrincipal(JobContext context) {
 +    return InputConfigurator.getPrincipal(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * Gets the serialized token class from either the configuration or the token file.
 +   * 
 +   * @since 1.5.0
 +   * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobContext)} instead.
 +   */
 +  @Deprecated
 +  protected static String getTokenClass(JobContext context) {
 +    return getAuthenticationToken(context).getClass().getName();
 +  }
 +
 +  /**
 +   * Gets the serialized token from either the configuration or the token file.
 +   * 
 +   * @since 1.5.0
 +   * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobContext)} instead.
 +   */
 +  @Deprecated
 +  protected static byte[] getToken(JobContext context) {
 +    return AuthenticationToken.AuthenticationTokenSerializer.serialize(getAuthenticationToken(context));
 +  }
 +
 +  /**
 +   * Gets the authenticated token from either the specified token file or directly from the configuration, whichever was used when the job was configured.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @return the principal's authentication token
 +   * @since 1.6.0
 +   * @see #setConnectorInfo(Job, String, AuthenticationToken)
 +   * @see #setConnectorInfo(Job, String, String)
 +   */
 +  protected static AuthenticationToken getAuthenticationToken(JobContext context) {
 +    return InputConfigurator.getAuthenticationToken(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * Configures a {@link org.apache.accumulo.core.client.ZooKeeperInstance} for this job.
 +   * 
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param instanceName
 +   *          the Accumulo instance name
 +   * @param zooKeepers
 +   *          a comma-separated list of zookeeper servers
 +   * @since 1.5.0
 +   * @deprecated since 1.6.0; Use {@link #setZooKeeperInstance(Job, ClientConfiguration)} instead.
 +   */
 +  @Deprecated
 +  public static void setZooKeeperInstance(Job job, String instanceName, String zooKeepers) {
 +    InputConfigurator.setZooKeeperInstance(CLASS, job.getConfiguration(), instanceName, zooKeepers);
 +  }
 +
 +  /**
 +   * Configures a {@link org.apache.accumulo.core.client.ZooKeeperInstance} for this job.
 +   *
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param clientConfig
 +   *          client configuration containing connection options
 +   * @since 1.6.0
 +   */
 +  public static void setZooKeeperInstance(Job job, ClientConfiguration clientConfig) {
 +    InputConfigurator.setZooKeeperInstance(CLASS, job.getConfiguration(), clientConfig);
 +  }
 +
 +  /**
 +   * Configures a {@link org.apache.accumulo.core.client.mock.MockInstance} for this job.
 +   * 
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param instanceName
 +   *          the Accumulo instance name
 +   * @since 1.5.0
 +   */
 +  public static void setMockInstance(Job job, String instanceName) {
 +    InputConfigurator.setMockInstance(CLASS, job.getConfiguration(), instanceName);
 +  }
 +
 +  /**
 +   * Initializes an Accumulo {@link org.apache.accumulo.core.client.Instance} based on the configuration.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @return an Accumulo instance
 +   * @since 1.5.0
 +   * @see #setZooKeeperInstance(Job, String, String)
 +   * @see #setMockInstance(Job, String)
 +   */
 +  protected static Instance getInstance(JobContext context) {
 +    return InputConfigurator.getInstance(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * Sets the log level for this job.
 +   * 
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param level
 +   *          the logging level
 +   * @since 1.5.0
 +   */
 +  public static void setLogLevel(Job job, Level level) {
 +    InputConfigurator.setLogLevel(CLASS, job.getConfiguration(), level);
 +  }
 +
 +  /**
 +   * Gets the log level from this configuration.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @return the log level
 +   * @since 1.5.0
 +   * @see #setLogLevel(Job, Level)
 +   */
 +  protected static Level getLogLevel(JobContext context) {
 +    return InputConfigurator.getLogLevel(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * Sets the {@link org.apache.accumulo.core.security.Authorizations} used to scan. Must be a subset of the user's authorization. Defaults to the empty set.
 +   * 
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param auths
 +   *          the user's authorizations
 +   */
 +  public static void setScanAuthorizations(Job job, Authorizations auths) {
 +    InputConfigurator.setScanAuthorizations(CLASS, job.getConfiguration(), auths);
 +  }
 +
 +  /**
 +   * Gets the authorizations to set for the scans from the configuration.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @return the Accumulo scan authorizations
 +   * @since 1.5.0
 +   * @see #setScanAuthorizations(Job, Authorizations)
 +   */
 +  protected static Authorizations getScanAuthorizations(JobContext context) {
 +    return InputConfigurator.getScanAuthorizations(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * Fetches all {@link InputTableConfig}s that have been set on the given job.
 +   * 
 +   * @param context
 +   *          the Hadoop job instance to be configured
 +   * @return the {@link InputTableConfig} objects for the job
 +   * @since 1.6.0
 +   */
 +  protected static Map<String,InputTableConfig> getInputTableConfigs(JobContext context) {
 +    return InputConfigurator.getInputTableConfigs(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * Fetches a {@link InputTableConfig} that has been set on the configuration for a specific table.
 +   * 
 +   * <p>
 +   * null is returned in the event that the table doesn't exist.
 +   * 
 +   * @param context
 +   *          the Hadoop job instance to be configured
 +   * @param tableName
 +   *          the table name for which to grab the config object
 +   * @return the {@link InputTableConfig} for the given table
 +   * @since 1.6.0
 +   */
 +  protected static InputTableConfig getInputTableConfig(JobContext context, String tableName) {
 +    return InputConfigurator.getInputTableConfig(CLASS, getConfiguration(context), tableName);
 +  }
 +
 +  /**
 +   * Initializes an Accumulo {@link org.apache.accumulo.core.client.impl.TabletLocator} based on the configuration.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @param table
 +   *          the table for which to initialize the locator
 +   * @return an Accumulo tablet locator
 +   * @throws org.apache.accumulo.core.client.TableNotFoundException
 +   *           if the table name set on the configuration doesn't exist
 +   * @since 1.6.0
 +   */
 +  protected static TabletLocator getTabletLocator(JobContext context, String table) throws TableNotFoundException {
 +    return InputConfigurator.getTabletLocator(CLASS, getConfiguration(context), table);
 +  }
 +
 +  // InputFormat doesn't have the equivalent of OutputFormat's checkOutputSpecs(JobContext job)
 +  /**
 +   * Check whether a configuration is fully configured to be used with an Accumulo {@link org.apache.hadoop.mapreduce.InputFormat}.
 +   * 
 +   * @param context
 +   *          the Hadoop context for the configured job
 +   * @throws java.io.IOException
 +   *           if the context is improperly configured
 +   * @since 1.5.0
 +   */
 +  protected static void validateOptions(JobContext context) throws IOException {
 +    InputConfigurator.validateOptions(CLASS, getConfiguration(context));
 +  }
 +
 +  /**
 +   * An abstract base class to be used to create {@link org.apache.hadoop.mapreduce.RecordReader} instances that convert from Accumulo
 +   * {@link org.apache.accumulo.core.data.Key}/{@link org.apache.accumulo.core.data.Value} pairs to the user's K/V types.
 +   * 
 +   * Subclasses must implement {@link #nextKeyValue()} and use it to update the following variables:
 +   * <ul>
 +   * <li>K {@link #currentK}</li>
 +   * <li>V {@link #currentV}</li>
 +   * <li>Key {@link #currentKey} (used for progress reporting)</li>
 +   * <li>int {@link #numKeysRead} (used for progress reporting)</li>
 +   * </ul>
 +   */
 +  protected abstract static class AbstractRecordReader<K,V> extends RecordReader<K,V> {
 +    protected long numKeysRead;
 +    protected Iterator<Map.Entry<Key,Value>> scannerIterator;
 +    protected RangeInputSplit split;
 +
 +    /**
 +     * Configures the iterators on a scanner for the given table name.
 +     * 
 +     * @param context
 +     *          the Hadoop context for the configured job
 +     * @param scanner
 +     *          the scanner for which to configure the iterators
 +     * @param tableName
 +     *          the table name for which the scanner is configured
 +     * @since 1.6.0
 +     */
 +    protected abstract void setupIterators(TaskAttemptContext context, Scanner scanner, String tableName, RangeInputSplit split);
 +
 +    /**
 +     * Initialize a scanner over the given input split using this task attempt configuration.
 +     */
 +    @Override
 +    public void initialize(InputSplit inSplit, TaskAttemptContext attempt) throws IOException {
 +
 +      Scanner scanner;
 +      split = (RangeInputSplit) inSplit;
 +      log.debug("Initializing input split: " + split.getRange());
 +      
 +      Instance instance = split.getInstance();
 +      if (null == instance) {
 +        instance = getInstance(attempt);
 +      }
 +
 +      String principal = split.getPrincipal();
 +      if (null == principal) {
 +        principal = getPrincipal(attempt);
 +      }
 +
 +      AuthenticationToken token = split.getToken();
 +      if (null == token) {
 +        token = getAuthenticationToken(attempt);
 +      }
 +
 +      Authorizations authorizations = split.getAuths();
 +      if (null == authorizations) {
 +        authorizations = getScanAuthorizations(attempt);
 +      }
 +
 +      String table = split.getTableName();
 +
 +      // in case the table name changed, we can still use the previous name for terms of configuration,
 +      // but the scanner will use the table id resolved at job setup time
 +      InputTableConfig tableConfig = getInputTableConfig(attempt, split.getTableName());
 +      
 +      Boolean isOffline = split.isOffline();
 +      if (null == isOffline) {
 +        isOffline = tableConfig.isOfflineScan();
 +      }
 +
 +      Boolean isIsolated = split.isIsolatedScan();
 +      if (null == isIsolated) {
 +        isIsolated = tableConfig.shouldUseIsolatedScanners();
 +      }
 +
 +      Boolean usesLocalIterators = split.usesLocalIterators();
 +      if (null == usesLocalIterators) {
 +        usesLocalIterators = tableConfig.shouldUseLocalIterators();
 +      }
 +      
 +      List<IteratorSetting> iterators = split.getIterators();
 +      if (null == iterators) {
 +        iterators = tableConfig.getIterators();
 +      }
 +      
 +      Collection<Pair<Text,Text>> columns = split.getFetchedColumns();
 +      if (null == columns) {
 +        columns = tableConfig.getFetchedColumns();
 +      }
 +
 +      try {
 +        log.debug("Creating connector with user: " + principal);
 +        log.debug("Creating scanner for table: " + table);
 +        log.debug("Authorizations are: " + authorizations);
 +        if (isOffline) {
 +          scanner = new OfflineScanner(instance, new Credentials(principal, token), split.getTableId(), authorizations);
 +        } else if (instance instanceof MockInstance) {
 +          scanner = instance.getConnector(principal, token).createScanner(split.getTableName(), authorizations);
 +        } else {
 +          scanner = new ScannerImpl(instance, new Credentials(principal, token), split.getTableId(), authorizations);
 +        }
 +        if (isIsolated) {
 +          log.info("Creating isolated scanner");
 +          scanner = new IsolatedScanner(scanner);
 +        }
 +        if (usesLocalIterators) {
 +          log.info("Using local iterators");
 +          scanner = new ClientSideIteratorScanner(scanner);
 +        }
 +        
 +        setupIterators(attempt, scanner, split.getTableName(), split);
 +      } catch (Exception e) {
 +        throw new IOException(e);
 +      }
 +
 +      // setup a scanner within the bounds of this split
 +      for (Pair<Text,Text> c : columns) {
 +        if (c.getSecond() != null) {
 +          log.debug("Fetching column " + c.getFirst() + ":" + c.getSecond());
 +          scanner.fetchColumn(c.getFirst(), c.getSecond());
 +        } else {
 +          log.debug("Fetching column family " + c.getFirst());
 +          scanner.fetchColumnFamily(c.getFirst());
 +        }
 +      }
 +
 +      scanner.setRange(split.getRange());
 +      numKeysRead = 0;
 +
 +      // do this last after setting all scanner options
 +      scannerIterator = scanner.iterator();
 +    }
 +
 +    @Override
 +    public void close() {}
 +
 +    @Override
 +    public float getProgress() throws IOException {
 +      if (numKeysRead > 0 && currentKey == null)
 +        return 1.0f;
 +      return split.getProgress(currentKey);
 +    }
 +
 +    /**
 +     * The Key that should be returned to the client
 +     */
 +    protected K currentK = null;
 +    
 +    /**
 +     * The Value that should be return to the client
 +     */
 +    protected V currentV = null;
 +    
 +    /**
 +     * The Key that is used to determine progress in the current InputSplit. It is not returned to the client and is only used internally
 +     */
 +    protected Key currentKey = null;
 +
 +    @Override
 +    public K getCurrentKey() throws IOException, InterruptedException {
 +      return currentK;
 +    }
 +
 +    @Override
 +    public V getCurrentValue() throws IOException, InterruptedException {
 +      return currentV;
 +    }
 +  }
 +
 +  Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobContext context, String tableId, List<Range> ranges) throws TableNotFoundException,
 +      AccumuloException, AccumuloSecurityException {
 +
 +    Instance instance = getInstance(context);
 +    Connector conn = instance.getConnector(getPrincipal(context), getAuthenticationToken(context));
 +
 +    return InputConfigurator.binOffline(tableId, ranges, instance, conn);
 +  }
 +
 +  /**
 +   * Gets the splits of the tables that have been set on the job.
 +   * 
 +   * @param context
 +   *          the configuration of the job
 +   * @return the splits from the tables based on the ranges.
 +   * @throws java.io.IOException
 +   *           if a table set on the job doesn't exist or an error occurs initializing the tablet locator
 +   */
++  @Override
 +  public List<InputSplit> getSplits(JobContext context) throws IOException {
 +    Level logLevel = getLogLevel(context);
 +    log.setLevel(logLevel);
 +    validateOptions(context);
 +    Random random = new Random();
 +    LinkedList<InputSplit> splits = new LinkedList<InputSplit>();
 +    Map<String,InputTableConfig> tableConfigs = getInputTableConfigs(context);
 +    for (Map.Entry<String,InputTableConfig> tableConfigEntry : tableConfigs.entrySet()) {
 +
 +      String tableName = tableConfigEntry.getKey();
 +      InputTableConfig tableConfig = tableConfigEntry.getValue();
 +      
 +      Instance instance = getInstance(context);
 +      boolean mockInstance;
 +      String tableId;
 +      // resolve table name to id once, and use id from this point forward
 +      if (instance instanceof MockInstance) {
 +        tableId = "";
 +        mockInstance = true;
 +      } else {
 +        try {
 +          tableId = Tables.getTableId(instance, tableName);
 +        } catch (TableNotFoundException e) {
 +          throw new IOException(e);
 +        }
 +        mockInstance = false;
 +      }
 +      
 +      Authorizations auths = getScanAuthorizations(context);
 +      String principal = getPrincipal(context);
 +      AuthenticationToken token = getAuthenticationToken(context);
 +
 +      boolean autoAdjust = tableConfig.shouldAutoAdjustRanges();
 +      List<Range> ranges = autoAdjust ? Range.mergeOverlapping(tableConfig.getRanges()) : tableConfig.getRanges();
 +      if (ranges.isEmpty()) {
 +        ranges = new ArrayList<Range>(1);
 +        ranges.add(new Range());
 +      }
 +
 +      // get the metadata information for these ranges
 +      Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<String,Map<KeyExtent,List<Range>>>();
 +      TabletLocator tl;
 +      try {
 +        if (tableConfig.isOfflineScan()) {
 +          binnedRanges = binOfflineTable(context, tableId, ranges);
 +          while (binnedRanges == null) {
 +            // Some tablets were still online, try again
 +            UtilWaitThread.sleep(100 + random.nextInt(100)); // sleep randomly between 100 and 200 ms
 +            binnedRanges = binOfflineTable(context, tableId, ranges);
 +
 +          }
 +        } else {
 +          tl = getTabletLocator(context, tableId);
 +          // its possible that the cache could contain complete, but old information about a tables tablets... so clear it
 +          tl.invalidateCache();
 +          Credentials creds = new Credentials(getPrincipal(context), getAuthenticationToken(context));
 +
 +          while (!tl.binRanges(creds, ranges, binnedRanges).isEmpty()) {
 +            if (!(instance instanceof MockInstance)) {
 +              if (!Tables.exists(instance, tableId))
 +                throw new TableDeletedException(tableId);
 +              if (Tables.getTableState(instance, tableId) == TableState.OFFLINE)
 +                throw new TableOfflineException(instance, tableId);
 +            }
 +            binnedRanges.clear();
 +            log.warn("Unable to locate bins for specified ranges. Retrying.");
 +            UtilWaitThread.sleep(100 + random.nextInt(100)); // sleep randomly between 100 and 200 ms
 +            tl.invalidateCache();
 +          }
 +        }
 +      } catch (Exception e) {
 +        throw new IOException(e);
 +      }
 +
 +      HashMap<Range,ArrayList<String>> splitsToAdd = null;
 +
 +      if (!autoAdjust)
 +        splitsToAdd = new HashMap<Range,ArrayList<String>>();
 +
 +      HashMap<String,String> hostNameCache = new HashMap<String,String>();
 +      for (Map.Entry<String,Map<KeyExtent,List<Range>>> tserverBin : binnedRanges.entrySet()) {
 +        String ip = tserverBin.getKey().split(":", 2)[0];
 +        String location = hostNameCache.get(ip);
 +        if (location == null) {
 +          InetAddress inetAddress = InetAddress.getByName(ip);
 +          location = inetAddress.getCanonicalHostName();
 +          hostNameCache.put(ip, location);
 +        }
 +        for (Map.Entry<KeyExtent,List<Range>> extentRanges : tserverBin.getValue().entrySet()) {
 +          Range ke = extentRanges.getKey().toDataRange();
 +          for (Range r : extentRanges.getValue()) {
 +            if (autoAdjust) {
 +              // divide ranges into smaller ranges, based on the tablets
 +              RangeInputSplit split = new RangeInputSplit(tableName, tableId, ke.clip(r), new String[] {location});
 +              
 +              split.setOffline(tableConfig.isOfflineScan());
 +              split.setIsolatedScan(tableConfig.shouldUseIsolatedScanners());
 +              split.setUsesLocalIterators(tableConfig.shouldUseLocalIterators());
 +              split.setMockInstance(mockInstance);
 +              split.setFetchedColumns(tableConfig.getFetchedColumns());
 +              split.setPrincipal(principal);
 +              split.setToken(token);
 +              split.setInstanceName(instance.getInstanceName());
 +              split.setZooKeepers(instance.getZooKeepers());
 +              split.setAuths(auths);
 +              split.setIterators(tableConfig.getIterators());
 +              split.setLogLevel(logLevel);
 +              
 +              splits.add(split);
 +            } else {
 +              // don't divide ranges
 +              ArrayList<String> locations = splitsToAdd.get(r);
 +              if (locations == null)
 +                locations = new ArrayList<String>(1);
 +              locations.add(location);
 +              splitsToAdd.put(r, locations);
 +            }
 +          }
 +        }
 +      }
 +
 +      if (!autoAdjust)
 +        for (Map.Entry<Range,ArrayList<String>> entry : splitsToAdd.entrySet()) {
 +          RangeInputSplit split = new RangeInputSplit(tableName, tableId, entry.getKey(), entry.getValue().toArray(new String[0]));
 +
 +          split.setOffline(tableConfig.isOfflineScan());
 +          split.setIsolatedScan(tableConfig.shouldUseIsolatedScanners());
 +          split.setUsesLocalIterators(tableConfig.shouldUseLocalIterators());
 +          split.setMockInstance(mockInstance);
 +          split.setFetchedColumns(tableConfig.getFetchedColumns());
 +          split.setPrincipal(principal);
 +          split.setToken(token);
 +          split.setInstanceName(instance.getInstanceName());
 +          split.setZooKeepers(instance.getZooKeepers());
 +          split.setAuths(auths);
 +          split.setIterators(tableConfig.getIterators());
 +          split.setLogLevel(logLevel);
 +          
 +          splits.add(split);
 +        }
 +    }
 +    return splits;
 +  }
 +
 +  // use reflection to pull the Configuration out of the JobContext for Hadoop 1 and Hadoop 2 compatibility
 +  static Configuration getConfiguration(JobContext context) {
 +    try {
 +      Class<?> c = AbstractInputFormat.class.getClassLoader().loadClass("org.apache.hadoop.mapreduce.JobContext");
 +      Method m = c.getMethod("getConfiguration");
 +      Object o = m.invoke(context, new Object[0]);
 +      return (Configuration) o;
 +    } catch (Exception e) {
 +      throw new RuntimeException(e);
 +    }
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
index 0c924b1,1f83541..2c01b0d
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
@@@ -92,26 -92,7 +91,25 @@@ public class AccumuloOutputFormat exten
    public static void setConnectorInfo(Job job, String principal, AuthenticationToken token) throws AccumuloSecurityException {
      OutputConfigurator.setConnectorInfo(CLASS, job.getConfiguration(), principal, token);
    }
 -  
 +
 +  /**
 +   * Sets the connector information needed to communicate with Accumulo in this job.
 +   * 
 +   * <p>
 +   * Stores the password in a file in HDFS and pulls that into the Distributed Cache in an attempt to be more secure than storing it in the Configuration.
 +   * 
 +   * @param job
 +   *          the Hadoop job instance to be configured
 +   * @param principal
 +   *          a valid Accumulo user name (user must have Table.CREATE permission if {@link #setCreateTables(Job, boolean)} is set to true)
 +   * @param tokenFile
 +   *          the path to the token file
-    * @throws AccumuloSecurityException
 +   * @since 1.6.0
 +   */
 +  public static void setConnectorInfo(Job job, String principal, String tokenFile) throws AccumuloSecurityException {
 +    OutputConfigurator.setConnectorInfo(CLASS, job.getConfiguration(), principal, tokenFile);
 +  }
 +
    /**
     * Determines if the connector has been configured.
     * 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputTableConfig.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputTableConfig.java
index 808bd7c,0000000..e59451e
mode 100644,000000..100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputTableConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputTableConfig.java
@@@ -1,370 -1,0 +1,367 @@@
 +/*
 + * 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.core.client.mapreduce;
 +
 +import java.io.DataInput;
 +import java.io.DataOutput;
 +import java.io.IOException;
 +import java.util.ArrayList;
 +import java.util.Collection;
 +import java.util.HashSet;
 +import java.util.List;
 +
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.data.Range;
 +import org.apache.accumulo.core.util.Pair;
 +import org.apache.hadoop.io.Text;
 +import org.apache.hadoop.io.Writable;
 +
 +/**
 + * This class to holds a batch scan configuration for a table. It contains all the properties needed to specify how rows should be returned from the table.
 + */
 +public class InputTableConfig implements Writable {
 +
 +  private List<IteratorSetting> iterators;
 +  private List<Range> ranges;
 +  private Collection<Pair<Text,Text>> columns;
 +
 +  private boolean autoAdjustRanges = true;
 +  private boolean useLocalIterators = false;
 +  private boolean useIsolatedScanners = false;
 +  private boolean offlineScan = false;
 +
 +  public InputTableConfig() {}
 +
 +  /**
 +   * Creates a batch scan config object out of a previously serialized batch scan config object.
 +   * 
 +   * @param input
 +   *          the data input of the serialized batch scan config
-    * @throws IOException
 +   */
 +  public InputTableConfig(DataInput input) throws IOException {
 +    readFields(input);
 +  }
 +
 +  /**
 +   * Sets the input ranges to scan for all tables associated with this job. This will be added to any per-table ranges that have been set using
 +   * 
 +   * @param ranges
 +   *          the ranges that will be mapped over
 +   * @since 1.6.0
 +   */
 +  public InputTableConfig setRanges(List<Range> ranges) {
 +    this.ranges = ranges;
 +    return this;
 +  }
 +
 +  /**
 +   * Returns the ranges to be queried in the configuration
 +   */
 +  public List<Range> getRanges() {
 +    return ranges != null ? ranges : new ArrayList<Range>();
 +  }
 +
 +  /**
 +   * Restricts the columns that will be mapped over for this job for the default input table.
 +   * 
 +   * @param columns
 +   *          a pair of {@link Text} objects corresponding to column family and column qualifier. If the column qualifier is null, the entire column family is
 +   *          selected. An empty set is the default and is equivalent to scanning the all columns.
 +   * @since 1.6.0
 +   */
 +  public InputTableConfig fetchColumns(Collection<Pair<Text,Text>> columns) {
 +    this.columns = columns;
 +    return this;
 +  }
 +
 +  /**
 +   * Returns the columns to be fetched for this configuration
 +   */
 +  public Collection<Pair<Text,Text>> getFetchedColumns() {
 +    return columns != null ? columns : new HashSet<Pair<Text,Text>>();
 +  }
 +
 +  /**
 +   * Set iterators on to be used in the query.
 +   * 
 +   * @param iterators
 +   *          the configurations for the iterators
 +   * @since 1.6.0
 +   */
 +  public InputTableConfig setIterators(List<IteratorSetting> iterators) {
 +    this.iterators = iterators;
 +    return this;
 +  }
 +
 +  /**
 +   * Returns the iterators to be set on this configuration
 +   */
 +  public List<IteratorSetting> getIterators() {
 +    return iterators != null ? iterators : new ArrayList<IteratorSetting>();
 +  }
 +
 +  /**
 +   * Controls the automatic adjustment of ranges for this job. This feature merges overlapping ranges, then splits them to align with tablet boundaries.
 +   * Disabling this feature will cause exactly one Map task to be created for each specified range. The default setting is enabled. *
 +   * 
 +   * <p>
 +   * By default, this feature is <b>enabled</b>.
 +   * 
 +   * @param autoAdjustRanges
 +   *          the feature is enabled if true, disabled otherwise
 +   * @see #setRanges(java.util.List)
 +   * @since 1.6.0
 +   */
 +  public InputTableConfig setAutoAdjustRanges(boolean autoAdjustRanges) {
 +    this.autoAdjustRanges = autoAdjustRanges;
 +    return this;
 +  }
 +
 +  /**
 +   * Determines whether a configuration has auto-adjust ranges enabled.
 +   * 
 +   * @return false if the feature is disabled, true otherwise
 +   * @since 1.6.0
 +   * @see #setAutoAdjustRanges(boolean)
 +   */
 +  public boolean shouldAutoAdjustRanges() {
 +    return autoAdjustRanges;
 +  }
 +
 +  /**
 +   * Controls the use of the {@link org.apache.accumulo.core.client.ClientSideIteratorScanner} in this job. Enabling this feature will cause the iterator stack
 +   * to be constructed within the Map task, rather than within the Accumulo TServer. To use this feature, all classes needed for those iterators must be
 +   * available on the classpath for the task.
 +   * 
 +   * <p>
 +   * By default, this feature is <b>disabled</b>.
 +   * 
 +   * @param useLocalIterators
 +   *          the feature is enabled if true, disabled otherwise
 +   * @since 1.6.0
 +   */
 +  public InputTableConfig setUseLocalIterators(boolean useLocalIterators) {
 +    this.useLocalIterators = useLocalIterators;
 +    return this;
 +  }
 +
 +  /**
 +   * Determines whether a configuration uses local iterators.
 +   * 
 +   * @return true if the feature is enabled, false otherwise
 +   * @since 1.6.0
 +   * @see #setUseLocalIterators(boolean)
 +   */
 +  public boolean shouldUseLocalIterators() {
 +    return useLocalIterators;
 +  }
 +
 +  /**
 +   * <p>
 +   * Enable reading offline tables. By default, this feature is disabled and only online tables are scanned. This will make the map reduce job directly read the
 +   * table's files. If the table is not offline, then the job will fail. If the table comes online during the map reduce job, it is likely that the job will
 +   * fail.
 +   * 
 +   * <p>
 +   * To use this option, the map reduce user will need access to read the Accumulo directory in HDFS.
 +   * 
 +   * <p>
 +   * Reading the offline table will create the scan time iterator stack in the map process. So any iterators that are configured for the table will need to be
 +   * on the mapper's classpath. The accumulo-site.xml may need to be on the mapper's classpath if HDFS or the Accumulo directory in HDFS are non-standard.
 +   * 
 +   * <p>
 +   * One way to use this feature is to clone a table, take the clone offline, and use the clone as the input table for a map reduce job. If you plan to map
 +   * reduce over the data many times, it may be better to the compact the table, clone it, take it offline, and use the clone for all map reduce jobs. The
 +   * reason to do this is that compaction will reduce each tablet in the table to one file, and it is faster to read from one file.
 +   * 
 +   * <p>
 +   * There are two possible advantages to reading a tables file directly out of HDFS. First, you may see better read performance. Second, it will support
 +   * speculative execution better. When reading an online table speculative execution can put more load on an already slow tablet server.
 +   * 
 +   * <p>
 +   * By default, this feature is <b>disabled</b>.
 +   * 
 +   * @param offlineScan
 +   *          the feature is enabled if true, disabled otherwise
 +   * @since 1.6.0
 +   */
 +  public InputTableConfig setOfflineScan(boolean offlineScan) {
 +    this.offlineScan = offlineScan;
 +    return this;
 +  }
 +
 +  /**
 +   * Determines whether a configuration has the offline table scan feature enabled.
 +   * 
 +   * @return true if the feature is enabled, false otherwise
 +   * @since 1.6.0
 +   * @see #setOfflineScan(boolean)
 +   */
 +  public boolean isOfflineScan() {
 +    return offlineScan;
 +  }
 +
 +  /**
 +   * Controls the use of the {@link org.apache.accumulo.core.client.IsolatedScanner} in this job.
 +   * 
 +   * <p>
 +   * By default, this feature is <b>disabled</b>.
 +   * 
 +   * @param useIsolatedScanners
 +   *          the feature is enabled if true, disabled otherwise
 +   * @since 1.6.0
 +   */
 +  public InputTableConfig setUseIsolatedScanners(boolean useIsolatedScanners) {
 +    this.useIsolatedScanners = useIsolatedScanners;
 +    return this;
 +  }
 +
 +  /**
 +   * Determines whether a configuration has isolation enabled.
 +   * 
 +   * @return true if the feature is enabled, false otherwise
 +   * @since 1.6.0
 +   * @see #setUseIsolatedScanners(boolean)
 +   */
 +  public boolean shouldUseIsolatedScanners() {
 +    return useIsolatedScanners;
 +  }
 +
 +  /**
 +   * Writes the state for the current object out to the specified {@link DataOutput}
 +   * 
 +   * @param dataOutput
 +   *          the output for which to write the object's state
-    * @throws IOException
 +   */
 +  @Override
 +  public void write(DataOutput dataOutput) throws IOException {
 +    if (iterators != null) {
 +      dataOutput.writeInt(iterators.size());
 +      for (IteratorSetting setting : iterators)
 +        setting.write(dataOutput);
 +    } else {
 +      dataOutput.writeInt(0);
 +    }
 +    if (ranges != null) {
 +      dataOutput.writeInt(ranges.size());
 +      for (Range range : ranges)
 +        range.write(dataOutput);
 +    } else {
 +      dataOutput.writeInt(0);
 +    }
 +    if (columns != null) {
 +      dataOutput.writeInt(columns.size());
 +      for (Pair<Text,Text> column : columns) {
 +        if (column.getSecond() == null) {
 +          dataOutput.writeInt(1);
 +          column.getFirst().write(dataOutput);
 +        } else {
 +          dataOutput.writeInt(2);
 +          column.getFirst().write(dataOutput);
 +          column.getSecond().write(dataOutput);
 +        }
 +      }
 +    } else {
 +      dataOutput.writeInt(0);
 +    }
 +    dataOutput.writeBoolean(autoAdjustRanges);
 +    dataOutput.writeBoolean(useLocalIterators);
 +    dataOutput.writeBoolean(useIsolatedScanners);
 +  }
 +
 +  /**
 +   * Reads the fields in the {@link DataInput} into the current object
 +   * 
 +   * @param dataInput
 +   *          the input fields to read into the current object
-    * @throws IOException
 +   */
 +  @Override
 +  public void readFields(DataInput dataInput) throws IOException {
 +    // load iterators
 +    long iterSize = dataInput.readInt();
 +    if (iterSize > 0)
 +      iterators = new ArrayList<IteratorSetting>();
 +    for (int i = 0; i < iterSize; i++)
 +      iterators.add(new IteratorSetting(dataInput));
 +    // load ranges
 +    long rangeSize = dataInput.readInt();
 +    if (rangeSize > 0)
 +      ranges = new ArrayList<Range>();
 +    for (int i = 0; i < rangeSize; i++) {
 +      Range range = new Range();
 +      range.readFields(dataInput);
 +      ranges.add(range);
 +    }
 +    // load columns
 +    long columnSize = dataInput.readInt();
 +    if (columnSize > 0)
 +      columns = new HashSet<Pair<Text,Text>>();
 +    for (int i = 0; i < columnSize; i++) {
 +      long numPairs = dataInput.readInt();
 +      Text colFam = new Text();
 +      colFam.readFields(dataInput);
 +      if (numPairs == 1) {
 +        columns.add(new Pair<Text,Text>(colFam, null));
 +      } else if (numPairs == 2) {
 +        Text colQual = new Text();
 +        colQual.readFields(dataInput);
 +        columns.add(new Pair<Text,Text>(colFam, colQual));
 +      }
 +    }
 +    autoAdjustRanges = dataInput.readBoolean();
 +    useLocalIterators = dataInput.readBoolean();
 +    useIsolatedScanners = dataInput.readBoolean();
 +  }
 +
 +  @Override
 +  public boolean equals(Object o) {
 +    if (this == o)
 +      return true;
 +    if (o == null || getClass() != o.getClass())
 +      return false;
 +
 +    InputTableConfig that = (InputTableConfig) o;
 +
 +    if (autoAdjustRanges != that.autoAdjustRanges)
 +      return false;
 +    if (offlineScan != that.offlineScan)
 +      return false;
 +    if (useIsolatedScanners != that.useIsolatedScanners)
 +      return false;
 +    if (useLocalIterators != that.useLocalIterators)
 +      return false;
 +    if (columns != null ? !columns.equals(that.columns) : that.columns != null)
 +      return false;
 +    if (iterators != null ? !iterators.equals(that.iterators) : that.iterators != null)
 +      return false;
 +    if (ranges != null ? !ranges.equals(that.ranges) : that.ranges != null)
 +      return false;
 +    return true;
 +  }
 +
 +  @Override
 +  public int hashCode() {
 +    int result = 31 * (iterators != null ? iterators.hashCode() : 0);
 +    result = 31 * result + (ranges != null ? ranges.hashCode() : 0);
 +    result = 31 * result + (columns != null ? columns.hashCode() : 0);
 +    result = 31 * result + (autoAdjustRanges ? 1 : 0);
 +    result = 31 * result + (useLocalIterators ? 1 : 0);
 +    result = 31 * result + (useIsolatedScanners ? 1 : 0);
 +    result = 31 * result + (offlineScan ? 1 : 0);
 +    return result;
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
index cf861ce,1a029dc..54ff976
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
@@@ -125,43 -102,8 +124,42 @@@ public class ConfiguratorBase 
      ArgumentChecker.notNull(principal, token);
      conf.setBoolean(enumToConfKey(implementingClass, ConnectorInfo.IS_CONFIGURED), true);
      conf.set(enumToConfKey(implementingClass, ConnectorInfo.PRINCIPAL), principal);
 -    conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN_CLASS), token.getClass().getCanonicalName());
 -    conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), CredentialHelper.tokenAsBase64(token));
 +    conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN),
 +        TokenSource.INLINE.prefix() + token.getClass().getName() + ":" + Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(token)));
 +  }
 +
 +  /**
 +   * Sets the connector information needed to communicate with Accumulo in this job.
 +   * 
 +   * <p>
 +   * Pulls a token file into the Distributed Cache that contains the authentication token in an attempt to be more secure than storing the password in the
 +   * Configuration. Token file created with "bin/accumulo create-token".
 +   * 
 +   * @param implementingClass
 +   *          the class whose name will be used as a prefix for the property configuration key
 +   * @param conf
 +   *          the Hadoop configuration object to configure
 +   * @param principal
 +   *          a valid Accumulo user name
 +   * @param tokenFile
 +   *          the path to the token file in DFS
-    * @throws AccumuloSecurityException
 +   * @since 1.6.0
 +   */
 +  public static void setConnectorInfo(Class<?> implementingClass, Configuration conf, String principal, String tokenFile) throws AccumuloSecurityException {
 +    if (isConnectorInfoSet(implementingClass, conf))
 +      throw new IllegalStateException("Connector info for " + implementingClass.getSimpleName() + " can only be set once per job");
 +
 +    ArgumentChecker.notNull(principal, tokenFile);
 +
 +    try {
 +      DistributedCacheHelper.addCacheFile(new URI(tokenFile), conf);
 +    } catch (URISyntaxException e) {
 +      throw new IllegalStateException("Unable to add tokenFile \"" + tokenFile + "\" to distributed cache.");
 +    }
 +
 +    conf.setBoolean(enumToConfKey(implementingClass, ConnectorInfo.IS_CONFIGURED), true);
 +    conf.set(enumToConfKey(implementingClass, ConnectorInfo.PRINCIPAL), principal);
 +    conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), TokenSource.FILE.prefix() + tokenFile);
    }
  
    /**

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/data/Condition.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/data/Condition.java
index c80dcd6,0000000..bfd4818
mode 100644,000000..100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Condition.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Condition.java
@@@ -1,245 -1,0 +1,238 @@@
 +/*
 + * 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.core.data;
 +
 +import java.util.Arrays;
 +import java.util.HashSet;
 +
 +import org.apache.accumulo.core.Constants;
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.security.ColumnVisibility;
 +import org.apache.accumulo.core.util.ArgumentChecker;
 +import org.apache.hadoop.io.Text;
 +
 +/**
 + * Conditions that must be met on a particular column in a row.
 + * 
 + * @since 1.6.0
 + */
 +public class Condition {
 +  
 +  private ByteSequence cf;
 +  private ByteSequence cq;
 +  private ByteSequence cv;
 +  private ByteSequence val;
 +  private Long ts;
 +  private IteratorSetting iterators[] = new IteratorSetting[0];
 +  private static final ByteSequence EMPTY = new ArrayByteSequence(new byte[0]);
 +  
 +
 +  public Condition(CharSequence cf, CharSequence cq) {
 +    ArgumentChecker.notNull(cf, cq);
 +    this.cf = new ArrayByteSequence(cf.toString().getBytes(Constants.UTF8));
 +    this.cq = new ArrayByteSequence(cq.toString().getBytes(Constants.UTF8));
 +    this.cv = EMPTY;
 +  }
 +  
 +  public Condition(byte[] cf, byte[] cq) {
 +    ArgumentChecker.notNull(cf, cq);
 +    this.cf = new ArrayByteSequence(cf);
 +    this.cq = new ArrayByteSequence(cq);
 +    this.cv = EMPTY;
 +  }
 +
 +  public Condition(Text cf, Text cq) {
 +    ArgumentChecker.notNull(cf, cq);
 +    this.cf = new ArrayByteSequence(cf.getBytes(), 0, cf.getLength());
 +    this.cq = new ArrayByteSequence(cq.getBytes(), 0, cq.getLength());
 +    this.cv = EMPTY;
 +  }
 +
 +  public Condition(ByteSequence cf, ByteSequence cq) {
 +    ArgumentChecker.notNull(cf, cq);
 +    this.cf = cf;
 +    this.cq = cq;
 +    this.cv = EMPTY;
 +  }
 +
 +  public ByteSequence getFamily() {
 +    return cf;
 +  }
 +  
 +  public ByteSequence getQualifier() {
 +    return cq;
 +  }
 +
 +  /**
 +   * Sets the version for the column to check. If this is not set then the latest column will be checked, unless iterators do something different.
 +   * 
-    * @param ts
 +   * @return returns this
 +   */
 +
 +  public Condition setTimestamp(long ts) {
 +    this.ts = ts;
 +    return this;
 +  }
 +  
 +  public Long getTimestamp() {
 +    return ts;
 +  }
 +
 +  /**
 +   * see {@link #setValue(byte[])}
 +   * 
-    * @param value
 +   * @return returns this
 +   */
 +
 +  public Condition setValue(CharSequence value) {
 +    ArgumentChecker.notNull(value);
 +    this.val = new ArrayByteSequence(value.toString().getBytes(Constants.UTF8));
 +    return this;
 +  }
 +
 +  /**
 +   * This method sets the expected value of a column. Inorder for the condition to pass the column must exist and have this value. If a value is not set, then
 +   * the column must be absent for the condition to pass.
 +   * 
-    * @param value
 +   * @return returns this
 +   */
 +
 +  public Condition setValue(byte[] value) {
 +    ArgumentChecker.notNull(value);
 +    this.val = new ArrayByteSequence(value);
 +    return this;
 +  }
 +  
 +  /**
 +   * see {@link #setValue(byte[])}
 +   * 
-    * @param value
 +   * @return returns this
 +   */
 +
 +  public Condition setValue(Text value) {
 +    ArgumentChecker.notNull(value);
 +    this.val = new ArrayByteSequence(value.getBytes(), 0, value.getLength());
 +    return this;
 +  }
 +  
 +  /**
 +   * see {@link #setValue(byte[])}
 +   * 
-    * @param value
 +   * @return returns this
 +   */
 +
 +  public Condition setValue(ByteSequence value) {
 +    ArgumentChecker.notNull(value);
 +    this.val = value;
 +    return this;
 +  }
 +
 +  public ByteSequence getValue() {
 +    return val;
 +  }
 +
 +  /**
 +   * Sets the visibility for the column to check. If not set it defaults to empty visibility.
 +   * 
-    * @param cv
 +   * @return returns this
 +   */
 +
 +  public Condition setVisibility(ColumnVisibility cv) {
 +    ArgumentChecker.notNull(cv);
 +    this.cv = new ArrayByteSequence(cv.getExpression());
 +    return this;
 +  }
 +
 +  public ByteSequence getVisibility() {
 +    return cv;
 +  }
 +
 +  /**
 +   * Set iterators to use when reading the columns value. These iterators will be applied in addition to the iterators configured for the table. Using iterators
 +   * its possible to test other conditions, besides equality and absence, like less than. On the server side the iterators will be seeked using a range that
 +   * covers only the family, qualifier, and visibility (if the timestamp is set then it will be used to narrow the range). Value equality will be tested using
 +   * the first entry returned by the iterator stack.
 +   * 
-    * @param iterators
 +   * @return returns this
 +   */
 +
 +  public Condition setIterators(IteratorSetting... iterators) {
 +    ArgumentChecker.notNull(iterators);
 +    
 +    if (iterators.length > 1) {
 +      HashSet<String> names = new HashSet<String>();
 +      HashSet<Integer> prios = new HashSet<Integer>();
 +      
 +      for (IteratorSetting iteratorSetting : iterators) {
 +        if (!names.add(iteratorSetting.getName()))
 +          throw new IllegalArgumentException("iterator name used more than once " + iteratorSetting.getName());
 +        if (!prios.add(iteratorSetting.getPriority()))
 +          throw new IllegalArgumentException("iterator priority used more than once " + iteratorSetting.getPriority());
 +      }
 +    }
 +    
 +    this.iterators = iterators;
 +    return this;
 +  }
 +
 +  public IteratorSetting[] getIterators() {
 +    return iterators;
 +  }
 +
 +  @Override
 +  public boolean equals(Object o) {
 +    if (o == this) {
 +      return true;
 +    }
 +    if (o == null || !(o instanceof Condition)) {
 +      return false;
 +    }
 +    Condition c = (Condition) o;
 +    if (!(c.cf.equals(cf))) {
 +      return false;
 +    }
 +    if (!(c.cq.equals(cq))) {
 +      return false;
 +    }
 +    if (!(c.cv.equals(cv))) {
 +      return false;
 +    }
 +    if (!(c.val == null ? val == null : c.val.equals(val))) {
 +      return false;
 +    }
 +    if (!(c.ts == null ? ts == null : c.ts.equals(ts))) {
 +      return false;
 +    }
 +    if (!(Arrays.equals(c.iterators, iterators))) {
 +      return false;
 +    }
 +    return true;
 +  }
 +
 +  @Override
 +  public int hashCode() {
 +    int result = 17;
 +    result = 31 * result + cf.hashCode();
 +    result = 31 * result + cq.hashCode();
 +    result = 31 * result + cv.hashCode();
 +    result = 31 * result + (val == null ? 0 : val.hashCode());
 +    result = 31 * result + (ts == null ? 0 : ts.hashCode());
 +    result = 31 * result + Arrays.hashCode(iterators);
 +    return result;
 +  }
 +
 +}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/data/Range.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/file/rfile/BlockIndex.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
index 6c3ea0d,7d15851..ca97e01
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
@@@ -136,13 -113,8 +136,11 @@@ public final class BCFile 
        /**
         * @param compressionAlgo
         *          The compression algorithm to be used to for compression.
 +       * @param cryptoModule
 +       *          the module to use to obtain cryptographic streams
-        * @param cryptoParams
-        * @throws IOException
         */
 -      public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf) throws IOException {
 +      public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf, CryptoModule cryptoModule,
 +          CryptoModuleParameters cryptoParams) throws IOException {
          this.compressAlgo = compressionAlgo;
          this.fsOut = fsOut;
          this.posStart = fsOut.getPos();
@@@ -343,10 -263,9 +339,9 @@@
       *          FS output stream.
       * @param compressionName
       *          Name of the compression algorithm, which will be used for all data blocks.
-      * @throws IOException
       * @see Compression#getSupportedAlgorithms
       */
 -    public Writer(FSDataOutputStream fout, String compressionName, Configuration conf, boolean trackDataBlocks) throws IOException {
 +    public Writer(FSDataOutputStream fout, String compressionName, Configuration conf, boolean trackDataBlocks, AccumuloConfiguration accumuloConfiguration) throws IOException {
        if (fout.getPos() != 0) {
          throw new IOException("Output file not at zero offset.");
        }
@@@ -507,7 -402,8 +500,8 @@@
          this.name = name;
          this.compressAlgo = compressAlgo;
        }
 -      
 +
+       @Override
        public void register(long raw, long begin, long end) {
          metaIndex.addEntry(new MetaIndexEntry(name, compressAlgo, new BlockRegion(begin, end - begin, raw)));
        }
@@@ -521,7 -417,8 +515,8 @@@
        DataBlockRegister() {
          // do nothing
        }
 -      
 +
+       @Override
        public void register(long raw, long begin, long end) {
          dataIndex.addBlockRegion(new BlockRegion(begin, end - begin, raw));
        }
@@@ -734,37 -560,22 +729,36 @@@
       *          FS input stream.
       * @param fileLength
       *          Length of the corresponding file
-      * @throws IOException
       */
 -    public Reader(FSDataInputStream fin, long fileLength, Configuration conf) throws IOException {
 +    public Reader(FSDataInputStream fin, long fileLength, Configuration conf, AccumuloConfiguration accumuloConfiguration) throws IOException {
 +
        this.in = fin;
        this.conf = conf;
 -      
 -      // move the cursor to the beginning of the tail, containing: offset to the
 -      // meta block index, version and magic
 -      fin.seek(fileLength - Magic.size() - Version.size() - Long.SIZE / Byte.SIZE);
 -      long offsetIndexMeta = fin.readLong();
 +
 +      // Move the cursor to grab the version and the magic first
 +      fin.seek(fileLength - Magic.size() - Version.size());
        version = new Version(fin);
        Magic.readAndVerify(fin);
 -      
 -      if (!version.compatibleWith(BCFile.API_VERSION)) {
 +
 +      // Do a version check
 +      if (!version.compatibleWith(BCFile.API_VERSION) && !version.equals(BCFile.API_VERSION_1)) {
          throw new RuntimeException("Incompatible BCFile fileBCFileVersion.");
        }
 -      
 +
 +      // Read the right number offsets based on version
 +      long offsetIndexMeta = 0;
 +      long offsetCryptoParameters = 0;
 +
 +      if (version.equals(API_VERSION_1)) {
 +        fin.seek(fileLength - Magic.size() - Version.size() - (Long.SIZE / Byte.SIZE));
 +        offsetIndexMeta = fin.readLong();
 +
 +      } else {
 +        fin.seek(fileLength - Magic.size() - Version.size() - (2 * (Long.SIZE / Byte.SIZE)));
 +        offsetIndexMeta = fin.readLong();
 +        offsetCryptoParameters = fin.readLong();
 +      }
 +
        // read meta index
        fin.seek(offsetIndexMeta);
        metaIndex = new MetaIndex(fin);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
index 541a379,53ea0e8..0ebf4d8
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
@@@ -628,11 -628,11 +628,11 @@@ abstract public class TransformingItera
     * @return the part of the key this iterator is not transforming
     */
    abstract protected PartialKey getKeyPrefix();
 -
 -  public static interface KVBuffer {
 +  
 +  public interface KVBuffer {
      void append(Key key, Value val);
    }
-   
+ 
    /**
     * Transforms {@code input}. This method must not change the row part of the key, and must only change the parts of the key after the return value of
     * {@link #getKeyPrefix()}. Implementors must also remember to copy the delete flag from {@code originalKey} onto the new key. Or, implementors should use one

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/security/SecurityUtil.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/716ea0ee/core/src/main/java/org/apache/accumulo/core/security/crypto/CryptoModuleFactory.java
----------------------------------------------------------------------


Mime
View raw message