Merge pull request #124 from gnodet/improvements

Improvements
This commit is contained in:
Peter Palaga
2020-10-22 14:26:28 +02:00
committed by GitHub
5 changed files with 15 additions and 9 deletions

View File

@@ -17,6 +17,7 @@ package org.jboss.fuse.mvnd.client;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.channels.SocketChannel;
@@ -143,7 +144,7 @@ public class DaemonConnector {
stopEvent.getUid(), stopEvent.getTimestamp(), stopEvent.getReason());
}
LOGGER.debug(generate(busyDaemons.size(), idleDaemons.size(), recentStopEvents.size()));
System.out.println(generate(busyDaemons.size(), idleDaemons.size(), recentStopEvents.size()));
}
public static String generate(final int numBusy, final int numIncompatible, final int numStopped) {
@@ -362,7 +363,7 @@ public class DaemonConnector {
}
public DaemonConnection<Message> connect(int port) throws DaemonException.ConnectException {
InetSocketAddress address = new InetSocketAddress(port);
InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress(), port);
try {
LOGGER.debug("Trying to connect to address {}.", address);
SocketChannel socketChannel = SocketChannel.open();

View File

@@ -142,13 +142,14 @@ public class DefaultClient implements Client {
try (DaemonRegistry registry = new DaemonRegistry(layout.registry())) {
boolean status = args.remove("--status");
if (status) {
output.accept(null, String.format(" %36s %7s %5s %7s %s",
"UUID", "PID", "Port", "Status", "Last activity"));
registry.getAll().forEach(d -> output.accept(null, String.format(" %36s %7s %5s %7s %s",
output.accept(null, String.format(" %36s %7s %5s %7s %23s %s",
"UUID", "PID", "Port", "Status", "Last activity", "Java home"));
registry.getAll().forEach(d -> output.accept(null, String.format(" %36s %7s %5s %7s %23s %s",
d.getUid(), d.getPid(), d.getAddress(), d.getState(),
LocalDateTime.ofInstant(
Instant.ofEpochMilli(Math.max(d.getLastIdle(), d.getLastBusy())),
ZoneId.systemDefault()))));
ZoneId.systemDefault()),
d.getJavaHome())));
return new DefaultResult(argv, null);
}
boolean stop = args.remove("--stop");

View File

@@ -38,7 +38,6 @@ public enum Environment {
MAVEN_REPO_LOCAL("maven.repo.local", null),
MAVEN_MULTIMODULE_PROJECT_DIRECTORY("maven.multiModuleProjectDirectory", null),
MVND_PROPERTIES_PATH("mvnd.properties.path", "MVND_PROPERTIES_PATH"),
MVND_DIST_URI("mvnd.dist.uri", "MVND_DIST_URI"),
DAEMON_DEBUG("daemon.debug", null),
DAEMON_IDLE_TIMEOUT("daemon.idleTimeout", null),
DAEMON_UID("daemon.uid", null);
@@ -141,7 +140,7 @@ public enum Environment {
return LOGBACK_CONFIGURATION_FILE
.systemProperty()
.orLocalProperty(mvndProperties, mvndPropertiesPath)
.orDefault(() -> mvndHome.resolve("conf/logging/logback.xml").toString())
.orDefault(() -> mvndHome.resolve("mvn/conf/logging/logback.xml").toString())
.orFail()
.asPath();
}

View File

@@ -41,6 +41,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.fuse.mvnd</groupId>
<artifactId>mvnd-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>

View File

@@ -18,6 +18,7 @@ package org.jboss.fuse.mvnd.daemon;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
@@ -93,7 +94,7 @@ public class Server implements AutoCloseable, Runnable {
cli = new DaemonMavenCli();
registry = new DaemonRegistry(layout.registry());
socket = ServerSocketChannel.open().bind(new InetSocketAddress(0));
socket = ServerSocketChannel.open().bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
final int idleTimeout = Environment.DAEMON_IDLE_TIMEOUT
.systemProperty()