Skip to content

Commit

Permalink
Merge pull request apache#124 from gnodet/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
ppalaga authored Oct 22, 2020
2 parents 9acf6cd + 755dc6b commit 41088ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand Down Expand Up @@ -143,7 +144,7 @@ private void handleStopEvents(Collection<DaemonInfo> idleDaemons, Collection<Dae
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) {
Expand Down Expand Up @@ -362,7 +363,7 @@ public boolean maybeStaleAddress(Exception failure) {
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -141,7 +140,7 @@ public static Path findLogbackConfigurationPath(Supplier<Properties> mvndPropert
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();
}
Expand Down
4 changes: 4 additions & 0 deletions daemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion daemon/src/main/java/org/jboss/fuse/mvnd/daemon/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -93,7 +94,7 @@ public Server(String uid) throws IOException {
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()
Expand Down

0 comments on commit 41088ab

Please sign in to comment.