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

Implement jps: java process status #4650

Merged
merged 1 commit into from
Feb 23, 2019

Conversation

pdbain-ibm
Copy link
Contributor

@pdbain-ibm pdbain-ibm commented Feb 7, 2019

Add Java code to implement the main function. This uses Attach API to acquire the list of processes
and query their information.

Update Attach API to return JVM arguments

Launchers will be added using coordinated changes in the extension repos.

Requires (mutually):

These required test utility changes should be merged before this is merged:

Doc issues:

Fixes #2377

Signed-off-by: Peter Bain peter_bain@ca.ibm.com

@pdbain-ibm pdbain-ibm force-pushed the attach_jps branch 2 times, most recently from 5a17cdd to 760fd23 Compare February 7, 2019 18:07
@pdbain-ibm
Copy link
Contributor Author

To build a launcher, add closed/make/closed_make/launcher/Launcher-openj9.diagnostics.gmk in the extensions repository containing the following:

include LauncherCommon.gmk

$(eval $(call SetupBuildLauncher, jps, \
    MAIN_MODULE := openj9.diagnostics, \
    MAIN_CLASS := openj9.tools.attach.diagnostics.Jps, \
    CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS, \
    JAVA_ARGS := -Djdk.attach.allowAttachSelf=true, \
))

@pdbain-ibm
Copy link
Contributor Author

Related issues:
#2259,
#2621,
#2378,
#2377.

@pshipton
Copy link
Member

pshipton commented Feb 7, 2019

Please open a https://github.com/eclipse/openj9-docs issue

@pshipton
Copy link
Member

pshipton commented Feb 7, 2019

I prefer to have the launchers and tests before this is merged, so they can be run to confirm everything is working properly.

@pshipton
Copy link
Member

pshipton commented Feb 7, 2019

Likely been asked before, but for the record here, does the sun.tools.jps.Jps implementation work on OpenJ9? Is there any need to write another one?

If we do, I'm thinking it should go into the jdk.jcmd module for compatibility, instead of openj9.diagnostics.

@pshipton
Copy link
Member

pshipton commented Feb 7, 2019

@keithc-ca

@pshipton
Copy link
Member

pshipton commented Feb 7, 2019

I'm thinking any new module we use needs to be added to the j9modules.txt to ensure everything is built in the correct order.

@pdbain-ibm
Copy link
Contributor Author

Does the sun.tools.jps.Jps implementation work on OpenJ9? Is there any need to write another one?

No, the existing jps silently produces no results when compiled with OpenJ9. This utility predates,and does not use, attach API; it appears to use an undocumented proprietary mechanism. It is also not available on Windows.

If we do, I'm thinking it should go into the jdk.jcmd module for compatibility, instead of openj9.diagnostics.

Will do.

@pdbain-ibm
Copy link
Contributor Author

I'm thinking any new module we use needs to be added to the j9modules.txt to ensure everything is built in the correct order.

Done

@keithc-ca
Copy link
Contributor

I don't see the changes you've claimed to have made - will you be pushing to your branch shortly?

@pdbain-ibm
Copy link
Contributor Author

I don't see the changes you've claimed to have made - will you be pushing to your branch shortly?

I am testing the changes now and will advise when the updates are pushed.

@pshipton
Copy link
Member

pshipton commented Feb 8, 2019

Note that Keith advised me the j9modules.txt was only needed for IBM builds and is now obsolete.

pdbain-ibm added a commit to pdbain-ibm/openj9-openjdk-jdk11 that referenced this pull request Feb 8, 2019
Requires eclipse-openj9/openj9#4650

Signed-off-by: Peter Bain <peter_bain@ca.ibm.com>
pdbain-ibm added a commit to pdbain-ibm/openj9-openjdk-jdk11 that referenced this pull request Feb 8, 2019
Requires eclipse-openj9/openj9#4650

Signed-off-by: Peter Bain <peter_bain@ca.ibm.com>
pdbain-ibm added a commit to pdbain-ibm/openj9-openjdk-jdk8 that referenced this pull request Feb 8, 2019
Depends on eclipse-openj9/openj9#4650

Signed-off-by: Peter Bain <peter_bain@ca.ibm.com>
@pdbain-ibm pdbain-ibm force-pushed the attach_jps branch 2 times, most recently from 81dd587 to 48b2b84 Compare February 8, 2019 15:43
pdbain-ibm added a commit to pdbain-ibm/openj9-openjdk-jdk11 that referenced this pull request Feb 8, 2019
Requires eclipse-openj9/openj9#4650

Signed-off-by: Peter Bain <peter_bain@ca.ibm.com>
@pdbain-ibm
Copy link
Contributor Author

Recent changes seem to have broken Java 8. Investigating...

@pshipton
Copy link
Member

@pdbain-ibm please indicate when this is ready to go, and remove the WIP.

@pdbain
Copy link

pdbain commented Feb 20, 2019

Working on it. The first problem was I mucked up jppd_configuration.xml. I fixed that and it passes manual tests, but the unit tests are failing. Will fix that ASAP, expect late Thursday.

@pdbain-ibm pdbain-ibm force-pushed the attach_jps branch 3 times, most recently from 347d99b to 68853e7 Compare February 21, 2019 20:56
@pdbain-ibm pdbain-ibm changed the title WIP: Implement jps: java process status Implement jps: java process status Feb 22, 2019
@pdbain-ibm
Copy link
Contributor Author

