Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

package oap.http.pniov3;

import com.google.common.base.Preconditions;
import io.undertow.io.Receiver;
import io.undertow.util.SameThreadExecutor;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import oap.http.server.nio.HttpServerExchange;

Expand All @@ -21,35 +19,26 @@
@Slf4j
public class PnioHttpHandler<RequestState> implements PnioHttpHandlerReference {
public final String uniqueName;

public final int requestSize;
public final int responseSize;
public final int ioQueueSize;
public final boolean important;
public final PnioListener<RequestState> pnioListener;
public final ConcurrentHashMap<Long, PnioExchange<RequestState>> exchanges = new ConcurrentHashMap<>();
private final PnioController pnioController;
private final PnioMetrics metrics;
public int requestSize = 64 * 1024;
public int responseSize = 32 * 1024;
public boolean important = false;
public ComputeTask<RequestState> task;

public PnioHttpHandler( String uniqueName,
PnioHttpSettings settings,
ComputeTask<RequestState> task,
PnioListener<RequestState> pnioListener,
PnioController pnioController ) {
this.uniqueName = uniqueName;
this.requestSize = settings.requestSize;
this.responseSize = settings.responseSize;
this.ioQueueSize = settings.ioQueueSize;
this.important = settings.important;

this.task = task;
this.pnioListener = pnioListener;
this.pnioController = pnioController;

this.metrics = new PnioMetrics( uniqueName );

Preconditions.checkArgument( settings.responseSize > 0, "responseSize must be greater than 0" );
}

public void handleRequest( HttpServerExchange oapExchange, long timeout, RequestState requestState ) {
Expand Down Expand Up @@ -108,12 +97,4 @@ public void handleRequest( HttpServerExchange oapExchange, long timeout, Request
public PnioHttpHandler<?> getPnioHttpHandler() {
return this;
}

@Builder
public static class PnioHttpSettings {
int requestSize;
int responseSize;
int ioQueueSize;
boolean important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ public void test() throws IOException {
int port = 12345;


PnioHttpHandler.PnioHttpSettings settings = PnioHttpHandler.PnioHttpSettings.builder()
.requestSize( 64000 )
.responseSize( 64000 )
.build();
try( PnioController pnioController = new PnioController( 10, 10000 );
NioHttpServer httpServer = new NioHttpServer( new NioHttpServer.DefaultPort( port ) ) ) {
httpServer.ioThreads = 2;
httpServer.statistics = true;
httpServer.start();

PnioHttpHandler<TestState> httpHandler = new PnioHttpHandler<>( "perf", settings, new TestHandler(), new PnioHttpHandlerTest.TestPnioListener(), pnioController );
PnioHttpHandler<TestState> httpHandler = new PnioHttpHandler<>( "perf", new TestHandler(), new PnioHttpHandlerTest.TestPnioListener(), pnioController );

Scheduler.scheduleWithFixedDelay( 10, TimeUnit.SECONDS, () -> {
System.out.println();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,14 @@ private void runWithWorkflow( int requestSize, int responseSize, int ioThreads,
int maxThreads, long timeout, ComputeTask<TestState> task, Consumer<Integer> cons ) throws IOException {
int port = Ports.getFreePort( getClass() );

PnioHttpHandler.PnioHttpSettings settings = PnioHttpHandler.PnioHttpSettings.builder()
.requestSize( requestSize )
.responseSize( responseSize )
.build();
try( NioHttpServer httpServer = new NioHttpServer( new NioHttpServer.DefaultPort( port ) ) ) {
httpServer.ioThreads = ioThreads;
httpServer.start();

try( PnioController pnioController = new PnioController( ioThreads, maxThreads ) ) {
PnioHttpHandler<TestState> httpHandler = new PnioHttpHandler<>( "test", settings, task, new TestPnioListener(), pnioController );
PnioHttpHandler<TestState> httpHandler = new PnioHttpHandler<>( "test", task, new TestPnioListener(), pnioController );
httpHandler.requestSize = requestSize;
httpHandler.responseSize = responseSize;
httpServer.bind( "/test",
exchange -> httpHandler.handleRequest( exchange, timeout, new TestState() ), false );

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</distributionManagement>

<properties>
<oap.project.version>25.4.8</oap.project.version>
<oap.project.version>25.4.9</oap.project.version>

<oap.deps.config.version>25.0.1</oap.deps.config.version>
<oap.deps.oap-teamcity.version>25.0.0</oap.deps.oap-teamcity.version>
Expand Down
Loading