Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configurable maxPipeline parameter, refactored net config.
- Loading branch information
1 parent
405adbf
commit 7d8aecd
Showing
20 changed files
with
474 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
networking/rapidoid-net/src/main/java/org/rapidoid/net/NetworkingParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
} | |||
} |
Oops, something went wrong.