HBASE-19862 addendum: Checkstyle fixes, remove unused imports and variables. Add @Rule for timeout.

This commit is contained in:
Apekshit Sharma 2018-01-26 00:21:39 -08:00
parent dbe5cbf5ae
commit f8295a810d
1 changed files with 42 additions and 42 deletions

View File

@ -32,23 +32,20 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentMap;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.ChoreService; import org.apache.hadoop.hbase.ChoreService;
import org.apache.hadoop.hbase.ClusterId; import org.apache.hadoop.hbase.ClusterId;
import org.apache.hadoop.hbase.CoordinatedStateManager; import org.apache.hadoop.hbase.CoordinatedStateManager;
import org.apache.hadoop.hbase.HBaseTestingUtility; 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.Server;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.ClusterConnection; import org.apache.hadoop.hbase.client.ClusterConnection;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.coprocessor.HasRegionServerServices; 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.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.ipc.FifoRpcScheduler; import org.apache.hadoop.hbase.ipc.FifoRpcScheduler;
import org.apache.hadoop.hbase.ipc.NettyRpcServer; 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.ServerRpcController;
import org.apache.hadoop.hbase.ipc.SimpleRpcServer; import org.apache.hadoop.hbase.ipc.SimpleRpcServer;
import org.apache.hadoop.hbase.log.HBaseMarkers; 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.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.regionserver.RegionServerServices;
import org.apache.hadoop.hbase.security.SecurityInfo; import org.apache.hadoop.hbase.security.SecurityInfo;
import org.apache.hadoop.hbase.security.User; 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.apache.hadoop.security.token.TokenIdentifier;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter; 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.realm", "hbase");
System.setProperty("java.security.krb5.kdc", "blah"); 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 * Basic server process for RPC authentication testing
@ -141,8 +138,7 @@ public class TestTokenAuthentication {
private boolean stopped = false; private boolean stopped = false;
private long startcode; private long startcode;
public TokenServer(Configuration conf, HBaseTestingUtility TEST_UTIL) public TokenServer(Configuration conf, HBaseTestingUtility TEST_UTIL) throws IOException {
throws IOException {
this.conf = conf; this.conf = conf;
this.TEST_UTIL = TEST_UTIL; this.TEST_UTIL = TEST_UTIL;
this.startcode = EnvironmentEdgeManager.currentTime(); this.startcode = EnvironmentEdgeManager.currentTime();
@ -164,7 +160,8 @@ public class TestTokenAuthentication {
AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this); AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this);
final org.apache.hbase.thirdparty.com.google.protobuf.BlockingService proxy = final org.apache.hbase.thirdparty.com.google.protobuf.BlockingService proxy =
new org.apache.hbase.thirdparty.com.google.protobuf.BlockingService() { new org.apache.hbase.thirdparty.com.google.protobuf.BlockingService() {
@Override public Message callBlockingMethod(MethodDescriptor md, @Override
public Message callBlockingMethod(MethodDescriptor md,
org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller, org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller,
Message param) Message param)
throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException { throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException {
@ -181,24 +178,27 @@ public class TestTokenAuthentication {
return null;// Convert 'response'. return null;// Convert 'response'.
} }
@Override public ServiceDescriptor getDescriptorForType() { @Override
public ServiceDescriptor getDescriptorForType() {
return null; return null;
} }
@Override public Message getRequestPrototype(MethodDescriptor arg0) { @Override
public Message getRequestPrototype(MethodDescriptor arg0) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override public Message getResponsePrototype(MethodDescriptor arg0) { @Override
public Message getResponsePrototype(MethodDescriptor arg0) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
}; };
sai.add(new BlockingServiceAndInterface(proxy, sai.add(new BlockingServiceAndInterface(proxy,
AuthenticationProtos.AuthenticationService.BlockingInterface.class)); AuthenticationProtos.AuthenticationService.BlockingInterface.class));
this.rpcServer = RpcServerFactory.createRpcServer(this, "tokenServer", sai, this.rpcServer = RpcServerFactory.createRpcServer(this, "tokenServer", sai, initialIsa, conf,
initialIsa, conf, new FifoRpcScheduler(conf, 1)); new FifoRpcScheduler(conf, 1));
InetSocketAddress address = rpcServer.getListenerAddress(); InetSocketAddress address = rpcServer.getListenerAddress();
if (address == null) { if (address == null) {
throw new IOException("Listener channel is closed"); throw new IOException("Listener channel is closed");
@ -329,7 +329,7 @@ public class TestTokenAuthentication {
ServerRpcController serverController = new ServerRpcController(); ServerRpcController serverController = new ServerRpcController();
final NonShadedBlockingRpcCallback<AuthenticationProtos.GetAuthenticationTokenResponse> final NonShadedBlockingRpcCallback<AuthenticationProtos.GetAuthenticationTokenResponse>
callback = new NonShadedBlockingRpcCallback<>(); callback = new NonShadedBlockingRpcCallback<>();
getAuthenticationToken((RpcController)null, request, callback); getAuthenticationToken(null, request, callback);
try { try {
serverController.checkFailed(); serverController.checkFailed();
return callback.get(); return callback.get();