Skip to content
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

7455: Add support for jolokia JMX service connection #548

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ffe7eab
JMC-7455: Add plugin with support for Jolokia connections
skarsaune Jan 25, 2024
07b4f90
JMC-7455: Fix rjmx imports after rebasing with master
skarsaune Jan 26, 2024
92c86ca
JMC-7455: Fix copyright notices (change year) in Jolokia plugin
skarsaune Jan 26, 2024
0658a01
JMC-7455: Fixed whitespace of feature declaration
skarsaune Jan 26, 2024
0fc546a
JMC-7455: Fix copy paste and outdated errors in Jolokia plugin manifest
skarsaune Jan 26, 2024
dc588b6
JMC-7455: Ensure that jolokia version is set
skarsaune Jan 26, 2024
d444888
JMC-7455: Clean up some test comments
skarsaune Jan 26, 2024
f64b599
JMC-7455: Provide env map for discovered jolokia connections
skarsaune Feb 3, 2024
e2c2275
Merge remote-tracking branch 'origin/master' into jolokia-support-only
skarsaune Feb 3, 2024
b41db31
JMC-7455: Remove explicit package imports, as they are exported from …
skarsaune Feb 4, 2024
95f48a9
JMC-7455: Include jolokia in latest platform definition
skarsaune Feb 4, 2024
a7774a0
JMC-7455: fix copyrigt notice
skarsaune Feb 11, 2024
a8016ec
JMC-7455: [WIP] try to pick up protocol extensions
skarsaune Feb 27, 2024
449a7ec
JMC-7455: Pick up protocol extension and use it
skarsaune Mar 7, 2024
dd5c512
JMC-7455: Fix Eclipse warning
skarsaune Mar 7, 2024
8f4d3da
JMC-7455: Fixes for review comments, copyright notices and other impr…
skarsaune Mar 8, 2024
7ab418f
JMC-7455: Review: restriction warning
skarsaune Mar 8, 2024
5b3a479
JMC-7455: Work around Jolokia issues seen from MBean console
skarsaune Mar 25, 2024
7fc74d2
JMC-7455: Work around another Jolokia exception observed from MBean c…
skarsaune Mar 26, 2024
8f37cd2
JMC-7455: Fix for linux. Handle invoke with no parameters
skarsaune Mar 28, 2024
5aaf654
JMC-7455: Upgrade to latest jolokia (and give up on JVM discovery for…
skarsaune Mar 29, 2024
eba3935
JMC-7455: Remove mess of jolokia versions in pom files
skarsaune May 1, 2024
168719e
JMC-7455: Added jolokia to coverage
skarsaune May 2, 2024
a4ac785
JMC-7455: Updated copyright in coverage pom.xml
skarsaune May 2, 2024
889290d
JMC-7455: Externalize one more string
skarsaune May 2, 2024
17a7eaf
JMC-7455: Actually measure coverage of jolokia
skarsaune May 3, 2024
13210f6
JMC-7455: Attempt to use late property resolution for surefireArgLine
skarsaune May 3, 2024
f6c40ff
Revert "JMC-7455: Attempt to use late property resolution for surefir…
skarsaune May 4, 2024
24c3c1c
Revert "JMC-7455: Actually measure coverage of jolokia"
skarsaune May 4, 2024
8431313
Merge remote-tracking branch 'origin/master' into jolokia-support-only
skarsaune Jun 9, 2024
66ecc0f
JMC-7455: Update bundle version 9.0.0 -> 9.1.0
skarsaune Jun 9, 2024
c58c37a
JMC-7455: Whitespace corrections
skarsaune Jun 9, 2024
cb07367
JMC-7455: More whitespace corrections
skarsaune Jun 9, 2024
816b353
JMC-7455: Compare certiain retrieved attributes directly with local …
skarsaune Jun 14, 2024
0af1024
JMC-7455: Use explicit imports. Exclude attribute
skarsaune Jun 14, 2024
333fb18
JMC-7455: Use more meaningful message key
skarsaune Jun 14, 2024
a68aad5
JMC-7455: Spotless violation fixes
skarsaune Jun 14, 2024
6099e94
JMC-7455: Need to exclude one more attribute in test
skarsaune Jun 14, 2024
0a6c9e8
JMC-7455: Exclude one more unsafe attribute
skarsaune Jun 14, 2024
77b6de7
JMC-7455: Log attribute test data
skarsaune Jun 14, 2024
da8949b
JMC-7455: Spotless corrections.
skarsaune Jun 14, 2024
bea2516
Merge remote-tracking branch 'origin/master' into jolokia-support-only
skarsaune Jun 18, 2024
0fc1253
JMC-7455: Added jolokia to platform 2024-03
skarsaune Jun 18, 2024
eb5ac76
Merge remote-tracking branch 'origin/master' into jolokia-support-only
skarsaune Jun 26, 2024
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
7 changes: 7 additions & 0 deletions application/org.openjdk.jmc.feature.core/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,11 @@
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="org.openjdk.jmc.jolokia"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
17 changes: 17 additions & 0 deletions application/org.openjdk.jmc.jolokia/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<!-- Convenience: Regarding access rules. It appears that these packages are exported from jolokia standalone. Wondering whether eclipse caps at 36 access rules or something. Setting access rules on that specific plugin dependency does not seem to be persisted to the .classpath file, hence setting access policy globally for all plugin dependencies-->
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
<accessrules>
<accessrule kind="accessible" pattern="org/jolokia/**"/>
<accessrule kind="accessible" pattern="org/json/simple/*"/>
</accessrules>
</classpathentry>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
20 changes: 20 additions & 0 deletions application/org.openjdk.jmc.jolokia/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.openjdk.jmc.jolokia;singleton:=true
Bundle-Version: 9.0.0.qualifier
skarsaune marked this conversation as resolved.
Show resolved Hide resolved
Automatic-Module-Name: org.openjdk.jmc.jolokia
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.jolokia.jmx-adapter.standalone;bundle-version="1.7.2";visibility:=reexport,
org.jolokia.jvm;bundle-version="1.7.2",
org.openjdk.jmc.common,
org.openjdk.jmc.rjmx,
org.openjdk.jmc.ui
Export-Package: org.openjdk.jmc.jolokia,
org.openjdk.jmc.jolokia.preferences
Import-Package: org.jolokia.converter,
org.json.simple
Bundle-Activator: org.openjdk.jmc.jolokia.JmcJolokiaPlugin
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Properties file for org.openjdk.jmc.jolokia
page.name = Jolokia
Bundle-Name = Jolokia JMC Connection
39 changes: 39 additions & 0 deletions application/org.openjdk.jmc.jolokia/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2024, Kantega AS. All rights reserved.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# The contents of this file are subject to the terms of either the Universal Permissive License
# v 1.0 as shown at http://oss.oracle.com/licenses/upl
#
# or the following license:
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to
# endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
# WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
source.. = src/main/java/
output.. = target/classes/
bin.includes = META-INF/,\
OSGI-INF/,\
.,\
plugin.xml,\
OSGI-INF/l10n/bundle.properties
65 changes: 65 additions & 0 deletions application/org.openjdk.jmc.jolokia/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2024, Kantega AS. All rights reserved.

DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

The contents of this file are subject to the terms of either the Universal Permissive License
v 1.0 as shown at http://oss.oracle.com/licenses/upl

or the following license:

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided with
the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.openjdk.jmc.rjmx.descriptorProvider">
<provider
class="org.openjdk.jmc.jolokia.JolokiaDiscoveryListener">
</provider>
</extension>
<extension
point="org.openjdk.jmc.rjmx.jmxProtocols">
<client
class="org.openjdk.jmc.jolokia.JmcJolokiaJmxConnectionProvider" protocol="jolokia">
<sysproperty name="running.in.jmc" include="true" />
</client>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
category="org.openjdk.jmc.browser.preferences.BrowserPreferencePage"
class="org.openjdk.jmc.jolokia.preferences.JolokiaPreferencePage"
id="org.openjdk.jmc.jolokia.preferences.JolokiaPreferencePage"
name="%page.name">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.openjdk.jmc.jolokia.preferences.PreferenceInitializer">
</initializer>
</extension>
</plugin>
49 changes: 49 additions & 0 deletions application/org.openjdk.jmc.jolokia/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2024, Kantega AS. All rights reserved.

DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

The contents of this file are subject to the terms of either the Universal Permissive License
v 1.0 as shown at http://oss.oracle.com/licenses/upl

or the following license:

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided with
the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openjdk.jmc</groupId>
<artifactId>missioncontrol.application</artifactId>
<version>${revision}${changelist}</version>
</parent>
<artifactId>org.openjdk.jmc.jolokia</artifactId>
<packaging>eclipse-plugin</packaging>
<properties>
<jmc.config.path>${project.basedir}/../../configuration</jmc.config.path>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, Kantega AS. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The contents of this file are subject to the terms of either the Universal Permissive License
* v 1.0 as shown at http://oss.oracle.com/licenses/upl
*
* or the following license:
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided with
* the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openjdk.jmc.jolokia;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.openjdk.jmc.rjmx.descriptorprovider.AbstractDescriptorProvider;
import org.openjdk.jmc.rjmx.descriptorprovider.IDescriptorListener;

/**
* The {@code AbstractCachedDescriptorProvider} keeps a list of identified JVMs that can be
* refreshed in the background by some means of discovering JVMs. Listeners will be notified of any
* changes.
*/
@SuppressWarnings("restriction")
skarsaune marked this conversation as resolved.
Show resolved Hide resolved
public abstract class AbstractCachedDescriptorProvider extends AbstractDescriptorProvider {

private static final long LOCAL_REFRESH_INTERVAL = 20000;
private Scanner scanner;
private Thread scannerThread;
/**
* Map<UUID, IServerDescriptor>
*/
private final Map<String, ServerConnectionDescriptor> knownDescriptors = new HashMap<>();

/**
* This is where we periodically scan and report deltas to the listeners.
*/
private class Scanner implements Runnable {
boolean isRunning;

@Override
public void run() {
isRunning = true;
while (isRunning) {
try {
scan();
Thread.sleep(LOCAL_REFRESH_INTERVAL);
} catch (InterruptedException ignore) {
// Don't mind being interrupted.
}
}
}

/**
* Marks this scanner as terminated.
*/
public void shutdown() {
isRunning = false;
}

protected void scan() {
Map<String, ServerConnectionDescriptor> newOnes = discoverJvms();

synchronized (knownDescriptors) {
// Remove stale ones...
for (Iterator<Entry<String, ServerConnectionDescriptor>> entryIterator = knownDescriptors.entrySet()
.iterator(); entryIterator.hasNext();) {
Entry<String, ServerConnectionDescriptor> entry = entryIterator.next();
if (newOnes.containsKey(entry.getKey())) {
continue;
}
entryIterator.remove();
onDescriptorRemoved(entry.getKey());
}

// Add new ones...
for (Entry<String, ServerConnectionDescriptor> entry : newOnes.entrySet()) {
if (knownDescriptors.containsKey(entry.getKey())) {
continue;
}
onDescriptorDetected(entry.getValue(), entry.getValue().getPath(), entry.getValue().serviceUrl(),
entry.getValue());
}
knownDescriptors.clear();
knownDescriptors.putAll(newOnes);
}
}
}

/**
* Sets up the thread.
*/
private void initialize() {

skarsaune marked this conversation as resolved.
Show resolved Hide resolved
scanner = new Scanner();
scannerThread = new Thread(scanner, getName()); // $NON-NLS-1$
scannerThread.start();
}

protected abstract boolean isEnabled();

protected abstract Map<String, ServerConnectionDescriptor> discoverJvms();

@Override
public void addDescriptorListener(IDescriptorListener l) {
synchronized (m_descriptorListeners) {
if (m_descriptorListeners.size() == 0) {
super.addDescriptorListener(l);
initialize();
} else {
super.addDescriptorListener(l);
}
}
}

@Override
public void removeDescriptorListener(IDescriptorListener l) {
synchronized (m_descriptorListeners) {
super.removeDescriptorListener(l);
if (m_descriptorListeners.size() == 0 && scanner != null) {
scanner.shutdown();
scannerThread.interrupt();
}
}
}

/**
* Shuts down the scanner thread.
*/
public void shutdown() {
if (scanner != null) {
scanner.shutdown();
}
}

}
Loading