accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch master updated: Remove unnecessary exceptions from ClientContext (#805)
Date Fri, 07 Dec 2018 15:23:35 GMT
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 9456433  Remove unnecessary exceptions from ClientContext (#805)
9456433 is described below

commit 9456433b288aeba75326e4ca93e6dd27a9d46b9d
Author: Christopher Tubbs <ctubbsii@apache.org>
AuthorDate: Fri Dec 7 10:23:31 2018 -0500

    Remove unnecessary exceptions from ClientContext (#805)
    
    Remove exceptions which are never thrown, and clean up exception
    handling of internal code which called ClientContext.getClient()
    
    Fix rawtypes warnings by adding generic type parameters to
    ClientBuilderImpl in AccumuloClientImpl
    
    Save actions in IDE automatically converted some anonymous inner classes
    to cleaner lambdas.
---
 .../core/client/mapred/AbstractInputFormat.java    |  7 +------
 .../core/client/mapreduce/AbstractInputFormat.java |  7 +------
 .../core/clientImpl/AccumuloClientImpl.java        |  4 ++--
 .../accumulo/core/clientImpl/ClientContext.java    |  3 +--
 .../core/metadata/schema/MetadataScanner.java      |  6 +-----
 .../hadoopImpl/mapred/AbstractInputFormat.java     |  7 +------
 .../hadoopImpl/mapreduce/AbstractInputFormat.java  |  7 +------
 .../org/apache/accumulo/server/ServerContext.java  |  5 +----
 .../server/client/ClientServiceHandler.java        |  5 +----
 .../server/master/balancer/TableLoadBalancer.java  |  8 +-------
 .../server/replication/ReplicationUtil.java        |  6 ++----
 .../accumulo/server/util/ReplicationTableUtil.java |  7 +------
 .../accumulo/gc/GarbageCollectWriteAheadLogs.java  | 24 ++++++----------------
 13 files changed, 20 insertions(+), 76 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
index e1546f4..92d6be9 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
@@ -482,12 +482,7 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V>
{
       log.debug("Initializing input split: " + baseSplit);
 
       ClientContext context = new ClientContext(getClientInfo(job));
-      AccumuloClient client;
-      try {
-        client = context.getClient();
-      } catch (AccumuloException | AccumuloSecurityException e) {
-        throw new IllegalStateException(e);
-      }
+      AccumuloClient client = context.getClient();
       Authorizations authorizations = getScanAuthorizations(job);
       String classLoaderContext = getClassLoaderContext(job);
       String table = baseSplit.getTableName();
diff --git 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
index 235ac32..b159291 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
@@ -490,12 +490,7 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V>
{
 
       ClientInfo info = getClientInfo(attempt);
       ClientContext context = new ClientContext(info);
-      AccumuloClient client;
-      try {
-        client = context.getClient();
-      } catch (AccumuloException | AccumuloSecurityException e) {
-        throw new IllegalStateException(e);
-      }
+      AccumuloClient client = context.getClient();
       Authorizations authorizations = getScanAuthorizations(attempt);
       String classLoaderContext = getClassLoaderContext(attempt);
       String table = split.getTableName();
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/AccumuloClientImpl.java
b/core/src/main/java/org/apache/accumulo/core/clientImpl/AccumuloClientImpl.java
index 8657119..54f111d 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/AccumuloClientImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/AccumuloClientImpl.java
@@ -293,9 +293,9 @@ public class AccumuloClientImpl implements AccumuloClient {
 
     private Properties properties = new Properties();
     private AuthenticationToken token = null;
-    private Function<ClientBuilderImpl,T> builderFunction;
+    private Function<ClientBuilderImpl<T>,T> builderFunction;
 
-    public ClientBuilderImpl(Function<ClientBuilderImpl,T> builderFunction) {
+    public ClientBuilderImpl(Function<ClientBuilderImpl<T>,T> builderFunction)
{
       this.builderFunction = builderFunction;
     }
 
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
index d80ddba..16915a3 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
@@ -243,8 +243,7 @@ public class ClientContext {
   /**
    * Retrieve an Accumulo client
    */
-  public synchronized AccumuloClient getClient()
-      throws AccumuloException, AccumuloSecurityException {
+  public synchronized AccumuloClient getClient() {
     ensureOpen();
     if (client == null) {
       client = new AccumuloClientImpl(SingletonReservation.noop(), this);
diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java
b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java
index eec663c..6434de0 100644
--- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java
@@ -256,11 +256,7 @@ public class MetadataScanner implements Iterable<TabletMetadata>,
AutoCloseable
 
     @Override
     public TableOptions from(ClientContext ctx) {
-      try {
-        this.client = ctx.getClient();
-      } catch (AccumuloException | AccumuloSecurityException e) {
-        throw new RuntimeException(e);
-      }
+      this.client = ctx.getClient();
       return this;
     }
 
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AbstractInputFormat.java
b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AbstractInputFormat.java
index 7b91397..c86c310 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AbstractInputFormat.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AbstractInputFormat.java
@@ -283,12 +283,7 @@ public abstract class AbstractInputFormat {
       log.debug("Initializing input split: " + baseSplit);
 
       ClientContext context = new ClientContext(getClientInfo(job));
-      AccumuloClient client;
-      try {
-        client = context.getClient();
-      } catch (AccumuloException | AccumuloSecurityException e) {
-        throw new IllegalStateException(e);
-      }
+      AccumuloClient client = context.getClient();
       Authorizations authorizations = getScanAuthorizations(job);
       String classLoaderContext = getClassLoaderContext(job);
       String table = baseSplit.getTableName();
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AbstractInputFormat.java
b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AbstractInputFormat.java
index 7a9bfb5..891a354 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AbstractInputFormat.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AbstractInputFormat.java
@@ -287,12 +287,7 @@ public abstract class AbstractInputFormat {
 
       ClientInfo info = getClientInfo(attempt);
       ClientContext context = new ClientContext(info);
-      AccumuloClient client;
-      try {
-        client = context.getClient();
-      } catch (AccumuloException | AccumuloSecurityException e) {
-        throw new IllegalStateException(e);
-      }
+      AccumuloClient client = context.getClient();
       Authorizations authorizations = getScanAuthorizations(attempt);
       String classLoaderContext = getClassLoaderContext(attempt);
       String table = split.getTableName();
diff --git a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
index 8106baf..bf5240e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
@@ -25,8 +25,6 @@ import java.util.Properties;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Accumulo;
 import org.apache.accumulo.core.client.AccumuloClient;
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.ClientInfo;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.clientImpl.AccumuloClientImpl;
@@ -242,8 +240,7 @@ public class ServerContext extends ClientContext {
   }
 
   @Override
-  public synchronized AccumuloClient getClient()
-      throws AccumuloException, AccumuloSecurityException {
+  public synchronized AccumuloClient getClient() {
     if (client == null) {
       client = new AccumuloClientImpl(SingletonReservation.noop(), this);
     }
diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
index 268ffaf..2aa7cbe 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
@@ -28,7 +28,6 @@ import java.util.Set;
 import java.util.TreeSet;
 
 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.NamespaceNotFoundException;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -476,9 +475,7 @@ public class ClientServiceHandler implements ClientService.Iface {
       }
       return retUsages;
 
-    } catch (AccumuloSecurityException e) {
-      throw e.asThriftException();
-    } catch (AccumuloException | TableNotFoundException | IOException e) {
+    } catch (TableNotFoundException | IOException e) {
       throw new TException(e);
     }
   }
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
index b763f64..8fadccd 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
@@ -25,8 +25,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.SortedMap;
 
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.admin.TableOperations;
 import org.apache.accumulo.core.clientImpl.Table;
 import org.apache.accumulo.core.conf.Property;
@@ -138,11 +136,7 @@ public class TableLoadBalancer extends TabletBalancer {
 
   protected TableOperations getTableOperations() {
     if (tops == null)
-      try {
-        tops = this.context.getClient().tableOperations();
-      } catch (AccumuloException | AccumuloSecurityException e) {
-        log.error("Unable to access table operations from within table balancer", e);
-      }
+      tops = this.context.getClient().tableOperations();
     return tops;
   }
 
diff --git a/server/base/src/main/java/org/apache/accumulo/server/replication/ReplicationUtil.java
b/server/base/src/main/java/org/apache/accumulo/server/replication/ReplicationUtil.java
index c1ab885..a58a4f1 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/replication/ReplicationUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/replication/ReplicationUtil.java
@@ -27,8 +27,6 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 
 import org.apache.accumulo.core.client.AccumuloClient;
-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.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -164,7 +162,7 @@ public class ReplicationUtil {
     BatchScanner bs;
     try {
       bs = context.getClient().createBatchScanner(ReplicationTable.NAME, Authorizations.EMPTY,
4);
-    } catch (TableNotFoundException | AccumuloException | AccumuloSecurityException e) {
+    } catch (TableNotFoundException e) {
       log.debug("No replication table exists", e);
       return counts;
     }
@@ -201,7 +199,7 @@ public class ReplicationUtil {
     BatchScanner bs;
     try {
       bs = context.getClient().createBatchScanner(ReplicationTable.NAME, Authorizations.EMPTY,
4);
-    } catch (TableNotFoundException | AccumuloException | AccumuloSecurityException e) {
+    } catch (TableNotFoundException e) {
       log.debug("No replication table exists", e);
       return paths;
     }
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java
b/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java
index 1aa90ed..5ec0000 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java
@@ -84,12 +84,7 @@ public class ReplicationTableUtil {
   static synchronized Writer getWriter(ClientContext context) {
     Writer replicationTable = writers.get(context.getCredentials());
     if (replicationTable == null) {
-      AccumuloClient client;
-      try {
-        client = context.getClient();
-      } catch (AccumuloException | AccumuloSecurityException e) {
-        throw new RuntimeException(e);
-      }
+      AccumuloClient client = context.getClient();
 
       configureMetadataTable(client, MetadataTable.NAME);
 
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
index 0458c28..eae5969 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
@@ -29,8 +29,6 @@ import java.util.Set;
 import java.util.UUID;
 
 import org.apache.accumulo.core.client.AccumuloClient;
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.data.Key;
@@ -53,7 +51,6 @@ import org.apache.accumulo.server.log.WalStateManager;
 import org.apache.accumulo.server.log.WalStateManager.WalMarkerException;
 import org.apache.accumulo.server.log.WalStateManager.WalState;
 import org.apache.accumulo.server.master.LiveTServerSet;
-import org.apache.accumulo.server.master.LiveTServerSet.Listener;
 import org.apache.accumulo.server.master.state.MetaDataStateStore;
 import org.apache.accumulo.server.master.state.RootTabletStateStore;
 import org.apache.accumulo.server.master.state.TServerInstance;
@@ -94,23 +91,14 @@ public class GarbageCollectWriteAheadLogs {
     this.context = context;
     this.fs = fs;
     this.useTrash = useTrash;
-    this.liveServers = new LiveTServerSet(context, new Listener() {
-      @Override
-      public void update(LiveTServerSet current, Set<TServerInstance> deleted,
-          Set<TServerInstance> added) {
-        log.debug("New tablet servers noticed: {}", added);
-        log.debug("Tablet servers removed: {}", deleted);
-      }
+    this.liveServers = new LiveTServerSet(context, (current, deleted, added) -> {
+      log.debug("New tablet servers noticed: {}", added);
+      log.debug("Tablet servers removed: {}", deleted);
     });
     liveServers.startListeningForTabletServerChanges();
     this.walMarker = new WalStateManager(context);
-    this.store = new Iterable<TabletLocationState>() {
-      @Override
-      public Iterator<TabletLocationState> iterator() {
-        return Iterators.concat(new RootTabletStateStore(context).iterator(),
-            new MetaDataStateStore(context).iterator());
-      }
-    };
+    this.store = () -> Iterators.concat(new RootTabletStateStore(context).iterator(),
+        new MetaDataStateStore(context).iterator());
   }
 
   /**
@@ -377,7 +365,7 @@ public class GarbageCollectWriteAheadLogs {
       }
 
       return candidates.size();
-    } catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) {
+    } catch (TableNotFoundException e) {
       log.error("Failed to scan metadata table", e);
       throw new IllegalArgumentException(e);
     }


Mime
View raw message