Skip to content

Commit

Permalink
Merge pull request #1456 from HubSpot/java8ify
Browse files Browse the repository at this point in the history
Bump to java 8
  • Loading branch information
ssalinas committed Mar 30, 2017
2 parents c218d31 + bef08e0 commit 927bad4
Show file tree
Hide file tree
Showing 33 changed files with 158 additions and 147 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
@@ -1,7 +1,5 @@
language: java
jdk:
- oraclejdk7
- openjdk7
- oraclejdk8

install: true
Expand Down
Expand Up @@ -142,7 +142,6 @@ public class SingularityExecutorConfiguration extends BaseRunnerConfiguration {
@JsonProperty
private int localDownloadServiceMaxConnections = 25;

@NotNull
@JsonProperty
private Optional<Integer> maxTaskThreads = Optional.absent();

Expand Down
Expand Up @@ -46,7 +46,6 @@ public class SingularityExecutorCleanupConfiguration extends BaseRunnerConfigura
@JsonProperty
private boolean runDockerCleanup = false;

@NotNull
@JsonProperty
private Optional<SingularityClientCredentials> singularityClientCredentials = Optional.absent();

Expand Down
2 changes: 1 addition & 1 deletion SingularityRunnerBase/pom.xml
Expand Up @@ -52,7 +52,7 @@
</dependency>

<dependency>
<groupId>com.codahale.metrics</groupId>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>

Expand Down
Expand Up @@ -23,12 +23,10 @@ public class SingularityS3Configuration extends BaseRunnerConfiguration {
@JsonProperty
private String artifactCacheDirectory;

@NotNull
@Obfuscate
@JsonProperty
private Optional<String> s3AccessKey = Optional.absent();

@NotNull
@Obfuscate
@JsonProperty
private Optional<String> s3SecretKey = Optional.absent();
Expand Down
2 changes: 1 addition & 1 deletion SingularityS3Downloader/pom.xml
Expand Up @@ -77,7 +77,7 @@
</dependency>

<dependency>
<groupId>com.codahale.metrics</groupId>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion SingularityS3Uploader/pom.xml
Expand Up @@ -74,7 +74,7 @@
</dependency>

<dependency>
<groupId>com.codahale.metrics</groupId>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>

Expand Down
Expand Up @@ -36,12 +36,10 @@ public class SingularityS3UploaderConfiguration extends BaseRunnerConfiguration
@JsonProperty
private long stopCheckingAfterMillisWithoutNewFile = TimeUnit.HOURS.toMillis(168);

@NotNull
@JsonProperty
@Obfuscate
private Optional<String> s3AccessKey = Optional.absent();

@NotNull
@JsonProperty
@Obfuscate
private Optional<String> s3SecretKey = Optional.absent();
Expand Down
36 changes: 18 additions & 18 deletions SingularityService/pom.xml
Expand Up @@ -90,7 +90,7 @@

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>

<dependency>
Expand Down Expand Up @@ -155,6 +155,11 @@
<artifactId>jetty-servlets</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>

<dependency>
<groupId>de.neuland-bfi</groupId>
<artifactId>jade4j</artifactId>
Expand Down Expand Up @@ -227,22 +232,22 @@
</dependency>

<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
</dependency>

<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>

<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
</dependency>

<dependency>
<groupId>com.codahale.metrics</groupId>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
</dependency>

Expand Down Expand Up @@ -276,16 +281,6 @@
<artifactId>jackson-datatype-guava</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
Expand Down Expand Up @@ -354,6 +349,11 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.squarespace.jersey2-guice</groupId>
<artifactId>jersey2-guice-impl</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Expand Up @@ -42,7 +42,7 @@ public class SingularityAbort implements ConnectionStateListener {

@Inject
public SingularityAbort(SingularitySmtpSender smtpSender, ServerProvider serverProvider, SingularityConfiguration configuration, SingularityExceptionNotifier exceptionNotifier, @Named(SingularityMainModule.HTTP_HOST_AND_PORT) HostAndPort hostAndPort) {
this.maybeSmtpConfiguration = configuration.getSmtpConfiguration();
this.maybeSmtpConfiguration = configuration.getSmtpConfigurationOptional();
this.serverProvider = serverProvider;
this.smtpSender = smtpSender;
this.exceptionNotifier = exceptionNotifier;
Expand Down
Expand Up @@ -129,7 +129,7 @@ public void configure(Binder binder) {

binder.bind(SingularityDriverManager.class).in(Scopes.SINGLETON);
binder.bind(SingularityLeaderController.class).in(Scopes.SINGLETON);
if (configuration.getSmtpConfiguration().isPresent()) {
if (configuration.getSmtpConfigurationOptional().isPresent()) {
binder.bind(SingularityMailer.class).to(SmtpMailer.class).in(Scopes.SINGLETON);
} else {
binder.bind(SingularityMailer.class).toInstance(NoopMailer.getInstance());
Expand Down Expand Up @@ -235,7 +235,7 @@ public ZooKeeperConfiguration zooKeeperConfiguration(final SingularityConfigurat
@Provides
@Singleton
public Optional<SentryConfiguration> sentryConfiguration(final SingularityConfiguration config) {
return config.getSentryConfiguration();
return config.getSentryConfigurationOptional();
}

@Provides
Expand Down Expand Up @@ -284,13 +284,13 @@ public CustomExecutorConfiguration customExecutorConfiguration(final Singularity
@Provides
@Singleton
public Optional<SMTPConfiguration> smtpConfiguration(final SingularityConfiguration config) {
return config.getSmtpConfiguration();
return config.getSmtpConfigurationOptional();
}

@Provides
@Singleton
public Optional<S3Configuration> s3Configuration(final SingularityConfiguration config) {
return config.getS3Configuration();
return config.getS3ConfigurationOptional();
}

@Provides
Expand Down
Expand Up @@ -6,9 +6,6 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

import com.sun.jersey.api.ConflictException;
import com.sun.jersey.api.NotFoundException;

public final class WebExceptions {

private WebExceptions() {
Expand Down Expand Up @@ -69,14 +66,14 @@ public static WebApplicationException conflict(String message, Object... args) {
if (args.length > 0) {
message = format(message, args);
}
throw new ConflictException(message);
throw new WebApplicationException(message, Status.CONFLICT);
}

public static WebApplicationException notFound(String message, Object... args) {
if (args.length > 0) {
message = format(message, args);
}
throw new NotFoundException(message);
throw new WebApplicationException(message, Status.NOT_FOUND);
}

public static WebApplicationException forbidden(String message, Object... args) {
Expand Down
Expand Up @@ -81,10 +81,10 @@ private static LdapConnectionPool createConnectionPool(LDAPConfiguration configu
@Inject
public SingularityLDAPDatastore(SingularityConfiguration configuration,
SingularityExceptionNotifier exceptionNotifier) throws IOException {
checkArgument(configuration.getLdapConfiguration().isPresent(), "LDAP configuration not present");
checkArgument(configuration.getLdapConfigurationOptional().isPresent(), "LDAP configuration not present");

this.connectionPool = createConnectionPool(configuration.getLdapConfiguration().get());
this.configuration = configuration.getLdapConfiguration().get();
this.connectionPool = createConnectionPool(configuration.getLdapConfigurationOptional().get());
this.configuration = configuration.getLdapConfigurationOptional().get();
this.exceptionNotifier = exceptionNotifier;

if (configuration.isLdapCacheEnabled()) {
Expand Down
Expand Up @@ -25,7 +25,6 @@ public class MesosConfiguration {

private boolean checkpoint = true;

@NotNull
private Optional<String> frameworkRole = Optional.absent();

@NotNull
Expand All @@ -35,7 +34,7 @@ public class MesosConfiguration {
private String defaultRackId = "DEFAULT";

private int slaveHttpPort = 5051;
@NotNull

private Optional<Integer> slaveHttpsPort = Optional.absent();

private int maxNumInstancesPerRequest = 25;
Expand Down
Expand Up @@ -61,10 +61,8 @@ public class S3Configuration {
@NotNull
private List<SingularityS3UploaderFile> s3UploaderAdditionalFiles = Collections.singletonList(SingularityS3UploaderFile.fromString("service.log"));

@NotNull
private Optional<String> s3StorageClass = Optional.absent();

@NotNull
private Optional<Long> applyS3StorageClassAfterBytes = Optional.absent();

public int getMaxS3Threads() {
Expand Down
Expand Up @@ -70,11 +70,9 @@ public class SMTPConfiguration {
@JsonProperty
private List<String> taskEmailTailFiles = Arrays.asList("stdout", "stderr");

@NotNull
@JsonProperty
private Optional<String> taskLogErrorRegex = Optional.absent();

@NotNull
@JsonProperty
private Optional<Boolean> taskLogErrorRegexCaseSensitive = Optional.absent();

Expand Down
Expand Up @@ -10,6 +10,7 @@
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
Expand Down Expand Up @@ -147,10 +148,8 @@ public class SingularityConfiguration extends Configuration {

private int startupIntervalSeconds = 2;

@NotNull
private Optional<Integer> healthcheckMaxRetries = Optional.absent();

@NotNull
private Optional<Integer> healthcheckMaxTotalTimeoutSeconds = Optional.absent();

@NotNull
Expand Down Expand Up @@ -248,8 +247,6 @@ public class SingularityConfiguration extends Configuration {
private long warnIfScheduledJobIsRunningForAtLeastMillis = TimeUnit.DAYS.toMillis(1);

@JsonProperty("taskExecutionTimeLimitMillis")
@Valid
@NotNull
private Optional<Long> taskExecutionTimeLimitMillis = Optional.absent();

private int warnIfScheduledJobIsRunningPastNextRunPct = 200;
Expand Down Expand Up @@ -637,7 +634,8 @@ public long getPersistHistoryEverySeconds() {
return persistHistoryEverySeconds;
}

public Optional<S3Configuration> getS3Configuration() {
@JsonIgnore
public Optional<S3Configuration> getS3ConfigurationOptional() {
return Optional.fromNullable(s3Configuration);
}

Expand All @@ -649,14 +647,28 @@ public long getSaveStateEverySeconds() {
return saveStateEverySeconds;
}

public Optional<SentryConfiguration> getSentryConfiguration(){
@JsonIgnore
public Optional<SentryConfiguration> getSentryConfigurationOptional(){
return Optional.fromNullable(sentryConfiguration);
}

public Optional<SMTPConfiguration> getSmtpConfiguration() {
@JsonIgnore
public Optional<SMTPConfiguration> getSmtpConfigurationOptional() {
return Optional.fromNullable(smtpConfiguration);
}

public S3Configuration getS3Configuration() {
return s3Configuration;
}

public SentryConfiguration getSentryConfiguration() {
return sentryConfiguration;
}

public SMTPConfiguration getSmtpConfiguration() {
return smtpConfiguration;
}

public long getStartNewReconcileEverySeconds() {
return startNewReconcileEverySeconds;
}
Expand Down Expand Up @@ -1091,7 +1103,12 @@ public void setTaskPersistAfterStartupBufferMillis(long taskPersistAfterStartupB
this.taskPersistAfterStartupBufferMillis = taskPersistAfterStartupBufferMillis;
}

public Optional<LDAPConfiguration> getLdapConfiguration() {
public LDAPConfiguration getLdapConfiguration() {
return ldapConfiguration;
}

@JsonIgnore
public Optional<LDAPConfiguration> getLdapConfigurationOptional() {
return Optional.fromNullable(ldapConfiguration);
}

Expand Down
Expand Up @@ -43,7 +43,6 @@ public static RootUrlMode parse(String value) {
private String title = "Singularity";

@JsonProperty
@NotNull
private Optional<String> navColor = Optional.absent();

@JsonProperty
Expand Down Expand Up @@ -76,7 +75,6 @@ public static RootUrlMode parse(String value) {
private String rootUrlMode = RootUrlMode.INDEX_CATCHALL.name();

@JsonProperty
@NotNull
private Optional<String> taskS3LogOmitPrefix = Optional.absent();

@NotEmpty
Expand All @@ -86,12 +84,10 @@ public static RootUrlMode parse(String value) {
private String timestampWithSecondsFormat = "lll:ss";

@JsonProperty
@NotNull
private Optional<String> redirectOnUnauthorizedUrl = Optional.absent();


@JsonProperty
@NotNull
private Optional<String> extraScript = Optional.absent();


Expand Down

0 comments on commit 927bad4

Please sign in to comment.