mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-26 23:45:47 +00:00
Better display of the message when creating a new daemon
This commit is contained in:
@@ -33,6 +33,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -96,7 +97,7 @@ public class DaemonConnector {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DaemonClientConnection connect(DaemonCompatibilitySpec constraint) {
|
public DaemonClientConnection connect(DaemonCompatibilitySpec constraint, Consumer<String> logger) {
|
||||||
Map<Boolean, List<DaemonInfo>> idleBusy = registry.getAll().stream()
|
Map<Boolean, List<DaemonInfo>> idleBusy = registry.getAll().stream()
|
||||||
.collect(Collectors.groupingBy(di -> di.getState() == DaemonState.Idle));
|
.collect(Collectors.groupingBy(di -> di.getState() == DaemonState.Idle));
|
||||||
|
|
||||||
@@ -116,11 +117,12 @@ public class DaemonConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No compatible daemons available - start a new daemon
|
// No compatible daemons available - start a new daemon
|
||||||
handleStopEvents(idleDaemons, busyDaemons);
|
String message = handleStopEvents(idleDaemons, busyDaemons);
|
||||||
|
logger.accept(message);
|
||||||
return startDaemon(constraint);
|
return startDaemon(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleStopEvents(Collection<DaemonInfo> idleDaemons, Collection<DaemonInfo> busyDaemons) {
|
private String handleStopEvents(Collection<DaemonInfo> idleDaemons, Collection<DaemonInfo> busyDaemons) {
|
||||||
final List<DaemonStopEvent> stopEvents = registry.getStopEvents();
|
final List<DaemonStopEvent> stopEvents = registry.getStopEvents();
|
||||||
|
|
||||||
// Clean up old stop events
|
// Clean up old stop events
|
||||||
@@ -144,7 +146,7 @@ public class DaemonConnector {
|
|||||||
stopEvent.getUid(), stopEvent.getTimestamp(), stopEvent.getReason());
|
stopEvent.getUid(), stopEvent.getTimestamp(), stopEvent.getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(generate(busyDaemons.size(), idleDaemons.size(), recentStopEvents.size()));
|
return generate(busyDaemons.size(), idleDaemons.size(), recentStopEvents.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generate(final int numBusy, final int numIncompatible, final int numStopped) {
|
public static String generate(final int numBusy, final int numIncompatible, final int numStopped) {
|
||||||
|
@@ -184,7 +184,8 @@ public class DefaultClient implements Client {
|
|||||||
|
|
||||||
final DaemonConnector connector = new DaemonConnector(layout, registry, buildProperties, new MessageSerializer());
|
final DaemonConnector connector = new DaemonConnector(layout, registry, buildProperties, new MessageSerializer());
|
||||||
List<String> opts = new ArrayList<>();
|
List<String> opts = new ArrayList<>();
|
||||||
DaemonClientConnection daemon = connector.connect(new DaemonCompatibilitySpec(javaHome, opts));
|
DaemonClientConnection daemon = connector.connect(new DaemonCompatibilitySpec(javaHome, opts),
|
||||||
|
s -> output.accept(null, s));
|
||||||
|
|
||||||
daemon.dispatch(new Message.BuildRequest(
|
daemon.dispatch(new Message.BuildRequest(
|
||||||
args,
|
args,
|
||||||
|
@@ -324,8 +324,6 @@ public class TerminalOutput implements ClientOutput {
|
|||||||
asb.append("... (cores: ").append(String.valueOf(usedCores)).append(")")
|
asb.append("... (cores: ").append(String.valueOf(usedCores)).append(")")
|
||||||
.append(dstr).append(pstr);
|
.append(dstr).append(pstr);
|
||||||
lines.add(asb.toAttributedString());
|
lines.add(asb.toAttributedString());
|
||||||
} else {
|
|
||||||
lines.add(new AttributedString("Building..."));
|
|
||||||
}
|
}
|
||||||
int remLogLines = dispLines - projects.size();
|
int remLogLines = dispLines - projects.size();
|
||||||
for (Project prj : projects.values()) {
|
for (Project prj : projects.values()) {
|
||||||
|
Reference in New Issue
Block a user