Skip to content

Support condensed-data directly in JMC - #174

Open
parttimenerd wants to merge 29 commits into
SAP:sapfrom
parttimenerd:sap
Open

Support condensed-data directly in JMC#174
parttimenerd wants to merge 29 commits into
SAP:sapfrom
parttimenerd:sap

Conversation

@parttimenerd

Copy link
Copy Markdown

Support reading condensed-data compressed JFR files directly.

Add org.openjdk.jmc.flightrecorder.cjfr OSGi plugin. CjfrRecordingLoader
inflates .cjfr to JFR bytes in memory via WritingJFRReader.toJFRStream
then delegates to JfrLoaderToolkit; CjfrEditor extends JfrEditor for UI.
Make RecordingLoader.doCreateRecording protected, wire the plugin into
the flightrecorder feature and application build, and add x-friends
access to org.openjdk.jmc.flightrecorder.internal for EventArrays.
Aether coordinate grammar requires version last:
  groupId:artifactId:extension:classifier:version
Register condensed-data-0.1.1-reader.jar as an OSGi bundle exposing
me.bechberger.* for use by the cjfr plugin.
…FRReader)

The reader classifier jar excludes WritingJFRReader (JMC-dependent).
Use the full condensed-data jar instead; condensed-data-reader is now a
separate artifact for firefox-profiler WASM use.
WritingJFRReader depends on org.openjdk.jmc.flightrecorder.writer.api.Types
at runtime. Without the writer bundle in the feature, OSGi throws
NoClassDefFoundError when opening a .cjfr file in JMC.

Changes:
- Add flightrecorder.writer plugin to feature.flightrecorder/feature.xml
- Add Require-Bundle: org.openjdk.jmc.flightrecorder.writer to cjfr MANIFEST.MF
- Add flightrecorder.writer to application/pom.xml dependencies so Tycho
  can resolve it during the application build
condensed-data's WritingJFRReader references org.openjdk.jmc.flightrecorder.writer.*
types. The bnd-wrapped bundle had all imports optional, so OSGi would not wire
the writer packages even when the writer bundle was present, causing
NoClassDefFoundError at runtime.

Add Require-Bundle: org.openjdk.jmc.flightrecorder.writer;resolution:=optional
to the condensed-data bnd instructions so OSGi wires writer packages when
the writer bundle is available (i.e. inside JMC).
WritingJFRReader uses internal impl types (RecordingImpl, TypeImpl,
TypedValueImpl, TypedFieldImpl, TypedFieldValueImpl) from
org.openjdk.jmc.flightrecorder.writer — not just the .api package.

The writer bundle only exported .api, so OSGi could not wire the impl
packages to condensed-data's classloader, causing NoClassDefFoundError
at runtime when opening .cjfr files.

Export all three writer packages: .writer.api, .writer, .writer.util.
WritingJFRReader calls RecordingImpl.setGmtOffset(long, String) to
carry the source recording's timezone through condense→inflate so
jfr print renders local time instead of UTC.

MetadataImpl gains setRegion() which stores the gmtOffset millis and
optional locale, and writeRegion() now emits them as attributes on the
<region> element when set.
condensed-data 0.1.2 is deployed as a thin jar; femtojson is a
separate dependency providing me.bechberger.util.json.JSONParser used
by BasicJFRWriter.parseEventDescription at runtime.

Add me.bechberger.util:femtojson:0.4.1 as an OSGi bundle in the p2
third-party site, require it from the condensed-data bundle, and
include it in the flightrecorder feature.
me.bechberger.util.femtojson 0.4.1 is served by the third-party p2
site but was not listed in the target platform .target file, causing
Tycho to fail resolving the flightrecorder feature on CI.
nohup jetty:run starts asynchronously; if the Tycho target platform
cache is cold (e.g. after a pom.xml change), the application build
starts before Jetty is up and femtojson/condensed-data cannot be
resolved from localhost:8080/site.

Poll content.jar until Jetty responds before returning.
Use curl --write-out to check HTTP 200 instead of --fail exit code,
with || echo '000' fallback to avoid set -e killing the loop on
connection refused. Adds per-attempt logging for diagnostics.

@RealCLanger RealCLanger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please do not update copyrights for downstream changes. And also, don't add "Johannes Bechberger" copyright, rather SAP (for new files).

And maybe you can go over the change once more to eliminate any unnecessary diff, even if it is only whitespace or line length or whatever...

Comment thread releng/third-party/pom.xml Outdated
<maven-enforcer-plugin.version>3.3.0</maven-enforcer-plugin.version>
<!-- Versions -->
<condensed-data.version>0.1.2</condensed-data.version>
<femtojson.version>0.4.1</femtojson.version>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

indentation

Comment thread releng/third-party/pom.xml Outdated
Comment thread scripts/startp2.bat Outdated
Comment thread scripts/startp2.sh Outdated
…cordingLoader

Avoids modifying RecordingLoader, flightrecorder MANIFEST, and
writer MANIFEST. CjfrEditor.createRecordingLoader() inflates the
.cjfr file to a temporary .jfr, swaps the editor input, and returns
a plain RecordingLoader. Removes 60 lines of diff.
…JfrEditor

Inflate .cjfr before super.createPartControl() so RecordingLoader sees
the temp .jfr — eliminates all changes to JfrEditor.java.
…ne support)

condensed-data.jar shades its own MetadataImpl/RecordingImpl with setGmtOffset/setRegion.
The JMC flightrecorder.writer bundle is not in the product feature, so modifications to
those files are unnecessary for the integration.
…r to feature

Switch to me.bechberger:condensed-data:<version>:jar:jmc which excludes shaded
writer classes. JMC's flightrecorder.writer OSGi bundle now supplies them at
runtime, eliminating drift risk when the writer evolves.
p2-maven-plugin expects groupId:artifactId:type:classifier:version,
not the standard Maven groupId:artifactId:version:type:classifier.
The wrong format caused Aether to fail resolving condensed-data-jmc.
p2-maven-plugin's bnd appends the Maven classifier to Bundle-SymbolicName,
producing me.bechberger.condensed.data.jmc instead of the intended .data.
Update target definition, feature.xml, MANIFEST.MF, and p2 instructions
to use the actual BSN so Tycho target platform resolution succeeds.
…uffix

p2-maven-plugin's bnd appends the Maven classifier (.jmc) to whatever
Bundle-SymbolicName is specified in <instructions>.  Setting
me.bechberger.condensed.data.jmc in the instructions produces
me.bechberger.condensed.data.jmc.jmc — one suffix too many.

Set the base name me.bechberger.condensed.data so bnd generates the
intended me.bechberger.condensed.data.jmc, matching the unit id in the
.target file and the Require-Bundle in MANIFEST.MF.
…target dep

Require-Bundle: org.openjdk.jmc.flightrecorder.writer causes Tycho target
platform resolution to fail because the writer bundle lives in the JMC
workspace, not the p2 third-party repository.

Remove the directive; Import-Package: *;resolution:=optional covers the
runtime wiring via OSGi's package namespace, which Tycho resolves from
the workspace.
…on pom

Commit ef9b2e2 removed this dependency when CjfrRecordingLoader was dropped,
but the MANIFEST.MF still has Require-Bundle: org.openjdk.jmc.flightrecorder.writer.
Without the Maven dependency, Tycho cannot find the writer bundle when resolving
the cjfr plugin's OSGi requirements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants