From 125b8a2ae3d1fb54152c8621db5d0b0117307f07 Mon Sep 17 00:00:00 2001 From: Chuck Bridgham Date: Fri, 14 Jun 2019 14:50:43 -0400 Subject: [PATCH] Revert "Issue #6379: Ulimit boost change" --- .../publish/bin/server | 20 -- dev/com.ibm.ws.kernel.boot_fat/bnd.bnd | 3 +- .../src/com/ibm/ws/kernel/boot/FATSuite.java | 3 +- .../com/ibm/ws/kernel/boot/UlimitTest.java | 184 ------------------ .../bootstrap.properties | 11 -- .../server.xml | 19 -- .../boot/ulimit/fat/uLimitAppServlet.java | 45 ----- 7 files changed, 2 insertions(+), 283 deletions(-) delete mode 100644 dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/UlimitTest.java delete mode 100644 dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/bootstrap.properties delete mode 100644 dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/server.xml delete mode 100644 dev/com.ibm.ws.kernel.boot_fat/test-applications/ulimitApp/src/com/ibm/ws/kernel/boot/ulimit/fat/uLimitAppServlet.java diff --git a/dev/com.ibm.ws.kernel.boot.ws-server/publish/bin/server b/dev/com.ibm.ws.kernel.boot.ws-server/publish/bin/server index a8a406306803..b307b1fa748c 100644 --- a/dev/com.ibm.ws.kernel.boot.ws-server/publish/bin/server +++ b/dev/com.ibm.ws.kernel.boot.ws-server/publish/bin/server @@ -64,10 +64,6 @@ # WLP_ZOS_JOBNAME - The job name to use when starting the server in # a z/OS environment. # -# WLP_FILE_SOFT_LIMIT - The soft limit of the number of file descriptors / open -# files allowed. The default value is 4096. -# -# ############################################################################### SERVER_UNKNOWN_STATUS=5 @@ -121,7 +117,6 @@ esac ## PS_P='ps -p' UMASK_O='umask o=' -ULIMIT_N='ulimit -n' tryShellExtensions=true os400lib=false shareclassesCacheDirPerm=true @@ -778,17 +773,6 @@ serverUmask() fi } -## call the ulimit -n value to set the specified number of open -## files or set the default to 4096. -setUlimit() -{ - if [ -z "${WLP_FILE_SOFT_LIMIT}" ]; then - $ULIMIT_N 4096 2> /dev/null - else - $ULIMIT_N "${WLP_FILE_SOFT_LIMIT}" 2> /dev/null - fi -} - ## ## javaCmd: Execute a java-based command. Arguments are: ## @@ -1084,8 +1068,6 @@ case "$ACTION" in JAVA_DEBUG="-Dwas.debug.mode=true -Dcom.ibm.websphere.ras.inject.at.transform=true -Dsun.reflect.noInflation=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=${WLP_DEBUG_SUSPEND},address=${WLP_DEBUG_ADDRESS}" fi - setUlimit - serverWorkingDirectory # WLP_JAR_CYGWIN is used only in support of java -jar startup of a Liberty server. @@ -1154,8 +1136,6 @@ case "$ACTION" in touchIfNotExist "${SERVER_OUTPUT_DIR}/workarea/.sLock" rmIfExist "${SERVER_OUTPUT_DIR}/workarea/.sCommand" - setUlimit - # Start the target server with the provided arguments serverCmd "${X_LOG_DIR}/${X_LOG_FILE}" "$@" rc=$? diff --git a/dev/com.ibm.ws.kernel.boot_fat/bnd.bnd b/dev/com.ibm.ws.kernel.boot_fat/bnd.bnd index 2c232a5a258d..9ff565b4e642 100644 --- a/dev/com.ibm.ws.kernel.boot_fat/bnd.bnd +++ b/dev/com.ibm.ws.kernel.boot_fat/bnd.bnd @@ -14,8 +14,7 @@ bVersion=1.0 src: \ fat/src,\ test-applications/checkJvmAppClasspath/src,\ - test-applications/shutdownfat/src, \ - test-applications/ulimitApp/src + test-applications/shutdownfat/src fat.project: true diff --git a/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/FATSuite.java b/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/FATSuite.java index 011c8275fcc0..7c0541a702f1 100644 --- a/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/FATSuite.java +++ b/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/FATSuite.java @@ -57,7 +57,6 @@ ServerStartJVMOptionsTest.class, PauseResumeCommandTest.class, EmbeddedServerMergeProductExtensionTest.class, - ServerEndpointControlMBeanTest.class, - UlimitTest.class + ServerEndpointControlMBeanTest.class }) public class FATSuite {} diff --git a/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/UlimitTest.java b/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/UlimitTest.java deleted file mode 100644 index 203fcbd389fb..000000000000 --- a/dev/com.ibm.ws.kernel.boot_fat/fat/src/com/ibm/ws/kernel/boot/UlimitTest.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package com.ibm.ws.kernel.boot; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.Properties; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.ibm.websphere.simplicity.OperatingSystem; -import com.ibm.websphere.simplicity.ProgramOutput; -import com.ibm.websphere.simplicity.ShrinkHelper; -import com.ibm.websphere.simplicity.log.Log; - -import componenttest.topology.impl.LibertyServer; -import componenttest.topology.impl.LibertyServerFactory; - -/** - * - */ -public class UlimitTest { - - private static final Class c = UlimitTest.class; - - private final String DEFAULT_ULIMIT = "4096"; - private final String NON_DEFAULT_ULIMIT = "1234"; - private final String WLP_FILE_SOFT_LIMIT = "WLP_FILE_SOFT_LIMIT"; - private final String SERVER_NAME = "com.ibm.ws.kernel.boot.ulimit.fat"; - - //@Rule - //public final TestName testName = new TestName(); - - LibertyServer server; - - @Before - public void before() throws Exception { - server = LibertyServerFactory.getLibertyServer(SERVER_NAME); - ShrinkHelper.defaultApp(server, "ulimitApp", "com.ibm.ws.kernel.boot.ulimit.fat"); - } - - @After - public void after() throws Exception { - if (server.isStarted()) - server.stopServer(); - } - - private String runTest(String exitMethodName) throws Exception { - final String m = exitMethodName; - StringBuffer output = new StringBuffer(); - Log.entering(c, m); - - try { - - URL url = new URL("http://" + server.getHostname() + ":" + server.getHttpDefaultPort() + "/ulimitApp?exit=" + exitMethodName); - try { - HttpURLConnection con = (HttpURLConnection) url.openConnection(); - Log.info(c, m, "HTTP response: " + con.getResponseCode()); - - InputStream in = con.getInputStream(); - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - - for (String line; (line = reader.readLine()) != null;) { - Log.info(c, m, "Output: " + line); - output.append(line); - } - } finally { - try { - in.close(); - } catch (IOException e) { - Log.error(c, m, e); - } - } - } catch (Throwable t) { - // The server might die before the response can be written. - StringWriter sw = new StringWriter(); - t.printStackTrace(new PrintWriter(sw)); - Log.info(UlimitTest.class, "UlimitTest", "Ignoring " + sw.toString()); - } - - return output.toString(); - } finally { - Log.exiting(c, m); - } - } - - public void startServerWithEnvVar(String runType, String ulimit) throws Exception { - String METHOD_NAME = "startServerWithEnvVar"; - - Log.entering(c, METHOD_NAME, "entering startServerWithEnvVar"); - - // ulimit only valid for Unix based systems... - OperatingSystem oS = server.getMachine().getOperatingSystem(); - if (oS != OperatingSystem.WINDOWS) { - - String executionDir = server.getInstallRoot(); - String command = "bin" + File.separator + "server"; - - String[] parms = new String[2]; - parms[0] = runType; - parms[1] = SERVER_NAME; - - Properties envVars = new Properties(); - if (ulimit != null) { - envVars.put(WLP_FILE_SOFT_LIMIT, ulimit); - } - - ProgramOutput po = server.getMachine().execute(command, parms, executionDir, envVars); - Log.info(c, METHOD_NAME, "server start stdout = " + po.getStdout()); - Log.info(c, METHOD_NAME, "server start stderr = " + po.getStderr()); - server.waitForStringInLog("CWWKF0011I"); - } else { - assumeTrue(false); - Log.info(c, METHOD_NAME, "Skipping test. Non-Unix platform."); - } - - Log.exiting(c, METHOD_NAME, "exiting startServerWithEnvVar"); - - } - - @Test - public void testEnvVarUlimitServerSTART() throws Exception { - final String METHOD_NAME = "testEnvVarUlimitServerSTART"; - Log.entering(c, METHOD_NAME); - - // Set ulimit to '1234' via env variable - startServerWithEnvVar("start", "1234"); - - String s = runTest(METHOD_NAME); - assertTrue("The output should contain a value of " + NON_DEFAULT_ULIMIT + " but contains = " + s, - s.contains(NON_DEFAULT_ULIMIT)); - - // because we didn't start the server using the LibertyServer APIs, we need to have it detect - // its started state so it will stop and save logs properly - server.resetStarted(); - server.stopServer(); - - Log.exiting(c, METHOD_NAME); - } - - @Test - public void testUlimitDefaultServerSTART() throws Exception { - - String METHOD_NAME = "testUlimitDefaultServerSTART"; - - Log.entering(c, METHOD_NAME); - - startServerWithEnvVar("start", null); - - String s = runTest(METHOD_NAME); - - assertTrue("The output should contain a value of " + DEFAULT_ULIMIT + " but contains = " + s, - s.contains(DEFAULT_ULIMIT)); - - // because we didn't start the server using the LibertyServer APIs, we need to have it detect - // its started state so it will stop and save logs properly - server.resetStarted(); - server.stopServer(); - - Log.exiting(c, METHOD_NAME); - } - -} diff --git a/dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/bootstrap.properties b/dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/bootstrap.properties deleted file mode 100644 index 66ee7f2418db..000000000000 --- a/dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/bootstrap.properties +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# Copyright (c) 2017 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -bootstrap.include=../testports.properties \ No newline at end of file diff --git a/dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/server.xml b/dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/server.xml deleted file mode 100644 index 5128977d690d..000000000000 --- a/dev/com.ibm.ws.kernel.boot_fat/publish/servers/com.ibm.ws.kernel.boot.ulimit.fat/server.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - servlet-3.1 - - - - \ No newline at end of file diff --git a/dev/com.ibm.ws.kernel.boot_fat/test-applications/ulimitApp/src/com/ibm/ws/kernel/boot/ulimit/fat/uLimitAppServlet.java b/dev/com.ibm.ws.kernel.boot_fat/test-applications/ulimitApp/src/com/ibm/ws/kernel/boot/ulimit/fat/uLimitAppServlet.java deleted file mode 100644 index 521dbe2aa074..000000000000 --- a/dev/com.ibm.ws.kernel.boot_fat/test-applications/ulimitApp/src/com/ibm/ws/kernel/boot/ulimit/fat/uLimitAppServlet.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package com.ibm.ws.kernel.boot.ulimit.fat; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@WebServlet("/*") -@SuppressWarnings("serial") -public class uLimitAppServlet extends HttpServlet { - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - final String input = request.getParameter("exit"); - StringBuffer sb = new StringBuffer(); - - try { - Process p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "ulimit -n" }); - BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); - String line = null; - - while ((line = in.readLine()) != null) { - sb.append("ulimit data = " + line); - } - - } catch (Exception e) { - e.printStackTrace(); - } - response.getOutputStream().println(sb.toString()); - } -}