Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,12 @@ public synchronized NettyEmbeddedServer start() {
}
//suppress unused
//done here to prevent a blocking service loader in the event loop
EventLoopGroupConfiguration workerConfig = resolveWorkerConfiguration();
workerGroup = createWorkerEventLoopGroup(workerConfig);
parentGroup = createParentEventLoopGroup();
EventLoopGroupConfiguration workerConfig = nettyEmbeddedServices.getEventLoopGroupRegistry()
.getEventLoopGroupConfiguration(serverConfiguration.getWorkerLoopName()).orElse(null);
workerGroup = nettyEmbeddedServices.getEventLoopGroupRegistry().getEventLoopGroup(serverConfiguration.getWorkerLoopName())
.orElseThrow(() -> new ConfigurationException("No event loop with name '" + serverConfiguration.getWorkerLoopName() + "' available, but this name was configured as the worker-loop-name"));
parentGroup = nettyEmbeddedServices.getEventLoopGroupRegistry().getEventLoopGroup(serverConfiguration.getParentLoopName())
.orElseThrow(() -> new ConfigurationException("No event loop with name '" + serverConfiguration.getParentLoopName() + "' available, but this name was configured as the parent-loop-name"));
Supplier<ServerBootstrap> serverBootstrap = SupplierUtil.memoized(() -> {
ServerBootstrap sb = createServerBootstrap();
processOptions(serverConfiguration.getOptions(), sb::option);
Expand Down Expand Up @@ -318,21 +321,6 @@ public synchronized NettyEmbeddedServer start() {
return this;
}

private EventLoopGroupConfiguration resolveWorkerConfiguration() {
EventLoopGroupConfiguration workerConfig = serverConfiguration.getWorker();
if (workerConfig == null) {
workerConfig = nettyEmbeddedServices.getEventLoopGroupRegistry()
.getEventLoopGroupConfiguration(EventLoopGroupConfiguration.DEFAULT).orElse(null);
} else {
final String eventLoopGroupName = workerConfig.getName();
if (!EventLoopGroupConfiguration.DEFAULT.equals(eventLoopGroupName)) {
workerConfig = nettyEmbeddedServices.getEventLoopGroupRegistry()
.getEventLoopGroupConfiguration(eventLoopGroupName).orElse(workerConfig);
}
}
return workerConfig;
}

@Override
@NonNull
public synchronized NettyEmbeddedServer stop() {
Expand Down Expand Up @@ -476,21 +464,6 @@ public final Set<Integer> getBoundPorts() {
.collect(Collectors.<Integer, Set<Integer>>toCollection(LinkedHashSet::new)));
}

/**
* @return The parent event loop group
*/
@SuppressWarnings("WeakerAccess")
protected EventLoopGroup createParentEventLoopGroup() {
final NettyHttpServerConfiguration.Parent parent = serverConfiguration.getParent();
return nettyEmbeddedServices.getEventLoopGroupRegistry()
.getEventLoopGroup(parent != null ? parent.getName() : NettyHttpServerConfiguration.Parent.NAME)
.orElseGet(() -> {
final EventLoopGroup newGroup = newEventLoopGroup(parent);
shutdownParent = true;
return newGroup;
});
}

/**
* @param workerConfig The worker configuration
* @return The worker event loop group
Expand Down Expand Up @@ -703,7 +676,8 @@ private void stopInternal(boolean stopServerOnly) {
List<Future<?>> futures = new ArrayList<>(2);
try {
if (shutdownParent) {
EventLoopGroupConfiguration parent = serverConfiguration.getParent();
EventLoopGroupConfiguration parent = nettyEmbeddedServices.getEventLoopGroupRegistry()
.getEventLoopGroupConfiguration(serverConfiguration.getParentLoopName()).orElse(null);
if (parent != null) {
long quietPeriod = parent.getShutdownQuietPeriod().toMillis();
long timeout = parent.getShutdownTimeout().toMillis();
Expand Down Expand Up @@ -960,7 +934,7 @@ protected void initChannel(Channel ch) throws Exception {
}
}

private static class DomainSocketHolder {
private static final class DomainSocketHolder {
@NonNull
private static SocketAddress makeDomainSocketAddress(String path) {
try {
Expand Down
Loading
Loading