hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [hbase] branch branch-2 updated: HBASE-23627 Resolved remaining Checkstyle violations in hbase-thrift
Date Wed, 01 Jan 2020 21:57:33 GMT
This is an automated email from the ASF dual-hosted git repository.

janh pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new a18a5c4  HBASE-23627 Resolved remaining Checkstyle violations in hbase-thrift
a18a5c4 is described below

commit a18a5c4baa2aee90830ac141ad70a76448aa3bb2
Author: Jan Hentschel <janh@apache.org>
AuthorDate: Wed Jan 1 22:41:13 2020 +0100

    HBASE-23627 Resolved remaining Checkstyle violations in hbase-thrift
    
    Signed-off-by: Viraj Jasani <vjasani@apache.org>
    Signed-off-by: stack <stack@apache.org>
---
 .../hadoop/hbase/thrift/IncrementCoalescer.java    | 94 ++++++++++------------
 .../thrift/TestThriftSpnegoHttpFallbackServer.java | 44 +++++-----
 .../hbase/thrift/TestThriftSpnegoHttpServer.java   | 44 +++++-----
 3 files changed, 84 insertions(+), 98 deletions(-)

diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/IncrementCoalescer.java
b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/IncrementCoalescer.java
index 122675c..0649b26 100644
--- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/IncrementCoalescer.java
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/IncrementCoalescer.java
@@ -15,7 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.hadoop.hbase.thrift;
 
 import java.io.IOException;
