You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by jx...@apache.org on 2019/09/30 18:23:14 UTC
[helix] branch master updated (3d1729b -> cdbdd4f)
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git.
from 3d1729b Make the Java Doc for API more clear
new bb198fc #493 Set jersey servlet application name with namespace name.
new cdbdd4f Add unit test for setting application name.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/helix/rest/server/HelixRestServer.java | 1 +
.../rest/server/TestDefaultMonitoringMbeans.java | 32 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
[helix] 02/02: Add unit test for setting application name.
Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
commit cdbdd4fecd9b7ddbf62f99b112364b46097b4108
Author: Huizhi Lu <ih...@gmail.com>
AuthorDate: Mon Sep 30 10:15:09 2019 -0700
Add unit test for setting application name.
---
.../rest/server/TestDefaultMonitoringMbeans.java | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestDefaultMonitoringMbeans.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestDefaultMonitoringMbeans.java
index 90ea420..be44d57 100644
--- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestDefaultMonitoringMbeans.java
+++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestDefaultMonitoringMbeans.java
@@ -20,19 +20,27 @@ package org.apache.helix.rest.server;
*/
import java.lang.management.ManagementFactory;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Random;
+import java.util.Set;
+
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.ws.rs.core.Response;
+
import org.apache.helix.TestHelper;
+import org.apache.helix.rest.common.HelixRestNamespace;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TestDefaultMonitoringMbeans extends AbstractTestClass {
+ private static final String DEFAULT_METRIC_DOMAIN = "org.glassfish.jersey";
// For entire testing environment, we could have 2 - 4 rest server during the testing. So we dont
// know which REST server got the request and report number. So we have to loop all of them to
@@ -74,4 +82,28 @@ public class TestDefaultMonitoringMbeans extends AbstractTestClass {
Assert.assertTrue(correctReports);
System.out.println("End test :" + TestHelper.getTestMethodName());
}
+
+ @Test
+ public void testMBeanApplicationName()
+ throws MalformedObjectNameException {
+ Set<String> namespaces =
+ new HashSet<>(Arrays.asList(HelixRestNamespace.DEFAULT_NAMESPACE_NAME, TEST_NAMESPACE));
+ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+ Set<ObjectName> objectNames =
+ mBeanServer.queryNames(new ObjectName(DEFAULT_METRIC_DOMAIN + ":*"), null);
+
+ Set<String> appNames = new HashSet<>();
+ for (ObjectName mBeanName : objectNames) {
+ appNames.add(mBeanName.getKeyProperty("type"));
+ }
+
+ Assert.assertEquals(appNames.size(), namespaces.size(), String
+ .format("appNames: %s does't have the same size as namespaces: %s.", appNames, namespaces));
+
+ for (String appName : appNames) {
+ Assert.assertTrue(namespaces.contains(appName), String
+ .format("Application name: %s is not one of the namespaces: %s.", appName, namespaces));
+ namespaces.remove(appName);
+ }
+ }
}
[helix] 01/02: #493 Set jersey servlet application name with
namespace name.
Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
commit bb198fc129dfd515cfec2f2fa158cd790e3864be
Author: Huizhi Lu <ih...@gmail.com>
AuthorDate: Fri Sep 27 20:53:13 2019 -0700
#493 Set jersey servlet application name with namespace name.
---
.../src/main/java/org/apache/helix/rest/server/HelixRestServer.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java b/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java
index c25fbc5..a23e1b1 100644
--- a/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java
+++ b/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java
@@ -143,6 +143,7 @@ public class HelixRestServer {
private ResourceConfig getResourceConfig(HelixRestNamespace namespace, ServletType type) {
ResourceConfig cfg = new ResourceConfig();
cfg.packages(type.getServletPackageArray());
+ cfg.setApplicationName(namespace.getName());
// Enable the default statistical monitoring MBean for Jersey server
cfg.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true);