mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-18 17:37:53 +00:00
Do not pass the maxKeepAlive as a parameter
This commit is contained in:
@@ -49,7 +49,6 @@ public class DaemonClientConnection implements Closeable {
|
|||||||
private final boolean newDaemon;
|
private final boolean newDaemon;
|
||||||
private boolean hasReceived;
|
private boolean hasReceived;
|
||||||
private final Lock dispatchLock = new ReentrantLock();
|
private final Lock dispatchLock = new ReentrantLock();
|
||||||
private final int maxKeepAliveMs;
|
|
||||||
private final BlockingQueue<Message> queue = new ArrayBlockingQueue<>(16);
|
private final BlockingQueue<Message> queue = new ArrayBlockingQueue<>(16);
|
||||||
private final Thread receiver;
|
private final Thread receiver;
|
||||||
private final AtomicBoolean running = new AtomicBoolean(true);
|
private final AtomicBoolean running = new AtomicBoolean(true);
|
||||||
@@ -57,12 +56,11 @@ public class DaemonClientConnection implements Closeable {
|
|||||||
private final DaemonParameters parameters;
|
private final DaemonParameters parameters;
|
||||||
|
|
||||||
public DaemonClientConnection(DaemonConnection connection, DaemonInfo daemon,
|
public DaemonClientConnection(DaemonConnection connection, DaemonInfo daemon,
|
||||||
StaleAddressDetector staleAddressDetector, boolean newDaemon, int maxKeepAliveMs, DaemonParameters parameters) {
|
StaleAddressDetector staleAddressDetector, boolean newDaemon, DaemonParameters parameters) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.daemon = daemon;
|
this.daemon = daemon;
|
||||||
this.staleAddressDetector = staleAddressDetector;
|
this.staleAddressDetector = staleAddressDetector;
|
||||||
this.newDaemon = newDaemon;
|
this.newDaemon = newDaemon;
|
||||||
this.maxKeepAliveMs = maxKeepAliveMs;
|
|
||||||
this.receiver = new Thread(this::doReceive);
|
this.receiver = new Thread(this::doReceive);
|
||||||
this.receiver.start();
|
this.receiver.start();
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
@@ -96,6 +94,7 @@ public class DaemonClientConnection implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Message> receive() throws ConnectException, StaleAddressException {
|
public List<Message> receive() throws ConnectException, StaleAddressException {
|
||||||
|
int maxKeepAliveMs = parameters.keepAliveMs() * parameters.maxLostKeepAlive();
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
final Message m = queue.poll(maxKeepAliveMs, TimeUnit.MILLISECONDS);
|
final Message m = queue.poll(maxKeepAliveMs, TimeUnit.MILLISECONDS);
|
||||||
|
@@ -326,9 +326,8 @@ public class DaemonConnector {
|
|||||||
throws DaemonException.ConnectException {
|
throws DaemonException.ConnectException {
|
||||||
LOGGER.debug("Connecting to Daemon");
|
LOGGER.debug("Connecting to Daemon");
|
||||||
try {
|
try {
|
||||||
int maxKeepAliveMs = parameters.keepAliveMs() * parameters.maxLostKeepAlive();
|
|
||||||
DaemonConnection connection = connect(daemon.getAddress());
|
DaemonConnection connection = connect(daemon.getAddress());
|
||||||
return new DaemonClientConnection(connection, daemon, staleAddressDetector, newDaemon, maxKeepAliveMs, parameters);
|
return new DaemonClientConnection(connection, daemon, staleAddressDetector, newDaemon, parameters);
|
||||||
} catch (DaemonException.ConnectException e) {
|
} catch (DaemonException.ConnectException e) {
|
||||||
staleAddressDetector.maybeStaleAddress(e);
|
staleAddressDetector.maybeStaleAddress(e);
|
||||||
throw e;
|
throw e;
|
||||||
|
Reference in New Issue
Block a user