changeset 1928:07c8d314c3ab

Complete vm-compiler plugin. This is a backport of the vm-compiler plugin from the hg/thermostat repository revision fd3632b6449c. This changeset is built on top of revision b4d3fa26417d and completes the backport of the vm-compiler plugin. The separation is to make it easier to see relevant changes for the vm-compiler plugin. PR3010 Reviewed-by: neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-June/019635.html
author Jie Kang <jkang@redhat.com>
date Wed, 22 Jun 2016 09:06:24 -0400
parents b4d3fa26417d
children 5400d0567e11
files common/core/src/main/java/com/redhat/thermostat/common/Ordered.java distribution/packaging/fedora/0002_shared_osgi_spec_fixes.patch distribution/packaging/fedora/thermostat.spec vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/VmCompilerStatView.java vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/internal/VmCompilerStatController.java vm-compiler/client-swing/src/main/java/com/redhat/thermostat/vm/compiler/client/swing/internal/SwingVmCompilerStatView.java vm-compiler/client-swing/src/test/java/com/redhat/thermostat/vm/compiler/client/swing/internal/ActivatorTest.java vm-compiler/common/pom.xml vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/ParsedVmCompilerStat.java vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatDaoImpl.java vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatDaoImplStatementDescriptorRegistration.java
diffstat 11 files changed, 144 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/common/Ordered.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/common/core/src/main/java/com/redhat/thermostat/common/Ordered.java	Wed Jun 22 09:06:24 2016 -0400
@@ -72,6 +72,13 @@
      * or VM's threads.
      */
     public static final int ORDER_THREAD_GROUP = 500;
