Skip to content

Commit

Permalink
Configurable maxPipeline parameter, refactored net config.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Dec 11, 2017
1 parent 405adbf commit 7d8aecd
Show file tree
Hide file tree
Showing 20 changed files with 474 additions and 381 deletions.
Expand Up @@ -79,6 +79,7 @@ net:
# workers: ${system.cpus} # workers: ${system.cpus}
bufSizeKB: 256 bufSizeKB: 256
noDelay: false noDelay: false
maxPipeline: 0
syncBufs: true syncBufs: true
blockingAccept: false blockingAccept: false


Expand Down
@@ -0,0 +1,140 @@
package org.rapidoid.net;

import org.rapidoid.config.BasicConfig;
import org.rapidoid.net.impl.DefaultExchange;
import org.rapidoid.net.impl.RapidoidHelper;

public class NetworkingParams {

private volatile String address;

private volatile int port;

private volatile int workers;

private volatile int bufSizeKB;

private volatile boolean noDelay;

private volatile long maxPipeline;

private volatile boolean syncBufs;

private volatile boolean blockingAccept;

private volatile Protocol protocol = null;

private volatile Class<? extends DefaultExchange<?>> exchangeClass = null;

private volatile Class<? extends RapidoidHelper> helperClass = RapidoidHelper.class;

public NetworkingParams(BasicConfig cfg) {
address = cfg.entry("address").or("0.0.0.0");
port = cfg.entry("port").or(8080);
workers = cfg.entry("workers").or(Runtime.getRuntime().availableProcessors());
bufSizeKB = cfg.entry("bufSizeKB").or(16);
noDelay = cfg.entry("noDelay").or(false);
maxPipeline = cfg.entry("maxPipeline").or(0);
syncBufs = cfg.entry("syncBufs").or(true);
blockingAccept = cfg.entry("blockingAccept").or(false);
}

public String address() {
return address;
}

public NetworkingParams address(String address) {
this.address = address;
return this;
}

public int port() {
return port;
}

public NetworkingParams port(int port) {
this.port = port;
return this;
}

public int workers() {
return workers;
}

public NetworkingParams workers(int workers) {
this.workers = workers;
return this;
}

public int bufSizeKB() {
return bufSizeKB;
}

public NetworkingParams bufSizeKB(int bufSizeKB) {
this.bufSizeKB = bufSizeKB;
return this;
}

public boolean noDelay() {
return noDelay;
}

public NetworkingParams noDelay(boolean noDelay) {
this.noDelay = noDelay;
return this;
}

public long maxPipeline() {
return maxPipeline;
}

public NetworkingParams maxPipeline(long maxPipelineSize) {
this.maxPipeline = maxPipelineSize;
return this;
}

public boolean syncBufs() {
return syncBufs;
}

public NetworkingParams syncBufs(boolean syncBufs) {
this.syncBufs = syncBufs;
return this;
}

public boolean blockingAccept() {
return blockingAccept;
}

public NetworkingParams blockingAccept(boolean blockingAccept) {
this.blockingAccept = blockingAccept;
return this;
}

public Protocol protocol() {
return protocol;
}

public NetworkingParams protocol(Protocol protocol) {
this.protocol = protocol;
return this;
}

public Class<? extends DefaultExchange<?>> exchangeClass() {
return exchangeClass;
}

public NetworkingParams exchangeClass(Class<? extends DefaultExchange<?>> exchangeClass) {
this.exchangeClass = exchangeClass;
return this;
}

public Class<? extends RapidoidHelper> helperClass() {
return helperClass;
}

public NetworkingParams helperClass(Class<? extends RapidoidHelper> helperClass) {
this.helperClass = helperClass;
return this;
}
}

0 comments on commit 7d8aecd

Please sign in to comment.