Skip to content

Commit

Permalink
Revert "Added logic to configure the Grizzly NPN Jar version."
Browse files Browse the repository at this point in the history
  • Loading branch information
MattGill98 committed Nov 14, 2018
1 parent 8c46ef7 commit ae3e828
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 123 deletions.
8 changes: 1 addition & 7 deletions nucleus/admin/launcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
only if the new code is made subject to such option by the copyright
holder.
Portions Copyright [2018] [Payara Foundation and/or its affiliates]
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Expand Down Expand Up @@ -73,12 +72,7 @@
<groupId>org.glassfish.main.common</groupId>
<artifactId>common-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.main.core</groupId>
<artifactId>glassfish</artifactId>
<version>${project.version}</version>
</dependency>
</dependency>
<dependency>
<groupId>org.glassfish.main.core</groupId>
<artifactId>logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,52 +36,31 @@
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
* Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates]
*/
// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.admin.launcher;

import static com.sun.enterprise.admin.launcher.GFLauncherConstants.DEFAULT_LOGFILE;
import static com.sun.enterprise.admin.launcher.GFLauncherConstants.FLASHLIGHT_AGENT_NAME;
import static com.sun.enterprise.admin.launcher.GFLauncherConstants.LIBMON_NAME;
import static com.sun.enterprise.admin.launcher.GFLauncherConstants.NEWLINE;
import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY;
import static com.sun.enterprise.util.SystemPropertyConstants.INSTANCE_ROOT_PROPERTY;
import static com.sun.enterprise.util.SystemPropertyConstants.JAVA_ROOT_PROPERTY;
import static fish.payara.admin.launcher.PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY;
import static fish.payara.admin.launcher.PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE;
import static fish.payara.admin.launcher.PayaraDefaultJvmOptions.GRIZZLY_NPN_JAR_LOCATION;

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;

import com.sun.enterprise.universal.collections.CollectionUtils;
import com.sun.enterprise.universal.glassfish.ASenvPropertyReader;
import com.sun.enterprise.universal.glassfish.GFLauncherUtils;
import com.sun.enterprise.universal.glassfish.TokenResolver;
import com.sun.enterprise.universal.i18n.LocalStringsImpl;
import com.sun.enterprise.universal.io.SmartFile;
import com.sun.enterprise.universal.process.ProcessStreamDrainer;
import com.sun.enterprise.universal.xml.MiniXmlParser;
import com.sun.enterprise.universal.xml.MiniXmlParserException;
import com.sun.enterprise.util.JDK;
import com.sun.enterprise.util.OS;
import com.sun.enterprise.util.SystemPropertyConstants;
import com.sun.enterprise.util.io.FileUtils;
import com.sun.enterprise.universal.glassfish.ASenvPropertyReader;
import com.sun.enterprise.universal.xml.MiniXmlParser;
import static com.sun.enterprise.util.SystemPropertyConstants.*;
import static com.sun.enterprise.admin.launcher.GFLauncherConstants.*;
import com.sun.enterprise.util.JDK;
import fish.payara.admin.launcher.PayaraDefaultJvmOptions;
import java.util.stream.Collectors;

/**
* This is the main Launcher class designed for external and internal usage.
Expand Down Expand Up @@ -907,21 +886,14 @@ private void setupProfilerAndJvmOptions(MiniXmlParser parser) throws MiniXmlPars
}

private void addDefaultJvmOptions() {
if (!jvmOptions.getCombinedMap().containsKey(GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY)) {
jvmOptions.sysProps.put(GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY,
GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE);
if (!jvmOptions.getCombinedMap().containsKey(PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY)) {
jvmOptions.sysProps.put(PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY,
PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE);

// Log that we've made the change
GFLauncherLogger.fine(GFLauncherLogger.DEFAULT_JVM_OPTION,
GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY,
GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE);
}

// Attempt to load the Grizzly NPN jar if it's needed
if (GRIZZLY_NPN_JAR_LOCATION != null && !jvmOptions.getCombinedMap().containsKey(GRIZZLY_NPN_JAR_LOCATION)) {
jvmOptions.xProps.put(GRIZZLY_NPN_JAR_LOCATION, null);

GFLauncherLogger.fine(GFLauncherLogger.DEFAULT_JVM_OPTION, GRIZZLY_NPN_JAR_LOCATION, null);
PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY,
PayaraDefaultJvmOptions.GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2016-2018] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2016-2017] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -39,77 +39,11 @@
*/
package fish.payara.admin.launcher;

