Skip to content

Update maxOpenConnections tests and update Netty implementation #31225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
6 changes: 2 additions & 4 deletions dev/io.openliberty.netty.internal.impl/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
# http://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# IBM Corporation - initial API and implementation
#*******************************************************************************

-include= ~../cnf/resources/bnd/bundle.props
Expand All @@ -34,7 +31,8 @@ Import-Package: \
# reuse the existing translated messages from the TCP Channel
Private-Package: \
com.ibm.ws.tcpchannel.internal.resources, \
com.ibm.ws.udpchannel.internal.resources
com.ibm.ws.udpchannel.internal.resources, \
com.ibm.ws.channelfw.internal.resources

-dsannotations: \
io.openliberty.netty.internal.impl.NettyFrameworkImpl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 IBM Corporation and others.
* Copyright (c) 2021, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -13,6 +13,7 @@ public interface NettyConstants {

/** RAS trace bundle for NLS */
String BASE_BUNDLE = "io.openliberty.netty.internal.impl.resources.NettyFrameworkMessages";
String CF_BUNDLE = "com.ibm.ws.channelfw.internal.resources.ChannelfwMessages";
/** RAS trace group name */
String NETTY_TRACE_NAME = "Netty";
/** default trace string */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 IBM Corporation and others.
* Copyright (c) 2021, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -53,13 +53,17 @@
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GlobalEventExecutor;
import io.openliberty.netty.internal.BootstrapConfiguration;
import io.openliberty.netty.internal.BootstrapExtended;
import io.openliberty.netty.internal.ConfigConstants;
import io.openliberty.netty.internal.NettyFramework;
import io.openliberty.netty.internal.ServerBootstrapExtended;
import io.openliberty.netty.internal.exception.NettyException;
import io.openliberty.netty.internal.tcp.TCPConfigConstants;
import io.openliberty.netty.internal.tcp.TCPConfigurationImpl;
import io.openliberty.netty.internal.tcp.TCPUtils;
import io.openliberty.netty.internal.udp.UDPUtils;

import com.ibm.websphere.channelfw.EndPointMgr;

/**
Expand All @@ -70,7 +74,7 @@
public class NettyFrameworkImpl implements ServerQuiesceListener, NettyFramework {

private static final TraceComponent tc = Tr.register(NettyFrameworkImpl.class, NettyConstants.NETTY_TRACE_NAME,
NettyConstants.BASE_BUNDLE);
NettyConstants.CF_BUNDLE);

/** Reference to the executor service -- required */
private ExecutorService executorService = null;
Expand Down Expand Up @@ -408,9 +412,16 @@ protected synchronized void unsetServerStarted(ServiceReference<ServerStarted> r
serverCompletelyStarted.set(false);
}

@FFDCIgnore({NettyException.class})
@Override
public ServerBootstrapExtended createTCPBootstrap(Map<String, Object> tcpOptions) throws NettyException {
return TCPUtils.createTCPBootstrap(this, tcpOptions);
try{
return TCPUtils.createTCPBootstrap(this, tcpOptions);
} catch (NettyException e){
Tr.error(tc, "chain.initialization.error", new Object[] { tcpOptions.get(ConfigConstants.EXTERNAL_NAME), e.toString() });
throw e;
}

}

@Override
Expand All @@ -429,9 +440,22 @@ public BootstrapExtended createUDPBootstrapOutbound(Map<String, Object> options)
}

