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.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<AuthenticationProtos.GetAuthenticationTokenResponse>
|
||||
callback = new NonShadedBlockingRpcCallback<>();
|
||||
getAuthenticationToken((RpcController)null, request, callback);
|
||||
getAuthenticationToken(null, request, callback);
|
||||
try {
|
||||
serverController.checkFailed();
|
||||
return callback.get();
|
||||
|
|
Loading…
Reference in New Issue