import com.sun.enterprise.glassfish.bootstrap.MainHelper;

/**
*
* @author Andrew Pielage
*/
public class PayaraDefaultJvmOptions {

public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY = "org.glassfish.grizzly.DEFAULT_MEMORY_MANAGER";
public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE = "org.glassfish.grizzly.memory.HeapMemoryManager";

private static String LATEST_NPN_JAR_VERSION = "1.8.1";
private static String GRIZZLY_NPN_JAR_LOCATION_BASE = "bootclasspath/p:${com.sun.aas.installRoot}/lib/grizzly-npn-bootstrap";
/**
* The location of the NPN Jar to load to the boot classpath. If null, none is
* required.
*/
public static final String GRIZZLY_NPN_JAR_LOCATION;

// Configure the Grizzly NPN Jar version, and from that find the location.
static {
String npnVersion = null;
String jarLocation = null;

try {
// For Java 8, configure the ALPN jar. Other versions of Java don't require this
if (MainHelper.getMajorJdkVersion() == 1 && MainHelper.getMinorJdkVersion() == 8) {
npnVersion = getNpnVersionFromJavaVersion();
jarLocation = GRIZZLY_NPN_JAR_LOCATION_BASE
+ ((npnVersion == null) ? "" : "-" + npnVersion)
+ ".jar";
}
} catch (Throwable t) {
// Any exceptions will also cause the NPN jar to be set to null
jarLocation = null;
} finally {
GRIZZLY_NPN_JAR_LOCATION = jarLocation;
}
}

/**
* Finds the NPN jar version that corresponds to the current Java version.
*
* @return the correct NPN jar version, or null if none is recognised. If the
* Java version is unrecognised, the latest NPN jar version will be
* returned.
*/
private static String getNpnVersionFromJavaVersion() {
final String javaVersion = System.getProperty("java.version");
String npnVersion = null;

// If the Java version is in a recognised format
if (javaVersion != null && javaVersion.matches("1.8.0_[0-9]{2,3}.*")) {
// Remove all letters, and parse the version to an integer
final Integer patchVersion = Integer.parseInt(javaVersion.split("_")[1].replaceAll("[^0-9]", ""));

if (patchVersion >= 191) {
npnVersion = LATEST_NPN_JAR_VERSION;
} else if (patchVersion >= 161) {
npnVersion = "1.8";
} else if (patchVersion >= 121) {
npnVersion = "1.7";
} else if (patchVersion >= 72) {
npnVersion = "1.6";
}
} else {
// The java version is unrecognisable, but is Java 8
// In this case, assume the most recent NPN version
npnVersion = LATEST_NPN_JAR_VERSION;
}

return npnVersion;
}
public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_PROPERTY="org.glassfish.grizzly.DEFAULT_MEMORY_MANAGER";
public static final String GRIZZLY_DEFAULT_MEMORY_MANAGER_VALUE="org.glassfish.grizzly.memory.HeapMemoryManager";
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
* Portions Copyright [2017-2018] [Payara Foundation and/or its affiliates]
*/
// Portions Copyright [2017] [Payara Foundation and/or its affiliates]
package com.sun.enterprise.glassfish.bootstrap;

import com.sun.enterprise.module.bootstrap.ArgumentManager;
Expand Down Expand Up @@ -81,7 +80,7 @@ static void checkJdkVersion() {
}
}

public static int getMajorJdkVersion() {
private static int getMajorJdkVersion() {
String jv = System.getProperty("java.version");
String[] split = jv.split("[\\._\\-]+");
if (split.length > 0) {
Expand All @@ -90,7 +89,7 @@ public static int getMajorJdkVersion() {
return -1;
}

public static int getMinorJdkVersion() {
private static int getMinorJdkVersion() {
// this is a subset of the code in com.sun.enterprise.util.JDK
// this module has no dependencies on util code so it was dragged in here.

Expand Down

0 comments on commit ae3e828

Please sign in to comment.