accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [09/10] accumulo git commit: ACCUMULO-3199 Internal refactor to add ClientContext
Date Tue, 25 Nov 2014 22:36:53 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
index e45bcc9..6fdf4db 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ReplicationOperationsImpl.java
@@ -27,7 +27,6 @@ import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.BatchScanner;
 import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.admin.ReplicationOperations;
 import org.apache.accumulo.core.client.admin.TableOperations;
@@ -38,7 +37,6 @@ import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.master.thrift.MasterClientService.Client;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.ReplicationSection;
@@ -49,9 +47,7 @@ import org.apache.accumulo.core.replication.ReplicationTable;
 import org.apache.accumulo.core.replication.StatusUtil;
 import org.apache.accumulo.core.replication.proto.Replication.Status;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.core.tabletserver.log.LogEntry;
-import org.apache.accumulo.core.trace.Tracer;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
@@ -66,14 +62,11 @@ import com.google.protobuf.InvalidProtocolBufferException;
 public class ReplicationOperationsImpl implements ReplicationOperations {
   private static final Logger log = LoggerFactory.getLogger(ReplicationOperationsImpl.class);
 
-  private final Instance inst;
-  private final Credentials creds;
+  private final ClientContext context;
 
-  public ReplicationOperationsImpl(Instance inst, Credentials creds) {
-    checkNotNull(inst);
-    checkNotNull(creds);
-    this.inst = inst;
-    this.creds = creds;
+  public ReplicationOperationsImpl(ClientContext context) {
+    checkNotNull(context);
+    this.context = context;
   }
 
   @Override
@@ -88,29 +81,13 @@ public class ReplicationOperationsImpl implements ReplicationOperations {
   public void addPeer(final String name, final String replicaType) throws AccumuloException, AccumuloSecurityException, PeerExistsException {
     checkNotNull(name);
     checkNotNull(replicaType);
-
-    MasterClient.execute(inst, new ClientExec<Client>() {
-
-      @Override
-      public void execute(Client client) throws Exception {
-        client.setSystemProperty(Tracer.traceInfo(), creds.toThrift(inst), Property.REPLICATION_PEERS.getKey() + name, replicaType);
-      }
-
-    });
+    context.getConnector().instanceOperations().setProperty(Property.REPLICATION_PEERS.getKey() + name, replicaType);
   }
 
   @Override
   public void removePeer(final String name) throws AccumuloException, AccumuloSecurityException, PeerNotFoundException {
     checkNotNull(name);
-
-    MasterClient.execute(inst, new ClientExec<Client>() {
-
-      @Override
-      public void execute(Client client) throws Exception {
-        client.removeSystemProperty(Tracer.traceInfo(), creds.toThrift(inst), Property.REPLICATION_PEERS.getKey() + name);
-      }
-
-    });
+    context.getConnector().instanceOperations().removeProperty(Property.REPLICATION_PEERS.getKey() + name);
   }
 
   @Override
@@ -126,7 +103,7 @@ public class ReplicationOperationsImpl implements ReplicationOperations {
   public void drain(String tableName, Set<String> wals) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     checkNotNull(tableName);
 
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
+    Connector conn = context.getConnector();
     Text tableId = getTableId(conn, tableName);
 
     log.info("Waiting for {} to be replicated for {}", wals, tableId);
@@ -238,7 +215,7 @@ public class ReplicationOperationsImpl implements ReplicationOperations {
 
     log.debug("Collecting referenced files for replication of table {}", tableName);
 
-    Connector conn = inst.getConnector(creds.getPrincipal(), creds.getToken());
+    Connector conn = context.getConnector();
     Text tableId = getTableId(conn, tableName);
 
     log.debug("Found id of {} for name {}", tableId, tableName);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java
index 97d476b..2a18765 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/RootTabletLocator.java
@@ -31,7 +31,6 @@ import org.apache.accumulo.core.data.KeyExtent;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.core.util.OpTimer;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
@@ -43,23 +42,22 @@ import org.apache.log4j.Logger;
 
 public class RootTabletLocator extends TabletLocator {
   
-  private final Instance instance;
   private final TabletServerLockChecker lockChecker;
   private final ZooCacheFactory zcf;
   
-  RootTabletLocator(Instance instance, TabletServerLockChecker lockChecker) {
-    this(instance, lockChecker, new ZooCacheFactory());
+  RootTabletLocator(TabletServerLockChecker lockChecker) {
+    this(lockChecker, new ZooCacheFactory());
   }
-  RootTabletLocator(Instance instance, TabletServerLockChecker lockChecker, ZooCacheFactory zcf) {
-    this.instance = instance;
+
+  RootTabletLocator(TabletServerLockChecker lockChecker, ZooCacheFactory zcf) {
     this.lockChecker = lockChecker;
     this.zcf = zcf;
   }
   
   @Override
-  public <T extends Mutation> void binMutations(Credentials credentials, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures)
+  public <T extends Mutation> void binMutations(ClientContext context, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures)
       throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
-    TabletLocation rootTabletLocation = getRootTabletLocation();
+    TabletLocation rootTabletLocation = getRootTabletLocation(context);
     if (rootTabletLocation != null) {
       TabletServerMutations<T> tsm = new TabletServerMutations<T>(rootTabletLocation.tablet_session);
       for (T mutation : mutations) {
@@ -72,10 +70,10 @@ public class RootTabletLocator extends TabletLocator {
   }
   
   @Override
-  public List<Range> binRanges(Credentials credentials, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges) throws AccumuloException,
+  public List<Range> binRanges(ClientContext context, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges) throws AccumuloException,
       AccumuloSecurityException, TableNotFoundException {
     
-    TabletLocation rootTabletLocation = getRootTabletLocation();
+    TabletLocation rootTabletLocation = getRootTabletLocation(context);
     if (rootTabletLocation != null) {
       for (Range range : ranges) {
         TabletLocatorImpl.addRange(binnedRanges, rootTabletLocation.tablet_location, RootTable.EXTENT, range);
@@ -92,7 +90,7 @@ public class RootTabletLocator extends TabletLocator {
   public void invalidateCache(Collection<KeyExtent> keySet) {}
   
   @Override
-  public void invalidateCache(String server) {
+  public void invalidateCache(Instance instance, String server) {
     ZooCache zooCache = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
     String root = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
     zooCache.clear(root + "/" + server);
@@ -101,7 +99,8 @@ public class RootTabletLocator extends TabletLocator {
   @Override
   public void invalidateCache() {}
   
-  protected TabletLocation getRootTabletLocation() {
+  protected TabletLocation getRootTabletLocation(ClientContext context) {
+    Instance instance = context.getInstance();
     String zRootLocPath = ZooUtil.getRoot(instance) + RootTable.ZROOT_TABLET_LOCATION;
     ZooCache zooCache = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
     
@@ -122,13 +121,13 @@ public class RootTabletLocator extends TabletLocator {
   }
 
   @Override
-  public TabletLocation locateTablet(Credentials credentials, Text row, boolean skipRow, boolean retry) throws AccumuloException, AccumuloSecurityException,
+  public TabletLocation locateTablet(ClientContext context, Text row, boolean skipRow, boolean retry) throws AccumuloException, AccumuloSecurityException,
       TableNotFoundException {
-    TabletLocation location = getRootTabletLocation();
+    TabletLocation location = getRootTabletLocation(context);
     // Always retry when finding the root tablet
     while (retry && location == null) {
       UtilWaitThread.sleep(500);
-      location = getRootTabletLocation();
+      location = getRootTabletLocation(context);
     }
     
     return location;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java
index 670782e..666a8af 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java
@@ -17,18 +17,17 @@
 package org.apache.accumulo.core.client.impl;
 
 import static com.google.common.base.Preconditions.checkArgument;
+
 import java.util.Iterator;
 import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.hadoop.io.Text;
 
 /**
@@ -46,8 +45,7 @@ public class ScannerImpl extends ScannerOptions implements Scanner {
   // hopefully, we can track all the state in the scanner on the client
   // and just query for the next highest row from the tablet server
   
-  private Instance instance;
-  private Credentials credentials;
+  private final ClientContext context;
   private Authorizations authorizations;
   private Text table;
   
@@ -57,13 +55,11 @@ public class ScannerImpl extends ScannerOptions implements Scanner {
   private boolean isolated = false;
   private long readaheadThreshold = Constants.SCANNER_DEFAULT_READAHEAD_THRESHOLD;
   
-  public ScannerImpl(Instance instance, Credentials credentials, String table, Authorizations authorizations) {
-    checkArgument(instance != null, "instance is null");
-    checkArgument(credentials != null, "credentials is null");
+  public ScannerImpl(ClientContext context, String table, Authorizations authorizations) {
+    checkArgument(context != null, "context is null");
     checkArgument(table != null, "table is null");
     checkArgument(authorizations != null, "authorizations is null");
-    this.instance = instance;
-    this.credentials = credentials;
+    this.context = context;
     this.table = new Text(table);
     this.range = new Range((Key) null, (Key) null);
     this.authorizations = authorizations;
@@ -101,7 +97,7 @@ public class ScannerImpl extends ScannerOptions implements Scanner {
    */
   @Override
   public synchronized Iterator<Entry<Key,Value>> iterator() {
-    return new ScannerIterator(instance, credentials, table, authorizations, range, size, getTimeOut(), this, isolated, readaheadThreshold);
+    return new ScannerIterator(context, table, authorizations, range, size, getTimeOut(), this, isolated, readaheadThreshold);
   }
   
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java
index b0bfc20..1e0ac99 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java
@@ -29,7 +29,6 @@ import java.util.concurrent.TimeUnit;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.TableDeletedException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.TableOfflineException;
@@ -40,7 +39,6 @@ import org.apache.accumulo.core.data.KeyValue;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.core.util.NamingThreadFactory;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
@@ -56,8 +54,6 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> {
   // scanner state
   private Iterator<KeyValue> iter;
   private ScanState scanState;
-  private Credentials credentials;
-  private Instance instance;
   
   private ScannerOptions options;
   
@@ -81,7 +77,7 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> {
       
       try {
         while (true) {
-          List<KeyValue> currentBatch = ThriftScanner.scan(instance, credentials, scanState, timeOut, ClientConfigurationHelper.getClientRpcConfiguration(instance));
+          List<KeyValue> currentBatch = ThriftScanner.scan(scanState.context, scanState, timeOut);
           
           if (currentBatch == null) {
             synchQ.add(EMPTY_LIST);
@@ -123,17 +119,15 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> {
     
   }
   
-  ScannerIterator(Instance instance, Credentials credentials, Text table, Authorizations authorizations, Range range, int size, int timeOut,
-      ScannerOptions options, boolean isolated) {
-    this(instance, credentials, table, authorizations, range, size, timeOut, options, isolated, Constants.SCANNER_DEFAULT_READAHEAD_THRESHOLD);
+  ScannerIterator(ClientContext context, Text table, Authorizations authorizations, Range range, int size, int timeOut, ScannerOptions options,
+      boolean isolated) {
+    this(context, table, authorizations, range, size, timeOut, options, isolated, Constants.SCANNER_DEFAULT_READAHEAD_THRESHOLD);
   }
   
-  ScannerIterator(Instance instance, Credentials credentials, Text table, Authorizations authorizations, Range range, int size, int timeOut,
-      ScannerOptions options, boolean isolated, long readaheadThreshold) {
-    this.instance = instance;
+  ScannerIterator(ClientContext context, Text table, Authorizations authorizations, Range range, int size, int timeOut, ScannerOptions options,
+      boolean isolated, long readaheadThreshold) {
     this.tableId = new Text(table);
     this.timeOut = timeOut;
-    this.credentials = credentials;
     this.readaheadThreshold = readaheadThreshold;
     
     this.options = new ScannerOptions(options);
@@ -144,7 +138,7 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> {
       range = range.bound(this.options.fetchedColumns.first(), this.options.fetchedColumns.last());
     }
     
-    scanState = new ScanState(instance, credentials, tableId, authorizations, new Range(range), options.fetchedColumns, size, options.serverSideIteratorList,
+    scanState = new ScanState(context, tableId, authorizations, new Range(range), options.fetchedColumns, size, options.serverSideIteratorList,
         options.serverSideIteratorOptions, isolated, readaheadThreshold);
     
     // If we want to start readahead immediately, don't wait for hasNext to be called

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java
index 8a17a77..feb1ee7 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java
@@ -17,12 +17,12 @@
 package org.apache.accumulo.core.client.impl;
 
 import static com.google.common.base.Preconditions.checkArgument;
+
 import java.nio.ByteBuffer;
 import java.util.Set;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.admin.SecurityOperations;
 import org.apache.accumulo.core.client.impl.thrift.ClientService;
 import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
@@ -41,12 +41,11 @@ import org.apache.accumulo.core.util.ByteBufferUtil;
 
 public class SecurityOperationsImpl implements SecurityOperations {
 
-  private Instance instance;
-  private Credentials credentials;
+  private final ClientContext context;
 
   private void execute(ClientExec<ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
     try {
-      ServerClient.executeRaw(instance, exec);
+      ServerClient.executeRaw(context, exec);
     } catch (ThriftTableOperationException ttoe) {
       // recast missing table
       if (ttoe.getType() == TableOperationExceptionType.NOTFOUND)
@@ -66,7 +65,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
 
   private <T> T execute(ClientExecReturn<T,ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
     try {
-      return ServerClient.executeRaw(instance, exec);
+      return ServerClient.executeRaw(context, exec);
     } catch (ThriftTableOperationException ttoe) {
       // recast missing table
       if (ttoe.getType() == TableOperationExceptionType.NOTFOUND)
@@ -84,11 +83,9 @@ public class SecurityOperationsImpl implements SecurityOperations {
     }
   }
 
-  public SecurityOperationsImpl(Instance instance, Credentials credentials) {
-    checkArgument(instance != null, "instance is null");
-    checkArgument(credentials != null, "credentials is null");
-    this.instance = instance;
-    this.credentials = credentials;
+  public SecurityOperationsImpl(ClientContext context) {
+    checkArgument(context != null, "context is null");
+    this.context = context;
   }
 
   @Deprecated
@@ -105,7 +102,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.createLocalUser(Tracer.traceInfo(), credentials.toThrift(instance), principal, ByteBuffer.wrap(password.getPassword()));
+        client.createLocalUser(Tracer.traceInfo(), context.rpcCreds(), principal, ByteBuffer.wrap(password.getPassword()));
       }
     });
   }
@@ -122,7 +119,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.dropLocalUser(Tracer.traceInfo(), credentials.toThrift(instance), principal);
+        client.dropLocalUser(Tracer.traceInfo(), context.rpcCreds(), principal);
       }
     });
   }
@@ -141,7 +138,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
       @Override
       public Boolean execute(ClientService.Client client) throws Exception {
-        return client.authenticateUser(Tracer.traceInfo(), credentials.toThrift(instance), toAuth.toThrift(instance));
+        return client.authenticateUser(Tracer.traceInfo(), context.rpcCreds(), toAuth.toThrift(context.getInstance()));
       }
     });
   }
@@ -160,11 +157,11 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.changeLocalUserPassword(Tracer.traceInfo(), credentials.toThrift(instance), principal, ByteBuffer.wrap(token.getPassword()));
+        client.changeLocalUserPassword(Tracer.traceInfo(), context.rpcCreds(), principal, ByteBuffer.wrap(token.getPassword()));
       }
     });
-    if (this.credentials.getPrincipal().equals(principal)) {
-      this.credentials = toChange;
+    if (context.getCredentials().getPrincipal().equals(principal)) {
+      context.setCredentials(toChange);
     }
   }
 
@@ -175,8 +172,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.changeAuthorizations(Tracer.traceInfo(), credentials.toThrift(instance), principal,
-            ByteBufferUtil.toByteBuffers(authorizations.getAuthorizations()));
+        client.changeAuthorizations(Tracer.traceInfo(), context.rpcCreds(), principal, ByteBufferUtil.toByteBuffers(authorizations.getAuthorizations()));
       }
     });
   }
@@ -187,7 +183,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     return execute(new ClientExecReturn<Authorizations,ClientService.Client>() {
       @Override
       public Authorizations execute(ClientService.Client client) throws Exception {
-        return new Authorizations(client.getUserAuthorizations(Tracer.traceInfo(), credentials.toThrift(instance), principal));
+        return new Authorizations(client.getUserAuthorizations(Tracer.traceInfo(), context.rpcCreds(), principal));
       }
     });
   }
@@ -199,7 +195,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
       @Override
       public Boolean execute(ClientService.Client client) throws Exception {
-        return client.hasSystemPermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, perm.getId());
+        return client.hasSystemPermission(Tracer.traceInfo(), context.rpcCreds(), principal, perm.getId());
       }
     });
   }
@@ -213,7 +209,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
         @Override
         public Boolean execute(ClientService.Client client) throws Exception {
-          return client.hasTablePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, table, perm.getId());
+          return client.hasTablePermission(Tracer.traceInfo(), context.rpcCreds(), principal, table, perm.getId());
         }
       });
     } catch (AccumuloSecurityException e) {
@@ -233,7 +229,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
       @Override
       public Boolean execute(ClientService.Client client) throws Exception {
-        return client.hasNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, namespace, permission.getId());
+        return client.hasNamespacePermission(Tracer.traceInfo(), context.rpcCreds(), principal, namespace, permission.getId());
       }
     });
   }
@@ -245,7 +241,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.grantSystemPermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, permission.getId());
+        client.grantSystemPermission(Tracer.traceInfo(), context.rpcCreds(), principal, permission.getId());
       }
     });
   }