@Override
@FFDCIgnore({ NettyException.class })
public FutureTask<ChannelFuture> start(ServerBootstrapExtended bootstrap, String inetHost, int inetPort,
ChannelFutureListener bindListener) throws NettyException {
return TCPUtils.start(this, bootstrap, inetHost, inetPort, bindListener);

BootstrapConfiguration config = bootstrap.getConfiguration();
String externalName = "NOT_DEFINED";
if(config!= null && config instanceof TCPConfigurationImpl){
externalName = ((TCPConfigurationImpl)config).getExternalName();
}

try{
return TCPUtils.start(this, bootstrap, inetHost, inetPort, bindListener);
}catch(NettyException e){
Tr.error(tc, "chain.initialization.error", new Object[] { externalName, e.toString() });
throw e;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corporation and others.
* Copyright (c) 2021, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -14,6 +14,7 @@
import com.ibm.websphere.ras.Tr;
import com.ibm.websphere.ras.TraceComponent;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
Expand Down Expand Up @@ -47,6 +48,15 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception {
long currentTime = System.currentTimeMillis();
if (currentTime > (lastConnExceededTime + 600000L)) {
String channelName = ctx.channel().attr(ConfigConstants.NAME_KEY).get();

// If the channelName is null check the parent for a name.
if (channelName == null) {
Channel parentChannel = ctx.channel().parent();
if (parentChannel != null) {
channelName = parentChannel.attr(ConfigConstants.NAME_KEY).get();
}
}

Tr.warning(tc, TCPMessageConstants.MAX_CONNS_EXCEEDED, channelName, maxConnections);
lastConnExceededTime = currentTime;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 IBM Corporation and others.
* Copyright (c) 2021, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -34,13 +34,13 @@ public class TCPChannelInitializerImpl extends ChannelInitializerWrapper {
TCPMessageConstants.TCP_BUNDLE, TCPChannelInitializerImpl.class.getName());

TCPConfigurationImpl config;

NettyFrameworkImpl bundle;
MaxOpenConnectionsHandler maxHandler;

public TCPChannelInitializerImpl(BootstrapConfiguration config, NettyFrameworkImpl bundle) {
this.bundle = bundle;
this.config = (TCPConfigurationImpl) config;
maxHandler = new MaxOpenConnectionsHandler(this.config.getMaxOpenConnections());
}

@Override
Expand All @@ -59,7 +59,6 @@ protected void initChannel(Channel channel) throws Exception {
if (config.getInactivityTimeout() > 0) {
channel.pipeline().addLast(NettyConstants.INACTIVITY_TIMEOUT_HANDLER_NAME, new InactivityTimeoutHandler(0, 0, config.getInactivityTimeout(), TimeUnit.MILLISECONDS));
}
MaxOpenConnectionsHandler maxHandler = new MaxOpenConnectionsHandler(config.getMaxOpenConnections());
if (config.getAccessLists() != null) {
AccessListHandler includeHandler = new AccessListHandler(config.getAccessLists());
channel.pipeline().addLast(NettyConstants.ACCESSLIST_HANDLER_NAME, includeHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public TCPConfigurationImpl(Map<String, Object> options, boolean inbound) throws
this.channelProperties = options;

if (this.channelProperties != null) {
// Set the name of the channel before setting the values of the other properties. This ensures it is available
// if a validation error occurs.
this.externalName = (String) this.channelProperties.get(ConfigConstants.EXTERNAL_NAME);

// read in values now, to save time reading them in each time
// they are requested
setValues();
Expand Down Expand Up @@ -162,7 +166,10 @@ public AddressAndHostNameAccessLists getAccessLists() {

//@formatter:off
private boolean skipKey(String key) {
return key.equals("id") ||
// We set externalName in the constructor. If we don't skip it while processing the rest of the properties the below error occurs:
// CWWKO0212W: TCP Channel defaultHttpEndpoint has been constructed with an incorrect configuration property. Property Name: ExternalName Value: defaultHttpEndpoint
return key.equals(ConfigConstants.EXTERNAL_NAME) ||
key.equals("id") ||
key.equals("type") ||
key.startsWith("service.") ||
key.startsWith("component.") ||
Expand Down Expand Up @@ -201,13 +208,7 @@ private void setValues() throws NettyException {
value = entry.getValue();

if (skipKey(key)) {
// skip osgi standard properties
continue;
}

// add the name for the channel
if (key.equalsIgnoreCase(ConfigConstants.EXTERNAL_NAME)) {
this.externalName = (String) value;
// skip osgi standard properties and ExternalName
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@RunWith(Suite.class)
@SuiteClasses({
AccessListsTests.class,
MaxOpenConnectionsTest.class,
MaxOpenConnectionsTests.class,
PortOpenRetriesTests.class,
SoLingerTests.class,
SoReuseAddrTests.class,
Expand Down

This file was deleted.

Loading