Cleanup some in o.e.transport (#49901) (#49971)

Cleaning up some obvious compile warnings and dead code.
This commit is contained in:
Armin Braun 2019-12-08 16:14:20 +01:00 committed by GitHub
parent 5b896c5bb5
commit 8ae11e176a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 17 deletions

View File

@ -73,8 +73,9 @@ public class InboundHandler {
requestHandlers = MapBuilder.newMapBuilder(requestHandlers).put(reg.getAction(), reg).immutableMap(); requestHandlers = MapBuilder.newMapBuilder(requestHandlers).put(reg.getAction(), reg).immutableMap();
} }
final RequestHandlerRegistry<? extends TransportRequest> getRequestHandler(String action) { @SuppressWarnings("unchecked")
return requestHandlers.get(action); final <T extends TransportRequest> RequestHandlerRegistry<T> getRequestHandler(String action) {
return (RequestHandlerRegistry<T>) requestHandlers.get(action);
} }
final Transport.ResponseHandlers getResponseHandlers() { final Transport.ResponseHandlers getResponseHandlers() {
@ -149,7 +150,7 @@ public class InboundHandler {
} }
} }
private void handleRequest(TcpChannel channel, InboundMessage.Request message, int messageLengthBytes) { private <T extends TransportRequest> void handleRequest(TcpChannel channel, InboundMessage.Request message, int messageLengthBytes) {
final Set<String> features = message.getFeatures(); final Set<String> features = message.getFeatures();
final String action = message.getActionName(); final String action = message.getActionName();
final long requestId = message.getRequestId(); final long requestId = message.getRequestId();
@ -161,7 +162,7 @@ public class InboundHandler {
if (message.isHandshake()) { if (message.isHandshake()) {
handshaker.handleHandshake(version, features, channel, requestId, stream); handshaker.handleHandshake(version, features, channel, requestId, stream);
} else { } else {
final RequestHandlerRegistry reg = getRequestHandler(action); final RequestHandlerRegistry<T> reg = getRequestHandler(action);
if (reg == null) { if (reg == null) {
throw new ActionNotFoundTransportException(action); throw new ActionNotFoundTransportException(action);
} }
@ -173,7 +174,7 @@ public class InboundHandler {
} }
transportChannel = new TcpTransportChannel(outboundHandler, channel, action, requestId, version, features, transportChannel = new TcpTransportChannel(outboundHandler, channel, action, requestId, version, features,
circuitBreakerService, messageLengthBytes, message.isCompress()); circuitBreakerService, messageLengthBytes, message.isCompress());
final TransportRequest request = reg.newRequest(stream); final T request = reg.newRequest(stream);
request.remoteAddress(new TransportAddress(channel.getRemoteAddress())); request.remoteAddress(new TransportAddress(channel.getRemoteAddress()));
// in case we throw an exception, i.e. when the limit is hit, we don't want to verify // in case we throw an exception, i.e. when the limit is hit, we don't want to verify
final int nextByte = stream.read(); final int nextByte = stream.read();
@ -182,7 +183,7 @@ public class InboundHandler {
throw new IllegalStateException("Message not fully read (request) for requestId [" + requestId + "], action [" + action throw new IllegalStateException("Message not fully read (request) for requestId [" + requestId + "], action [" + action
+ "], available [" + stream.available() + "]; resetting"); + "], available [" + stream.available() + "]; resetting");
} }
threadPool.executor(reg.getExecutor()).execute(new RequestHandler(reg, request, transportChannel)); threadPool.executor(reg.getExecutor()).execute(new RequestHandler<>(reg, request, transportChannel));
} }
} catch (Exception e) { } catch (Exception e) {
// the circuit breaker tripped // the circuit breaker tripped
@ -247,18 +248,17 @@ public class InboundHandler {
}); });
} }
private static class RequestHandler extends AbstractRunnable { private static class RequestHandler<T extends TransportRequest> extends AbstractRunnable {
private final RequestHandlerRegistry reg; private final RequestHandlerRegistry<T> reg;
private final TransportRequest request; private final T request;
private final TransportChannel transportChannel; private final TransportChannel transportChannel;
RequestHandler(RequestHandlerRegistry<?> reg, TransportRequest request, TransportChannel transportChannel) { RequestHandler(RequestHandlerRegistry<T> reg, T request, TransportChannel transportChannel) {
this.reg = reg; this.reg = reg;
this.request = request; this.request = request;
this.transportChannel = transportChannel; this.transportChannel = transportChannel;
} }
@SuppressWarnings({"unchecked"})
@Override @Override
protected void doRun() throws Exception { protected void doRun() throws Exception {
reg.processMessageReceived(request, transportChannel); reg.processMessageReceived(request, transportChannel);

View File

@ -65,8 +65,6 @@ public final class RemoteClusterService extends RemoteClusterAware implements Cl
private static final Logger logger = LogManager.getLogger(RemoteClusterService.class); private static final Logger logger = LogManager.getLogger(RemoteClusterService.class);
private static final ActionListener<Void> noopListener = ActionListener.wrap((x) -> {}, (x) -> {});
static { static {
// remove search.remote.* settings in 8.0.0 // remove search.remote.* settings in 8.0.0
assert Version.CURRENT.major < 8; assert Version.CURRENT.major < 8;

View File

@ -53,10 +53,6 @@ public class TransportRequestOptions {
return new Builder(); return new Builder();
} }
public static Builder builder(TransportRequestOptions options) {
return new Builder().withTimeout(options.timeout).withType(options.type());
}
public static class Builder { public static class Builder {
private TimeValue timeout; private TimeValue timeout;
private Type type = Type.REG; private Type type = Type.REG;