* Start Rest adapter via command line arguments
* Rest adapter config via management.properties
--- a/make/CompileJavaModules.gmk Mon Jan 01 23:59:14 2018 +0530
+++ b/make/CompileJavaModules.gmk Tue Jan 02 13:20:18 2018 +0530
@@ -248,6 +248,10 @@
################################################################################
+java.management.rest_ADD_JAVAC_FLAGS := -Xdoclint:none '-Xdoclint/package:javax.*'
+
+################################################################################
+
java.management.rmi_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:javax.*'
################################################################################
--- a/make/common/Modules.gmk Mon Jan 01 23:59:14 2018 +0530
+++ b/make/common/Modules.gmk Tue Jan 02 13:20:18 2018 +0530
@@ -53,6 +53,7 @@
java.logging \
java.management \
java.management.rmi \
+ java.management.rest \
java.naming \
java.prefs \
java.rmi \
@@ -62,6 +63,7 @@
jdk.management \
jdk.management.agent \
jdk.net \
+ jdk.httpserver \
jdk.sctp \
jdk.unsupported \
#
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/RestResource.java Mon Jan 01 23:59:14 2018 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/http/RestResource.java Tue Jan 02 13:20:18 2018 +0530
@@ -31,7 +31,6 @@
import java.io.IOException;
/**
- *
* @author harsha
*/
public interface RestResource extends HttpHandler {
@@ -67,7 +66,7 @@
httpResponse = doOptions(exchange);
break;
}
- HttpUtil.sendResponse(exchange,httpResponse);
+ HttpUtil.sendResponse(exchange, httpResponse);
}
public default HttpResponse doGet(HttpExchange exchange) {
--- a/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/mapper/JSONMappingFactory.java Mon Jan 01 23:59:14 2018 +0530
+++ b/src/java.management.rest/share/classes/com/oracle/jmx/remote/rest/mapper/JSONMappingFactory.java Tue Jan 02 13:20:18 2018 +0530
@@ -202,10 +202,6 @@
}
}
- /*
- Using class object is better than class name as class objects for same class
- name differ for each classloader
- */
public JSONMapper getTypeMapper(Class<?> type) {
if (type == null) return null;
if (type.isArray()) {
--- a/src/java.management.rest/share/classes/javax/management/remote/rest/PlatformRestAdapter.java Mon Jan 01 23:59:14 2018 +0530
+++ b/src/java.management.rest/share/classes/javax/management/remote/rest/PlatformRestAdapter.java Tue Jan 02 13:20:18 2018 +0530
@@ -73,8 +73,6 @@
}
private static class HttpThreadFactory implements ThreadFactory {
-
- private static final AtomicInteger poolNumber = new AtomicInteger(1);
private final ThreadGroup group;
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix = "http-thread-";
@@ -112,13 +110,14 @@
* javax.net.ssl.trustStore
* javax.net.ssl.keyStorePassword
* javax.net.ssl.trustStorePassword
- * @param properties Config properties for the HTTP server.
- * If null or if any properties are not specified, default values will be assumed.
- * @throws IOException If the server could not be created
+ *
+ * @param properties Config properties for the HTTP server.
+ * If null or if any properties are not specified, default values will be assumed.
+ * @throws IOException If the server could not be created
*/
public static synchronized void init(Properties properties) throws IOException {
if (httpServer == null) {
- if(properties == null || properties.isEmpty()) {
+ if (properties == null || properties.isEmpty()) {
properties = new Properties();
properties.setProperty("com.sun.management.jmxremote.ssl", "false");
properties.setProperty("com.sun.management.jmxremote.authenticate", "false");
--- a/src/java.management.rest/share/classes/module-info.java Mon Jan 01 23:59:14 2018 +0530
+++ b/src/java.management.rest/share/classes/module-info.java Tue Jan 02 13:20:18 2018 +0530
@@ -5,6 +5,4 @@
requires jdk.httpserver;
exports javax.management.remote.rest;
- exports com.oracle.jmx.remote.rest.json;
- exports com.oracle.jmx.remote.rest.json.parser;
}
--- a/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java Mon Jan 01 23:59:14 2018 +0530
+++ b/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java Tue Jan 02 13:20:18 2018 +0530
@@ -550,6 +550,7 @@
try {
if (props.get(REST_PORT) != null) {
PlatformRestAdapter.init(props);
+ System.out.println("Rest Base URL : " + PlatformRestAdapter.getBaseURL());
}
} catch (Throwable ex) {
ex.printStackTrace();
--- a/src/jdk.management.agent/share/conf/management.properties Mon Jan 01 23:59:14 2018 +0530
+++ b/src/jdk.management.agent/share/conf/management.properties Tue Jan 02 13:20:18 2018 +0530
@@ -29,6 +29,11 @@
# For setting the SNMP agent port use the following line
# com.sun.management.snmp.port=<port-number>
+# ################ Rest adapter Port #########################
+#
+# For starting the rest adapter, set the port use the following line
+# com.sun.management.jmxremote.port=<port-number>
+
#####################################################################
# Optional Instrumentation
#####################################################################
--- a/test/jdk/javax/management/remote/rest/RestAdapterConfigTest.java Mon Jan 01 23:59:14 2018 +0530
+++ b/test/jdk/javax/management/remote/rest/RestAdapterConfigTest.java Tue Jan 02 13:20:18 2018 +0530
@@ -14,8 +14,18 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+
+/* @test
+ * @summary Configuration test for rest adapter
+ * @library /test/lib
+ * @modules java.management.rest/com.oracle.jmx.remote.rest.http
+ * java.management.rest/com.oracle.jmx.remote.rest.json
+ * java.management.rest/com.oracle.jmx.remote.rest.json.parser
+ * java.management.rest/com.oracle.jmx.remote.rest.mapper
+ * @build RestAdapterConfigTest RestAdapterTest
+ * @run testng/othervm RestAdapterConfigTest
+ */
@Test
public class RestAdapterConfigTest {
@@ -23,7 +33,7 @@
private static String sslClientConfig;
private static String passwordFile;
private static String configFile;
- private static List<Runnable> tasks = new ArrayList<>();
+ private static final List<Runnable> tasks = new ArrayList<>();
private static RestAdapterTest test = new RestAdapterTest();
static {
@@ -98,9 +108,6 @@
@BeforeClass
public void init() throws Exception {
- // TODO : Remove this line for Jtreg testing
- System.setProperty("test.src", System.getProperty("user.dir")+ File.separator + "test");
-
String testSrcRoot = System.getProperty("test.src") + File.separator;
sslAgentConfig = testSrcRoot + "sslConfigAgent";
sslClientConfig = testSrcRoot + "sslConfigClient";
@@ -169,7 +176,6 @@
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
return ctx;
} catch (Exception ex) {
- Logger.getLogger(PlatformRestAdapter.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
@@ -215,5 +221,4 @@
if (f.exists())
f.delete();
}
-
}
--- a/test/jdk/javax/management/remote/rest/RestAdapterPerfTest.java Mon Jan 01 23:59:14 2018 +0530
+++ b/test/jdk/javax/management/remote/rest/RestAdapterPerfTest.java Tue Jan 02 13:20:18 2018 +0530
@@ -1,21 +1,39 @@
-import org.testng.annotations.Test;
+/* @test
+ * @summary Performance test for rest adapter
+ * @library /test/lib
+ * @modules java.management.rest/com.oracle.jmx.remote.rest.http
+ * java.management.rest/com.oracle.jmx.remote.rest.json
+ * java.management.rest/com.oracle.jmx.remote.rest.json.parser
+ * java.management.rest/com.oracle.jmx.remote.rest.mapper
+ * @build RestAdapterPerfTest RestAdapterTest
+ * @run testng/othervm RestAdapterPerfTest
+ */
+
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.ProcessTools;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
@Test
public class RestAdapterPerfTest {
- private static Random random = new Random(System.currentTimeMillis());
+ private static Random random = Utils.getRandomInstance();
private static AtomicInteger count = new AtomicInteger(1);
- public static void main(String[] args) throws Exception {
+ @Test
+ public void testMultipleClients() throws Exception {
RestAdapterTest test = new RestAdapterTest();
List<Runnable> tasks = new ArrayList<>();
--- a/test/jdk/javax/management/remote/rest/RestAdapterTest.java Mon Jan 01 23:59:14 2018 +0530
+++ b/test/jdk/javax/management/remote/rest/RestAdapterTest.java Tue Jan 02 13:20:18 2018 +0530
@@ -24,6 +24,17 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+ /* @test
+ * @summary Unit tests for Rest adapter
+ * @library /test/lib
+ * @modules java.management.rest/com.oracle.jmx.remote.rest.http
+ * java.management.rest/com.oracle.jmx.remote.rest.json
+ * java.management.rest/com.oracle.jmx.remote.rest.json.parser
+ * java.management.rest/com.oracle.jmx.remote.rest.mapper
+ * @build RestAdapterTest
+ * @run testng/othervm RestAdapterTest
+ */
+
@Test
public class RestAdapterTest {
@@ -40,8 +51,6 @@
JMXServiceURL addr = cs.getAddress();
connector = JMXConnectorFactory.connect(addr, null);
- System.setProperty("test.src", System.getProperty("user.dir") + "/test");
-
String testSrcRoot = System.getProperty("test.src") + File.separator;
String configFile = testSrcRoot + "mgmt.properties";
File f = new File(configFile);
--- a/test/jdk/javax/management/remote/rest/RunRestAdapter.java Mon Jan 01 23:59:14 2018 +0530
+++ b/test/jdk/javax/management/remote/rest/RunRestAdapter.java Tue Jan 02 13:20:18 2018 +0530
@@ -22,7 +22,6 @@
public static void main(String[] args) throws Exception {
RunRestAdapter rr = new RunRestAdapter();
- System.setProperty("test.src",System.getProperty("user.dir") + "/test");
rr.run();
while (true)
{