@@ -260,7 +256,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       execute(new ClientExec<ClientService.Client>() {
         @Override
         public void execute(ClientService.Client client) throws Exception {
-          client.grantTablePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, table, permission.getId());
+          client.grantTablePermission(Tracer.traceInfo(), context.rpcCreds(), principal, table, permission.getId());
         }
       });
     } catch (AccumuloSecurityException e) {
@@ -280,7 +276,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.grantNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, namespace, permission.getId());
+        client.grantNamespacePermission(Tracer.traceInfo(), context.rpcCreds(), principal, namespace, permission.getId());
       }
     });
   }
@@ -292,7 +288,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.revokeSystemPermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, permission.getId());
+        client.revokeSystemPermission(Tracer.traceInfo(), context.rpcCreds(), principal, permission.getId());
       }
     });
   }
@@ -307,7 +303,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       execute(new ClientExec<ClientService.Client>() {
         @Override
         public void execute(ClientService.Client client) throws Exception {
-          client.revokeTablePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, table, permission.getId());
+          client.revokeTablePermission(Tracer.traceInfo(), context.rpcCreds(), principal, table, permission.getId());
         }
       });
     } catch (AccumuloSecurityException e) {
@@ -327,7 +323,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.revokeNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, namespace, permission.getId());
+        client.revokeNamespacePermission(Tracer.traceInfo(), context.rpcCreds(), principal, namespace, permission.getId());
       }
     });
   }
