Skip to content

Commit

Permalink
Initial version of tracer support
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Mar 5, 2024
1 parent a2108e6 commit 097670c
Show file tree
Hide file tree
Showing 22 changed files with 1,261 additions and 59 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/test-against-released.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Set up JDK 8 for Tracer Build
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'zulu'

- name: Build Tracer
shell: bash
run: |
./scripts/install-tracer-library.sh
- name: Set up JDK 11 for Build
uses: actions/setup-java@v3
with:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test-against-snapshot-1440.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-snapshots

- name: Set up JDK 8 for Build
- name: Set up JDK 8 for Tracer Build
uses: actions/setup-java@v3
with:
java-version: 8
java-version: '8'
distribution: 'zulu'

- name: Build Tracer
shell: bash
run: |
./scripts/install-tracer-library.sh
- name: Print Versions
run: mvn -version && ant -version

Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/test-against-snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -58,6 +58,17 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-snapshots

- name: Set up JDK 8 for Tracer Build
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'zulu'

- name: Build Tracer
shell: bash
run: |
./scripts/install-tracer-library.sh
- name: Set up JDK 17 for Build
uses: actions/setup-java@v3
with:
Expand Down
17 changes: 17 additions & 0 deletions coherence-visualvm-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
<artifactId>org-graalvm-visualvm-lib-ui</artifactId>
</dependency>

<dependency>
<groupId>org.graalvm.visualvm.modules</groupId>
<artifactId>org-graalvm-visualvm-modules-tracer</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
Expand All @@ -125,6 +130,14 @@
<artifactId>coherence-discovery</artifactId>
</dependency>

<!--- mock dependency -->
<dependency>
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-tracer</artifactId>
<version>1.7.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
Expand Down Expand Up @@ -164,6 +177,10 @@
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version.release}</release>
<compilerArgs>
<arg>--add-opens</arg>
<arg>jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,6 +30,13 @@

import com.oracle.coherence.plugin.visualvm.impl.CoherenceClusterProvider;

import com.oracle.coherence.plugin.visualvm.tracer.cluster.ClusterMonitorPackage;

import org.graalvm.visualvm.application.Application;
import org.graalvm.visualvm.modules.tracer.TracerPackage;
import org.graalvm.visualvm.modules.tracer.TracerPackageProvider;
import org.graalvm.visualvm.modules.tracer.TracerSupport;

import org.openide.modules.ModuleInstall;

/**
Expand All @@ -56,6 +63,14 @@ public void restored()
CoherenceClusterDataSourceViewProvider.register();
CoherenceClusterProvider.initCoherenceClustersDataSource();
CoherenceApplicationTypeFactory.initialize();

// register the tracer probes
if (provider == null)
{
provider = new TracerPackageProviderImpl();
}

TracerSupport.getInstance().registerPackageProvider(provider);
}

/**
Expand All @@ -69,5 +84,34 @@ public void uninstalled()
CoherenceClusterDataSourceDescriptorProvider.unregister();
CoherenceClusterDataSourceViewProvider.unregister();
CoherenceApplicationTypeFactory.shutdown();

// un-register the tracer probes
if (provider == null)
{
provider = new TracerPackageProviderImpl();
}

TracerSupport.getInstance().unregisterPackageProvider(provider);
}


/**
* Provider of Coherence tracer probes.
*/
private static class TracerPackageProviderImpl
extends TracerPackageProvider<Application>
{

TracerPackageProviderImpl()
{
super(Application.class);
}

public TracerPackage<Application>[] getPackages(Application application)
{
return new ClusterMonitorPackage[] {new ClusterMonitorPackage(application)};
}
}

private TracerPackageProviderImpl provider;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -157,6 +158,14 @@ protected DataViewComponent createComponent()
{
final VisualVMModel model = VisualVMModel.getInstance();

m_model = model;

// only add the tracer if we are connecting via JMX
if (m_application != null)
{
addModelForApplication(m_application, model);
}

boolean fClusterSnapshotEnabled = com.oracle.coherence.plugin.visualvm.GlobalPreferences
.sharedInstance().isClusterSnapshotEnabled();

Expand Down Expand Up @@ -418,6 +427,9 @@ public void run()
protected void removed()
{
m_timer.stop();

// remove this application and the mapped VisualVmModel
f_visualVmModels.remove(m_application);
}

/**
Expand All @@ -430,6 +442,28 @@ public void dataRemoved(Application app)
m_timer.stop();
}

/**
* Returns the model that is being used for the application.
*
* @param application {@link Application} to associate with {@link VisualVMModel}
* @return the {@link VisualVMModel}
*/
public static VisualVMModel getModelForApplication(Application application)
{
return f_visualVmModels.get(application);
}

/**
* Add the model that is being used for the application.
*
* @param application {@link Application} to associate with {@link VisualVMModel}
* @param model {@link VisualVMModel}
*/
public static void addModelForApplication(Application application, VisualVMModel model)
{
f_visualVmModels.put(application, model);
}

// ----- constants ------------------------------------------------------

/**
Expand All @@ -447,8 +481,11 @@ public void dataRemoved(Application app)
*/
private static final Logger LOGGER = Logger.getLogger(VisualVMView.class.getName());

private static final ConcurrentHashMap<Application, VisualVMModel> f_visualVmModels = new ConcurrentHashMap<>();

// ----- data members ---------------------------------------------------

private VisualVMModel m_model;
/**
* Component used to display the tabs.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1229,9 +1229,9 @@ private static SimpleXYChartSupport createChart(SimpleXYChartDescriptor sxycd)
*/
public static final int VALUES_LIMIT = Integer.getInteger("coherence.plugin.visualvm.values.limit", 50000);

private static final String GRPH_CURRENT_AVERAGE = "GRPH_current_average";
private static final String GRPH_MINIMUM = "GRPH_minimum";
private static final String GRPH_MAXIMUM = "GRPH_maximum";
private static final String GRPH_AVERAGE = "GRPH_average";
private static final String GRPH_CURRENT_MAXIMUM = "GRPH_current_maximum";
public static final String GRPH_CURRENT_AVERAGE = "GRPH_current_average";
public static final String GRPH_MINIMUM = "GRPH_minimum";
public static final String GRPH_MAXIMUM = "GRPH_maximum";
public static final String GRPH_AVERAGE = "GRPH_average";
public static final String GRPH_CURRENT_MAXIMUM = "GRPH_current_maximum";
}
Loading

0 comments on commit 097670c

Please sign in to comment.