Mercurial > hg > release > thermostat-1.4
changeset 1520:a3579383abe1
Remove VM Caps from Thread Monitor
review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-October/011175.html
reviewed-by: omajid
line wrap: on
line diff
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollector.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/ThreadCollector.java Wed Oct 15 18:55:02 2014 +0200 @@ -43,9 +43,7 @@ import com.redhat.thermostat.thread.model.ThreadHeader; import com.redhat.thermostat.thread.model.ThreadState; import com.redhat.thermostat.thread.model.ThreadSummary; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; import com.redhat.thermostat.thread.model.VmDeadLockData; - import java.util.List; public interface ThreadCollector { @@ -53,15 +51,12 @@ void setAgentInfoDao(AgentInfoDAO agentDao); void setThreadDao(ThreadDao threadDao); - VMThreadCapabilities getVMThreadCapabilities(); - boolean startHarvester(); boolean stopHarvester(); boolean isHarvesterCollecting(); ThreadSummary getLatestThreadSummary(); List<ThreadSummary> getThreadSummary(long since); - List<ThreadSummary> getThreadSummary(); /** * Return the range of all {@link ThreadState} data (timestamp of first and
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadMXBeanCollector.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadMXBeanCollector.java Wed Oct 15 18:55:02 2014 +0200 @@ -54,7 +54,6 @@ import com.redhat.thermostat.thread.model.ThreadHeader; import com.redhat.thermostat.thread.model.ThreadState; import com.redhat.thermostat.thread.model.ThreadSummary; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; import com.redhat.thermostat.thread.model.VmDeadLockData; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -166,11 +165,6 @@ List<ThreadSummary> summary = threadDao.loadSummary(ref, since); return summary; } - - @Override - public List<ThreadSummary> getThreadSummary() { - return getThreadSummary(0); - } @Override public Range<Long> getThreadStateTotalTimeRange() { @@ -182,12 +176,6 @@ } @Override - public VMThreadCapabilities getVMThreadCapabilities() { - VMThreadCapabilities caps = threadDao.loadCapabilities(ref); - return caps; - } - - @Override public VmDeadLockData getLatestDeadLockData() { return threadDao.loadLatestDeadLockStatus(ref); }
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/ThreadView.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/ThreadView.java Wed Oct 15 18:55:02 2014 +0200 @@ -70,7 +70,6 @@ public abstract void setEnableRecordingControl(boolean enable); public abstract void setRecording(boolean recording, boolean notify); - public abstract VMThreadCapabilitiesView createVMThreadCapabilitiesView(); public abstract ThreadTableView createThreadTableView(); public abstract ThreadTimelineView createThreadTimelineView(); public abstract ThreadCountView createThreadCountView();
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/VMThreadCapabilitiesView.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.client.common.view; - -import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; - -public abstract class VMThreadCapabilitiesView extends BasicView { - - public abstract void setVMThreadCapabilities(VMThreadCapabilities caps); -} -
--- a/thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/client-common/src/test/java/com/redhat/thermostat/thread/client/common/collector/impl/ThreadCollectorTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -36,22 +36,6 @@ package com.redhat.thermostat.thread.client.common.collector.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - import com.redhat.thermostat.client.command.RequestQueue; import com.redhat.thermostat.common.command.Request; import com.redhat.thermostat.common.command.RequestResponseListener; @@ -64,7 +48,20 @@ import com.redhat.thermostat.thread.collector.HarvesterCommand; import com.redhat.thermostat.thread.dao.ThreadDao; import com.redhat.thermostat.thread.model.ThreadHarvestingStatus; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class ThreadCollectorTest { @@ -91,36 +88,6 @@ } @Test - public void testVMCapabilitiesNotInDAO() throws Exception { - when(threadDao.loadCapabilities(reference)).thenReturn(null); - - ThreadCollector collector = new ThreadMXBeanCollector(context, reference); - collector.setAgentInfoDao(agentDao); - collector.setThreadDao(threadDao); - - VMThreadCapabilities caps = collector.getVMThreadCapabilities(); - - verify(threadDao).loadCapabilities(reference); - assertEquals(null, caps); - } - - @Test - public void testVMCapabilitiesInDAO() throws Exception { - VMThreadCapabilities resCaps = mock(VMThreadCapabilities.class); - when(threadDao.loadCapabilities(reference)).thenReturn(resCaps); - - ThreadCollector collector = new ThreadMXBeanCollector(context, reference); - - collector.setAgentInfoDao(agentDao); - collector.setThreadDao(threadDao); - - VMThreadCapabilities caps = collector.getVMThreadCapabilities(); - - verify(threadDao).loadCapabilities(reference); - assertSame(resCaps, caps); - } - - @Test public void testHarvesterCollecting() { ThreadHarvestingStatus status = mock(ThreadHarvestingStatus.class); when(status.isHarvesting()).thenReturn(true);
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Wed Oct 15 18:55:02 2014 +0200 @@ -152,11 +152,7 @@ private void initControllers() { TimerFactory tf = appService.getTimerFactory(); - - VMThreadCapabilitiesController capsController = - new VMThreadCapabilitiesController(view.createVMThreadCapabilitiesView(), collector); - capsController.initialize(); - + VmDeadLockController deadLockController = new VmDeadLockController(view.createDeadLockView(), collector, tf.createTimer()); deadLockController.initialize();
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesController.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.client.controller.impl; - -import com.redhat.thermostat.client.core.views.BasicView.Action; -import com.redhat.thermostat.common.ActionEvent; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; -import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; - -public class VMThreadCapabilitiesController { - - private ThreadCollector collector; - private VMThreadCapabilitiesView view; - - public VMThreadCapabilitiesController(VMThreadCapabilitiesView view, ThreadCollector collector) { - this.view = view; - this.collector = collector; - } - - public void initialize() { - view.addActionListener(new ActionListener<Action>() { - @Override - public void actionPerformed(ActionEvent<Action> actionEvent) { - switch (actionEvent.getActionId()) { - case VISIBLE: - VMThreadCapabilities caps = collector.getVMThreadCapabilities(); - if (caps != null) { - view.setVMThreadCapabilities(caps); - } - break; - - default: - break; - } - } - }); - } -} -
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -56,7 +56,6 @@ import com.redhat.thermostat.thread.client.common.view.ThreadTableView.ThreadSelectionAction; import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView; import com.redhat.thermostat.thread.client.common.view.ThreadView; -import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.client.common.view.VmDeadLockView; import org.junit.Before; import org.junit.Test; @@ -84,7 +83,6 @@ private VmInfoDAO vmInfoDao; private ThreadTableView threadTableView; - private VMThreadCapabilitiesView threadCapsView; private VmDeadLockView deadLockView; private ThreadTimelineView threadTimelineView; private ThreadCountView threadCountView; @@ -106,7 +104,6 @@ } private void setUpView() { - threadCapsView = mock(VMThreadCapabilitiesView.class); deadLockView = mock(VmDeadLockView.class); threadTableView = mock(ThreadTableView.class); threadTimelineView = mock(ThreadTimelineView.class); @@ -116,7 +113,6 @@ viewFactory = mock(ThreadViewProvider.class); when(viewFactory.createView()).thenReturn(view); - when(view.createVMThreadCapabilitiesView()).thenReturn(threadCapsView); when(view.createDeadLockView()).thenReturn(deadLockView); when(view.createThreadTableView()).thenReturn(threadTableView); when(view.createThreadTimelineView()).thenReturn(threadTimelineView); @@ -168,7 +164,6 @@ createController(); verify(view).createThreadTableView(); - verify(view).createVMThreadCapabilitiesView(); verify(view).createDeadLockView(); verify(view).createThreadTimelineView(); verify(view).createThreadCountView();
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesControllerTest.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.client.controller.impl; - -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -import com.redhat.thermostat.common.ActionEvent; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; -import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; - -public class VMThreadCapabilitiesControllerTest { - - private VMThreadCapabilitiesView vmThreadCapsView; - private ThreadCollector collector; - private VMThreadCapabilities caps; - - private ActionListener<VMThreadCapabilitiesView.Action> actionListener; - - @Before - public void setUp() { - collector = mock(ThreadCollector.class); - caps = mock(VMThreadCapabilities.class); - - when(collector.getVMThreadCapabilities()).thenReturn(caps); - - vmThreadCapsView = mock(VMThreadCapabilitiesView.class); - } - - @Test - public void testStartVMThreadCapabilities() { - - ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class); - doNothing().when(vmThreadCapsView).addActionListener(viewArgumentCaptor.capture()); - - VMThreadCapabilitiesController controller = new VMThreadCapabilitiesController(vmThreadCapsView, collector); - controller.initialize(); - - actionListener = viewArgumentCaptor.getValue(); - actionListener.actionPerformed(new ActionEvent<>(vmThreadCapsView, VMThreadCapabilitiesView.Action.VISIBLE)); - - verify(collector).getVMThreadCapabilities(); - verify(vmThreadCapsView).setVMThreadCapabilities(caps); - } - -} -
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java Wed Oct 15 18:55:02 2014 +0200 @@ -36,18 +36,6 @@ package com.redhat.thermostat.thread.client.swing.impl; -import java.awt.Component; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import javax.swing.JOptionPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; - import com.redhat.thermostat.client.swing.ComponentVisibleListener; import com.redhat.thermostat.client.swing.SwingComponent; import com.redhat.thermostat.client.swing.UIDefaults; @@ -61,9 +49,18 @@ import com.redhat.thermostat.thread.client.common.view.ThreadTableView; import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView; import com.redhat.thermostat.thread.client.common.view.ThreadView; -import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.client.common.view.VmDeadLockView; import com.redhat.thermostat.thread.client.swing.impl.timeline.SwingTimelineDimensionModel; +import java.awt.Component; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.JOptionPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; public class SwingThreadView extends ThreadView implements SwingComponent { @@ -73,7 +70,6 @@ private SwingThreadCountView threadCountView; private SwingThreadTableView threadTableView; - private SwingVMThreadCapabilitiesView vmCapsView; private SwingVmDeadLockView vmDeadLockView; private SwingThreadTimelineView threadTimelineView; private SwingThreadDetailsView threadDetailsView; @@ -178,9 +174,6 @@ bottomPane.addTab(t.localize(LocaleResources.DETAILS).getContents(), threadDetailsView.getUiComponent()); threadDetailsPaneID = 1; - vmCapsView = new SwingVMThreadCapabilitiesView(); - bottomPane.addTab(t.localize(LocaleResources.VM_CAPABILITIES).getContents(), vmCapsView.getUiComponent()); - vmDeadLockView = new SwingVmDeadLockView(); bottomPane.addTab(t.localize(LocaleResources.VM_DEADLOCK).getContents(), vmDeadLockView.getUiComponent()); @@ -219,11 +212,6 @@ } }); } - - @Override - public VMThreadCapabilitiesView createVMThreadCapabilitiesView() { - return vmCapsView; - } @Override public VmDeadLockView createDeadLockView() {
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingVMThreadCapabilitiesView.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.client.swing.impl; - -import java.awt.Component; - -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; - -import com.redhat.thermostat.client.swing.ComponentVisibleListener; -import com.redhat.thermostat.client.swing.SwingComponent; -import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; - -public class SwingVMThreadCapabilitiesView extends VMThreadCapabilitiesView implements SwingComponent { - - private VMCapsSummaryPanel panel; - - public SwingVMThreadCapabilitiesView() { - panel = new VMCapsSummaryPanel(); - panel.addHierarchyListener(new ComponentVisibleListener() { - - @Override - public void componentShown(Component component) { - SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { - @Override - protected Void doInBackground() throws Exception { - SwingVMThreadCapabilitiesView.this.notify(Action.VISIBLE); - return null; - } - }; - worker.execute(); - } - - @Override - public void componentHidden(Component component) { - SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { - @Override - protected Void doInBackground() throws Exception { - SwingVMThreadCapabilitiesView.this.notify(Action.HIDDEN); - return null; - } - }; - worker.execute(); - } - }); - } - - @Override - public void setVMThreadCapabilities(final VMThreadCapabilities caps) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - panel.addInfo(caps.getSupportedFeaturesList()); - } - }); - } - - @Override - public Component getUiComponent() { - return panel; - } -} -
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/VMCapsSummaryPanel.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.client.swing.impl; - -import java.awt.Dimension; -import java.awt.GridLayout; - -import javax.swing.DefaultListModel; -import javax.swing.JList; -import javax.swing.JPanel; - -import com.redhat.thermostat.client.swing.components.models.NullSelectionModel; - -@SuppressWarnings("serial") -class VMCapsSummaryPanel extends JPanel { - - private DefaultListModel<String> listModel; - - /** - * Create the panel. - */ - public VMCapsSummaryPanel() { - setLayout(new GridLayout(0, 1, 0, 0)); - setOpaque(false); - - listModel = new DefaultListModel<>(); - - JPanel panel = new JPanel(); - panel.setLayout(new GridLayout(0, 1, 0, 0)); - panel.setOpaque(false); - - add(panel); - - JList<String> list = new JList<String>(); - list.setPreferredSize(new Dimension(0, 0)); - list.setOpaque(false); - list.setLayoutOrientation(JList.VERTICAL_WRAP); - list.setSelectionModel(new NullSelectionModel()); - - list.setModel(listModel); - - panel.add(list); - } - - void addInfo(String[] infos) { - listModel.removeAllElements(); - for (String info : infos) { - listModel.addElement(info); - } - } -} -
--- a/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/ThreadDao.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/ThreadDao.java Wed Oct 15 18:55:02 2014 +0200 @@ -45,9 +45,7 @@ import com.redhat.thermostat.thread.model.ThreadHeader; import com.redhat.thermostat.thread.model.ThreadState; import com.redhat.thermostat.thread.model.ThreadSummary; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; import com.redhat.thermostat.thread.model.VmDeadLockData; - import java.util.Arrays; import java.util.List; @@ -59,14 +57,6 @@ static final String CPU_TIME = "thread-cpu-time"; static final String CONTENTION_MONITOR = "thread-contention-monitor"; static final String THREAD_ALLOCATED_MEMORY = "thread-allocated-memory"; - - /* - * vm-thread-capabilities schema - */ - static final Key<List<String>> SUPPORTED_FEATURES_LIST_KEY = new Key<List<String>>("supportedFeaturesList"); - static final Category<VMThreadCapabilities> THREAD_CAPABILITIES = - new Category<>("vm-thread-capabilities", VMThreadCapabilities.class, Key.AGENT_ID, Key.VM_ID, - SUPPORTED_FEATURES_LIST_KEY); /* * vm-thread-summary schema @@ -187,9 +177,6 @@ ThreadHarvestingStatus getLatestHarvestingStatus(VmRef vm); void saveHarvestingStatus(ThreadHarvestingStatus status); - VMThreadCapabilities loadCapabilities(VmRef ref); - void saveCapabilities(VMThreadCapabilities caps); - void saveDeadLockStatus(VmDeadLockData deadLockInfo); /**
--- a/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDAOCategoryRegistration.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDAOCategoryRegistration.java Wed Oct 15 18:55:02 2014 +0200 @@ -54,7 +54,6 @@ public Set<String> getCategoryNames() { Set<String> categories = new HashSet<>(5); categories.add(ThreadDao.DEADLOCK_INFO.getName()); - categories.add(ThreadDao.THREAD_CAPABILITIES.getName()); categories.add(ThreadDao.THREAD_HARVESTING_STATUS.getName()); categories.add(ThreadDao.THREAD_HEADER.getName()); categories.add(ThreadDao.THREAD_STATE.getName());
--- a/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImpl.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImpl.java Wed Oct 15 18:55:02 2014 +0200 @@ -54,7 +54,6 @@ import com.redhat.thermostat.thread.model.ThreadHeader; import com.redhat.thermostat.thread.model.ThreadState; import com.redhat.thermostat.thread.model.ThreadSummary; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; import com.redhat.thermostat.thread.model.VmDeadLockData; import java.util.ArrayList; @@ -68,11 +67,7 @@ private static final Logger logger = LoggingUtils.getLogger(ThreadDaoImpl.class); // Queries - - static final String QUERY_THREAD_CAPS = "QUERY " - + THREAD_CAPABILITIES.getName() + " WHERE '" - + Key.AGENT_ID.getName() + "' = ?s AND '" - + Key.VM_ID.getName() + "' = ?s LIMIT 1"; + static final String QUERY_LATEST_SUMMARY = "QUERY " + THREAD_SUMMARY.getName() + " WHERE '" + Key.AGENT_ID.getName() + "' = ?s AND '" @@ -171,17 +166,7 @@ "'" + Key.VM_ID.getName() + "' = ?s , " + "'" + Key.TIMESTAMP.getName() + "' = ?l , " + "'" + DEADLOCK_DESCRIPTION_KEY.getName() + "' = ?s"; - // REPLACE vm-thread-capabilities SET 'agentId' = ?s , \ - // 'vmId' = ?s , \ - // 'supportedFeaturesList' = ?s[ - // WHERE 'agentId' = ?s AND 'vmId' = ?s - static final String DESC_REPLACE_THREAD_CAPS = "REPLACE " + THREAD_CAPABILITIES.getName() + - " SET '" + Key.AGENT_ID.getName() + "' = ?s , " + - "'" + Key.VM_ID.getName() + "' = ?s , " + - "'" + SUPPORTED_FEATURES_LIST_KEY.getName() + "' = ?s[" + - " WHERE '" + Key.AGENT_ID.getName() + "' = ?s AND " + - "'" + Key.VM_ID.getName() + "' = ?s"; - + static final String ADD_THREAD_HEADER = "ADD " + THREAD_HEADER.getName() + " " + "SET '" + Key.AGENT_ID.getName() + "' = ?s , " + @@ -226,7 +211,6 @@ public ThreadDaoImpl(Storage storage) { this.storage = storage; - storage.registerCategory(THREAD_CAPABILITIES); storage.registerCategory(THREAD_SUMMARY); storage.registerCategory(THREAD_HARVESTING_STATUS); storage.registerCategory(THREAD_HEADER); @@ -484,35 +468,6 @@ } @Override - public VMThreadCapabilities loadCapabilities(VmRef vm) { - PreparedStatement<VMThreadCapabilities> stmt = prepareQuery(THREAD_CAPABILITIES, QUERY_THREAD_CAPS, vm); - if (stmt == null) { - return null; - } - - return getFirstResult(stmt); - } - - @Override - public void saveCapabilities(VMThreadCapabilities caps) { - StatementDescriptor<VMThreadCapabilities> desc = new StatementDescriptor<>(THREAD_CAPABILITIES, DESC_REPLACE_THREAD_CAPS); - PreparedStatement<VMThreadCapabilities> prepared; - try { - prepared = storage.prepareStatement(desc); - prepared.setString(0, caps.getAgentId()); - prepared.setString(1, caps.getVmId()); - prepared.setStringList(2, caps.getSupportedFeaturesList()); - prepared.setString(3, caps.getAgentId()); - prepared.setString(4, caps.getVmId()); - 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 public void saveSummary(ThreadSummary summary) { StatementDescriptor<ThreadSummary> desc = new StatementDescriptor<>(THREAD_SUMMARY, DESC_ADD_THREAD_SUMMARY); PreparedStatement<ThreadSummary> prepared;
--- a/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImplStatementDescriptorRegistration.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/main/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImplStatementDescriptorRegistration.java Wed Oct 15 18:55:02 2014 +0200 @@ -60,11 +60,9 @@ descs.add(ThreadDaoImpl.QUERY_LATEST_HARVESTING_STATUS); descs.add(ThreadDaoImpl.QUERY_LATEST_SUMMARY); descs.add(ThreadDaoImpl.QUERY_SUMMARY_SINCE); - descs.add(ThreadDaoImpl.QUERY_THREAD_CAPS); descs.add(ThreadDaoImpl.DESC_ADD_THREAD_DEADLOCK_DATA); descs.add(ThreadDaoImpl.DESC_ADD_THREAD_HARVESTING_STATUS); descs.add(ThreadDaoImpl.DESC_ADD_THREAD_SUMMARY); - descs.add(ThreadDaoImpl.DESC_REPLACE_THREAD_CAPS); descs.add(ThreadDaoImpl.ADD_THREAD_HEADER); descs.add(ThreadDaoImpl.QUERY_THREAD_HEADER);
--- a/thread/collector/src/main/java/com/redhat/thermostat/thread/model/VMThreadCapabilities.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.model; - -import com.redhat.thermostat.storage.core.Entity; -import com.redhat.thermostat.storage.core.Persist; -import com.redhat.thermostat.storage.model.BasePojo; -import com.redhat.thermostat.thread.dao.ThreadDao; - -@Entity -public class VMThreadCapabilities extends BasePojo { - - private String[] features; - private String vmId; - - public VMThreadCapabilities() { - this(null); - } - - public VMThreadCapabilities(String writerId) { - super(writerId); - } - - @Persist - public void setVmId(String vmId) { - this.vmId = vmId; - } - - @Persist - public String getVmId() { - return vmId; - } - - public boolean supportCPUTime() { - return hasFeature(ThreadDao.CPU_TIME); - } - - public boolean supportContentionMonitor() { - return hasFeature(ThreadDao.CONTENTION_MONITOR); - } - - public String toString() { - return "[supportCPU: " + supportCPUTime() + ", supportContention: " + supportContentionMonitor() + - ", supportThreadAllocatedMemory: " + supportThreadAllocatedMemory() + "]"; - } - - public boolean supportThreadAllocatedMemory() { - return hasFeature(ThreadDao.THREAD_ALLOCATED_MEMORY); - } - - private boolean hasFeature(String feature) { - for (String f : features) { - if (f.equals(feature)) { - return true; - } - } - return false; - } - - @Persist - public String[] getSupportedFeaturesList() { - return features; - } - - @Persist - public void setSupportedFeaturesList(String[] features) { - this.features = features; - } - -} -
--- a/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDAOCategoryRegistrationTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDAOCategoryRegistrationTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -58,10 +58,9 @@ public void registersAllCategories() { ThreadDAOCategoryRegistration reg = new ThreadDAOCategoryRegistration(); Set<String> categories = reg.getCategoryNames(); - assertEquals(7, categories.size()); + assertEquals(6, categories.size()); assertFalse("null descriptor not allowed", categories.contains(null)); assertTrue(categories.contains(ThreadDao.DEADLOCK_INFO.getName())); - assertTrue(categories.contains(ThreadDao.THREAD_CAPABILITIES.getName())); assertTrue(categories.contains(ThreadDao.THREAD_HEADER.getName())); assertTrue(categories.contains(ThreadDao.THREAD_STATE.getName())); assertTrue(categories.contains(ThreadDao.THREAD_SUMMARY.getName())); @@ -93,7 +92,7 @@ // storage-core + this module assertEquals(2, registrations.size()); assertNotNull(threadCatReg); - assertEquals(7, threadCatReg.getCategoryNames().size()); + assertEquals(6, threadCatReg.getCategoryNames().size()); } }
--- a/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDAOImplStatementDescriptorRegistrationTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDAOImplStatementDescriptorRegistrationTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -77,7 +77,7 @@ public void registersAllDescriptors() { ThreadDaoImplStatementDescriptorRegistration reg = new ThreadDaoImplStatementDescriptorRegistration(); Set<String> descriptors = reg.getStatementDescriptors(); - assertEquals(21, descriptors.size()); + assertEquals(19, descriptors.size()); assertFalse("null descriptor not allowed", descriptors.contains(null)); } @@ -105,7 +105,7 @@ // storage-core + this module assertEquals(2, registrations.size()); assertNotNull(threadDaoReg); - assertEquals(21, threadDaoReg.getStatementDescriptors().size()); + assertEquals(19, threadDaoReg.getStatementDescriptors().size()); } private Triple<String, String, PreparedParameter[]> setupForMetaDataTest() { @@ -139,15 +139,6 @@ } @Test - public void canGetMetadataForThreadCapsQuery() { - Triple<String, String, PreparedParameter[]> triple = setupForMetaDataTest(); - - StatementDescriptorMetadataFactory factory = new ThreadDaoImplStatementDescriptorRegistration(); - DescriptorMetadata data = factory.getDescriptorMetadata(ThreadDaoImpl.QUERY_THREAD_CAPS, triple.third); - assertThreadMetadata(triple, data); - } - - @Test public void canGetMetadataForLatestHarvestingStatusQuery() { Triple<String, String, PreparedParameter[]> triple = setupForMetaDataTest();
--- a/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImplTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/impl/ThreadDaoImplTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -45,28 +45,22 @@ import com.redhat.thermostat.storage.core.StatementExecutionException; import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.storage.core.VmRef; -import com.redhat.thermostat.storage.model.AgentInformation; import com.redhat.thermostat.storage.model.Pojo; import com.redhat.thermostat.thread.dao.ThreadDao; import com.redhat.thermostat.thread.model.ThreadHarvestingStatus; import com.redhat.thermostat.thread.model.ThreadHeader; import com.redhat.thermostat.thread.model.ThreadState; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; import com.redhat.thermostat.thread.model.VmDeadLockData; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; -import java.util.List; -import java.util.NoSuchElementException; - import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -94,8 +88,6 @@ @Test public void preparedQueryDescriptorsAreSane() { - String expectedQueryThreadCaps = "QUERY vm-thread-capabilities WHERE 'agentId' = ?s AND 'vmId' = ?s LIMIT 1"; - assertEquals(expectedQueryThreadCaps, ThreadDaoImpl.QUERY_THREAD_CAPS); String expectedQueryLatestSummary = "QUERY vm-thread-summary WHERE 'agentId' = ?s AND 'vmId' = ?s SORT 'timeStamp' DSC LIMIT 1"; assertEquals(expectedQueryLatestSummary, ThreadDaoImpl.QUERY_LATEST_SUMMARY); @@ -146,12 +138,6 @@ "'timeStamp' = ?l , " + "'deadLockDescription' = ?s"; assertEquals(addDeadlockData, ThreadDaoImpl.DESC_ADD_THREAD_DEADLOCK_DATA); - String replaceThreadCaps = "REPLACE vm-thread-capabilities SET 'agentId' = ?s , "+ - "'vmId' = ?s , " + - "'supportedFeaturesList' = ?s[" + - " WHERE 'agentId' = ?s AND 'vmId' = ?s"; - assertEquals(replaceThreadCaps, ThreadDaoImpl.DESC_REPLACE_THREAD_CAPS); - String addThreadState = "ADD vm-thread-state SET 'agentId' = ?s , " + "'vmId' = ?s , 'state' = ?s , " + @@ -189,39 +175,9 @@ @SuppressWarnings("unused") ThreadDaoImpl dao = new ThreadDaoImpl(storage); - verify(storage).registerCategory(ThreadDao.THREAD_CAPABILITIES); verify(storage).registerCategory(ThreadDao.THREAD_HARVESTING_STATUS); verify(storage).registerCategory(ThreadDao.THREAD_SUMMARY); } - - @Test - public void testLoadVMCapabilities() throws DescriptorParsingException, StatementExecutionException { - @SuppressWarnings("unchecked") - PreparedStatement<VMThreadCapabilities> stmt = (PreparedStatement<VMThreadCapabilities>) mock(PreparedStatement.class); - Storage storage = mock(Storage.class); - when(storage.prepareStatement(anyDescriptor(VMThreadCapabilities.class))).thenReturn(stmt); - - VMThreadCapabilities expected = new VMThreadCapabilities(AGENT_ID); - expected.setSupportedFeaturesList(new String[] { ThreadDao.CPU_TIME, ThreadDao.THREAD_ALLOCATED_MEMORY }); - @SuppressWarnings("unchecked") - Cursor<VMThreadCapabilities> cursor = (Cursor<VMThreadCapabilities>) mock(Cursor.class); - when(cursor.hasNext()).thenReturn(true).thenReturn(false); - when(cursor.next()).thenReturn(expected).thenReturn(null); - when(stmt.executeQuery()).thenReturn(cursor); - - ThreadDaoImpl dao = new ThreadDaoImpl(storage); - VMThreadCapabilities caps = dao.loadCapabilities(vmRef); - - verify(storage).prepareStatement(anyDescriptor(VMThreadCapabilities.class)); - verify(stmt).setString(0, AGENT_ID); - verify(stmt).setString(1, VM_ID); - verify(stmt).executeQuery(); - verifyNoMoreInteractions(stmt); - - assertFalse(caps.supportContentionMonitor()); - assertTrue(caps.supportCPUTime()); - assertTrue(caps.supportThreadAllocatedMemory()); - } @SuppressWarnings("unchecked") private <T extends Pojo> StatementDescriptor<T> anyDescriptor(Class<T> type) { @@ -229,71 +185,6 @@ } @Test - public void testLoadVMCapabilitiesWithoutAnyDataInStorage() throws DescriptorParsingException, StatementExecutionException { - @SuppressWarnings("unchecked") - PreparedStatement<VMThreadCapabilities> stmt = (PreparedStatement<VMThreadCapabilities>) mock(PreparedStatement.class); - Storage storage = mock(Storage.class); - when(storage.prepareStatement(anyDescriptor(VMThreadCapabilities.class))).thenReturn(stmt); - - VMThreadCapabilities expected = new VMThreadCapabilities(AGENT_ID); - expected.setSupportedFeaturesList(new String[] { ThreadDao.CPU_TIME, ThreadDao.THREAD_ALLOCATED_MEMORY }); - @SuppressWarnings("unchecked") - Cursor<VMThreadCapabilities> cursor = (Cursor<VMThreadCapabilities>) mock(Cursor.class); - when(cursor.hasNext()).thenReturn(false); - when(cursor.next()).thenThrow(new NoSuchElementException()); - when(stmt.executeQuery()).thenReturn(cursor); - - ThreadDaoImpl dao = new ThreadDaoImpl(storage); - VMThreadCapabilities caps = dao.loadCapabilities(vmRef); - - verify(storage).prepareStatement(anyDescriptor(VMThreadCapabilities.class)); - verify(stmt).setString(0, AGENT_ID); - verify(stmt).setString(1, VM_ID); - verify(stmt).executeQuery(); - verifyNoMoreInteractions(stmt); - - assertEquals(null, caps); - } - - @SuppressWarnings("unchecked") - @Test - public void testSaveVMCapabilities() throws DescriptorParsingException, StatementExecutionException { - Storage storage = mock(Storage.class); - PreparedStatement<AgentInformation> replace = mock(PreparedStatement.class); - when(storage.prepareStatement(any(StatementDescriptor.class))).thenReturn(replace); - - VMThreadCapabilities caps = new VMThreadCapabilities(AGENT_ID); - String[] capsFeatures = new String[] { - ThreadDao.CONTENTION_MONITOR, - ThreadDao.CPU_TIME, - ThreadDao.THREAD_ALLOCATED_MEMORY, - }; - caps.setSupportedFeaturesList(capsFeatures); - assertTrue(caps.supportContentionMonitor()); - assertTrue(caps.supportCPUTime()); - assertTrue(caps.supportThreadAllocatedMemory()); - caps.setVmId(VM_ID); - - ThreadDaoImpl dao = new ThreadDaoImpl(storage); - dao.saveCapabilities(caps); - - @SuppressWarnings("rawtypes") - ArgumentCaptor<StatementDescriptor> captor = ArgumentCaptor.forClass(StatementDescriptor.class); - - verify(storage).prepareStatement(captor.capture()); - StatementDescriptor<?> desc = captor.getValue(); - assertEquals(ThreadDaoImpl.DESC_REPLACE_THREAD_CAPS, desc.getDescriptor()); - - verify(replace).setString(0, caps.getAgentId()); - verify(replace).setString(1, caps.getVmId()); - verify(replace).setStringList(2, caps.getSupportedFeaturesList()); - verify(replace).setString(3, caps.getAgentId()); - verify(replace).setString(4, caps.getVmId()); - verify(replace).execute(); - verifyNoMoreInteractions(replace); - } - - @Test public void testLoadLatestDeadLockStatusWithNoData() throws Exception { Storage storage = mock(Storage.class); @SuppressWarnings("unchecked")
--- a/thread/collector/src/test/java/com/redhat/thermostat/thread/model/ThreadModelPojosTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/collector/src/test/java/com/redhat/thermostat/thread/model/ThreadModelPojosTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -50,7 +50,6 @@ ThreadHeader.class, ThreadSummary.class, ThreadContentionSample.class, - VMThreadCapabilities.class, VmDeadLockData.class, };
--- a/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/Harvester.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/Harvester.java Wed Oct 15 18:55:02 2014 +0200 @@ -71,7 +71,6 @@ private HarvesterHelper harvesterHelper; private final MXBeanConnectionPool connectionPool; private final DeadlockHelper deadlockHelper; - private final VMCapsHelper vmCapsHelper; public Harvester(ThreadDao threadDao, ScheduledExecutorService threadPool, String vmId, int pid, MXBeanConnectionPool connectionPool, @@ -79,22 +78,19 @@ { this(pid, threadPool, connectionPool, new HarvesterHelper(threadDao, new SystemClock(), vmId, writerId), - new DeadlockHelper(threadDao, new SystemClock(), vmId, writerId), - new VMCapsHelper(threadDao, new SystemClock(), vmId, writerId)); + new DeadlockHelper(threadDao, new SystemClock(), vmId, writerId)); } Harvester(int pid, ScheduledExecutorService threadPool, MXBeanConnectionPool connectionPool, HarvesterHelper harvesterHelper, - DeadlockHelper deadlockHelper, - VMCapsHelper vmCapsHelper) + DeadlockHelper deadlockHelper) { this.pid = pid; this.threadPool = threadPool; this.connectionPool = connectionPool; this.harvesterHelper = harvesterHelper; this.deadlockHelper = deadlockHelper; - this.vmCapsHelper = vmCapsHelper; } synchronized boolean start() { @@ -230,27 +226,6 @@ } } } - - synchronized void saveVmCaps() { - - boolean disconnectAtEnd = false; - if (!isConnected()) { - disconnectAtEnd = true; - connect(); - } - - if (collectorBean == null) { - collectorBean = getDataCollectorBean(connection); - } - - if (collectorBean != null) { - vmCapsHelper.saveVMCapabilities(collectorBean); - } - - if (disconnectAtEnd) { - disconnect(); - } - } public boolean saveDeadLockData() { boolean disconnectAtEnd = false;
--- a/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/ThreadBackend.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/ThreadBackend.java Wed Oct 15 18:55:02 2014 +0200 @@ -119,7 +119,6 @@ switch (newStatus) { case VM_STARTED: case VM_ACTIVE: /* this is blocking */ - harvester.saveVmCaps(vmId, pid); harvester.addThreadHarvestingStatus(vmId); break; case VM_STOPPED:
--- a/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/ThreadHarvester.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/ThreadHarvester.java Wed Oct 15 18:55:02 2014 +0200 @@ -163,11 +163,6 @@ } return result; } - - void saveVmCaps(String vmId, int pid) { - Harvester harvester = getHarvester(vmId, pid); - harvester.saveVmCaps(); - } /** * Stops and detaches a harvester from the given PID.
--- a/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/VMCapsHelper.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.harvester; - -import com.redhat.thermostat.common.SystemClock; -import com.redhat.thermostat.storage.core.WriterID; -import com.redhat.thermostat.thread.dao.ThreadDao; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; -import java.lang.management.ThreadMXBean; -import java.util.ArrayList; -import java.util.List; - -/** - */ -public class VMCapsHelper { - - private final ThreadDao threadDao; - private final SystemClock systemClock; - private final String vmId; - private final WriterID writerId; - - public VMCapsHelper(ThreadDao threadDao, SystemClock systemClock, String vmId, WriterID writerId) { - - this.threadDao = threadDao; - this.systemClock = systemClock; - this.vmId = vmId; - this.writerId = writerId; - } - - public void saveVMCapabilities(ThreadMXBean collectorBean) { - - VMThreadCapabilities caps = new VMThreadCapabilities(writerId.getWriterID()); - - List<String> features = new ArrayList<>(); - if (collectorBean.isThreadCpuTimeSupported()) { - features.add(ThreadDao.CPU_TIME); - } - - if (collectorBean.isThreadContentionMonitoringSupported()) { - features.add(ThreadDao.CONTENTION_MONITOR); - } - - if (collectorBean instanceof com.sun.management.ThreadMXBean) { - com.sun.management.ThreadMXBean sunBean = - (com.sun.management.ThreadMXBean) collectorBean; - try { - if (sunBean.isThreadAllocatedMemorySupported()) { - features.add(ThreadDao.THREAD_ALLOCATED_MEMORY); - } - } catch (Exception ignore) {} - } - - caps.setSupportedFeaturesList(features.toArray(new String[features.size()])); - caps.setVmId(vmId); - - threadDao.saveCapabilities(caps); - } -}
--- a/thread/harvester/src/test/java/com/redhat/thermostat/thread/harvester/HarvesterTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/harvester/src/test/java/com/redhat/thermostat/thread/harvester/HarvesterTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -71,7 +71,6 @@ private MXBeanConnectionPool pool; private MXBeanConnection connection; private DeadlockHelper deadlockHelper; - private VMCapsHelper vmCapsHelper; @Before public void setup() throws Exception { @@ -81,7 +80,6 @@ int pid = 42; deadlockHelper = mock(DeadlockHelper.class); - vmCapsHelper = mock(VMCapsHelper.class); executor = mock(ScheduledExecutorService.class); dao = mock(ThreadDao.class); @@ -105,7 +103,7 @@ HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper); + deadlockHelper); harvester.start(); @@ -129,7 +127,7 @@ HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper); + deadlockHelper); harvester.start(); harvester.start(); @@ -154,7 +152,7 @@ HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper); + deadlockHelper); harvester.start(); assertTrue(harvester.isConnected()); @@ -178,7 +176,7 @@ HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper); + deadlockHelper); harvester.start(); assertTrue(harvester.isConnected()); @@ -204,7 +202,7 @@ HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper); + deadlockHelper); assertFalse(harvester.isConnected()); @@ -238,7 +236,7 @@ HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper); + deadlockHelper); harvester.start(); @@ -274,7 +272,7 @@ HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper); + deadlockHelper); harvester.start(); @@ -287,57 +285,12 @@ } @Test - public void testSaveDeadlockVmCaps() { - - final ThreadMXBean mxBean = mock(ThreadMXBean.class); - HarvesterHelper helper = mock(HarvesterHelper.class); - Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper) - { - @Override - ThreadMXBean getDataCollectorBean(MXBeanConnection connection) { - return mxBean; - } - - @Override - synchronized boolean isConnected() { - return true; - } - }; - - harvester.saveVmCaps(); - - verify(vmCapsHelper).saveVMCapabilities(mxBean); - } - - @Test - public void testSaveDeadlockVmCapsUnconnectedWillDisconnectAgain() throws Exception { - - final ThreadMXBean mxBean = mock(ThreadMXBean.class); - HarvesterHelper helper = mock(HarvesterHelper.class); - Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper) - { - @Override - ThreadMXBean getDataCollectorBean(MXBeanConnection connection) { - return mxBean; - } - }; - - harvester.saveVmCaps(); - - verify(pool).acquire(pid); - verify(vmCapsHelper).saveVMCapabilities(mxBean); - verify(pool).release(pid, connection); - } - - @Test public void testSaveDeadlockData() { final ThreadMXBean mxBean = mock(ThreadMXBean.class); HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper) + deadlockHelper) { @Override ThreadMXBean getDataCollectorBean(MXBeanConnection connection) { @@ -361,7 +314,7 @@ final ThreadMXBean mxBean = mock(ThreadMXBean.class); HarvesterHelper helper = mock(HarvesterHelper.class); Harvester harvester = new Harvester(pid, executor, pool, helper, - deadlockHelper, vmCapsHelper) + deadlockHelper) { @Override ThreadMXBean getDataCollectorBean(MXBeanConnection connection) {
--- a/thread/harvester/src/test/java/com/redhat/thermostat/thread/harvester/ThreadBackendTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/harvester/src/test/java/com/redhat/thermostat/thread/harvester/ThreadBackendTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -109,7 +109,6 @@ public void testVmStarts() { backend.vmStatusChanged(Status.VM_STARTED, "vmId", 10); - verify(threadHarvester).saveVmCaps("vmId", 10); verify(threadHarvester).addThreadHarvestingStatus("vmId"); }
--- a/thread/harvester/src/test/java/com/redhat/thermostat/thread/harvester/ThreadHarvesterTest.java Wed Oct 15 10:24:54 2014 -0400 +++ b/thread/harvester/src/test/java/com/redhat/thermostat/thread/harvester/ThreadHarvesterTest.java Wed Oct 15 18:55:02 2014 +0200 @@ -186,32 +186,6 @@ } @Test - public void testSaveVmCaps() { - ThreadDao dao = mock(ThreadDao.class); - - final boolean[] createHarvesterCalled = new boolean[1]; - final Harvester harvester = mock(Harvester.class); - - ThreadHarvester threadHarvester = new ThreadHarvester(executor, pool, writerId) { - @Override - Harvester createHarvester(String vmId, int pid) { - - createHarvesterCalled[0] = true; - assertEquals("vmId", vmId); - assertEquals(42, pid); - - return harvester; - } - }; - threadHarvester.setThreadDao(dao); - threadHarvester.saveVmCaps("vmId", 42); - - assertTrue(createHarvesterCalled[0]); - - verify(harvester).saveVmCaps(); - } - - @Test public void testReceiveWithoutDaosFails() { ThreadHarvester harvester = new ThreadHarvester(executor, pool, writerId); Response response = harvester.receive(mock(Request.class));
--- a/thread/harvester/src/test/java/com/redhat/thermostat/thread/harvester/VMCapsHelperTest.java Wed Oct 15 10:24:54 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright 2012-2014 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.thread.harvester; - -import com.redhat.thermostat.common.SystemClock; -import com.redhat.thermostat.storage.core.WriterID; -import com.redhat.thermostat.thread.dao.ThreadDao; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; -import java.lang.management.ThreadMXBean; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class VMCapsHelperTest { - - private static final String DEFAULT_W_ID = "0xcafe"; - private static final long TIME_IN_MILLIS = 101010l; - - private String vmId; - private WriterID writerId; - private ThreadDao threadDao; - private SystemClock clock; - - private ThreadMXBean collectorBean; - - @Before - public void setUp() throws Exception { - - clock = mock(SystemClock.class); - when(clock.getRealTimeMillis()).thenReturn(TIME_IN_MILLIS); - - vmId = "testVM"; - writerId = mock(WriterID.class); - when(writerId.getWriterID()).thenReturn(DEFAULT_W_ID); - - threadDao = mock(ThreadDao.class); - - collectorBean = mock(ThreadMXBean.class); - } - - @Test - public void testSaveVMCapabilities() throws Exception { - - ArgumentCaptor<VMThreadCapabilities> capsCapture = - ArgumentCaptor.forClass(VMThreadCapabilities.class); - - doNothing().when(threadDao).saveCapabilities(capsCapture.capture()); - - final ThreadMXBean collectorBean = mock(ThreadMXBean.class); - when(collectorBean.isThreadCpuTimeSupported()).thenReturn(true); - when(collectorBean.isThreadContentionMonitoringSupported()).thenReturn(true); - - final boolean [] getDataCollectorBeanCalled = new boolean[1]; - - VMCapsHelper vmCapsHelper = new VMCapsHelper(threadDao, clock, vmId, writerId); - - vmCapsHelper.saveVMCapabilities(collectorBean); - - verify(threadDao, times(1)).saveCapabilities(any(VMThreadCapabilities.class)); - assertEquals(vmId, capsCapture.getValue().getVmId()); - - String[] features = capsCapture.getValue().getSupportedFeaturesList(); - assertEquals(2, features.length); - assertEquals(ThreadDao.CPU_TIME, features[0]); - assertEquals(ThreadDao.CONTENTION_MONITOR, features[1]); - } -}