@@ -343,7 +339,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
     return execute(new ClientExecReturn<Set<String>,ClientService.Client>() {
       @Override
       public Set<String> execute(ClientService.Client client) throws Exception {
-        return client.listLocalUsers(Tracer.traceInfo(), credentials.toThrift(instance));
+        return client.listLocalUsers(Tracer.traceInfo(), context.rpcCreds());
       }
     });
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
index 2d76695..ebccdab 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
@@ -28,11 +28,8 @@ import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.thrift.ClientService;
 import org.apache.accumulo.core.client.impl.thrift.ClientService.Client;
 import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.util.ServerServices;
-import org.apache.accumulo.core.util.SslConnectionParams;
 import org.apache.accumulo.core.util.ServerServices.Service;
 import org.apache.accumulo.core.util.ThriftUtil;
 import org.apache.accumulo.core.util.UtilWaitThread;
@@ -46,9 +43,9 @@ import org.apache.thrift.transport.TTransportException;
 public class ServerClient {
   private static final Logger log = Logger.getLogger(ServerClient.class);
   
-  public static <T> T execute(Instance instance, ClientExecReturn<T,ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
+  public static <T> T execute(ClientContext context, ClientExecReturn<T,ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
     try {
-      return executeRaw(instance, exec);
+      return executeRaw(context, exec);
     } catch (ThriftSecurityException e) {
       throw new AccumuloSecurityException(e.user, e.code, e);
     } catch (AccumuloException e) {
@@ -58,9 +55,9 @@ public class ServerClient {
     }
   }
   
-  public static void execute(Instance instance, ClientExec<ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
+  public static void execute(ClientContext context, ClientExec<ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
     try {
-      executeRaw(instance, exec);
+      executeRaw(context, exec);
     } catch (ThriftSecurityException e) {
       throw new AccumuloSecurityException(e.user, e.code, e);
     } catch (AccumuloException e) {
@@ -70,12 +67,12 @@ public class ServerClient {
     }
   }
   
-  public static <T> T executeRaw(Instance instance, ClientExecReturn<T,ClientService.Client> exec) throws Exception {
+  public static <T> T executeRaw(ClientContext context, ClientExecReturn<T,ClientService.Client> exec) throws Exception {
     while (true) {
       ClientService.Client client = null;
       String server = null;
       try {
-        Pair<String,Client> pair = ServerClient.getConnection(instance);
+        Pair<String,Client> pair = ServerClient.getConnection(context);
         server = pair.getFirst();
         client = pair.getSecond();
         return exec.execute(client);
@@ -89,12 +86,12 @@ public class ServerClient {
     }
   }
   
-  public static void executeRaw(Instance instance, ClientExec<ClientService.Client> exec) throws Exception {
+  public static void executeRaw(ClientContext context, ClientExec<ClientService.Client> exec) throws Exception {
     while (true) {
       ClientService.Client client = null;
       String server = null;
       try {
-        Pair<String,Client> pair = ServerClient.getConnection(instance);
+        Pair<String,Client> pair = ServerClient.getConnection(context);
         server = pair.getFirst();
         client = pair.getSecond();
         exec.execute(client);
@@ -111,28 +108,28 @@ public class ServerClient {
   
   static volatile boolean warnedAboutTServersBeingDown = false;
 
-  public static Pair<String,ClientService.Client> getConnection(Instance instance) throws TTransportException {
-    return getConnection(instance, true);
+  public static Pair<String,ClientService.Client> getConnection(ClientContext context) throws TTransportException {
+    return getConnection(context, true);
   }
   
-  public static Pair<String,ClientService.Client> getConnection(Instance instance, boolean preferCachedConnections) throws TTransportException {
-    AccumuloConfiguration rpcConfig = ClientConfigurationHelper.getClientRpcConfiguration(instance);
-    return getConnection(instance, preferCachedConnections, rpcConfig.getTimeInMillis(Property.GENERAL_RPC_TIMEOUT));
+  public static Pair<String,ClientService.Client> getConnection(ClientContext context, boolean preferCachedConnections) throws TTransportException {
+    return getConnection(context, preferCachedConnections, context.getClientTimeoutInMillis());
   }
   
-  public static Pair<String,ClientService.Client> getConnection(Instance instance, boolean preferCachedConnections, long rpcTimeout) throws TTransportException {
-    checkArgument(instance != null, "instance is null");
+  public static Pair<String,ClientService.Client> getConnection(ClientContext context, boolean preferCachedConnections, long rpcTimeout)
+      throws TTransportException {
+    checkArgument(context != null, "context is null");
     // create list of servers
     ArrayList<ThriftTransportKey> servers = new ArrayList<ThriftTransportKey>();
     
     // add tservers
+    Instance instance = context.getInstance();
     ZooCache zc = new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
     for (String tserver : zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTSERVERS)) {
       String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + tserver;
       byte[] data = ZooUtil.getLockData(zc, path);
       if (data != null && !new String(data, UTF_8).equals("master"))
-        servers.add(new ThriftTransportKey(new ServerServices(new String(data)).getAddressString(Service.TSERV_CLIENT), rpcTimeout, SslConnectionParams
-            .forClient(ClientConfigurationHelper.getClientRpcConfiguration(instance))));
+        servers.add(new ThriftTransportKey(new ServerServices(new String(data)).getAddressString(Service.TSERV_CLIENT), rpcTimeout, context));
     }
     
     boolean opened = false;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
index 3c450c3..77b6a01 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
@@ -51,7 +51,6 @@ import java.util.zip.ZipInputStream;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-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.NamespaceExistsException;
@@ -64,8 +63,8 @@ import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.TableOfflineException;
 import org.apache.accumulo.core.client.admin.DiskUsage;
 import org.apache.accumulo.core.client.admin.FindMax;
-import org.apache.accumulo.core.client.admin.TimeType;
 import org.apache.accumulo.core.client.admin.TableOperations;
+import org.apache.accumulo.core.client.admin.TimeType;
 import org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation;
 import org.apache.accumulo.core.client.impl.thrift.ClientService;
 import org.apache.accumulo.core.client.impl.thrift.ClientService.Client;
@@ -92,7 +91,6 @@ import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
 import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
 import org.apache.accumulo.core.trace.Tracer;
@@ -120,26 +118,14 @@ import org.apache.thrift.transport.TTransportException;
 import com.google.common.base.Joiner;
 
 public class TableOperationsImpl extends TableOperationsHelper {
-  private Instance instance;
-  private Credentials credentials;
-  private AccumuloConfiguration rpcConfig;
 
   public static final String CLONE_EXCLUDE_PREFIX = "!";
-
   private static final Logger log = Logger.getLogger(TableOperations.class);
+  private final ClientContext context;
 
-  /**
-   * @param instance
-   *          the connection information for this instance
-   * @param credentials
-   *          the username/password for this connection
-   */
-  public TableOperationsImpl(Instance instance, Credentials credentials) {
-    checkArgument(instance != null, "instance is null");
-    checkArgument(credentials != null, "credentials is null");
-    this.instance = instance;
-    this.rpcConfig = ClientConfigurationHelper.getClientRpcConfiguration(instance);
-    this.credentials = credentials;
+  public TableOperationsImpl(ClientContext context) {
+    checkArgument(context != null, "context is null");
+    this.context = context;
   }
 
   /**
@@ -150,7 +136,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
   @Override
   public SortedSet<String> list() {
     OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Fetching list of tables...");
-    TreeSet<String> tableNames = new TreeSet<String>(Tables.getNameToIdMap(instance).keySet());
+    TreeSet<String> tableNames = new TreeSet<String>(Tables.getNameToIdMap(context.getInstance()).keySet());
     opTimer.stop("Fetched " + tableNames.size() + " table names in %DURATION%");
     return tableNames;
   }
@@ -169,7 +155,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
       return true;
 
     OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Checking if table " + tableName + " exists...");
-    boolean exists = Tables.getNameToIdMap(instance).containsKey(tableName);
+    boolean exists = Tables.getNameToIdMap(context.getInstance()).containsKey(tableName);
     opTimer.stop("Checked existance of " + exists + " in %DURATION%");
     return exists;
   }
@@ -235,8 +221,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
     while (true) {
       MasterClientService.Iface client = null;
       try {
-        client = MasterClient.getConnectionWithRetry(instance);
-        return client.beginFateOperation(Tracer.traceInfo(), credentials.toThrift(instance));
+        client = MasterClient.getConnectionWithRetry(context);
+        return client.beginFateOperation(Tracer.traceInfo(), context.rpcCreds());
       } catch (TTransportException tte) {
         log.debug("Failed to call beginFateOperation(), retrying ... ", tte);
         UtilWaitThread.sleep(100);
@@ -252,8 +238,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
     while (true) {
       MasterClientService.Iface client = null;
       try {
-        client = MasterClient.getConnectionWithRetry(instance);
-        client.executeFateOperation(Tracer.traceInfo(), credentials.toThrift(instance), opid, op, args, opts, autoCleanUp);
+        client = MasterClient.getConnectionWithRetry(context);
+        client.executeFateOperation(Tracer.traceInfo(), context.rpcCreds(), opid, op, args, opts, autoCleanUp);
         break;
       } catch (TTransportException tte) {
         log.debug("Failed to call executeFateOperation(), retrying ... ", tte);
@@ -268,8 +254,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
     while (true) {
       MasterClientService.Iface client = null;
       try {
-        client = MasterClient.getConnectionWithRetry(instance);
-        return client.waitForFateOperation(Tracer.traceInfo(), credentials.toThrift(instance), opid);
+        client = MasterClient.getConnectionWithRetry(context);
+        return client.waitForFateOperation(Tracer.traceInfo(), context.rpcCreds(), opid);
       } catch (TTransportException tte) {
         log.debug("Failed to call waitForFateOperation(), retrying ... ", tte);
         UtilWaitThread.sleep(100);
@@ -283,8 +269,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
     while (true) {
       MasterClientService.Iface client = null;
       try {
-        client = MasterClient.getConnectionWithRetry(instance);
-        client.finishFateOperation(Tracer.traceInfo(), credentials.toThrift(instance), opid);
+        client = MasterClient.getConnectionWithRetry(context);
+        client.finishFateOperation(Tracer.traceInfo(), context.rpcCreds(), opid);
         break;
       } catch (TTransportException tte) {
         log.debug("Failed to call finishFateOperation(), retrying ... ", tte);
@@ -321,7 +307,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
         case NAMESPACE_DOESNT_EXIST:
           throw new NamespaceNotFoundException(null, tableName, "Target namespace does not exist");
         default:
-          String tableInfo = Tables.getPrintableTableInfoFromName(instance, tableName);
+          String tableInfo = Tables.getPrintableTableInfoFromName(context.getInstance(), tableName);
           throw new AccumuloSecurityException(e.user, e.code, tableInfo, e);
       }
     } catch (ThriftTableOperationException e) {
@@ -335,14 +321,14 @@ public class TableOperationsImpl extends TableOperationsHelper {
         case NAMESPACE_NOTFOUND:
           throw new NamespaceNotFoundException(e);
         case OFFLINE:
-          throw new TableOfflineException(instance, null);
+          throw new TableOfflineException(context.getInstance(), null);
         default:
           throw new AccumuloException(e.description, e);
       }
     } catch (Exception e) {
       throw new AccumuloException(e.getMessage(), e);
     } finally {
-      Tables.clearCache(instance);
+      Tables.clearCache(context.getInstance());
       // always finish table op, even when exception
       if (opid != null)
         try {
@@ -423,7 +409,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
    */
   @Override
   public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
-    String tableId = Tables.getTableId(instance, tableName);
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
 
     List<Text> splits = new ArrayList<Text>(partitionKeys);
     // should be sorted because we copied from a sorted set, but that makes assumptions about
@@ -462,7 +448,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
   private void addSplits(String tableName, SortedSet<Text> partitionKeys, String tableId) throws AccumuloException, AccumuloSecurityException,
       TableNotFoundException, AccumuloServerException {
-    TabletLocator tabLocator = TabletLocator.getLocator(instance, new Text(tableId));
+    TabletLocator tabLocator = TabletLocator.getLocator(context, new Text(tableId));
 
     for (Text split : partitionKeys) {
       boolean successful = false;
@@ -476,24 +462,24 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
         attempt++;
 
-        TabletLocation tl = tabLocator.locateTablet(credentials, split, false, false);
+        TabletLocation tl = tabLocator.locateTablet(context, split, false, false);
 
         if (tl == null) {
-          if (!Tables.exists(instance, tableId))
+          if (!Tables.exists(context.getInstance(), tableId))
             throw new TableNotFoundException(tableId, tableName, null);
-          else if (Tables.getTableState(instance, tableId) == TableState.OFFLINE)
-            throw new TableOfflineException(instance, tableId);
+          else if (Tables.getTableState(context.getInstance(), tableId) == TableState.OFFLINE)
+            throw new TableOfflineException(context.getInstance(), tableId);
           continue;
         }
 
         try {
-          TabletClientService.Client client = ThriftUtil.getTServerClient(tl.tablet_location, rpcConfig);
+          TabletClientService.Client client = ThriftUtil.getTServerClient(tl.tablet_location, context);
           try {
             OpTimer opTimer = null;
             if (log.isTraceEnabled())
               opTimer = new OpTimer(log, Level.TRACE).start("Splitting tablet " + tl.tablet_extent + " on " + tl.tablet_location + " at " + split);
 
-            client.splitTablet(Tracer.traceInfo(), credentials.toThrift(instance), tl.tablet_extent.toThrift(), TextUtil.getByteBuffer(split));
+            client.splitTablet(Tracer.traceInfo(), context.rpcCreds(), tl.tablet_extent.toThrift(), TextUtil.getByteBuffer(split));
 
             // just split it, might as well invalidate it in the cache
             tabLocator.invalidateCache(tl.tablet_extent);
@@ -507,11 +493,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
         } catch (TApplicationException tae) {
           throw new AccumuloServerException(tl.tablet_location, tae);
         } catch (TTransportException e) {
-          tabLocator.invalidateCache(tl.tablet_location);
+          tabLocator.invalidateCache(context.getInstance(), tl.tablet_location);
           continue;
         } catch (ThriftSecurityException e) {
-          Tables.clearCache(instance);
-          if (!Tables.exists(instance, tableId))
+          Tables.clearCache(context.getInstance());
+          if (!Tables.exists(context.getInstance(), tableId))
             throw new TableNotFoundException(tableId, tableName, null);
           throw new AccumuloSecurityException(e.user, e.code, e);
         } catch (NotServingTabletException e) {
@@ -525,7 +511,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
           tabLocator.invalidateCache(tl.tablet_extent);
           continue;
         } catch (TException e) {
-          tabLocator.invalidateCache(tl.tablet_location);
+          tabLocator.invalidateCache(context.getInstance(), tl.tablet_location);
           continue;
         }
 
@@ -576,7 +562,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
     checkArgument(tableName != null, "tableName is null");
 
-    String tableId = Tables.getTableId(instance, tableName);
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
 
     TreeMap<KeyExtent,String> tabletLocations = new TreeMap<KeyExtent,String>();
 
@@ -584,12 +570,12 @@ public class TableOperationsImpl extends TableOperationsHelper {
       try {
         tabletLocations.clear();
         // the following method throws AccumuloException for some conditions that should be retried
-        MetadataServicer.forTableId(instance, credentials, tableId).getTabletLocations(tabletLocations);
+        MetadataServicer.forTableId(context, tableId).getTabletLocations(tabletLocations);
         break;
       } catch (AccumuloSecurityException ase) {
         throw ase;
       } catch (Exception e) {
-        if (!Tables.exists(instance, tableId)) {
+        if (!Tables.exists(context.getInstance(), tableId)) {
           throw new TableNotFoundException(tableId, tableName, null);
         }
 
@@ -698,7 +684,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
     checkArgument(srcTableName != null, "srcTableName is null");
     checkArgument(newTableName != null, "newTableName is null");
 
-    String srcTableId = Tables.getTableId(instance, srcTableName);
+    String srcTableId = Tables.getTableId(context.getInstance(), srcTableName);
 
     if (flush)
       _flush(srcTableId, null, null, true);
@@ -776,7 +762,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
   public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     checkArgument(tableName != null, "tableName is null");
 
-    String tableId = Tables.getTableId(instance, tableName);
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
     _flush(tableId, start, end, wait);
   }
 
@@ -792,13 +778,13 @@ public class TableOperationsImpl extends TableOperationsHelper {
     checkArgument(tableName != null, "tableName is null");
     ByteBuffer EMPTY = ByteBuffer.allocate(0);
 
-    String tableId = Tables.getTableId(instance, tableName);
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
 
     if (flush)
       _flush(tableId, start, end, true);
 
-    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes(UTF_8)), start == null ? EMPTY : TextUtil.getByteBuffer(start),
-        end == null ? EMPTY : TextUtil.getByteBuffer(end), ByteBuffer.wrap(IteratorUtil.encodeIteratorSettings(iterators)));
+    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes(UTF_8)), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
+        : TextUtil.getByteBuffer(end), ByteBuffer.wrap(IteratorUtil.encodeIteratorSettings(iterators)));
 
     Map<String,String> opts = new HashMap<String,String>();
     try {
@@ -816,7 +802,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
   @Override
   public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
-    String tableId = Tables.getTableId(instance, tableName);
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
 
     List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes(UTF_8)));
 
@@ -841,8 +827,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
       while (true) {
         MasterClientService.Iface client = null;
         try {
-          client = MasterClient.getConnectionWithRetry(instance);
-          flushID = client.initiateFlush(Tracer.traceInfo(), credentials.toThrift(instance), tableId);
+          client = MasterClient.getConnectionWithRetry(context);
+          flushID = client.initiateFlush(Tracer.traceInfo(), context.rpcCreds(), tableId);
           break;
         } catch (TTransportException tte) {
           log.debug("Failed to call initiateFlush, retrying ... ", tte);
@@ -855,8 +841,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
       while (true) {
         MasterClientService.Iface client = null;
         try {
-          client = MasterClient.getConnectionWithRetry(instance);
-          client.waitForFlush(Tracer.traceInfo(), credentials.toThrift(instance), tableId, TextUtil.getByteBuffer(start), TextUtil.getByteBuffer(end), flushID,
+          client = MasterClient.getConnectionWithRetry(context);
+          client.waitForFlush(Tracer.traceInfo(), context.rpcCreds(), tableId, TextUtil.getByteBuffer(start), TextUtil.getByteBuffer(end), flushID,
               wait ? Long.MAX_VALUE : 1);
           break;
         } catch (TTransportException tte) {
@@ -906,10 +892,10 @@ public class TableOperationsImpl extends TableOperationsHelper {
     checkArgument(property != null, "property is null");
     checkArgument(value != null, "value is null");
     try {
-      MasterClient.executeTable(instance, new ClientExec<MasterClientService.Client>() {
+      MasterClient.executeTable(context, new ClientExec<MasterClientService.Client>() {
         @Override
         public void execute(MasterClientService.Client client) throws Exception {
-          client.setTableProperty(Tracer.traceInfo(), credentials.toThrift(instance), tableName, property, value);
+          client.setTableProperty(Tracer.traceInfo(), context.rpcCreds(), tableName, property, value);
         }
       });
     } catch (TableNotFoundException e) {
@@ -934,10 +920,10 @@ public class TableOperationsImpl extends TableOperationsHelper {
     checkArgument(tableName != null, "tableName is null");
     checkArgument(property != null, "property is null");
     try {
-      MasterClient.executeTable(instance, new ClientExec<MasterClientService.Client>() {
+      MasterClient.executeTable(context, new ClientExec<MasterClientService.Client>() {
         @Override
         public void execute(MasterClientService.Client client) throws Exception {
-          client.removeTableProperty(Tracer.traceInfo(), credentials.toThrift(instance), tableName, property);
+          client.removeTableProperty(Tracer.traceInfo(), context.rpcCreds(), tableName, property);
         }
       });
     } catch (TableNotFoundException e) {
@@ -958,10 +944,10 @@ public class TableOperationsImpl extends TableOperationsHelper {
   public Iterable<Entry<String,String>> getProperties(final String tableName) throws AccumuloException, TableNotFoundException {
     checkArgument(tableName != null, "tableName is null");
     try {
-      return ServerClient.executeRaw(instance, new ClientExecReturn<Map<String,String>,ClientService.Client>() {
+      return ServerClient.executeRaw(context, new ClientExecReturn<Map<String,String>,ClientService.Client>() {
         @Override
         public Map<String,String> execute(ClientService.Client client) throws Exception {
-          return client.getTableConfiguration(Tracer.traceInfo(), credentials.toThrift(instance), tableName);
+          return client.getTableConfiguration(Tracer.traceInfo(), context.rpcCreds(), tableName);
         }
       }).entrySet();
     } catch (ThriftTableOperationException e) {
@@ -1098,15 +1084,15 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
     Random random = new Random();
     Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<String,Map<KeyExtent,List<Range>>>();
-    String tableId = Tables.getTableId(instance, tableName);
-    TabletLocator tl = TabletLocator.getLocator(instance, new Text(tableId));
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
+    TabletLocator tl = TabletLocator.getLocator(context, new Text(tableId));
     // its possible that the cache could contain complete, but old information about a tables tablets... so clear it
     tl.invalidateCache();
-    while (!tl.binRanges(credentials, Collections.singletonList(range), binnedRanges).isEmpty()) {
-      if (!Tables.exists(instance, tableId))
+    while (!tl.binRanges(context, Collections.singletonList(range), binnedRanges).isEmpty()) {
+      if (!Tables.exists(context.getInstance(), tableId))
         throw new TableDeletedException(tableId);
-      if (Tables.getTableState(instance, tableId) == TableState.OFFLINE)
-        throw new TableOfflineException(instance, tableId);
+      if (Tables.getTableState(context.getInstance(), tableId) == TableState.OFFLINE)
+        throw new TableOfflineException(context.getInstance(), tableId);
 
       log.warn("Unable to locate bins for specified range. Retrying.");
       // sleep randomly between 100 and 200ms
@@ -1151,9 +1137,12 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
   // TODO Remove deprecation warning suppression when Hadoop1 support is dropped
   @SuppressWarnings("deprecation")
-  private Path checkPath(String dir, String kind, String type) throws IOException, AccumuloException {
+  private Path checkPath(String dir, String kind, String type) throws IOException, AccumuloException, AccumuloSecurityException {
     Path ret;
-    FileSystem fs = VolumeConfiguration.getVolume(dir, CachedConfiguration.getInstance(), rpcConfig).getFileSystem();
+    Map<String,String> props = context.getConnector().instanceOperations().getSystemConfiguration();
+    AccumuloConfiguration conf = new ConfigurationCopy(props);
+
+    FileSystem fs = VolumeConfiguration.getVolume(dir, CachedConfiguration.getInstance(), conf).getFileSystem();
 
     if (dir.contains(":")) {
       ret = new Path(dir);
@@ -1185,7 +1174,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
     checkArgument(dir != null, "dir is null");
     checkArgument(failureDir != null, "failureDir is null");
     // check for table existance
-    Tables.getTableId(instance, tableName);
+    Tables.getTableId(context.getInstance(), tableName);
 
     Path dirPath = checkPath(dir, "Bulk", "");
     Path failPath = checkPath(failureDir, "Bulk", "failure");
@@ -1210,12 +1199,12 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
     while (true) {
 
-      if (Tables.getTableState(instance, tableId) != expectedState) {
-        Tables.clearCache(instance);
-        if (Tables.getTableState(instance, tableId) != expectedState) {
-          if (!Tables.exists(instance, tableId))
+      if (Tables.getTableState(context.getInstance(), tableId) != expectedState) {
+        Tables.clearCache(context.getInstance());
+        if (Tables.getTableState(context.getInstance(), tableId) != expectedState) {
+          if (!Tables.exists(context.getInstance(), tableId))
             throw new TableDeletedException(tableId);
-          throw new AccumuloException("Unexpected table state " + tableId + " " + Tables.getTableState(instance, tableId) + " != " + expectedState);
+          throw new AccumuloException("Unexpected table state " + tableId + " " + Tables.getTableState(context.getInstance(), tableId) + " != " + expectedState);
         }
       }
 
@@ -1229,7 +1218,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
       if (tableId.equals(MetadataTable.ID))
         metaTable = RootTable.NAME;
 
-      Scanner scanner = createMetadataScanner(instance, credentials, metaTable, range);
+      Scanner scanner = createMetadataScanner(metaTable, range);
 
       RowIterator rowIter = new RowIterator(scanner);
 
@@ -1319,10 +1308,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
   /**
    * Create an IsolatedScanner over the given table, fetching the columns necessary to determine when a table has transitioned to online or offline.
    */
-  protected IsolatedScanner createMetadataScanner(Instance inst, Credentials creds, String metaTable, Range range) throws TableNotFoundException,
-      AccumuloException,
-      AccumuloSecurityException {
-    Scanner scanner = inst.getConnector(creds.getPrincipal(), creds.getToken()).createScanner(metaTable, Authorizations.EMPTY);
+  protected IsolatedScanner createMetadataScanner(String metaTable, Range range) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
+    Scanner scanner = context.getConnector().createScanner(metaTable, Authorizations.EMPTY);
     TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
     scanner.fetchColumnFamily(TabletsSection.FutureLocationColumnFamily.NAME);
     scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
@@ -1348,7 +1335,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
   public void offline(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
 
     checkArgument(tableName != null, "tableName is null");
-    String tableId = Tables.getTableId(instance, tableName);
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
     List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes(UTF_8)));
     Map<String,String> opts = new HashMap<String,String>();
 
@@ -1380,7 +1367,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
   @Override
   public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
     checkArgument(tableName != null, "tableName is null");
-    String tableId = Tables.getTableId(instance, tableName);
+    String tableId = Tables.getTableId(context.getInstance(), tableName);
     List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes(UTF_8)));
     Map<String,String> opts = new HashMap<String,String>();
 
@@ -1406,7 +1393,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
   @Override
   public void clearLocatorCache(String tableName) throws TableNotFoundException {
     checkArgument(tableName != null, "tableName is null");
-    TabletLocator tabLocator = TabletLocator.getLocator(instance, new Text(Tables.getTableId(instance, tableName)));
+    TabletLocator tabLocator = TabletLocator.getLocator(context, new Text(Tables.getTableId(context.getInstance(), tableName)));
     tabLocator.invalidateCache();
   }
 
@@ -1417,7 +1404,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
    */
   @Override
   public Map<String,String> tableIdMap() {
-    return Tables.getNameToIdMap(instance);
+    return Tables.getNameToIdMap(context.getInstance());
   }
 
   @Override
@@ -1425,7 +1412,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
       throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
     checkArgument(tableName != null, "tableName is null");
     checkArgument(auths != null, "auths is null");
-    Scanner scanner = instance.getConnector(credentials.getPrincipal(), credentials.getToken()).createScanner(tableName, auths);
+    Scanner scanner = context.getConnector().createScanner(tableName, auths);
     return FindMax.findMax(scanner, startRow, startInclusive, endRow, endInclusive);
   }
 
@@ -1438,8 +1425,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
       try {
         // this operation may us a lot of memory... its likely that connections to tabletservers hosting metadata tablets will be cached, so do not use cached
         // connections
-        pair = ServerClient.getConnection(instance, false);
-        diskUsages = pair.getSecond().getDiskUsage(tableNames, credentials.toThrift(instance));
+        pair = ServerClient.getConnection(context, false);
+        diskUsages = pair.getSecond().getDiskUsage(tableNames, context.rpcCreds());
       } catch (ThriftTableOperationException e) {
         switch (e.getType()) {
           case NOTFOUND:
@@ -1569,10 +1556,10 @@ public class TableOperationsImpl extends TableOperationsHelper {
     checkArgument(asTypeName != null, "asTypeName is null");
 
     try {
-      return ServerClient.executeRaw(instance, new ClientExecReturn<Boolean,ClientService.Client>() {
+      return ServerClient.executeRaw(context, new ClientExecReturn<Boolean,ClientService.Client>() {
         @Override
         public Boolean execute(ClientService.Client client) throws Exception {
-          return client.checkTableClass(Tracer.traceInfo(), credentials.toThrift(instance), tableName, className, asTypeName);
+          return client.checkTableClass(Tracer.traceInfo(), context.rpcCreds(), tableName, className, asTypeName);
         }
       });
     } catch (ThriftTableOperationException e) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocator.java
index 6c57c29..3cb0fde 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocator.java
@@ -17,6 +17,7 @@
 package org.apache.accumulo.core.client.impl;
 
 import static com.google.common.base.Preconditions.checkArgument;
+
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -35,18 +36,17 @@ import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.metadata.MetadataLocationObtainer;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.hadoop.io.Text;
 
 public abstract class TabletLocator {
   
-  public abstract TabletLocation locateTablet(Credentials credentials, Text row, boolean skipRow, boolean retry) throws AccumuloException,
+  public abstract TabletLocation locateTablet(ClientContext context, Text row, boolean skipRow, boolean retry) throws AccumuloException,
       AccumuloSecurityException, TableNotFoundException;
   
-  public abstract <T extends Mutation> void binMutations(Credentials credentials, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations,
+  public abstract <T extends Mutation> void binMutations(ClientContext context, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations,
       List<T> failures) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
   
-  public abstract List<Range> binRanges(Credentials credentials, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges)
+  public abstract List<Range> binRanges(ClientContext context, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges)
       throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
   
   public abstract void invalidateCache(KeyExtent failedExtent);
@@ -61,7 +61,7 @@ public abstract class TabletLocator {
   /**
    * Invalidate all metadata entries that point to server
    */
-  public abstract void invalidateCache(String server);
+  public abstract void invalidateCache(Instance instance, String server);
   
   private static class LocatorKey {
     String instanceId;
@@ -92,19 +92,19 @@ public abstract class TabletLocator {
   
   private static HashMap<LocatorKey,TabletLocator> locators = new HashMap<LocatorKey,TabletLocator>();
   
-  public static synchronized TabletLocator getLocator(Instance instance, Text tableId) {
-    
+  public static synchronized TabletLocator getLocator(ClientContext context, Text tableId) {
+    Instance instance = context.getInstance();
     LocatorKey key = new LocatorKey(instance.getInstanceID(), tableId);
     TabletLocator tl = locators.get(key);
     if (tl == null) {
-      MetadataLocationObtainer mlo = new MetadataLocationObtainer(instance);
+      MetadataLocationObtainer mlo = new MetadataLocationObtainer();
       
       if (tableId.toString().equals(RootTable.ID)) {
-        tl = new RootTabletLocator(instance, new ZookeeperLockChecker(instance));
+        tl = new RootTabletLocator(new ZookeeperLockChecker(instance));
       } else if (tableId.toString().equals(MetadataTable.ID)) {
-        tl = new TabletLocatorImpl(new Text(MetadataTable.ID), getLocator(instance, new Text(RootTable.ID)), mlo, new ZookeeperLockChecker(instance));
+        tl = new TabletLocatorImpl(new Text(MetadataTable.ID), getLocator(context, new Text(RootTable.ID)), mlo, new ZookeeperLockChecker(instance));
       } else {
-        tl = new TabletLocatorImpl(tableId, getLocator(instance, new Text(MetadataTable.ID)), mlo, new ZookeeperLockChecker(instance));
+        tl = new TabletLocatorImpl(tableId, getLocator(context, new Text(MetadataTable.ID)), mlo, new ZookeeperLockChecker(instance));
       }
       locators.put(key, tl);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
index c550f15..1d49647 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
@@ -35,13 +35,13 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.KeyExtent;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.PartialKey;
 import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.core.util.OpTimer;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.util.TextUtil;
@@ -98,15 +98,14 @@ public class TabletLocatorImpl extends TabletLocator {
   private final Lock rLock = rwLock.readLock();
   private final Lock wLock = rwLock.writeLock();
 
-  
   public interface TabletLocationObtainer {
     /**
      * @return null when unable to read information successfully
      */
-    TabletLocations lookupTablet(Credentials credentials, TabletLocation src, Text row, Text stopRow, TabletLocator parent) throws AccumuloSecurityException,
+    TabletLocations lookupTablet(ClientContext context, TabletLocation src, Text row, Text stopRow, TabletLocator parent) throws AccumuloSecurityException,
         AccumuloException;
     
-    List<TabletLocation> lookupTablets(Credentials credentials, String tserver, Map<KeyExtent,List<Range>> map, TabletLocator parent)
+    List<TabletLocation> lookupTablets(ClientContext context, String tserver, Map<KeyExtent,List<Range>> map, TabletLocator parent)
         throws AccumuloSecurityException, AccumuloException;
   }
   
@@ -162,7 +161,7 @@ public class TabletLocatorImpl extends TabletLocator {
   }
   
   @Override
-  public <T extends Mutation> void binMutations(Credentials credentials, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures)
+  public <T extends Mutation> void binMutations(ClientContext context, List<T> mutations, Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures)
       throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     
     OpTimer opTimer = null;
@@ -176,7 +175,7 @@ public class TabletLocatorImpl extends TabletLocator {
 
     rLock.lock();
     try {
-      processInvalidated(credentials, lcSession);
+      processInvalidated(context, lcSession);
       
       // for this to be efficient rows need to be in sorted order, but always sorting is slow... therefore only sort the
       // stuff not in the cache.... it is most efficient to pass _locateTablet rows in sorted order
@@ -215,7 +214,7 @@ public class TabletLocatorImpl extends TabletLocator {
           
           row.set(mutation.getRow());
           
-          TabletLocation tl = _locateTablet(credentials, row, false, false, false, lcSession);
+          TabletLocation tl = _locateTablet(context, row, false, false, false, lcSession);
           
           if (tl == null || !addMutation(binnedMutations, mutation, tl, lcSession)) {
             failures.add(mutation);
@@ -255,7 +254,7 @@ public class TabletLocatorImpl extends TabletLocator {
     return false;
   }
   
-  private List<Range> binRanges(Credentials credentials, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges, boolean useCache,
+  private List<Range> binRanges(ClientContext context, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges, boolean useCache,
       LockCheckerSession lcSession) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     List<Range> failures = new ArrayList<Range>();
     List<TabletLocation> tabletLocations = new ArrayList<TabletLocation>();
@@ -278,7 +277,7 @@ public class TabletLocatorImpl extends TabletLocator {
       if (useCache)
         tl = lcSession.checkLock(locateTabletInCache(startRow));
       else if (!lookupFailed)
-        tl = _locateTablet(credentials, startRow, false, false, false, lcSession);
+        tl = _locateTablet(context, startRow, false, false, false, lcSession);
       
       if (tl == null) {
         failures.add(range);
@@ -295,7 +294,7 @@ public class TabletLocatorImpl extends TabletLocator {
           row.append(new byte[] {0}, 0, 1);
           tl = lcSession.checkLock(locateTabletInCache(row));
         } else {
-          tl = _locateTablet(credentials, tl.tablet_extent.getEndRow(), true, false, false, lcSession);
+          tl = _locateTablet(context, tl.tablet_extent.getEndRow(), true, false, false, lcSession);
         }
         
         if (tl == null) {
@@ -317,7 +316,7 @@ public class TabletLocatorImpl extends TabletLocator {
   }
   
   @Override
-  public List<Range> binRanges(Credentials credentials, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges) throws AccumuloException,
+  public List<Range> binRanges(ClientContext context, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges) throws AccumuloException,
       AccumuloSecurityException, TableNotFoundException {
     
     /*
@@ -334,14 +333,14 @@ public class TabletLocatorImpl extends TabletLocator {
     List<Range> failures;
     rLock.lock();
     try {
-      processInvalidated(credentials, lcSession);
+      processInvalidated(context, lcSession);
       
       // for this to be optimal, need to look ranges up in sorted order when
       // ranges are not present in cache... however do not want to always
       // sort ranges... therefore try binning ranges using only the cache
       // and sort whatever fails and retry
       
-      failures = binRanges(credentials, ranges, binnedRanges, true, lcSession);
+      failures = binRanges(context, ranges, binnedRanges, true, lcSession);
     } finally {
       rLock.unlock();
     }
@@ -353,7 +352,7 @@ public class TabletLocatorImpl extends TabletLocator {
       // try lookups again
       wLock.lock();
       try {
-        failures = binRanges(credentials, failures, binnedRanges, false, lcSession);
+        failures = binRanges(context, failures, binnedRanges, false, lcSession);
       } finally {
         wLock.unlock();
       }
@@ -390,7 +389,7 @@ public class TabletLocatorImpl extends TabletLocator {
   }
   
   @Override
-  public void invalidateCache(String server) {
+  public void invalidateCache(Instance instance, String server) {
     int invalidatedCount = 0;
     
     wLock.lock();
@@ -426,7 +425,7 @@ public class TabletLocatorImpl extends TabletLocator {
   }
   
   @Override
-  public TabletLocation locateTablet(Credentials credentials, Text row, boolean skipRow, boolean retry) throws AccumuloException, AccumuloSecurityException,
+  public TabletLocation locateTablet(ClientContext context, Text row, boolean skipRow, boolean retry) throws AccumuloException, AccumuloSecurityException,
       TableNotFoundException {
     
     OpTimer opTimer = null;
@@ -437,7 +436,7 @@ public class TabletLocatorImpl extends TabletLocator {
     while (true) {
       
       LockCheckerSession lcSession = new LockCheckerSession();
-      TabletLocation tl = _locateTablet(credentials, row, skipRow, retry, true, lcSession);
+      TabletLocation tl = _locateTablet(context, row, skipRow, retry, true, lcSession);
 
       if (retry && tl == null) {
         UtilWaitThread.sleep(100);
@@ -453,24 +452,23 @@ public class TabletLocatorImpl extends TabletLocator {
     }
   }
   
-  private void lookupTabletLocation(Credentials credentials, Text row, boolean retry, LockCheckerSession lcSession) throws AccumuloException,
-      AccumuloSecurityException,
-      TableNotFoundException {
+  private void lookupTabletLocation(ClientContext context, Text row, boolean retry, LockCheckerSession lcSession) throws AccumuloException,
+      AccumuloSecurityException, TableNotFoundException {
     Text metadataRow = new Text(tableId);
     metadataRow.append(new byte[] {';'}, 0, 1);
     metadataRow.append(row.getBytes(), 0, row.getLength());
-    TabletLocation ptl = parent.locateTablet(credentials, metadataRow, false, retry);
+    TabletLocation ptl = parent.locateTablet(context, metadataRow, false, retry);
     
     if (ptl != null) {
-      TabletLocations locations = locationObtainer.lookupTablet(credentials, ptl, metadataRow, lastTabletRow, parent);
+      TabletLocations locations = locationObtainer.lookupTablet(context, ptl, metadataRow, lastTabletRow, parent);
       while (locations != null && locations.getLocations().isEmpty() && locations.getLocationless().isEmpty()) {
         // try the next tablet, the current tablet does not have any tablets that overlap the row
         Text er = ptl.tablet_extent.getEndRow();
         if (er != null && er.compareTo(lastTabletRow) < 0) {
           // System.out.println("er "+er+"  ltr "+lastTabletRow);
-          ptl = parent.locateTablet(credentials, er, true, retry);
+          ptl = parent.locateTablet(context, er, true, retry);
           if (ptl != null)
-            locations = locationObtainer.lookupTablet(credentials, ptl, metadataRow, lastTabletRow, parent);
+            locations = locationObtainer.lookupTablet(context, ptl, metadataRow, lastTabletRow, parent);
           else
             break;
         } else {
@@ -593,9 +591,8 @@ public class TabletLocatorImpl extends TabletLocator {
     return null;
   }
   
-  protected TabletLocation _locateTablet(Credentials credentials, Text row, boolean skipRow, boolean retry, boolean lock, LockCheckerSession lcSession)
-      throws AccumuloException,
-      AccumuloSecurityException, TableNotFoundException {
+  protected TabletLocation _locateTablet(ClientContext context, Text row, boolean skipRow, boolean retry, boolean lock, LockCheckerSession lcSession)
+      throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     
     if (skipRow) {
       row = new Text(row);
@@ -607,7 +604,7 @@ public class TabletLocatorImpl extends TabletLocator {
     if (lock)
       rLock.lock();
     try {
-      processInvalidated(credentials, lcSession);
+      processInvalidated(context, lcSession);
       tl = lcSession.checkLock(locateTabletInCache(row));
     } finally {
       if (lock)
@@ -619,7 +616,7 @@ public class TabletLocatorImpl extends TabletLocator {
         wLock.lock();
       try {
         // not in cache, so obtain info
-        lookupTabletLocation(credentials, row, retry, lcSession);
+        lookupTabletLocation(context, row, retry, lcSession);
         
         tl = lcSession.checkLock(locateTabletInCache(row));
       } finally {
@@ -631,7 +628,7 @@ public class TabletLocatorImpl extends TabletLocator {
     return tl;
   }
   
-  private void processInvalidated(Credentials credentials, LockCheckerSession lcSession) throws AccumuloSecurityException, AccumuloException,
+  private void processInvalidated(ClientContext context, LockCheckerSession lcSession) throws AccumuloSecurityException, AccumuloException,
       TableNotFoundException {
     
     if (badExtents.size() == 0)
@@ -657,14 +654,14 @@ public class TabletLocatorImpl extends TabletLocator {
       
       Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<String,Map<KeyExtent,List<Range>>>();
       
-      parent.binRanges(credentials, lookups, binnedRanges);
+      parent.binRanges(context, lookups, binnedRanges);
       
       // randomize server order
       ArrayList<String> tabletServers = new ArrayList<String>(binnedRanges.keySet());
       Collections.shuffle(tabletServers);
       
       for (String tserver : tabletServers) {
-        List<TabletLocation> locations = locationObtainer.lookupTablets(credentials, tserver, binnedRanges.get(tserver), parent);
+        List<TabletLocation> locations = locationObtainer.lookupTablets(context, tserver, binnedRanges.get(tserver), parent);
         
         for (TabletLocation tabletLocation : locations) {
           updateCache(tabletLocation, lcSession);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
index 4858c7b..b88571a 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
@@ -22,7 +22,6 @@ import java.util.Map.Entry;
 import org.apache.accumulo.core.client.BatchDeleter;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -32,20 +31,17 @@ import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.SortedKeyIterator;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.ColumnVisibility;
-import org.apache.accumulo.core.security.Credentials;
 
 public class TabletServerBatchDeleter extends TabletServerBatchReader implements BatchDeleter {
   
-  private Instance instance;
-  private Credentials credentials;
+  private final ClientContext context;
   private String tableId;
   private BatchWriterConfig bwConfig;
   
-  public TabletServerBatchDeleter(Instance instance, Credentials credentials, String tableId, Authorizations authorizations, int numQueryThreads,
-      BatchWriterConfig bwConfig) throws TableNotFoundException {
-    super(instance, credentials, tableId, authorizations, numQueryThreads);
-    this.instance = instance;
-    this.credentials = credentials;
+  public TabletServerBatchDeleter(ClientContext context, String tableId, Authorizations authorizations, int numQueryThreads, BatchWriterConfig bwConfig)
+      throws TableNotFoundException {
+    super(context, tableId, authorizations, numQueryThreads);
+    this.context = context;
     this.tableId = tableId;
     this.bwConfig = bwConfig;
     super.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, BatchDeleter.class.getName() + ".NOVALUE", SortedKeyIterator.class));
@@ -55,7 +51,7 @@ public class TabletServerBatchDeleter extends TabletServerBatchReader implements
   public void delete() throws MutationsRejectedException, TableNotFoundException {
     BatchWriter bw = null;
     try {
-      bw = new BatchWriterImpl(instance, credentials, tableId, bwConfig);
+      bw = new BatchWriterImpl(context, tableId, bwConfig);
       Iterator<Entry<Key,Value>> iter = super.iterator();
       while (iter.hasNext()) {
         Entry<Key,Value> next = iter.next();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/42c25faa/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java
index c6f3a70..2a79f05 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java
@@ -17,6 +17,7 @@
 package org.apache.accumulo.core.client.impl;
 
 import static com.google.common.base.Preconditions.checkArgument;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -24,12 +25,10 @@ import java.util.Map.Entry;
 import java.util.concurrent.ExecutorService;
 
 import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.core.util.SimpleThreadPool;
 import org.apache.log4j.Logger;
 
@@ -40,10 +39,9 @@ public class TabletServerBatchReader extends ScannerOptions implements BatchScan
   private int numThreads;
   private ExecutorService queryThreadPool;
   
-  private Instance instance;
+  private final ClientContext context;
   private ArrayList<Range> ranges;
   
-  private Credentials credentials;
   private Authorizations authorizations = Authorizations.EMPTY;
   private Throwable ex = null;
   
@@ -55,13 +53,11 @@ public class TabletServerBatchReader extends ScannerOptions implements BatchScan
   
   private final int batchReaderInstance = getNextBatchReaderInstance();
   
-  public TabletServerBatchReader(Instance instance, Credentials credentials, String table, Authorizations authorizations, int numQueryThreads) {
-    checkArgument(instance != null, "instance is null");
-    checkArgument(credentials != null, "credentials is null");
+  public TabletServerBatchReader(ClientContext context, String table, Authorizations authorizations, int numQueryThreads) {
+    checkArgument(context != null, "context is null");
     checkArgument(table != null, "table is null");
     checkArgument(authorizations != null, "authorizations is null");
-    this.instance = instance;
-    this.credentials = credentials;
+    this.context = context;
     this.authorizations = authorizations;
     this.table = table;
     this.numThreads = numQueryThreads;
@@ -112,6 +108,6 @@ public class TabletServerBatchReader extends ScannerOptions implements BatchScan
       throw new IllegalStateException("batch reader closed");
     }
     
-    return new TabletServerBatchReaderIterator(instance, credentials, table, authorizations, ranges, numThreads, queryThreadPool, this, timeOut);
+    return new TabletServerBatchReaderIterator(context, table, authorizations, ranges, numThreads, queryThreadPool, this, timeOut);
   }
 }


Mime
View raw message