@@ -35,7 +34,6 @@ import org.apache.hadoop.hbase.thrift.generated.TIncrement;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.metrics2.util.MBeans;
-import org.apache.thrift.TException;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,7 +49,6 @@ import org.slf4j.LoggerFactory;
  */
 @InterfaceAudience.Private
 public class IncrementCoalescer implements IncrementCoalescerMBean {
-
   /**
    * Used to identify a cell that will be incremented.
    *
@@ -82,10 +79,6 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
       return rowKey;
     }
 
-    public void setRowKey(byte[] rowKey) {
-      this.rowKey = rowKey;
-    }
-
     public byte[] getFamily() {
       return family;
     }
@@ -119,13 +112,19 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
       if (obj == null) return false;
       if (getClass() != obj.getClass()) return false;
       FullyQualifiedRow other = (FullyQualifiedRow) obj;
-      if (!Arrays.equals(family, other.family)) return false;
-      if (!Arrays.equals(qualifier, other.qualifier)) return false;
-      if (!Arrays.equals(rowKey, other.rowKey)) return false;
-      if (!Arrays.equals(table, other.table)) return false;
-      return true;
-    }
 
+      if (!Arrays.equals(family, other.family)) {
+        return false;
+      }
+      if (!Arrays.equals(qualifier, other.qualifier)) {
+        return false;
+      }
+      if (!Arrays.equals(rowKey, other.rowKey)) {
+        return false;
+      }
+
+      return Arrays.equals(table, other.table);
+    }
   }
 
   private final LongAdder failedIncrements = new LongAdder();
@@ -139,9 +138,8 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
   private int maxQueueSize = 500000;
   private static final int CORE_POOL_SIZE = 1;
 
-  private static final Logger LOG = LoggerFactory.getLogger(FullyQualifiedRow.class);
+  private static final Logger LOG = LoggerFactory.getLogger(IncrementCoalescer.class);
 
-  @SuppressWarnings("deprecation")
   public IncrementCoalescer(ThriftHBaseServiceHandler hand) {
     this.handler = hand;
     LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
@@ -151,7 +149,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
     MBeans.register("thrift", "Thrift", this);
   }
 
-  public boolean queueIncrement(TIncrement inc) throws TException {
+  public boolean queueIncrement(TIncrement inc) {
     if (!canQueue()) {
       failedIncrements.increment();
       return false;
@@ -159,7 +157,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
     return internalQueueTincrement(inc);
   }
 
-  public boolean queueIncrements(List<TIncrement> incs) throws TException {
+  public boolean queueIncrements(List<TIncrement> incs) {
     if (!canQueue()) {
       failedIncrements.increment();
       return false;
@@ -172,7 +170,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
 
   }
 
-  private boolean internalQueueTincrement(TIncrement inc) throws TException {
+  private boolean internalQueueTincrement(TIncrement inc) {
     byte[][] famAndQf = CellUtil.parseColumn(inc.getColumn());
     if (famAndQf.length != 2) return false;
 
@@ -182,7 +180,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
 
   @SuppressWarnings("FutureReturnValueIgnored")
   private boolean internalQueueIncrement(byte[] tableName, byte[] rowKey, byte[] fam,
-      byte[] qual, long ammount) throws TException {
+      byte[] qual, long ammount) {
     int countersMapSize = countersMap.size();
 
 
@@ -199,7 +197,7 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
       Long value = countersMap.remove(key);
       if (value == null) {
         // There was nothing there, create a new value
-        value = Long.valueOf(currentAmount);
+        value = currentAmount;
       } else {
         value += currentAmount;
         successfulCoalescings.increment();
@@ -232,39 +230,36 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
   }
 
   private Callable<Integer> createIncCallable() {
-    return new Callable<Integer>() {
-      @Override
-      public Integer call() throws Exception {
-        int failures = 0;
-        Set<FullyQualifiedRow> keys = countersMap.keySet();
-        for (FullyQualifiedRow row : keys) {
-          Long counter = countersMap.remove(row);
-          if (counter == null) {
-            continue;
+    return () -> {
+      int failures = 0;
+      Set<FullyQualifiedRow> keys = countersMap.keySet();
+      for (FullyQualifiedRow row : keys) {
+        Long counter = countersMap.remove(row);
+        if (counter == null) {
+          continue;
+        }
+        Table table = null;
+        try {
+          table = handler.getTable(row.getTable());
+          if (failures > 2) {
+            throw new IOException("Auto-Fail rest of ICVs");
           }
-          Table table = null;
-          try {
-            table = handler.getTable(row.getTable());
-            if (failures > 2) {
-              throw new IOException("Auto-Fail rest of ICVs");
-            }
-            table.incrementColumnValue(row.getRowKey(), row.getFamily(), row.getQualifier(),
-              counter);
-          } catch (IOException e) {
-            // log failure of increment
-            failures++;
-            LOG.error("FAILED_ICV: " + Bytes.toString(row.getTable()) + ", "
-                + Bytes.toStringBinary(row.getRowKey()) + ", "
-                + Bytes.toStringBinary(row.getFamily()) + ", "
-                + Bytes.toStringBinary(row.getQualifier()) + ", " + counter, e);
-          } finally{
-            if(table != null){
-              table.close();
-            }
+          table.incrementColumnValue(row.getRowKey(), row.getFamily(), row.getQualifier(),
+            counter);
+        } catch (IOException e) {
+          // log failure of increment
+          failures++;
+          LOG.error("FAILED_ICV: " + Bytes.toString(row.getTable()) + ", "
+              + Bytes.toStringBinary(row.getRowKey()) + ", "
+              + Bytes.toStringBinary(row.getFamily()) + ", "
+              + Bytes.toStringBinary(row.getQualifier()) + ", " + counter, e);
+        } finally{
+          if(table != null){
+            table.close();
           }
         }
-        return failures;
       }
+      return failures;
     };
   }
 
@@ -369,5 +364,4 @@ public class IncrementCoalescer implements IncrementCoalescerMBean {
   public long getCountersMapSize() {
     return countersMap.size();
   }
-
 }
diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
index 0d11215..a1334a4 100644
--- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
+++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
@@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.thrift.generated.Hbase;
-import org.apache.hadoop.hbase.util.TableDescriptorChecker;
 import org.apache.hadoop.security.authentication.util.KerberosName;
 import org.apache.http.HttpHeaders;
 import org.apache.http.auth.AuthSchemeProvider;
@@ -212,29 +211,26 @@ public class TestThriftSpnegoHttpFallbackServer extends TestThriftHttpServer
{
     // The name of the principal
     final String clientPrincipalName = clientPrincipals.iterator().next().getName();
 
-    return Subject.doAs(clientSubject, new PrivilegedExceptionAction<CloseableHttpClient>()
{
-      @Override
-      public CloseableHttpClient run() throws Exception {
-        // Logs in with Kerberos via GSS
-        GSSManager gssManager = GSSManager.getInstance();
-        // jGSS Kerberos login constant
-        Oid oid = new Oid("1.2.840.113554.1.2.2");
-        GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
-        GSSCredential credential = gssManager.createCredential(gssClient,
-          GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
-
-        Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
-          .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
-          .build();
-
-        BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-        credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
-
-        return HttpClients.custom()
-          .setDefaultAuthSchemeRegistry(authRegistry)
-          .setDefaultCredentialsProvider(credentialsProvider)
-          .build();
-      }
+    return Subject.doAs(clientSubject, (PrivilegedExceptionAction<CloseableHttpClient>)
() -> {
+      // Logs in with Kerberos via GSS
+      GSSManager gssManager = GSSManager.getInstance();
+      // jGSS Kerberos login constant
+      Oid oid = new Oid("1.2.840.113554.1.2.2");
+      GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
+      GSSCredential credential = gssManager.createCredential(gssClient,
+        GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
+
+      Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+        .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
+        .build();
+
+      BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+      credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
+
+      return HttpClients.custom()
+        .setDefaultAuthSchemeRegistry(authRegistry)
+        .setDefaultCredentialsProvider(credentialsProvider)
+        .build();
     });
   }
 }
diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
index f126da1..3206b54 100644
--- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
+++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
@@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.thrift.generated.Hbase;
-import org.apache.hadoop.hbase.util.TableDescriptorChecker;
 import org.apache.hadoop.security.authentication.util.KerberosName;
 import org.apache.http.HttpHeaders;
 import org.apache.http.auth.AuthSchemeProvider;
@@ -211,29 +210,26 @@ public class TestThriftSpnegoHttpServer extends TestThriftHttpServer
{
     // The name of the principal
     final String clientPrincipalName = clientPrincipals.iterator().next().getName();
 
-    return Subject.doAs(clientSubject, new PrivilegedExceptionAction<CloseableHttpClient>()
{
-      @Override
-      public CloseableHttpClient run() throws Exception {
-        // Logs in with Kerberos via GSS
-        GSSManager gssManager = GSSManager.getInstance();
-        // jGSS Kerberos login constant
-        Oid oid = new Oid("1.2.840.113554.1.2.2");
-        GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
-        GSSCredential credential = gssManager.createCredential(gssClient,
-            GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
-
-        Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
-            .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
-            .build();
-
-        BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-        credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
-
-        return HttpClients.custom()
-            .setDefaultAuthSchemeRegistry(authRegistry)
-            .setDefaultCredentialsProvider(credentialsProvider)
-            .build();
-      }
+    return Subject.doAs(clientSubject, (PrivilegedExceptionAction<CloseableHttpClient>)
() -> {
+      // Logs in with Kerberos via GSS
+      GSSManager gssManager = GSSManager.getInstance();
+      // jGSS Kerberos login constant
+      Oid oid = new Oid("1.2.840.113554.1.2.2");
+      GSSName gssClient = gssManager.createName(clientPrincipalName, GSSName.NT_USER_NAME);
+      GSSCredential credential = gssManager.createCredential(gssClient,
+          GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);
+
+      Lookup<AuthSchemeProvider> authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+          .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, true))
+          .build();
+
+      BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+      credentialsProvider.setCredentials(AuthScope.ANY, new KerberosCredentials(credential));
+
+      return HttpClients.custom()
+          .setDefaultAuthSchemeRegistry(authRegistry)
+          .setDefaultCredentialsProvider(credentialsProvider)
+          .build();
     });
   }
 }


Mime
View raw message