diff --git a/oap-highload/pom.xml b/oap-highload/pom.xml
new file mode 100644
index 0000000000..817da201a8
--- /dev/null
+++ b/oap-highload/pom.xml
@@ -0,0 +1,35 @@
+
+
+ 4.0.0
+
+
+ oap
+ oap
+ ${oap.project.version}
+
+
+ oap-highload
+
+
+
+ net.openhft
+ affinity
+ ${oap.deps.affinity.version}
+
+
+
+ oap
+ oap-stdlib-test
+ ${project.version}
+
+
+
+ org.projectlombok
+ lombok
+ ${oap.deps.lombok.version}
+ provided
+
+
+
diff --git a/oap-highload/src/main/java/oap/highload/Affinity.java b/oap-highload/src/main/java/oap/highload/Affinity.java
new file mode 100644
index 0000000000..1db0012ea5
--- /dev/null
+++ b/oap-highload/src/main/java/oap/highload/Affinity.java
@@ -0,0 +1,72 @@
+package oap.highload;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Slf4j
+public class Affinity {
+ @Getter
+ private final int[] cpus;
+ private final AtomicInteger position = new AtomicInteger();
+
+ public Affinity( String cpu ) {
+ log.info( "cpu {}", cpu );
+
+ if( cpu.trim().equals( "*" ) ) {
+ cpus = new int[0];
+ } else {
+ String[] split = cpu.split( "," );
+
+ ArrayList cpus = new ArrayList<>();
+
+ for( var n : split ) {
+ String nTrimmed = n.trim();
+ if( nTrimmed.endsWith( "+" ) ) {
+ for( int i = Integer.parseInt( nTrimmed.substring( 0, nTrimmed.length() - 1 ) ); i < Runtime.getRuntime().availableProcessors(); i++ ) {
+ cpus.add( i );
+ }
+ } else {
+ String[] range = n.split( "-" );
+
+ if( range.length > 1 ) {
+ int start = Integer.parseInt( range[0].trim() );
+ int end = Integer.parseInt( range[1].trim() );
+
+ for( int i = start; i <= end; i++ ) {
+ cpus.add( i );
+ }
+
+ } else {
+ cpus.add( Integer.parseInt( nTrimmed ) );
+ }
+ }
+ }
+
+ this.cpus = cpus.stream().mapToInt( i -> i ).toArray();
+ }
+ }
+
+ public static Affinity any() {
+ return new Affinity( "*" );
+ }
+
+ public void set() {
+ if( isEnabled() ) {
+ int cpuIndex = position.getAndUpdate( index -> index >= cpus.length ? 0 : index + 1 );
+ int cpu = cpus[cpuIndex];
+ log.trace( "affinity -> {}", cpu );
+ net.openhft.affinity.Affinity.setAffinity( cpu );
+ }
+ }
+
+ public boolean isEnabled() {
+ return cpus.length > 0;
+ }
+
+ public int size() {
+ return cpus.length;
+ }
+}
diff --git a/oap-highload/src/test/java/oap/highload/AffinityTest.java b/oap-highload/src/test/java/oap/highload/AffinityTest.java
new file mode 100644
index 0000000000..a797f20f3d
--- /dev/null
+++ b/oap-highload/src/test/java/oap/highload/AffinityTest.java
@@ -0,0 +1,20 @@
+package oap.highload;
+
+import org.testng.annotations.Test;
+
+import java.util.stream.IntStream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class AffinityTest {
+ @Test
+ public void testCpuParse() {
+ assertThat( new Affinity( "1" ).getCpus() ).isEqualTo( new int[] { 1 } );
+ assertThat( new Affinity( "3+" ).getCpus() ).isEqualTo( IntStream.range( 3, Runtime.getRuntime().availableProcessors() ).toArray() );
+ assertThat( new Affinity( "1, 3 ,7 " ).getCpus() ).isEqualTo( new int[] { 1, 3, 7 } );
+ assertThat( new Affinity( "1-3, 8" ).getCpus() ).isEqualTo( new int[] { 1, 2, 3, 8 } );
+ assertThat( new Affinity( "1-3, 8" ).isEnabled() ).isTrue();
+ assertThat( new Affinity( "*" ).getCpus() ).isEqualTo( new int[0] );
+ assertThat( new Affinity( "*" ).isEnabled() ).isFalse();
+ }
+}
diff --git a/oap-pnio/pom.xml b/oap-pnio/pom.xml
index 46f1531e32..b97902bc31 100644
--- a/oap-pnio/pom.xml
+++ b/oap-pnio/pom.xml
@@ -16,7 +16,12 @@
oap
oap-stdlib
- ${project.parent.version}
+ ${project.version}
+
+
+ oap
+ oap-highload
+ ${project.version}
diff --git a/oap-pnio/src/main/java/oap/http/pnio/PnioHttpHandler.java b/oap-pnio/src/main/java/oap/http/pnio/PnioHttpHandler.java
index e1797942a7..aa989cbb5d 100644
--- a/oap-pnio/src/main/java/oap/http/pnio/PnioHttpHandler.java
+++ b/oap-pnio/src/main/java/oap/http/pnio/PnioHttpHandler.java
@@ -13,14 +13,20 @@
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.Builder;
+import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import oap.LogConsolidated;
+import oap.highload.Affinity;
import oap.http.Http;
import oap.http.server.nio.HttpServerExchange;
import oap.util.Dates;
import org.slf4j.event.Level;
+import org.xnio.XnioExecutor;
+import org.xnio.XnioWorker;
import java.io.Closeable;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.SynchronousQueue;
@@ -36,25 +42,14 @@ public class PnioHttpHandler implements Closeable, AutoCloseable
public final int requestSize;
public final int responseSize;
public final int threads;
- private RequestWorkflow workflow;
+ public final double queueTimeoutPercent;
+ public final Affinity cpuAffinity;
+ public final Affinity ioAffinity;
private final ErrorResponse errorResponse;
private final ThreadPoolExecutor pool;
private final SynchronousQueue> queue;
-
- public final double queueTimeoutPercent;
- public final int cpuAffinityFirstCpu;
-
private final List> tasks = new ArrayList<>();
-
- @Builder
- public static class PnioHttpSettings {
- int requestSize;
- int responseSize;
- double queueTimeoutPercent;
- int cpuThreads;
- boolean cpuQueueFair;
- int cpuAffinityFirstCpu;
- }
+ private RequestWorkflow workflow;
@Deprecated
// use builder for settings
@@ -63,20 +58,23 @@ public PnioHttpHandler( int requestSize,
double queueTimeoutPercent,
int cpuThreads,
boolean cpuQueueFair,
- int cpuAffinityFirstCpu,
+ Affinity cpuAffinity,
+ Affinity ioAffinity,
RequestWorkflow workflow,
ErrorResponse errorResponse ) {
- this( PnioHttpSettings.builder()
- .requestSize( requestSize )
- .responseSize( responseSize )
- .queueTimeoutPercent( queueTimeoutPercent )
- .cpuThreads( cpuThreads )
- .cpuQueueFair( cpuQueueFair )
- .cpuAffinityFirstCpu( cpuAffinityFirstCpu )
- .build(),
- workflow,
- errorResponse );
+ this( PnioHttpSettings.builder()
+ .requestSize( requestSize )
+ .responseSize( responseSize )
+ .queueTimeoutPercent( queueTimeoutPercent )
+ .cpuThreads( cpuThreads )
+ .cpuQueueFair( cpuQueueFair )
+ .cpuAffinity( cpuAffinity )
+ .ioAffinity( ioAffinity )
+ .build(),
+ workflow,
+ errorResponse );
}
+
public PnioHttpHandler( PnioHttpSettings settings,
RequestWorkflow workflow,
ErrorResponse errorResponse ) {
@@ -84,8 +82,15 @@ public PnioHttpHandler( PnioHttpSettings settings,
this.responseSize = settings.responseSize;
this.queueTimeoutPercent = settings.queueTimeoutPercent;
- this.threads = settings.cpuThreads > 0 ? settings.cpuThreads : Runtime.getRuntime().availableProcessors();
- this.cpuAffinityFirstCpu = settings.cpuAffinityFirstCpu;
+ if( settings.cpuThreads > 0 ) {
+ this.threads = settings.cpuThreads;
+ } else if( settings.cpuAffinity.isEnabled() ) {
+ this.threads = settings.cpuAffinity.size();
+ } else {
+ this.threads = Runtime.getRuntime().availableProcessors();
+ }
+ this.cpuAffinity = settings.cpuAffinity;
+ this.ioAffinity = settings.ioAffinity;
this.workflow = workflow;
this.errorResponse = errorResponse;
@@ -98,8 +103,7 @@ public PnioHttpHandler( PnioHttpSettings settings,
new oap.concurrent.ThreadPoolExecutor.BlockingPolicy() );
for( var i = 0; i < settings.cpuThreads; i++ ) {
- RequestTaskComputeRunner requestTaskComputeRunner = new RequestTaskComputeRunner<>( queue,
- cpuAffinityFirstCpu >= 0 ? cpuAffinityFirstCpu + i : -1 );
+ RequestTaskComputeRunner requestTaskComputeRunner = new RequestTaskComputeRunner<>( queue, cpuAffinity );
pool.submit( requestTaskComputeRunner );
tasks.add( requestTaskComputeRunner );
}
@@ -117,6 +121,18 @@ public long getPoolCompletedTaskCount() {
return pool.getCompletedTaskCount();
}
+ @SneakyThrows
+ public void init( XnioWorker xnioWorker ) {
+ Field workerThreadsField = xnioWorker.getClass().getDeclaredField( "workerThreads" );
+ workerThreadsField.setAccessible( true );
+ Object workerThreads = workerThreadsField.get( xnioWorker );
+ int length = Array.getLength( workerThreads );
+ for( int i = 0; i < length; i++ ) {
+ XnioExecutor xnioExecutor = ( XnioExecutor ) Array.get( workerThreads, i );
+ xnioExecutor.execute( ioAffinity::set );
+ }
+ }
+
public void handleRequest( HttpServerExchange exchange, long startTimeNano, long timeout, WorkflowState workflowState ) {
var requestState = new PnioExchange<>( requestSize, responseSize, workflow, workflowState, exchange, startTimeNano, timeout );
@@ -145,7 +161,7 @@ private void response( PnioExchange pnioExchange, WorkflowState w
errorResponse.handle( pnioExchange, workflowState );
} catch( Throwable e ) {
- if ( e instanceof OutOfMemoryError ) {
+ if( e instanceof OutOfMemoryError ) {
log.error( "OOM error, need restarting!", e );
}
LogConsolidated.log( log, Level.ERROR, Dates.s( 5 ), e.getMessage(), e );
@@ -190,4 +206,15 @@ public void close() {
public interface ErrorResponse {
void handle( PnioExchange pnioExchange, WorkflowState workflowState );
}
+
+ @Builder
+ public static class PnioHttpSettings {
+ int requestSize;
+ int responseSize;
+ double queueTimeoutPercent;
+ int cpuThreads;
+ boolean cpuQueueFair;
+ Affinity cpuAffinity;
+ Affinity ioAffinity;
+ }
}
diff --git a/oap-pnio/src/main/java/oap/http/pnio/RequestTaskComputeRunner.java b/oap-pnio/src/main/java/oap/http/pnio/RequestTaskComputeRunner.java
index 518adaa92c..0d0127717d 100644
--- a/oap-pnio/src/main/java/oap/http/pnio/RequestTaskComputeRunner.java
+++ b/oap-pnio/src/main/java/oap/http/pnio/RequestTaskComputeRunner.java
@@ -10,7 +10,7 @@
package oap.http.pnio;
import lombok.extern.slf4j.Slf4j;
-import net.openhft.affinity.Affinity;
+import oap.highload.Affinity;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;
@@ -20,20 +20,19 @@
@Slf4j
class RequestTaskComputeRunner implements Runnable {
private final BlockingQueue> queue;
- private final int cpu;
+ private final Affinity affinity;
volatile boolean done = false;
private Thread thread;
- RequestTaskComputeRunner( BlockingQueue> queue, int cpu ) {
+ RequestTaskComputeRunner( BlockingQueue> queue, Affinity affinity ) {
this.queue = Objects.requireNonNull( queue );
- this.cpu = cpu;
+ this.affinity = affinity;
}
@Override
public void run() {
this.thread = Thread.currentThread();
- if( cpu >= 0 )
- Affinity.setAffinity( cpu );
+ affinity.set();
Thread.currentThread().setPriority( Thread.MAX_PRIORITY );
while( !done ) {
diff --git a/oap-pnio/src/test/java/oap/http/pnio/PnioHttpHandlerTest.java b/oap-pnio/src/test/java/oap/http/pnio/PnioHttpHandlerTest.java
index 88931bfce8..58b5156bf6 100644
--- a/oap-pnio/src/test/java/oap/http/pnio/PnioHttpHandlerTest.java
+++ b/oap-pnio/src/test/java/oap/http/pnio/PnioHttpHandlerTest.java
@@ -24,12 +24,16 @@
package oap.http.pnio;
+import oap.highload.Affinity;
import oap.http.Http;
+import oap.http.server.nio.HttpHandler;
+import oap.http.server.nio.HttpServerExchange;
import oap.http.server.nio.NioHttpServer;
import oap.testng.EnvFixture;
import oap.testng.Fixtures;
import oap.util.Dates;
import org.testng.annotations.Test;
+import org.xnio.XnioWorker;
import java.io.IOException;
import java.util.function.Consumer;
@@ -168,20 +172,31 @@ private void runWithWorkflow( RequestWorkflow workflow, Consumer workflow, Consumer cons ) throws IOException {
int port = envFixture.portFor( "pnio" );
var settings = PnioHttpHandler.PnioHttpSettings.builder()
- .requestSize( requestSize )
- .responseSize( responseSize )
- .queueTimeoutPercent( 0.99 )
- .cpuThreads( cpuThreads )
- .cpuQueueFair( true )
- .cpuAffinityFirstCpu( -1 )
- .build();
+ .requestSize( requestSize )
+ .responseSize( responseSize )
+ .queueTimeoutPercent( 0.99 )
+ .cpuThreads( cpuThreads )
+ .cpuQueueFair( true )
+ .cpuAffinity( new Affinity( "0" ) )
+ .ioAffinity( new Affinity( "1+" ) )
+ .build();
try( PnioHttpHandler httpHandler = new PnioHttpHandler<>( settings, workflow, this::errorResponse );
NioHttpServer httpServer = new NioHttpServer( new NioHttpServer.DefaultPort( port ) ) ) {
httpServer.ioThreads = ioThreads;
httpServer.start();
httpServer.bind( "/test",
- exchange -> httpHandler.handleRequest( exchange, System.nanoTime(), timeout, new TestState() ) );
+ new HttpHandler() {
+ @Override
+ public void init( XnioWorker xnioWorker ) {
+ httpHandler.init( xnioWorker );
+ }
+
+ @Override
+ public void handleRequest( HttpServerExchange exchange ) throws Exception {
+ httpHandler.handleRequest( exchange, System.nanoTime(), timeout, new TestState() );
+ }
+ } );
cons.accept( port );
}
diff --git a/oap-pnio/src/test/resources/logback-test.xml b/oap-pnio/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..e79410b4e8
--- /dev/null
+++ b/oap-pnio/src/test/resources/logback-test.xml
@@ -0,0 +1,15 @@
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
diff --git a/oap-stdlib/pom.xml b/oap-stdlib/pom.xml
index 59b70d0f06..5f95021bf8 100644
--- a/oap-stdlib/pom.xml
+++ b/oap-stdlib/pom.xml
@@ -371,11 +371,6 @@
undertow-core
${oap.deps.undertow.version}
-
- net.openhft
- affinity
- ${oap.deps.affinity.version}
-
org.openjdk.jol
jol-core
diff --git a/oap-stdlib/src/main/java/oap/http/server/nio/HttpHandler.java b/oap-stdlib/src/main/java/oap/http/server/nio/HttpHandler.java
index c4975043b3..8b78f8484d 100644
--- a/oap-stdlib/src/main/java/oap/http/server/nio/HttpHandler.java
+++ b/oap-stdlib/src/main/java/oap/http/server/nio/HttpHandler.java
@@ -25,6 +25,10 @@
package oap.http.server.nio;
+import org.xnio.XnioWorker;
+
public interface HttpHandler {
+ default void init( XnioWorker xnioWorker ) {}
+
void handleRequest( HttpServerExchange exchange ) throws Exception;
}
diff --git a/oap-stdlib/src/main/java/oap/http/server/nio/NioHttpServer.java b/oap-stdlib/src/main/java/oap/http/server/nio/NioHttpServer.java
index 142d943c64..97d2e3f272 100644
--- a/oap-stdlib/src/main/java/oap/http/server/nio/NioHttpServer.java
+++ b/oap-stdlib/src/main/java/oap/http/server/nio/NioHttpServer.java
@@ -39,6 +39,7 @@
import oap.http.server.nio.handlers.CompressionNioHandler;
import oap.util.Lists;
import org.xnio.Options;
+import org.xnio.XnioWorker;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
@@ -71,11 +72,11 @@ public class NioHttpServer implements Closeable, AutoCloseable {
public final DefaultPort defaultPort;
public final LinkedHashMap defaultPorts = new LinkedHashMap<>();
public final LinkedHashMap additionalHttpPorts = new LinkedHashMap<>();
-
+ public final ArrayList handlers = new ArrayList<>();
private final Map pathHandler = new HashMap<>();
private final Map servers = new HashMap<>();
-
private final AtomicLong requestId = new AtomicLong();
+ private final KeyManager[] keyManagers;
public int backlog = -1;
public long idleTimeout = -1;
public boolean tcpNodelay = true;
@@ -88,10 +89,7 @@ public class NioHttpServer implements Closeable, AutoCloseable {
public boolean statistics = false;
public boolean alwaysSetDate = true;
public boolean alwaysSetKeepAlive = true;
-
- private final KeyManager[] keyManagers;
-
- public final ArrayList handlers = new ArrayList<>();
+ public XnioWorker xnioWorker;
public NioHttpServer( DefaultPort defaultPort ) {
this.defaultPort = defaultPort;
@@ -113,24 +111,54 @@ public NioHttpServer( DefaultPort defaultPort ) {
}
}
- private boolean isHttpsEnabled() {
- return defaultPort.httpsPort > 0;
+ @SneakyThrows
+ private static KeyStore loadKeyStore( URL keyStoreLocation, String storePassword ) {
+ final KeyStore loadedKeystore;
+ final String type = "JKS";
+ try {
+ loadedKeystore = KeyStore.getInstance( type );
+ } catch( KeyStoreException ex ) {
+ log.error( "loadKeyStore KeyStore.getInstance({}) exception: {}", type, ex.toString() );
+ throw ex;
+ }
+ try( InputStream stream = keyStoreLocation.openStream() ) {
+ loadedKeystore.load( stream, storePassword.toCharArray() );
+ return loadedKeystore;
+ } catch( NoSuchAlgorithmException | CertificateException | IOException ex ) {
+ log.error( "loadKeyStore KeyStore.load({}, {}) as {} exception: {}", keyStoreLocation, storePassword.length(), type, ex.toString() );
+ throw ex;
+ }
}
- @ToString( exclude = { "server" } )
- private static class Holder {
- Undertow server;
- int port;
-
- Holder( int port, Undertow server ) {
- this.port = port;
- this.server = server;
- server.start();
+ @SneakyThrows
+ private static KeyManager[] getKeyManagers( KeyStore keyStore, final String storePassword ) {
+ final KeyManagerFactory keyManagerFactory;
+ try {
+ keyManagerFactory = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() );
+ } catch( NoSuchAlgorithmException ex ) {
+ log.error( "getKeyManagers KeyManagerFactory.getInstance exception: {}", ex.toString() );
+ throw ex;
}
-
- public void stop() {
- server.stop();
+ // https://github.com/ops4j/org.ops4j.pax.web/blob/web-5.0.0.M1/pax-web-undertow/src/main/java/org/ops4j/pax/web/undertow/ssl/SslContextFactory.java
+ try {
+ keyManagerFactory.init( keyStore, storePassword.toCharArray() );
+ } catch( NoSuchAlgorithmException | UnrecoverableKeyException | KeyStoreException exc ) {
+ log.error( "getKeyManagers exception initialising keyManagerFactory: {}", exc.toString() );
+ throw exc;
}
+ return keyManagerFactory.getKeyManagers();
+ }
+
+ @SneakyThrows
+ private static KeyManager[] makeKeyManagers( URL keyStoreLocation, final String password ) {
+ KeyStore keyStore = loadKeyStore( keyStoreLocation, password );
+ KeyManager[] managers = getKeyManagers( keyStore, password );
+ log.info( "makeKeyManagers({}, {}) created KeyManagers {}", keyStoreLocation, password.length(), managers );
+ return managers;
+ }
+
+ private boolean isHttpsEnabled() {
+ return defaultPort.httpsPort > 0;
}
public void start() {
@@ -144,7 +172,7 @@ private void startNewPort( int port, PathHandler portPathHandler ) {
log.info( "starting server on port: {} with {} ...", port, portPathHandler );
long time = System.currentTimeMillis();
- Undertow server = servers.computeIfAbsent( port, h -> new Holder( port, createUndertowServer( port, portPathHandler ) ) ).server;
+ Undertow server = servers.computeIfAbsent( port, h -> new Holder( port, createUndertowServerAndStart( port, portPathHandler ) ) ).server;
log.info( "server on port: {} (statistics: {}, ioThreads: {}, workerThreads: {}) has started in {} ms",
port, statistics,
@@ -179,7 +207,7 @@ private void addStats( Undertow server ) {
}
}
- private Undertow createUndertowServer( int port, PathHandler portPathHandler ) {
+ private synchronized Undertow createUndertowServerAndStart( int port, PathHandler portPathHandler ) {
Undertow.Builder builder = Undertow.builder()
.setSocketOption( Options.REUSE_ADDRESSES, true )
.setSocketOption( Options.TCP_NODELAY, tcpNodelay )
@@ -198,6 +226,10 @@ private Undertow createUndertowServer( int port, PathHandler portPathHandler ) {
builder.setServerOption( UndertowOptions.ALWAYS_SET_DATE, alwaysSetDate );
builder.setServerOption( UndertowOptions.ALWAYS_SET_KEEP_ALIVE, alwaysSetKeepAlive );
+ if( xnioWorker != null ) {
+ builder.setWorker( xnioWorker );
+ }
+
io.undertow.server.HttpHandler handler = portPathHandler;
for( int i = handlers.size() - 1; i >= 0; i-- ) {
@@ -221,7 +253,12 @@ private Undertow createUndertowServer( int port, PathHandler portPathHandler ) {
builder.addHttpListener( port, "0.0.0.0", handler );
}
- return builder.build();
+ Undertow undertow = builder.build();
+ undertow.start();
+ if( xnioWorker == null ) {
+ xnioWorker = undertow.getWorker();
+ }
+ return undertow;
}
public void bind( String prefix, HttpHandler handler, boolean compressionSupport, List types ) {
@@ -243,6 +280,8 @@ public void bind( String prefix, HttpHandler handler, boolean compressionSupport
throw new IllegalArgumentException( "Unknown port " + portName );
}
+ handler.init( xnioWorker );
+
int port = defaultPorts.getOrDefault( portName, -1 );
if( port <= 0 ) {
port = additionalHttpPorts.get( portName );
@@ -290,10 +329,29 @@ public void close() throws IOException {
preStop();
}
+ private boolean hasHandler( Class extends NioHandler> handlerClass ) {
+ return Lists.anyMatch( handlers, h -> h.getClass().equals( handlerClass ) );
+ }
+
public enum PortType {
HTTP, HTTPS
}
+ @ToString( exclude = { "server" } )
+ private static class Holder {
+ Undertow server;
+ int port;
+
+ Holder( int port, Undertow server ) {
+ this.port = port;
+ this.server = server;
+ }
+
+ public void stop() {
+ server.stop();
+ }
+ }
+
@ToString
public static class DefaultPort {
public final int httpPort;
@@ -312,54 +370,4 @@ public DefaultPort( int httpPort ) {
this( httpPort, -1, null, null );
}
}
-
- @SneakyThrows
- private static KeyStore loadKeyStore( URL keyStoreLocation, String storePassword ) {
- final KeyStore loadedKeystore;
- final String type = "JKS";
- try {
- loadedKeystore = KeyStore.getInstance( type );
- } catch( KeyStoreException ex ) {
- log.error( "loadKeyStore KeyStore.getInstance({}) exception: {}", type, ex.toString() );
- throw ex;
- }
- try( InputStream stream = keyStoreLocation.openStream() ) {
- loadedKeystore.load( stream, storePassword.toCharArray() );
- return loadedKeystore;
- } catch( NoSuchAlgorithmException | CertificateException | IOException ex ) {
- log.error( "loadKeyStore KeyStore.load({}, {}) as {} exception: {}", keyStoreLocation, storePassword.length(), type, ex.toString() );
- throw ex;
- }
- }
-
- @SneakyThrows
- private static KeyManager[] getKeyManagers( KeyStore keyStore, final String storePassword ) {
- final KeyManagerFactory keyManagerFactory;
- try {
- keyManagerFactory = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() );
- } catch( NoSuchAlgorithmException ex ) {
- log.error( "getKeyManagers KeyManagerFactory.getInstance exception: {}", ex.toString() );
- throw ex;
- }
- // https://github.com/ops4j/org.ops4j.pax.web/blob/web-5.0.0.M1/pax-web-undertow/src/main/java/org/ops4j/pax/web/undertow/ssl/SslContextFactory.java
- try {
- keyManagerFactory.init( keyStore, storePassword.toCharArray() );
- } catch( NoSuchAlgorithmException | UnrecoverableKeyException | KeyStoreException exc ) {
- log.error( "getKeyManagers exception initialising keyManagerFactory: {}", exc.toString() );
- throw exc;
- }
- return keyManagerFactory.getKeyManagers();
- }
-
- @SneakyThrows
- private static KeyManager[] makeKeyManagers( URL keyStoreLocation, final String password ) {
- KeyStore keyStore = loadKeyStore( keyStoreLocation, password );
- KeyManager[] managers = getKeyManagers( keyStore, password );
- log.info( "makeKeyManagers({}, {}) created KeyManagers {}", keyStoreLocation, password.length(), managers );
- return managers;
- }
-
- private boolean hasHandler( Class extends NioHandler> handlerClass ) {
- return Lists.anyMatch( handlers, h -> h.getClass().equals( handlerClass ) );
- }
}
diff --git a/pom.xml b/pom.xml
index 5c63cbafda..8af1cdbc24 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,6 +25,7 @@
oap-hadoop
oap-formats
oap-mail
+ oap-highload
oap-maven-plugin
@@ -49,7 +50,7 @@
- 21.7.0
+ 21.8.0
21.0.0
21.0.1