Updated and re-tested on Linux X86 Java 8 & 11. Changes since last review:

  • jpp_configuration.xml fixed
  • TestJps.java setupSuite() updated to create an absolute path to the jps executable, searching both bin and jre/bin
  • playlist.xml added a Java 8-specific variant of the test with tools.jar in the classpath. Also add an export to the Java 11 variant to suppress error messages.

@pshipton
Copy link
Member

pshipton commented Feb 22, 2019

I ran some testing on plinux, which passed, although the jps tests took 20min to run.
I see another change was pushed since this testing to fix the WARNING about illegal reflective access.

08:27:34  ...
08:27:34  ... TestNG 6.14.2 by Cédric Beust (cedric@beust.com)
08:27:34  ...
08:27:34  
08:27:34  WARNING: An illegal reflective access operation has occurred
08:27:34  WARNING: Illegal reflective access by org.openj9.test.attachAPI.TargetManager (file:/home/jenkins/jenkins-agent/workspace/Test-Grinder/jvmtest/functional/Java8andUp/GeneralTest.jar) to method com.ibm.tools.attach.target.AttachHandler.waitForAttachApiInitialization()
08:27:34  WARNING: Please consider reporting this to the maintainers of org.openj9.test.attachAPI.TargetManager
08:27:34  WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
08:27:34  WARNING: All illegal access operations will be denied in a future release
08:47:40  PASSED: testApplicationArguments
08:47:40  PASSED: testJpsIdOnly
08:47:40  PASSED: testJpsPackageName
08:47:40  PASSED: testJpsSanity
08:47:40  PASSED: testJvmArguments

jdk8: https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/308/ - ub16-ppcle-1
jdk11: https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/306/ - ub16-ppcle-1

@pdbain-ibm
Copy link
Contributor Author

I ran some testing on plinux, which passed, although the jps tests took 20min to run.

The test runs in well under a minute on my Mac and Linux box, and on the internal Linux X86 build farm. I am testing on a PPCLE machine. Note that the AttachAPISanity exercises much of the same code. Does it run slowly in a grinder too? Could you try TestJps on xLinux?

@pdbain-ibm
Copy link
Contributor Author

pdbain-ibm commented Feb 22, 2019

I ran TestJps on a pLinux box locally; it ran in ~15 seconds.

Manually tested on Windows.

@pshipton
Copy link
Member

xlinux
jdk8: https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/310/
jdk11: https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/311/

@pshipton
Copy link
Member

pshipton commented Feb 22, 2019

Checked AttachAPISanity on plinux from the nightly build last night, but it isn't taking much time to run.
https://ci.eclipse.org/openj9/job/Test-sanity.functional-JDK11-linux_ppc-64_cmprssptrs_le/542
ub16-ppcle-1

02:22:34  ... TestNG 6.14.2 by Cédric Beust (cedric@beust.com)
02:22:34  ...
02:22:34  
02:22:42  PASSED: testAttachToOtherProcess
02:22:42  PASSED: testAttachToSelf
02:22:42  PASSED: testAttachToSelfAndOthers

@pshipton
Copy link
Member

~10s on xlinux.

Please request access to the plinux machine ub16-ppcle-1 and check why it is slow to run TestJps.

assertTrue(CHILD_PROCESS_DID_NOT_LAUNCH, tgtMgr.syncWithTarget());
List<String> jpsOutput = runCommand(Collections.singletonList("-l")); //$NON-NLS-1$
Optional<String> searchResult = search(tgtMgr.targetId, jpsOutput);
assertTrue(CHILD_IS_MISSING, search(tgtMgr.targetId, jpsOutput).isPresent());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchResult can be used here.

commandName = JPS_COMMAND;
assertTrue("Attach API failed to launch", TargetManager.waitForAttachApiInitialization()); //$NON-NLS-1$
vmId = TargetManager.getVmId();
skipTest = !System.getProperty("java.vm.vendor").contains("OpenJ9"); //$NON-NLS-1$//$NON-NLS-2$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really required? I'm not sure that it is, since IBM isn't listed as an <impl> in the playlist.

@pshipton
Copy link
Member

pshipton commented Feb 22, 2019

Windows - all passed
jdk8: https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/314/
jdk8 32-bit: https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/313/
jdk11: https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/312/

@pdbain-ibm
Copy link
Contributor Author

Ran a personal build on Windows, Java 8 and 11 passed.

Add Java code to implement the main function

Update Attach API to return JVM arguments

Add unit test

[ci skip]

Signed-off-by: Peter Bain <peter_bain@ca.ibm.com>
@pdbain-ibm
Copy link
Contributor Author

searchResult can be used here.

Right.

Should there be a tgtMgr2.syncWithTarget()?

Yes.

Is this really required? I'm not sure that it is, since IBM isn't listed as an <impl> in the playlist.

I added it for the case where someone is running testNG without the test tooling. I removed the flag and changed the check to an assertion so the test fails if you try to run with a different JVM.

@pdbain-ibm
Copy link
Contributor Author

Test code updated.

@pshipton
Copy link
Member

Validation test https://ci.eclipse.org/openj9/view/Test/job/Test-Grinder/315/

@pshipton
Copy link
Member

Previous grinder passed.

@pshipton pshipton merged commit 655bf0d into eclipse-openj9:master Feb 23, 2019
@pdbain-ibm pdbain-ibm deleted the attach_jps branch February 25, 2019 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants