-
Notifications
You must be signed in to change notification settings - Fork 738
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
Included a new MXBean to dynamically configure dump options #718
Conversation
* </table> | ||
*/ | ||
|
||
public interface DiagnosticsMXBean extends PlatformManagedObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better named OpenJ9DiagnosticsMXBean
*/ | ||
@Override | ||
public void triggerDump(String dumpAgent) throws IllegalArgumentException { | ||
switch (dumpAgent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be a security check here. Although these Dump APIs contain security checks, they are only enabled when the com.ibm.jvm.enableLegacyDumpSecurity system property is set to true, which it is not by default. Considering you can attach to a running JVM and invoke this, the proper security checks need to be in place.
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void configureDumpOptions(String dumpOptions) throws InvalidDumpOptionException, DumpConfigurationUnavailableException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be called setDumpOptions instead of configureDumpOptions? According to the MXBean naming conventions, a setter should be called set...
As a practical example, jconsole handles the APIs differently when they are getters, setters and boolean APIs,
*/ | ||
@Override | ||
public void configureDumpOptions(String dumpOptions) throws InvalidDumpOptionException, DumpConfigurationUnavailableException { | ||
System.out.println("Dump Options = " + dumpOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is marked WIP, but its been sitting for a while with no updates, not sure if you are ready for a review? The println() needs to be removed before merging.
ed9635c
to
bd2d966
Compare
@pshipton Sorry for the delay I was on vacation. I have a query, Dump.setDumpOptions() did not work when I passed the below option: After investigation, I found -Xdump:dynamic has to be specified if throw/catch events are configured through Dump.setDumpOptions() when JIT is ON, whereas this option is not required when we set the above option on command line using -Xdump. Shouldn't this be documented in Dump API or somewhere else? I could not find any documentation on this. |
Yes it should. I've seen this mentioned elsewhere recently as well, but can't remember where. Can you please request an update to the User Guide. |
Thanks Peter. I had asked the same query here too - #153 |
e81da25
to
1937ab8
Compare
@pshipton - I have implemented the review comments and also fixed some synchronization issues in the test case. Please review. Thanks. |
import com.ibm.jvm.DumpConfigurationUnavailableException; | ||
import com.ibm.jvm.InvalidDumpOptionException; | ||
|
||
import com.ibm.jvm.Trace; | ||
import com.ibm.lang.management.OpenJ9DiagnosticsMXBean; | ||
|
||
public class OpenJ9DiagnosticsMXBeanImpl implements OpenJ9DiagnosticsMXBean { | ||
private static final DumpPermission DUMP_PERMISSION = new DumpPermission(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking security here is no longer required. Since my original comment, OpenJ9 has turned on the legacy security checks by default, in #979.
* | ||
* @throws DumpConfigurationUnavailableException - if the configuration cannot be changed because a dump is already in progress. | ||
*/ | ||
public void resetDumpOption() throws DumpConfigurationUnavailableException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be resetDumpOptions with a 's', to match the jvm.Dump API being called.
* This function sets options for the dump subsystem. | ||
* The dump option is passed in as a String. Use the same syntax as the -Xdump command-line option, with the | ||
* initial -Xdump: omitted. See Using the -Xdump option as described in the section on dump agents in the | ||
* documentation for the IBM JVM. This method may throw a DumpConfigurationUnavailableException if the dump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not refer to IBM
* This function triggers the specified dump agent. | ||
* The JVM will attempt to write the file to the specified file name. This may | ||
* include replacement tokens as documented in the section on dump agents | ||
* in the documentation for the IBM JVM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not refer to IBM
@@ -32,6 +32,7 @@ | |||
import com.ibm.lang.management.JvmCpuMonitorMXBean; | |||
import com.ibm.virtualization.management.internal.GuestOS; | |||
import com.ibm.virtualization.management.internal.HypervisorMXBeanImpl; | |||
import com.ibm.lang.management.OpenJ9DiagnosticsMXBean; | |||
|
|||
/** | |||
* This class implements the service-provider interface to make IBM-specific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change IBM to OpenJ9 here.
* @param dumpAgent - the dump agent to be triggered | ||
* @throws IllegalArgumentException - if the specified dump agent is invalid or unsupported by this method. | ||
* @throws java.lang.RuntimeException - if the vm does not contain RAS dump support | ||
* @throws java.lang.SecurityException - if there is a security manager and it doesn't allow the checks required to take this dump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use different wording, perform
instead of take
would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or trigger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pshipton I have taken this description from Dump.java, Should I change take to trigger in that file too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, please change it there too
Dump.SnapDump(); | ||
break; | ||
default: | ||
throw new IllegalArgumentException("Invalid or Unsupported Dump Agent Option, cannot be triggered"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please externalize this message. For an example, search for /*[MSG
and also see openj9/jcl/src/java.base/share/classes/com/ibm/oti/util/ExternalMessages-MasterIndex.properties
fileName = Dump.snapDumpToFile(fileNamePattern); | ||
break; | ||
default: | ||
throw new IllegalArgumentException("Invalid or Unsupported Dump Agent Option, cannot be triggered"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please externalize the message
* | ||
*/ | ||
|
||
@Test(groups = { "level.sanity" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be a sanity test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed it to level.extended, is this alright or is there any other group that I need to include it in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its fine. The test team can comment on this.
@llxia please have someone review the tests |
1937ab8
to
9213ea3
Compare
pull request for openjdk8 - ibmruntimes/openj9-openjdk-jdk8#60 Submitted a personal build, openjdk8 build was created and all sanity tests passed. So, I think it is fine to merge the changes required in the make. Have asked the same in the above pull request too. |
* @throws IllegalArgumentException if the specified dump agent is invalid or unsupported by this method | ||
* @throws RuntimeException if the vm does not contain RAS dump support | ||
* @throws SecurityException if there is a security manager and it doesn't allow the checks required to trigger this dump | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document NPE (if dumpAgent is null).
* @throws IllegalArgumentException if the specified dump agent is invalid or unsupported by this method | ||
* @throws SecurityException if there is a security manager and it doesn't allow the checks required to trigger this dump | ||
*/ | ||
public String triggerDumpToFile(String dumpAgent, String fileNamePattern) throws IllegalArgumentException, InvalidOptionException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document NPE (if dumpAgent is null).
} | ||
/*[ELSE] | ||
try { | ||
Dump.resetDumpOptions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please move the conditional boundaries as only the body of the try statement is different (and to similar situations in other methods).
test/JLM_Tests/testng.xml
Outdated
@@ -56,6 +56,7 @@ | |||
<class name="org.openj9.test.java.lang.management.TestMisc" /> | |||
<class name="org.openj9.test.java.lang.management.TestManagementUtils" /> | |||
<class name="org.openj9.test.java.lang.management.TestLoggingMXBean" /> | |||
<class name="org.openj9.test.java.lang.management.TestOpenJ9DiagnosticsMXBean" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late review. I had issue with my email filtering.
TestOpenJ9DiagnosticsMXBean has annotation level.extended
and it is added into JLM_Tests_IBMinternal in testng.xml.
In playlist.xml, we only run sanity
for JLM_Tests_IBMinternal, which means we will not run tests in TestOpenJ9DiagnosticsMXBean.
37630c1
to
4651232
Compare
Implemented the review comments, please review again. Thanks |
<variation>Mode100</variation> | ||
<variation>Mode101</variation> | ||
</variations> | ||
<command>$(ADD_JVM_LIB_DIR_TO_LIBPATH) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run test in REPORTDIR as the test may generate core file.
$(MKTREE) $(REPORTDIR); \
cd $(REPORTDIR); \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@llxia I have made these changes, please review. Thanks
7783f1f
to
4922923
Compare
*/ | ||
@Override | ||
public void resetDumpOptions() throws ConfigurationUnavailableException { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the dump APIs already check security permissions, it may be useful to have an extra layer of permission checking for the MXBean, since the MXBean can be used remotely. Please add a security check for java.lang.ManagementPermission("control") (i.e. ManagementPermissionHelper.MPCONTROL) to each of the APIs. This allows the local application to have DumpPermssion, but if ManagementPermission("control") is not granted then the MXBean APIs cannot be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ManagementPermissionHelper is an internal class in java.management module, not sure if there would be any restrictions in accessing internal classes using reflection from another module in future. Instead can I just use ManagementPermission("control") directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can use ManagementPermission("control")
directly, but you should capture that object somewhere (like ManagementPermissionHelper does) so that you can reuse it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java.management already exports com.ibm.java.lang.management.internal to jdk.management;
so I think ManagementPermissionHelper can be used directly.
fyi #1551, similar changes are required here |
8ddfd06
to
d1d7b6a
Compare
I have made the changes as suggested, please review. Thanks. |
|
||
/** | ||
* <p> | ||
* This interface provides APIs to dynamically trigger Dump agents. APIs are also available to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't captialize 'Dump'.
public interface OpenJ9DiagnosticsMXBean extends PlatformManagedObject { | ||
/** | ||
* Reset the JVM dump options to the settings specified when the JVM was started removing any additional | ||
* configuration done since then. This method may throw a DumpConfigurationUnavailableException if the dump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be 'ConfigurationUnavailableException' instead of 'DumpConfigurationUnavailableException'.
* This function sets options for the dump subsystem. | ||
* The dump option is passed in as a String. Use the same syntax as the -Xdump command-line option, with the | ||
* initial -Xdump: omitted. See Using the -Xdump option as described in the section on dump agents in the | ||
* documentation for the OpenJ9 JVM. This method may throw a DumpConfigurationUnavailableException if the dump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DumpConfigurationUnavailableException -> ConfigurationUnavailableException
ObjectName name = new ObjectName("openj9.lang.management:type=OpenJ9Diagnostics"); //$NON-NLS-1$ | ||
return name; | ||
} catch (MalformedObjectNameException e) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably throw an Error rather than return null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other MXBeans such as JVMCpuMonitor, ProcessorMXBeanImpl all have similar logic and return null on MalformedObjectNameException. Hence used the same logic here. Should I change it to throw an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they all should throw an Error, but I'm fine leaving that cleanup for later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Keith. I have made the other changes as per your review comments. Please review again.
/*[IF Sidecar19-SE]*/ | ||
try { | ||
Object controlPermission = managementPermission.get(null); | ||
manager.checkPermission((java.security.Permission)controlPermission); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pull the call to checkPermission() out of the try
statement so it doesn't flow through handleError
and is common for all Java versions.
</groups> | ||
<subsets> | ||
<subset>SE80</subset> | ||
<subset>SE90</subset> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should apply to all Java versions: can we just remove the <subsets>
element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, in able to support special subsets like Panama and Valhalla, we are caught in the position of explicitly stating the subset. If you do remove < subsets >, it will generate make targets for 5-6 supported subsets (SE80, SE90, SE100, SE110, Panama, Valhalla) and test compilation will fail, as Panama and Valhalla have special requirements for build. (At some point we should address this in a more satisfying way, in order not to play this game of continuously updating these... perhaps Panama & Valhalla off in a separate branch of openj9? but currently explicit statement is the way)
So, in this case, you may want to add SE100 to run this test also against Java10.
d1d7b6a
to
7efef6b
Compare
Signed-off-by: Chandrakala <chandra-ms@in.ibm.com>
7efef6b
to
54c8280
Compare
dumpConfigurationUnavailableExClass = classes[2]; | ||
Class<?> managementPermissionHelperClass = classes[3]; | ||
|
||
managementPermission= managementPermissionHelperClass.getField("MPCONTROL"); //$NON-NLS-1$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think access to ManagementPermissionHelper.MPCONTROL
needs to be via reflection. That package is exported to this module so it should be able to use the class and field directly in all Java versions. That change can wait for a separate PR though.
jenkins test sanity plinux |
Included a new MXBean to dynamically configure dump options. Internally it reuses the methods in com.ibm.jvm.Dump APIs to trigger dumps.
Issue #153
Signed-off-by: Chandrakala chandra-ms@in.ibm.com