Clean up Gradle stylings and fix issues IDed in Prober (#212)

This commit is contained in:
gbrodman 2019-08-05 15:54:20 -04:00 committed by GitHub
parent b36cae52e9
commit 2a381b7071
8 changed files with 63 additions and 62 deletions

View file

@ -236,9 +236,7 @@ subprojects {
}
}
if (project.name == 'util') return
if (project.name == 'proxy') return
if (project.name == 'core') return
if (['util', 'proxy', 'core', 'prober'].contains(project.name)) return
test {
testLogging.showStandardStreams = Boolean.parseBoolean(showAllOutput)

View file

@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@ -12,38 +12,36 @@
// See the License for the specific language governing permissions and
// limitations under the License.
apply plugin: 'java'
createUberJar('deployJar', 'prober', 'google.registry.monitoring.blackbox.Prober')
dependencies {
def deps = rootProject.dependencyMap
def deps = rootProject.dependencyMap
compile deps['com.google.auto.value:auto-value-annotations']
compile deps['com.google.dagger:dagger']
compile deps['com.google.flogger:flogger']
compile deps['com.google.guava:guava']
compile deps['io.netty:netty-buffer']
compile deps['io.netty:netty-codec-http']
compile deps['io.netty:netty-codec']
compile deps['io.netty:netty-common']
compile deps['io.netty:netty-handler']
compile deps['io.netty:netty-transport']
compile deps['javax.inject:javax.inject']
compile deps['com.google.auto.value:auto-value-annotations']
compile deps['com.google.dagger:dagger']
compile deps['com.google.flogger:flogger']
compile deps['com.google.guava:guava']
compile deps['io.netty:netty-buffer']
compile deps['io.netty:netty-codec-http']
compile deps['io.netty:netty-codec']
compile deps['io.netty:netty-common']
compile deps['io.netty:netty-handler']
compile deps['io.netty:netty-transport']
compile deps['javax.inject:javax.inject']
runtime deps['com.google.flogger:flogger-system-backend']
runtime deps['com.google.auto.value:auto-value']
runtime deps['io.netty:netty-tcnative-boringssl-static']
runtime deps['com.google.flogger:flogger-system-backend']
runtime deps['com.google.auto.value:auto-value']
runtime deps['io.netty:netty-tcnative-boringssl-static']
testCompile deps['com.google.truth:truth']
testCompile deps['junit:junit']
testCompile deps['org.mockito:mockito-core']
testCompile project(':third_party')
testCompile deps['com.google.truth:truth']
testCompile deps['junit:junit']
testCompile deps['org.mockito:mockito-core']
testCompile project(':third_party')
// Include auto-value in compile until nebula-lint understands
// annotationProcessor
annotationProcessor deps['com.google.auto.value:auto-value']
testAnnotationProcessor deps['com.google.auto.value:auto-value']
annotationProcessor deps['com.google.dagger:dagger-compiler']
testAnnotationProcessor deps['com.google.dagger:dagger-compiler']
// Include auto-value in compile until nebula-lint understands
// annotationProcessor
annotationProcessor deps['com.google.auto.value:auto-value']
testAnnotationProcessor deps['com.google.auto.value:auto-value']
annotationProcessor deps['com.google.dagger:dagger-compiler']
testAnnotationProcessor deps['com.google.dagger:dagger-compiler']
}

View file

@ -41,14 +41,16 @@ public abstract class Protocol {
return new AutoValue_Protocol.Builder();
}
/** Builder for {@link Protocol}. */
@AutoValue.Builder
public static abstract class Builder {
public abstract static class Builder {
public abstract Builder name(String value);
public abstract Builder port(int num);
public abstract Builder handlerProviders(ImmutableList<Provider<? extends ChannelHandler>> providers);
public abstract Builder handlerProviders(
ImmutableList<Provider<? extends ChannelHandler>> providers);
public abstract Builder persistentConnection(boolean value);

View file

@ -17,22 +17,23 @@ package google.registry.monitoring.blackbox.handlers;
import com.google.common.flogger.FluentLogger;
import google.registry.monitoring.blackbox.messages.InboundMessageType;
import google.registry.monitoring.blackbox.messages.OutboundMessageType;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.channel.SimpleChannelInboundHandler;
/**
*Superclass of all {@link ChannelHandler}s placed at end of channel pipeline
* Superclass of all {@link ChannelHandler}s placed at end of channel pipeline
*
* <p> {@code ActionHandler} inherits from {@link SimpleChannelInboundHandler< InboundMessageType >}, as it should only be passed in
* messages that implement the {@link InboundMessageType} interface. </p>
* <p>{@code ActionHandler} inherits from {@link SimpleChannelInboundHandler< InboundMessageType >},
* as it should only be passed in messages that implement the {@link InboundMessageType} interface.
*
* <p> The {@code ActionHandler} skeleton exists for a few main purposes. First, it returns a {@link ChannelPromise},
* which informs the {@link ProbingAction} in charge that a response has been read. Second, it stores the {@link OutboundMessageType}
* passed down the pipeline, so that subclasses can use that information for their own processes. Lastly, with any exception
* thrown, the connection is closed, and the ProbingAction governing this channel is informed of the error. Subclasses
* specify further work to be done for specific kinds of channel pipelines. </p>
* <p>The {@code ActionHandler} skeleton exists for a few main purposes. First, it returns a {@link
* ChannelPromise}, which informs the {@link ProbingAction} in charge that a response has been read.
* Second, it stores the {@link OutboundMessageType} passed down the pipeline, so that subclasses
* can use that information for their own processes. Lastly, with any exception thrown, the
* connection is closed, and the ProbingAction governing this channel is informed of the error.
* Subclasses specify further work to be done for specific kinds of channel pipelines.
*/
public abstract class ActionHandler extends SimpleChannelInboundHandler<InboundMessageType> {
@ -40,7 +41,10 @@ public abstract class ActionHandler extends SimpleChannelInboundHandler<InboundM
protected ChannelPromise finished;
/** Takes in {@link OutboundMessageType} type and saves for subclasses. Then returns initialized {@link ChannelPromise}*/
/**
* Takes in {@link OutboundMessageType} type and saves for subclasses. Then returns initialized
* {@link ChannelPromise}
*/
public ChannelFuture getFuture() {
return finished;
}
@ -48,27 +52,30 @@ public abstract class ActionHandler extends SimpleChannelInboundHandler<InboundM
/** Initializes new {@link ChannelPromise} */
@Override
public void handlerAdded(ChannelHandlerContext ctx) {
//Once handler is added to channel pipeline, initialize channel and future for this handler
// Once handler is added to channel pipeline, initialize channel and future for this handler
finished = ctx.newPromise();
}
@Override
public void channelRead0(ChannelHandlerContext ctx, InboundMessageType inboundMessage) throws Exception {
//simply marks finished as success
finished.setSuccess();
public void channelRead0(ChannelHandlerContext ctx, InboundMessageType inboundMessage)
throws Exception {
// simply marks finished as success
finished = finished.setSuccess();
}
/** Logs the channel and pipeline that caused error, closes channel, then informs {@link ProbingAction} listeners of error */
/**
* Logs the channel and pipeline that caused error, closes channel, then informs {@link
* ProbingAction} listeners of error
*/
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
logger.atSevere().withCause(cause).log(String.format(
"Attempted Action was unsuccessful with channel: %s, having pipeline: %s",
ctx.channel().toString(),
ctx.channel().pipeline().toString()));
logger.atSevere().withCause(cause).log(
String.format(
"Attempted Action was unsuccessful with channel: %s, having pipeline: %s",
ctx.channel().toString(), ctx.channel().pipeline().toString()));
finished.setFailure(cause);
finished = finished.setFailure(cause);
ChannelFuture closedFuture = ctx.channel().close();
closedFuture.addListener(f -> logger.atInfo().log("Unsuccessful channel connection closed"));
}
}

View file

@ -15,7 +15,7 @@
package google.registry.monitoring.blackbox.messages;
/**
* Marker Interface that is implemented by all classes that serve as {@code inboundMessages} in channel pipeline
* Marker Interface that is implemented by all classes that serve as {@code inboundMessages} in
* channel pipeline
*/
public interface InboundMessageType {}

View file

@ -15,7 +15,7 @@
package google.registry.monitoring.blackbox.messages;
/**
* Marker Interface that is implemented by all classes that serve as {@code outboundMessages} in channel pipeline
* Marker Interface that is implemented by all classes that serve as {@code outboundMessages} in
* channel pipeline
*/
public interface OutboundMessageType {}

View file

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
apply plugin: 'java'
createUberJar('deployJar', 'proxy_server', 'google.registry.proxy.ProxyServer')
task buildProxyImage(dependsOn: deployJar, type: Exec) {

View file

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
apply plugin: 'java'
dependencies {
def deps = rootProject.dependencyMap
compile deps['com.google.api-client:google-api-client']