HBASE-19862 addendum: Checkstyle fixes, remove unused imports and variables. Add @Rule for timeout.
This commit is contained in:
parent
dbe5cbf5ae
commit
f8295a810d
|
@ -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();
|
||||||
|
@ -163,42 +159,46 @@ public class TestTokenAuthentication {
|
||||||
final BlockingService service =
|
final BlockingService service =
|
||||||
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
|
||||||
org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller,
|
public Message callBlockingMethod(MethodDescriptor md,
|
||||||
Message param)
|
org.apache.hbase.thirdparty.com.google.protobuf.RpcController controller,
|
||||||
throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException {
|
Message param)
|
||||||
com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor =
|
throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException {
|
||||||
service.getDescriptorForType().findMethodByName(md.getName());
|
com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor =
|
||||||
com.google.protobuf.Message request = service.getRequestPrototype(methodDescriptor);
|
service.getDescriptorForType().findMethodByName(md.getName());
|
||||||
// TODO: Convert rpcController
|
com.google.protobuf.Message request = service.getRequestPrototype(methodDescriptor);
|
||||||
com.google.protobuf.Message response = null;
|
// TODO: Convert rpcController
|
||||||
try {
|
com.google.protobuf.Message response = null;
|
||||||
response = service.callBlockingMethod(methodDescriptor, null, request);
|
try {
|
||||||
} catch (ServiceException e) {
|
response = service.callBlockingMethod(methodDescriptor, null, request);
|
||||||
throw new org.apache.hbase.thirdparty.com.google.protobuf.ServiceException(e);
|
} catch (ServiceException e) {
|
||||||
}
|
throw new org.apache.hbase.thirdparty.com.google.protobuf.ServiceException(e);
|
||||||
return null;// Convert 'response'.
|
|
||||||
}
|
}
|
||||||
|
return null;// Convert 'response'.
|
||||||
|
}
|
||||||
|
|
||||||
@Override public ServiceDescriptor getDescriptorForType() {
|
@Override
|
||||||
return null;
|
public ServiceDescriptor getDescriptorForType() {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public Message getRequestPrototype(MethodDescriptor arg0) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public Message getRequestPrototype(MethodDescriptor arg0) {
|
||||||
return null;
|
// TODO Auto-generated method stub
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public Message getResponsePrototype(MethodDescriptor arg0) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public Message getResponsePrototype(MethodDescriptor arg0) {
|
||||||
return null;
|
// TODO Auto-generated method stub
|
||||||
}
|
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();
|
||||||
|
|
Loading…
Reference in New Issue