+
+    /**
+     * Order group for services that provide information about code running in a
+     * Host or a VM.
+     */
+    public static final int ORDER_CODE_GROUP = 600;
+
     /**
      * Order group for user-defined services. This should always be
      * the last order group.
--- a/distribution/packaging/fedora/0002_shared_osgi_spec_fixes.patch	Wed Jun 22 09:04:21 2016 -0400
+++ b/distribution/packaging/fedora/0002_shared_osgi_spec_fixes.patch	Wed Jun 22 09:06:24 2016 -0400
@@ -744,7 +744,7 @@
  
      <netty.version>3.2.4.Final</netty.version>
      <httpcomponents.core.version>4.3.2</httpcomponents.core.version>
-@@ -556,16 +568,6 @@
+@@ -557,16 +569,6 @@
        </dependency>
      
        <dependency>
@@ -858,7 +858,7 @@
 diff --git a/thread/collector/pom.xml b/thread/collector/pom.xml
 --- a/thread/collector/pom.xml
 +++ b/thread/collector/pom.xml
-@@ -85,14 +85,8 @@
+@@ -91,14 +91,8 @@
      </dependency>
  
      <dependency>
@@ -995,6 +995,86 @@
      </dependency>
      <dependency>
        <groupId>com.redhat.thermostat</groupId>
+diff --git a/vm-compiler/agent/pom.xml b/vm-compiler/agent/pom.xml
+--- a/vm-compiler/agent/pom.xml
++++ b/vm-compiler/agent/pom.xml
+@@ -80,14 +80,8 @@
+       <scope>test</scope>
+     </dependency>
+     <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.core</artifactId>
+-      <scope>provided</scope>
+-    </dependency>
+-    <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.compendium</artifactId>
+-      <scope>provided</scope>
++      <groupId>org.apache.felix</groupId>
++      <artifactId>org.apache.felix.framework</artifactId>
+     </dependency>
+     <dependency>
+       <groupId>com.redhat.thermostat</groupId>
+diff --git a/vm-compiler/client-core/pom.xml b/vm-compiler/client-core/pom.xml
+--- a/vm-compiler/client-core/pom.xml
++++ b/vm-compiler/client-core/pom.xml
+@@ -99,14 +99,8 @@
+       <scope>test</scope>
+     </dependency>
+     <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.core</artifactId>
+-      <scope>provided</scope>
+-    </dependency>
+-    <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.compendium</artifactId>
+-      <scope>provided</scope>
++      <groupId>org.apache.felix</groupId>
++      <artifactId>org.apache.felix.framework</artifactId>
+     </dependency>
+     <dependency>
+       <groupId>com.redhat.thermostat</groupId>
+diff --git a/vm-compiler/client-swing/pom.xml b/vm-compiler/client-swing/pom.xml
+--- a/vm-compiler/client-swing/pom.xml
++++ b/vm-compiler/client-swing/pom.xml
+@@ -87,14 +87,8 @@
+       <scope>test</scope>
+     </dependency>
+     <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.core</artifactId>
+-      <scope>provided</scope>
+-    </dependency>
+-    <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.compendium</artifactId>
+-      <scope>provided</scope>
++      <groupId>org.apache.felix</groupId>
++      <artifactId>org.apache.felix.framework</artifactId>
+     </dependency>
+     <dependency>
+       <groupId>org.jfree</groupId>
+diff --git a/vm-compiler/common/pom.xml b/vm-compiler/common/pom.xml
+--- a/vm-compiler/common/pom.xml
++++ b/vm-compiler/common/pom.xml
+@@ -99,14 +99,8 @@
+       <scope>test</scope>
+     </dependency>
+     <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.core</artifactId>
+-      <scope>provided</scope>
+-    </dependency>
+-    <dependency>
+-      <groupId>org.osgi</groupId>
+-      <artifactId>org.osgi.compendium</artifactId>
+-      <scope>provided</scope>
++      <groupId>org.apache.felix</groupId>
++      <artifactId>org.apache.felix.framework</artifactId>
+     </dependency>
+     <dependency>
+       <groupId>com.redhat.thermostat</groupId>
 diff --git a/vm-cpu/agent/pom.xml b/vm-cpu/agent/pom.xml
 --- a/vm-cpu/agent/pom.xml
 +++ b/vm-cpu/agent/pom.xml
--- a/distribution/packaging/fedora/thermostat.spec	Wed Jun 22 09:04:21 2016 -0400
+++ b/distribution/packaging/fedora/thermostat.spec	Wed Jun 22 09:06:24 2016 -0400
@@ -1041,6 +1041,7 @@
 %{_datadir}/%{pkg_name}/plugins/validate
 %{_datadir}/%{pkg_name}/plugins/setup
 %{_datadir}/%{pkg_name}/plugins/vm-classstat
+%{_datadir}/%{pkg_name}/plugins/vm-compiler
 %{_datadir}/%{pkg_name}/plugins/vm-cpu
 %{_datadir}/%{pkg_name}/plugins/vm-gc
 %{_datadir}/%{pkg_name}/plugins/vm-heap-analysis
--- a/vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/VmCompilerStatView.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/VmCompilerStatView.java	Wed Jun 22 09:06:24 2016 -0400
@@ -38,9 +38,9 @@
 
 import java.util.List;
 
+import com.redhat.thermostat.client.core.experimental.Duration;
 import com.redhat.thermostat.client.core.views.BasicView;
 import com.redhat.thermostat.client.core.views.UIComponent;
-import com.redhat.thermostat.common.Duration;
 import com.redhat.thermostat.common.model.Range;
 import com.redhat.thermostat.shared.locale.LocalizedString;
 import com.redhat.thermostat.shared.locale.Translate;
--- a/vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/internal/VmCompilerStatController.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/internal/VmCompilerStatController.java	Wed Jun 22 09:06:24 2016 -0400
@@ -43,13 +43,13 @@
 import java.util.concurrent.TimeUnit;
 
 import com.redhat.thermostat.client.core.controllers.InformationServiceController;
+import com.redhat.thermostat.client.core.experimental.Duration;
 import com.redhat.thermostat.client.core.experimental.TimeRangeController;
 import com.redhat.thermostat.client.core.views.BasicView.Action;
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
 import com.redhat.thermostat.common.ApplicationService;
-import com.redhat.thermostat.common.Duration;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
@@ -168,7 +168,7 @@
             data.totalCompiles = String.valueOf(stat.getTotalCompiles());
             data.totalBailouts = String.valueOf(stat.getTotalBailouts());
             data.totalInvalidates = String.valueOf(stat.getTotalInvalidates());
-            data.compilationTime = String.format("%d %s", stat.getCompilationTime().asMilliseconds(), "ms");
+            data.compilationTime = String.format("%d %s", stat.getCompilationTime(), "ms");
             data.lastSize = stat.getLastSize().toString();
             data.lastType = translateCompileDescription(stat.getLastType());
             data.lastMethod = stat.getLastMethod();
--- a/vm-compiler/client-swing/src/main/java/com/redhat/thermostat/vm/compiler/client/swing/internal/SwingVmCompilerStatView.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/client-swing/src/main/java/com/redhat/thermostat/vm/compiler/client/swing/internal/SwingVmCompilerStatView.java	Wed Jun 22 09:06:24 2016 -0400
@@ -45,16 +45,15 @@
 import javax.swing.SwingUtilities;
 import javax.swing.table.DefaultTableModel;
 
+import com.redhat.thermostat.client.core.experimental.Duration;
 import com.redhat.thermostat.client.swing.EdtHelper;
 import com.redhat.thermostat.client.swing.NonEditableTableModel;
 import com.redhat.thermostat.client.swing.SwingComponent;
 import com.redhat.thermostat.client.swing.components.HeaderPanel;
-import com.redhat.thermostat.client.swing.components.MultiChartPanel;
-import com.redhat.thermostat.client.swing.components.MultiChartPanel.DataGroup;
 import com.redhat.thermostat.client.swing.components.ThermostatScrollPane;
 import com.redhat.thermostat.client.swing.components.ThermostatTable;
+import com.redhat.thermostat.client.swing.components.experimental.MultiChartPanel;
 import com.redhat.thermostat.client.swing.experimental.ComponentVisibilityNotifier;
-import com.redhat.thermostat.common.Duration;
 import com.redhat.thermostat.common.model.Range;
 import com.redhat.thermostat.shared.locale.Translate;
 import com.redhat.thermostat.storage.model.DiscreteTimeData;
@@ -70,8 +69,8 @@
     private DefaultTableModel model;
     private MultiChartPanel multiChart;
 
-    private DataGroup numberGroup;
-    private DataGroup timeGroup;
+    private MultiChartPanel.DataGroup numberGroup;
+    private MultiChartPanel.DataGroup timeGroup;
 
     public SwingVmCompilerStatView() {
         visiblePanel = new HeaderPanel();
@@ -126,7 +125,7 @@
 
     private void addChartTypes() {
         for (Type type : Type.values()) {
-            DataGroup group = getGroup(type);
+            MultiChartPanel.DataGroup group = getGroup(type);
             String tag = getTag(type);
             multiChart.addChart(group, tag, type.getLabel());
             multiChart.showChart(group, tag);
@@ -207,8 +206,8 @@
         });
     }
 
-    private DataGroup getGroup(final Type type) {
-        final DataGroup group;
+    private MultiChartPanel.DataGroup getGroup(final Type type) {
+        final MultiChartPanel.DataGroup group;
         if (type == Type.TOTAL_BAILOUTS || type == Type.TOTAL_COMPILES || type == Type.TOTAL_INVALIDATES) {
             group = numberGroup;
         } else {
--- a/vm-compiler/client-swing/src/test/java/com/redhat/thermostat/vm/compiler/client/swing/internal/ActivatorTest.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/client-swing/src/test/java/com/redhat/thermostat/vm/compiler/client/swing/internal/ActivatorTest.java	Wed Jun 22 09:06:24 2016 -0400
@@ -36,7 +36,6 @@
 
 package com.redhat.thermostat.vm.compiler.client.swing.internal;
 
-import static com.redhat.thermostat.testutils.Asserts.assertServiceIsRegistered;
 import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
@@ -52,7 +51,9 @@
         Activator activator = new Activator();
         activator.start(ctx);
 
-        assertServiceIsRegistered(ctx, VmCompilerStatViewProvider.class, SwingVmCompilerStatViewProvider.class);
+        if (!ctx.isServiceRegistered(VmCompilerStatViewProvider.class.getName(), SwingVmCompilerStatViewProvider.class)) {
+            throw new AssertionError("Service " + SwingVmCompilerStatViewProvider.class.getName() + " is not registered under the API " + VmCompilerStatViewProvider.class.getName());
+        }
 
         assertEquals(1, ctx.getAllServices().size());
     }
--- a/vm-compiler/common/pom.xml	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/common/pom.xml	Wed Jun 22 09:06:24 2016 -0400
@@ -115,6 +115,11 @@
     </dependency>
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-client-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-storage-core</artifactId>
       <version>${project.version}</version>
     </dependency>
--- a/vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/ParsedVmCompilerStat.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/ParsedVmCompilerStat.java	Wed Jun 22 09:06:24 2016 -0400
@@ -38,7 +38,7 @@
 
 import java.util.concurrent.TimeUnit;
 
-import com.redhat.thermostat.common.Duration;
+import com.redhat.thermostat.client.core.experimental.Duration;
 import com.redhat.thermostat.common.Size;
 
 public class ParsedVmCompilerStat {
@@ -68,8 +68,8 @@
         return original.getTotalBailouts();
     }
 
-    public Duration getCompilationTime() {
-        return new Duration(original.getCompilationTime(), TimeUnit.MILLISECONDS);
+    public long getCompilationTime() {
+        return original.getCompilationTime();
     }
 
     public CompileType getLastType() {
--- a/vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatDaoImpl.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatDaoImpl.java	Wed Jun 22 09:06:24 2016 -0400
@@ -37,22 +37,24 @@
 package com.redhat.thermostat.vm.compiler.common.internal;
 
 import java.util.List;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import com.redhat.thermostat.common.utils.LoggingUtils;
+import com.redhat.thermostat.storage.core.DescriptorParsingException;
 import com.redhat.thermostat.storage.core.Key;
 import com.redhat.thermostat.storage.core.PreparedStatement;
+import com.redhat.thermostat.storage.core.StatementDescriptor;
+import com.redhat.thermostat.storage.core.StatementExecutionException;
 import com.redhat.thermostat.storage.core.Storage;
 import com.redhat.thermostat.storage.core.VmBoundaryPojoGetter;
 import com.redhat.thermostat.storage.core.VmLatestPojoListGetter;
 import com.redhat.thermostat.storage.core.VmRef;
 import com.redhat.thermostat.storage.core.VmTimeIntervalPojoListGetter;
-import com.redhat.thermostat.storage.dao.AbstractDao;
-import com.redhat.thermostat.storage.dao.AbstractDaoStatement;
 import com.redhat.thermostat.vm.compiler.common.VmCompilerStat;
 import com.redhat.thermostat.vm.compiler.common.VmCompilerStatDao;
 
-class VmCompilerStatDaoImpl extends AbstractDao implements VmCompilerStatDao {
+class VmCompilerStatDaoImpl implements VmCompilerStatDao {
 
     private static final Logger logger = LoggingUtils.getLogger(VmCompilerStatDaoImpl.class);
 
@@ -95,24 +97,28 @@
 
     @Override
     public void putVmCompilerStat(final VmCompilerStat stat) {
-        executeStatement(new AbstractDaoStatement<VmCompilerStat>(storage, vmCompilerStatsCategory, DESC_ADD_VM_COMPILER_STAT) {
-            @Override
-            public PreparedStatement<VmCompilerStat> customize(PreparedStatement<VmCompilerStat> preparedStatement) {
-                preparedStatement.setString(0, stat.getAgentId());
-                preparedStatement.setString(1, stat.getVmId());
-                preparedStatement.setLong(2, stat.getTimeStamp());
-                preparedStatement.setLong(3, stat.getTotalCompiles());
-                preparedStatement.setLong(4, stat.getTotalBailouts());
-                preparedStatement.setLong(5, stat.getTotalInvalidates());
-                preparedStatement.setLong(6, stat.getCompilationTime());
-                preparedStatement.setLong(7, stat.getLastSize());
-                preparedStatement.setLong(8, stat.getLastType());
-                preparedStatement.setString(9, stat.getLastMethod());
-                preparedStatement.setLong(10, stat.getLastFailedType());
-                preparedStatement.setString(11, stat.getLastFailedMethod());
-                return preparedStatement;
-            }
-        });
+        StatementDescriptor<VmCompilerStat> desc = new StatementDescriptor<>(vmCompilerStatsCategory, DESC_ADD_VM_COMPILER_STAT);
+        PreparedStatement<VmCompilerStat> prepared;
+        try {
+            prepared = storage.prepareStatement(desc);
+            prepared.setString(0, stat.getAgentId());
+            prepared.setString(1, stat.getVmId());
+            prepared.setLong(2, stat.getTimeStamp());
+            prepared.setLong(3, stat.getTotalCompiles());
+            prepared.setLong(4, stat.getTotalBailouts());
+            prepared.setLong(5, stat.getTotalInvalidates());
+            prepared.setLong(6, stat.getCompilationTime());
+            prepared.setLong(7, stat.getLastSize());
+            prepared.setLong(8, stat.getLastType());
+            prepared.setString(9, stat.getLastMethod());
+            prepared.setLong(10, stat.getLastFailedType());
+            prepared.setString(11, stat.getLastFailedMethod());
+            prepared.execute();
+        } catch (DescriptorParsingException e) {
+            logger.log(Level.SEVERE, "Preparing stmt '" + desc + "' failed!", e);
+        } catch (StatementExecutionException e) {
+            logger.log(Level.SEVERE, "Executing stmt '" + desc + "' failed!", e);
+        }
     }
 
     @Override
@@ -124,10 +130,5 @@
     public VmCompilerStat getNewest(final VmRef ref) {
         return boundaryGetter.getNewestStat(ref);
     }
-
-    @Override
-    protected Logger getLogger() {
-        return logger;
-    }
 }
 
--- a/vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatDaoImplStatementDescriptorRegistration.java	Wed Jun 22 09:04:21 2016 -0400
+++ b/vm-compiler/common/src/main/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatDaoImplStatementDescriptorRegistration.java	Wed Jun 22 09:06:24 2016 -0400
@@ -39,9 +39,11 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import com.redhat.thermostat.storage.core.PreparedParameter;
 import com.redhat.thermostat.storage.core.VmBoundaryPojoGetter;
 import com.redhat.thermostat.storage.core.VmLatestPojoListGetter;
 import com.redhat.thermostat.storage.core.VmTimeIntervalPojoListGetter;
+import com.redhat.thermostat.storage.core.auth.DescriptorMetadata;
 import com.redhat.thermostat.storage.core.auth.StatementDescriptorRegistration;
 import com.redhat.thermostat.vm.compiler.common.VmCompilerStatDao;
 
@@ -73,5 +75,9 @@
         return descs;
     }
 
+    @Override
+    public DescriptorMetadata getDescriptorMetadata(String descriptor, PreparedParameter[] params) {
+        throw new AssertionError("Should not be used");
+    }
 }