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 (['util', 'proxy', 'core', 'prober'].contains(project.name)) return
if (project.name == 'proxy') return
if (project.name == 'core') return
test { test {
testLogging.showStandardStreams = Boolean.parseBoolean(showAllOutput) 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 not use this file except in compliance with the License.
// You may obtain a copy of the License at // 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 // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
apply plugin: 'java'
createUberJar('deployJar', 'prober', 'google.registry.monitoring.blackbox.Prober') createUberJar('deployJar', 'prober', 'google.registry.monitoring.blackbox.Prober')
dependencies { dependencies {
def deps = rootProject.dependencyMap def deps = rootProject.dependencyMap
compile deps['com.google.auto.value:auto-value-annotations'] compile deps['com.google.auto.value:auto-value-annotations']
compile deps['com.google.dagger:dagger'] compile deps['com.google.dagger:dagger']
compile deps['com.google.flogger:flogger'] compile deps['com.google.flogger:flogger']
compile deps['com.google.guava:guava'] compile deps['com.google.guava:guava']
compile deps['io.netty:netty-buffer'] compile deps['io.netty:netty-buffer']
compile deps['io.netty:netty-codec-http'] compile deps['io.netty:netty-codec-http']
compile deps['io.netty:netty-codec'] compile deps['io.netty:netty-codec']
compile deps['io.netty:netty-common'] compile deps['io.netty:netty-common']
compile deps['io.netty:netty-handler'] compile deps['io.netty:netty-handler']
compile deps['io.netty:netty-transport'] compile deps['io.netty:netty-transport']
compile deps['javax.inject:javax.inject'] compile deps['javax.inject:javax.inject']
runtime deps['com.google.flogger:flogger-system-backend'] runtime deps['com.google.flogger:flogger-system-backend']
runtime deps['com.google.auto.value:auto-value'] runtime deps['com.google.auto.value:auto-value']
runtime deps['io.netty:netty-tcnative-boringssl-static'] runtime deps['io.netty:netty-tcnative-boringssl-static']
testCompile deps['com.google.truth:truth'] testCompile deps['com.google.truth:truth']
testCompile deps['junit:junit'] testCompile deps['junit:junit']
testCompile deps['org.mockito:mockito-core'] testCompile deps['org.mockito:mockito-core']
testCompile project(':third_party') testCompile project(':third_party')
// Include auto-value in compile until nebula-lint understands // Include auto-value in compile until nebula-lint understands
// annotationProcessor // annotationProcessor
annotationProcessor deps['com.google.auto.value:auto-value'] annotationProcessor deps['com.google.auto.value:auto-value']
testAnnotationProcessor deps['com.google.auto.value:auto-value'] testAnnotationProcessor deps['com.google.auto.value:auto-value']
annotationProcessor deps['com.google.dagger:dagger-compiler'] annotationProcessor deps['com.google.dagger:dagger-compiler']
testAnnotationProcessor 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(); return new AutoValue_Protocol.Builder();
} }
/** Builder for {@link Protocol}. */
@AutoValue.Builder @AutoValue.Builder
public static abstract class Builder { public abstract static class Builder {
public abstract Builder name(String value); public abstract Builder name(String value);
public abstract Builder port(int num); 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); 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 com.google.common.flogger.FluentLogger;
import google.registry.monitoring.blackbox.messages.InboundMessageType; import google.registry.monitoring.blackbox.messages.InboundMessageType;
import google.registry.monitoring.blackbox.messages.OutboundMessageType; import google.registry.monitoring.blackbox.messages.OutboundMessageType;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise; 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 * <p>{@code ActionHandler} inherits from {@link SimpleChannelInboundHandler< InboundMessageType >},
* messages that implement the {@link InboundMessageType} interface. </p> * 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}, * <p>The {@code ActionHandler} skeleton exists for a few main purposes. First, it returns a {@link
* which informs the {@link ProbingAction} in charge that a response has been read. Second, it stores the {@link OutboundMessageType} * ChannelPromise}, which informs the {@link ProbingAction} in charge that a response has been read.
* passed down the pipeline, so that subclasses can use that information for their own processes. Lastly, with any exception * Second, it stores the {@link OutboundMessageType} passed down the pipeline, so that subclasses
* thrown, the connection is closed, and the ProbingAction governing this channel is informed of the error. Subclasses * can use that information for their own processes. Lastly, with any exception thrown, the
* specify further work to be done for specific kinds of channel pipelines. </p> * 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> { public abstract class ActionHandler extends SimpleChannelInboundHandler<InboundMessageType> {
@ -40,7 +41,10 @@ public abstract class ActionHandler extends SimpleChannelInboundHandler<InboundM
protected ChannelPromise finished; 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() { public ChannelFuture getFuture() {
return finished; return finished;
} }
@ -48,27 +52,30 @@ public abstract class ActionHandler extends SimpleChannelInboundHandler<InboundM
/** Initializes new {@link ChannelPromise} */ /** Initializes new {@link ChannelPromise} */
@Override @Override
public void handlerAdded(ChannelHandlerContext ctx) { 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(); finished = ctx.newPromise();
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, InboundMessageType inboundMessage) throws Exception { public void channelRead0(ChannelHandlerContext ctx, InboundMessageType inboundMessage)
//simply marks finished as success throws Exception {
finished.setSuccess(); // 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 @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
logger.atSevere().withCause(cause).log(String.format( logger.atSevere().withCause(cause).log(
"Attempted Action was unsuccessful with channel: %s, having pipeline: %s", String.format(
ctx.channel().toString(), "Attempted Action was unsuccessful with channel: %s, having pipeline: %s",
ctx.channel().pipeline().toString())); ctx.channel().toString(), ctx.channel().pipeline().toString()));
finished.setFailure(cause); finished = finished.setFailure(cause);
ChannelFuture closedFuture = ctx.channel().close(); ChannelFuture closedFuture = ctx.channel().close();
closedFuture.addListener(f -> logger.atInfo().log("Unsuccessful channel connection closed")); closedFuture.addListener(f -> logger.atInfo().log("Unsuccessful channel connection closed"));
} }
} }

View file

@ -15,7 +15,7 @@
package google.registry.monitoring.blackbox.messages; 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 {} public interface InboundMessageType {}

View file

@ -15,7 +15,7 @@
package google.registry.monitoring.blackbox.messages; 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 {} public interface OutboundMessageType {}

View file

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

View file

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