Skip to content

Commit

Permalink
Bunch of fixes
Browse files Browse the repository at this point in the history
- Move spring boot version from 2.7.10 to 2.7.18
- Remove jetty-utils dependency by importing what's necessary
- Fix thread pool initialization from configured values
  • Loading branch information
enricovianello committed Mar 19, 2024
1 parent cb3c4c5 commit 490ad21
Show file tree
Hide file tree
Showing 10 changed files with 876 additions and 76 deletions.
84 changes: 31 additions & 53 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- Keep this aligned with the spring.boot-version property below! -->
<version>2.7.10</version>
<version>2.7.18</version>
<relativePath />
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<plugin.compiler.version>3.6.0</plugin.compiler.version>
<maven.compiler.release>11</maven.compiler.release>
<plugin.compiler.version>3.8.0</plugin.compiler.version>

<plugin.jar.version>2.4</plugin.jar.version>
<plugin.assembly.version>2.4</plugin.assembly.version>
Expand All @@ -32,14 +31,14 @@
<java.version>11</java.version>

<!-- Keep this aligned with the parent project version! -->
<spring-boot.version>2.7.10</spring-boot.version>
<spring-boot.version>2.7.18</spring-boot.version>

<!-- Sonarcloud.io properties -->
<sonar.projectKey>italiangrid_storm-webdav</sonar.projectKey>
<sonar.organization>italiangrid</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<jetty-utils.version>0.4.6.v20220506</jetty-utils.version>
<voms-api-java.version>3.3.2</voms-api-java.version>
<milton.version>2.7.1.7</milton.version>

<commons-lang.version>2.3</commons-lang.version>
Expand All @@ -50,14 +49,13 @@
<http-core.version>4.2.2</http-core.version>
<http-client.version>4.2.1</http-client.version>

<guava.version>31.1-jre</guava.version>
<guava.version>32.0.0-jre</guava.version>

<owner-config.version>1.0.5.1</owner-config.version>

<spring-security-oauth2.version>2.3.3.RELEASE</spring-security-oauth2.version>
<nimbus-jose-jwt.version>6.0.2</nimbus-jose-jwt.version>
<mock-server.version>5.5.1</mock-server.version>
<bouncycastle.version>1.72</bouncycastle.version>

</properties>

Expand All @@ -70,8 +68,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
</configuration>
</plugin>

Expand Down Expand Up @@ -99,14 +96,16 @@
<descriptors>
<descriptor>src/assembly/tarball.xml</descriptor>
</descriptors>
<finalName>storm-webdav</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
Expand Down Expand Up @@ -190,13 +189,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<exclusions>
<!-- Exclude this to make failure reporting work -->
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -256,6 +248,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -326,11 +324,6 @@
<artifactId>metrics-core</artifactId>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jvm</artifactId>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jetty9</artifactId>
Expand All @@ -348,45 +341,30 @@
</dependency>

<dependency>
<groupId>org.italiangrid</groupId>
<artifactId>jetty-utils</artifactId>
<version>${jetty-utils.version}</version>
<exclusions>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-conscrypt-server</artifactId>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>

<dependency>
<groupId>org.italiangrid</groupId>
<artifactId>voms-api-java</artifactId>
<version>${voms-api-java.version}</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public interface ServiceConfiguration {

public long getTrustAnchorsRefreshIntervalInSeconds();

public int getMinConnections();

public int getMaxConnections();

public int getMaxQueueSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,13 @@ public static class ConnectorProperties {
int securePort = 8443;

@Positive
int maxConnections = 200;
int minConnections = 50;

@Positive
int maxQueueSize = 512;
int maxConnections = 300;

@Positive
int maxQueueSize = 900;

@Positive
int maxIdleTimeMsec = 30000;
Expand Down Expand Up @@ -292,6 +295,14 @@ public void setSecurePort(int securePort) {
this.securePort = securePort;
}

public int getMinConnections() {
return minConnections;
}

public void setMinConnections(int minConnections) {
this.minConnections = minConnections;
}

public int getMaxConnections() {
return maxConnections;
}
Expand Down Expand Up @@ -732,55 +743,51 @@ public long getTrustAnchorsRefreshIntervalInSeconds() {
return getTls().getTrustAnchorsRefreshIntervalSecs();
}

@Override
public int getMinConnections() {
return getConnector().getMinConnections();
}

@Override
public int getMaxConnections() {
return getConnector().getMaxConnections();
}


@Override
public int getMaxQueueSize() {
return getConnector().getMaxQueueSize();
}


@Override
public int getConnectorMaxIdleTimeInMsec() {
return getConnector().getMaxIdleTimeMsec();
}


@Override
public String getSAConfigDir() {
return getSa().getConfigDir();
}


@Override
public boolean enableVOMapFiles() {
return getVoMapFiles().isEnabled();
}


@Override
public String getVOMapFilesConfigDir() {
return getVoMapFiles().getConfigDir();
}


@Override
public long getVOMapFilesRefreshIntervalInSeconds() {
return getVoMapFiles().getRefreshIntervalSec();
}


@Override
public boolean isAuthorizationDisabled() {
return getAuthz().isDisabled();
}


@Override
public boolean requireClientCertificateAuthentication() {
return getTls().isRequireClientCert();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.italiangrid.storm.webdav.config.ServiceConfiguration;
import org.italiangrid.storm.webdav.config.ServiceConfigurationProperties;
import org.italiangrid.storm.webdav.config.StorageAreaConfiguration;
import org.italiangrid.utils.jetty.TLSServerConnectorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ServerProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
*/
package org.italiangrid.storm.webdav.server;

import java.util.concurrent.ArrayBlockingQueue;

import org.italiangrid.storm.webdav.config.ServiceConfiguration;
import org.italiangrid.utils.jetty.ThreadPoolBuilder;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.jetty9.InstrumentedQueuedThreadPool;

public class DefaultWebServerFactory
implements WebServerFactoryCustomizer<JettyServletWebServerFactory> {
Expand All @@ -42,18 +44,18 @@ public DefaultWebServerFactory(ServiceConfiguration configuration,
this.metricRegistry = registry;
}

private InstrumentedQueuedThreadPool getInstrumentedThreadPool() {
InstrumentedQueuedThreadPool tPool = new InstrumentedQueuedThreadPool(metricRegistry, configuration.getMaxConnections(),
configuration.getMinConnections(), configuration.getConnectorMaxIdleTimeInMsec(),
new ArrayBlockingQueue<Runnable>(configuration.getMaxQueueSize()), "storm.http");
tPool.setName("thread-pool");
return tPool;
}

@Override
public void customize(JettyServletWebServerFactory factory) {

factory.setThreadPool(ThreadPoolBuilder.instance()
.withMaxRequestQueueSize(configuration.getMaxQueueSize())
.withMaxThreads(serverProperties.getJetty().getThreads().getMax())
.withMinThreads(serverProperties.getJetty().getThreads().getMin())
.registry(metricRegistry)
.withPrefix("storm.http")
.withName("thread-pool")
.build());

factory.setThreadPool(getInstrumentedThreadPool());
factory.addServerCustomizers(serverCustomizer);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) Istituto Nazionale di Fisica Nucleare, 2014-2023.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.italiangrid.storm.webdav.server;

public class TLSConnectorBuilderError extends RuntimeException {

private static final long serialVersionUID = 1L;

public TLSConnectorBuilderError(Throwable cause) {
super(cause);
}

public TLSConnectorBuilderError(String message, Throwable cause) {
super(message, cause);
}

public TLSConnectorBuilderError(String message) {
super(message);
}

}
Loading

0 comments on commit 490ad21

Please sign in to comment.