From 1beb687f4e489dff352a746d4544ff1a0a1ed829 Mon Sep 17 00:00:00 2001 From: Apekshit Sharma Date: Fri, 26 Jan 2018 00:21:39 -0800 Subject: [PATCH] HBASE-19862 addendum: Checkstyle fixes, remove unused imports and variables. Add @Rule for timeout. --- .../token/TestTokenAuthentication.java | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java index 4b2332e982e..67887e681e2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java @@ -32,23 +32,20 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.concurrent.ConcurrentMap; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.hbase.CategoryBasedTimeout; import org.apache.hadoop.hbase.ChoreService; import org.apache.hadoop.hbase.ClusterId; import org.apache.hadoop.hbase.CoordinatedStateManager; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HRegionInfo; -import org.apache.hadoop.hbase.RawCellBuilder; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.client.ClusterConnection; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.coprocessor.HasRegionServerServices; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.ipc.FifoRpcScheduler; import org.apache.hadoop.hbase.ipc.NettyRpcServer; @@ -59,10 +56,7 @@ import org.apache.hadoop.hbase.ipc.RpcServerInterface; import org.apache.hadoop.hbase.ipc.ServerRpcController; import org.apache.hadoop.hbase.ipc.SimpleRpcServer; import org.apache.hadoop.hbase.log.HBaseMarkers; -import org.apache.hadoop.hbase.metrics.MetricRegistry; import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos; -import org.apache.hadoop.hbase.regionserver.HRegion; -import org.apache.hadoop.hbase.regionserver.OnlineRegions; import org.apache.hadoop.hbase.regionserver.RegionServerServices; import org.apache.hadoop.hbase.security.SecurityInfo; import org.apache.hadoop.hbase.security.User; @@ -85,8 +79,10 @@ import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.TokenIdentifier; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; @@ -120,9 +116,10 @@ public class TestTokenAuthentication { System.setProperty("java.security.krb5.realm", "hbase"); System.setProperty("java.security.krb5.kdc", "blah"); } - private static final Logger LOG = LoggerFactory.getLogger(TestTokenAuthentication.class); - public interface AuthenticationServiceSecurityInfo {} + @Rule + public final TestRule timeout = CategoryBasedTimeout.builder().withTimeout(this.getClass()) + .withLookingForStuckThread(true).build(); /** * Basic server process for RPC authentication testing @@ -141,8 +138,7 @@ public class TestTokenAuthentication { private boolean stopped = false; private long startcode; - public TokenServer(Configuration conf, HBaseTestingUtility TEST_UTIL) - throws IOException { + public TokenServer(Configuration conf, HBaseTestingUtility TEST_UTIL) throws IOException { this.conf = conf; this.TEST_UTIL = TEST_UTIL; this.startcode = EnvironmentEdgeManager.currentTime(); @@ -163,42 +159,46 @@ public class TestTokenAuthentication { final BlockingService service = AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this); final org.apache.hbase.thirdparty.com.google.protobuf.BlockingService proxy = - new org.apache.hbase.thirdparty.com.google.protobuf.BlockingService() { - @Override public Message callBlockingMethod(MethodDescriptor md, - org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, - Message param) - throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException { - com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor = - service.getDescriptorForType().findMethodByName(md.getName()); - com.google.protobuf.Message request = service.getRequestPrototype(methodDescriptor); - // TODO: Convert rpcController - com.google.protobuf.Message response = null; - try { - response = service.callBlockingMethod(methodDescriptor, null, request); - } catch (ServiceException e) { - throw new org.apache.hbase.thirdparty.com.google.protobuf.ServiceException(e); - } - return null;// Convert 'response'. + new org.apache.hbase.thirdparty.com.google.protobuf.BlockingService() { + @Override + public Message callBlockingMethod(MethodDescriptor md, + org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, + Message param) + throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException { + com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor = + service.getDescriptorForType().findMethodByName(md.getName()); + com.google.protobuf.Message request = service.getRequestPrototype(methodDescriptor); + // TODO: Convert rpcController + com.google.protobuf.Message response = null; + try { + response = service.callBlockingMethod(methodDescriptor, null, request); + } catch (ServiceException e) { + throw new org.apache.hbase.thirdparty.com.google.protobuf.ServiceException(e); } + return null;// Convert 'response'. + } - @Override public ServiceDescriptor getDescriptorForType() { - return null; - } + @Override + public ServiceDescriptor getDescriptorForType() { + return null; + } - @Override public Message getRequestPrototype(MethodDescriptor arg0) { - // TODO Auto-generated method stub - return null; - } + @Override + public Message getRequestPrototype(MethodDescriptor arg0) { + // TODO Auto-generated method stub + return null; + } - @Override public Message getResponsePrototype(MethodDescriptor arg0) { - // TODO Auto-generated method stub - return null; - } - }; + @Override + public Message getResponsePrototype(MethodDescriptor arg0) { + // TODO Auto-generated method stub + return null; + } + }; sai.add(new BlockingServiceAndInterface(proxy, AuthenticationProtos.AuthenticationService.BlockingInterface.class)); - this.rpcServer = RpcServerFactory.createRpcServer(this, "tokenServer", sai, - initialIsa, conf, new FifoRpcScheduler(conf, 1)); + this.rpcServer = RpcServerFactory.createRpcServer(this, "tokenServer", sai, initialIsa, conf, + new FifoRpcScheduler(conf, 1)); InetSocketAddress address = rpcServer.getListenerAddress(); if (address == null) { throw new IOException("Listener channel is closed"); @@ -329,7 +329,7 @@ public class TestTokenAuthentication { ServerRpcController serverController = new ServerRpcController(); final NonShadedBlockingRpcCallback callback = new NonShadedBlockingRpcCallback<>(); - getAuthenticationToken((RpcController)null, request, callback); + getAuthenticationToken(null, request, callback); try { serverController.checkFailed(); return callback.get();