Mercurial > hg > release > thermostat-0.5
changeset 804:094d4af7f231
Move VM GC into its own bundle
This commit moves the VM GC controller/view into its own core and swing
client bundles in the top-level directory of the Thermostat source tree.
This commit also moves the remote GC work under this top-level directory.
This commit adds a VmInformationService which the swing bundle uses to
register the controller dynamically. Strings specific to VM GC have been
removed from the client-core resource bundle. VmMemoryStatDAO and
VmGcStatDAO have been removed from VmInformationServiceController and
UiFacadeFactory.
Reviewed-by: jerboaa, vanaltj
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-November/004288.html
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/views/VmGcView.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright 2012 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.client.core.views; - -import java.util.List; - -import com.redhat.thermostat.storage.model.IntervalTimeData; - -public abstract class VmGcView extends BasicView implements UIComponent { - - public abstract void addChart(String tag, String title, String valueUnit); - - public abstract void removeChart(String tag); - - public abstract void addData(String tag, List<IntervalTimeData<Double>> data); - - public abstract void clearData(String tag); - -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/views/VmGcViewProvider.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2012 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.client.core.views; - -public interface VmGcViewProvider extends ViewProvider { - - @Override - public VmGcView createView(); - -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Tue Nov 27 14:51:18 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Tue Nov 27 14:54:58 2012 -0500 @@ -65,16 +65,6 @@ MENU_HELP, MENU_HELP_ABOUT, - GARBAGE_COLLECTION, - YOUNG_GEN, - EDEN_GEN, - S0_GEN, - S1_GEN, - OLD_GEN, - PERM_GEN, - UNKNOWN_GEN, - SOME_GENERATION, - SECONDS, MINUTES, HOURS, @@ -110,14 +100,6 @@ HOST_INFO_TAB_IO, - VM_INFO_TAB_GC, - - VM_GC_TITLE, - - VM_GC_COLLECTOR_OVER_GENERATION, - VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL, - VM_GC_COLLECTOR_CHART_GC_TIME_LABEL, - AGENT_INFO_WINDOW_TITLE, AGENT_INFO_AGENTS_LIST, AGENT_INFO_AGENT_SECTION_TITLE,
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/UiFacadeFactory.java Tue Nov 27 14:51:18 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/UiFacadeFactory.java Tue Nov 27 14:54:58 2012 -0500 @@ -43,9 +43,7 @@ import com.redhat.thermostat.client.osgi.service.VMContextAction; import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmGcStatDAO; import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmMemoryStatDAO; import com.redhat.thermostat.common.dao.VmRef; public interface UiFacadeFactory { @@ -53,8 +51,6 @@ void setHostInfoDao(HostInfoDAO hostInfoDao); void setVmInfoDao(VmInfoDAO vmInfoDAO); - void setVmMemoryStatDao(VmMemoryStatDAO vmMemoryStatDao); - void setVmGcStatDao(VmGcStatDAO vmGcStatDao); public MainWindowController getMainWindow();
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/VmGcController.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,197 +0,0 @@ -/* - * Copyright 2012 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.client.ui; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.concurrent.TimeUnit; - -import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.client.core.views.VmGcView; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; -import com.redhat.thermostat.client.core.views.BasicView.Action; -import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.common.ActionEvent; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.NotImplementedException; -import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.appctx.ApplicationContext; -import com.redhat.thermostat.common.dao.VmGcStatDAO; -import com.redhat.thermostat.common.dao.VmMemoryStatDAO; -import com.redhat.thermostat.common.dao.VmRef; -import com.redhat.thermostat.common.locale.Translate; -import com.redhat.thermostat.storage.model.IntervalTimeData; -import com.redhat.thermostat.storage.model.TimeStampedPojoComparator; -import com.redhat.thermostat.storage.model.VmGcStat; -import com.redhat.thermostat.storage.model.VmMemoryStat; -import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; - -public class VmGcController { - - private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); - - private final VmRef ref; - private final VmGcView view; - - private final VmGcStatDAO gcDao; - private final VmMemoryStatDAO memDao; - - private final Set<String> addedCollectors = new TreeSet<>(); - // the last value seen for each collector - private final Map<String, VmGcStat> lastValueSeen = new TreeMap<>(); - - private final Timer timer; - - private long lastSeenTimeStamp = Long.MIN_VALUE; - - public VmGcController(VmMemoryStatDAO vmMemoryStatDao, VmGcStatDAO vmGcStatDao, VmRef ref, VmGcViewProvider provider) { - this.ref = ref; - this.view = provider.createView(); - this.timer = ApplicationContext.getInstance().getTimerFactory().createTimer(); - - gcDao = vmGcStatDao; - memDao = vmMemoryStatDao; - - view.addActionListener(new ActionListener<VmGcView.Action>() { - @Override - public void actionPerformed(ActionEvent<Action> actionEvent) { - switch (actionEvent.getActionId()) { - case HIDDEN: - stop(); - break; - case VISIBLE: - start(); - break; - default: - throw new NotImplementedException("unkonwn action: " + actionEvent.getActionId()); - } - } - }); - - timer.setAction(new Runnable() { - @Override - public void run() { - try { - doUpdateCollectorData(); - } catch (Throwable t) { - t.printStackTrace(); - throw t; - } - } - }); - timer.setSchedulingType(SchedulingType.FIXED_RATE); - timer.setInitialDelay(0); - timer.setDelay(5); - timer.setTimeUnit(TimeUnit.SECONDS); - } - - private void start() { - timer.start(); - } - - private void stop() { - timer.stop(); - } - - // FIXME - private String chartName(String collectorName, String generationName) { - return translator.localize(LocaleResources.VM_GC_COLLECTOR_OVER_GENERATION, - collectorName, generationName); - } - - private void doUpdateCollectorData() { - Map<String, List<IntervalTimeData<Double>>> dataToAdd = new HashMap<>(); - List<VmGcStat> sortedList = gcDao.getLatestVmGcStats(ref, lastSeenTimeStamp); - Collections.sort(sortedList, new TimeStampedPojoComparator<>()); - - for (VmGcStat stat : sortedList) { - String collector = stat.getCollectorName(); - List<IntervalTimeData<Double>> data = dataToAdd.get(collector); - if (data == null) { - data = new ArrayList<>(); - dataToAdd.put(collector, data); - } - if (lastValueSeen.containsKey(collector)) { - if (stat.getTimeStamp() <= lastValueSeen.get(collector).getTimeStamp()) { - System.out.println("new gc collector value is older than previous value"); - } - VmGcStat last = lastValueSeen.get(collector); - lastSeenTimeStamp = Math.max(lastSeenTimeStamp, stat.getTimeStamp()); - long diffInMicro = (stat.getWallTime() - last.getWallTime()); - double diffInMillis = diffInMicro / 1000.0; - // TODO there is not much point in adding data when diff is 0, - // but we need to make the chart scroll automatically based on - // the current time when we do that - // if (diff != 0) { - data.add(new IntervalTimeData<>(last.getTimeStamp(), stat.getTimeStamp(), diffInMillis)); - // } - } - lastValueSeen.put(collector, stat); - } - for (Map.Entry<String, List<IntervalTimeData<Double>>> entry : dataToAdd.entrySet()) { - String name = entry.getKey(); - if (!addedCollectors.contains(name)) { - view.addChart(name, chartName(name, getCollectorGeneration(name)), "ms"); - addedCollectors.add(name); - } - view.addData(entry.getKey(), entry.getValue()); - } - } - - public String getCollectorGeneration(String collectorName) { - VmMemoryStat info = memDao.getLatestMemoryStat(ref); - - for (Generation g: info.getGenerations()) { - if (g.getCollector().equals(collectorName)) { - return g.getName(); - } - } - return translator.localize(LocaleResources.UNKNOWN_GEN); - } - - public UIComponent getView() { - return (UIComponent) view; - } - -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Tue Nov 27 14:51:18 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Tue Nov 27 14:54:58 2012 -0500 @@ -41,34 +41,21 @@ import com.redhat.thermostat.client.core.VmInformationService; import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; import com.redhat.thermostat.client.core.views.VmInformationView; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; -import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.common.dao.VmGcStatDAO; -import com.redhat.thermostat.common.dao.VmMemoryStatDAO; import com.redhat.thermostat.common.dao.VmRef; -import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.utils.OSGIUtils; public class VmInformationController { - private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); - private final VmInformationView view; - private final VmGcController gcController; - - public VmInformationController(UiFacadeFactory uiFacadeFactory, VmMemoryStatDAO vmMemoryStatDao, VmGcStatDAO vmGcStatDao, VmRef vmRef, VmInformationViewProvider provider) { - this(OSGIUtils.getInstance(), uiFacadeFactory, vmMemoryStatDao, vmGcStatDao, vmRef, provider); + public VmInformationController(UiFacadeFactory uiFacadeFactory, VmRef vmRef, VmInformationViewProvider provider) { + this(OSGIUtils.getInstance(), uiFacadeFactory, vmRef, provider); } - VmInformationController(OSGIUtils serviceProvider, UiFacadeFactory uiFacadeFactory, VmMemoryStatDAO vmMemoryStatDao, VmGcStatDAO vmGcStatDao, VmRef vmRef, VmInformationViewProvider provider) { - VmGcViewProvider vmGCProvider = serviceProvider.getService(VmGcViewProvider.class); - gcController = new VmGcController(vmMemoryStatDao, vmGcStatDao, vmRef, vmGCProvider); - + VmInformationController(OSGIUtils serviceProvider, UiFacadeFactory uiFacadeFactory, VmRef vmRef, VmInformationViewProvider provider) { view = provider.createView(); - view.addChildView(translator.localize(LocaleResources.VM_INFO_TAB_GC), gcController.getView()); Collection<VmInformationService> vmInfoServices = uiFacadeFactory.getVmInformationServices(); for (VmInformationService vmInfoService : vmInfoServices) {
--- a/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Tue Nov 27 14:51:18 2012 -0500 +++ b/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Tue Nov 27 14:54:58 2012 -0500 @@ -23,16 +23,6 @@ MENU_HELP = Help MENU_HELP_ABOUT = About -GARBAGE_COLLECTION = Garbage Collection -YOUNG_GEN = Young -EDEN_GEN = Eden -S0_GEN = Survivor 0 -S1_GEN = Survivor 1 -OLD_GEN = Tenured -PERM_GEN = Permanent -UNKNOWN_GEN = Unknown -SOME_GENERATION = {0} Generation - SECONDS = Seconds MINUTES = Minutes HOURS = Hours @@ -68,13 +58,6 @@ HOST_INFO_TAB_IO = IO -VM_INFO_TAB_GC = GC - -VM_GC_TITLE = Garbage Collection in the VM -VM_GC_COLLECTOR_OVER_GENERATION = Collector {0} running on {1} -VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL = Time -VM_GC_COLLECTOR_CHART_GC_TIME_LABEL = GC Time ({0}) - AGENT_INFO_WINDOW_TITLE = Known Agents AGENT_INFO_AGENTS_LIST = Agents AGENT_INFO_AGENT_SECTION_TITLE = Agent Information
--- a/client/core/src/test/java/com/redhat/thermostat/client/ui/VmGcControllerTest.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -/* - * Copyright 2012 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.client.ui; - -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; -import static org.mockito.Matchers.isNotNull; -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 java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -import com.redhat.thermostat.client.core.views.VmGcView; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; -import com.redhat.thermostat.common.ActionEvent; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.TimerFactory; -import com.redhat.thermostat.common.appctx.ApplicationContext; -import com.redhat.thermostat.common.appctx.ApplicationContextUtil; -import com.redhat.thermostat.common.dao.VmGcStatDAO; -import com.redhat.thermostat.common.dao.VmMemoryStatDAO; -import com.redhat.thermostat.common.dao.VmRef; -import com.redhat.thermostat.storage.model.VmGcStat; -import com.redhat.thermostat.storage.model.VmMemoryStat; -import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; - -public class VmGcControllerTest { - - private Timer timer; - private Runnable timerAction; - private VmGcView view; - private ActionListener<VmGcView.Action> viewListener; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Before - public void setUp() { - ApplicationContextUtil.resetApplicationContext(); - - // Setup Timer - timer = mock(Timer.class); - ArgumentCaptor<Runnable> timerActionCaptor = ArgumentCaptor.forClass(Runnable.class); - doNothing().when(timer).setAction(timerActionCaptor.capture()); - - TimerFactory timerFactory = mock(TimerFactory.class); - when(timerFactory.createTimer()).thenReturn(timer); - ApplicationContext.getInstance().setTimerFactory(timerFactory); - - // Set up fake data - List<VmGcStat> stats = new ArrayList<>(); - VmGcStat stat1 = new VmGcStat(42, 1, "collector1", 1, 10); - VmGcStat stat2 = new VmGcStat(42, 2, "collector1", 5, 20); - stats.add(stat1); - stats.add(stat2); - - Generation gen; - gen = new Generation(); - gen.setName("generation 1"); - gen.setCollector("collector1"); - VmMemoryStat memoryStat = new VmMemoryStat(1, 42, new Generation[] { gen }); - - // Setup DAO - VmGcStatDAO vmGcStatDAO = mock(VmGcStatDAO.class); - when(vmGcStatDAO.getLatestVmGcStats(isA(VmRef.class), eq(Long.MIN_VALUE))).thenReturn(stats); - VmMemoryStatDAO vmMemoryStatDAO = mock(VmMemoryStatDAO.class); - when(vmMemoryStatDAO.getLatestMemoryStat(isA(VmRef.class))).thenReturn(memoryStat); - - // Setup View - view = mock(VmGcView.class); - ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class); - doNothing().when(view).addActionListener(viewArgumentCaptor.capture()); - - VmGcViewProvider viewProvider = mock(VmGcViewProvider.class); - when(viewProvider.createView()).thenReturn(view); - - // Now start the controller - VmRef ref = mock(VmRef.class); - - new VmGcController(vmMemoryStatDAO, vmGcStatDAO, ref, viewProvider); - - // Extract relevant objects - viewListener = viewArgumentCaptor.getValue(); - timerAction = timerActionCaptor.getValue(); - } - - @After - public void tearDown() { - ApplicationContextUtil.resetApplicationContext(); - } - - @Test - public void verifyTimer() { - verify(timer).setAction(isNotNull(Runnable.class)); - verify(timer).setAction(isA(Runnable.class)); - verify(timer).setDelay(5); - verify(timer).setInitialDelay(0); - verify(timer).setTimeUnit(TimeUnit.SECONDS); - verify(timer).setSchedulingType(SchedulingType.FIXED_RATE); - - } - - @Test - public void verifyStartAndStop() { - viewListener.actionPerformed(new ActionEvent<>(view, VmGcView.Action.VISIBLE)); - - verify(timer).start(); - - viewListener.actionPerformed(new ActionEvent<>(view, VmGcView.Action.HIDDEN)); - - verify(timer).stop(); - } - - @SuppressWarnings("unchecked") - @Test - public void verifyAction() { - timerAction.run(); - - verify(view).addData(isA(String.class), isA(List.class)); - } - -}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java Tue Nov 27 14:51:18 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java Tue Nov 27 14:54:58 2012 -0500 @@ -282,10 +282,7 @@ // register the storage, so other services can request it daoFactory.registerDAOsAndStorageAsOSGiServices(); uiFacadeFactory.setHostInfoDao(daoFactory.getHostInfoDAO()); - uiFacadeFactory.setVmInfoDao(daoFactory.getVmInfoDAO()); - uiFacadeFactory.setVmMemoryStatDao(daoFactory.getVmMemoryStatDAO()); - uiFacadeFactory.setVmGcStatDao(daoFactory.getVmGcStatDAO()); showMainWindow(); } else if (newStatus == ConnectionStatus.FAILED_TO_CONNECT) {
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java Tue Nov 27 14:51:18 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java Tue Nov 27 14:54:58 2012 -0500 @@ -56,9 +56,7 @@ import com.redhat.thermostat.client.ui.VmInformationController; import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmGcStatDAO; import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmMemoryStatDAO; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; @@ -73,10 +71,7 @@ private BundleContext context; private HostInfoDAO hostInfoDao; - private VmInfoDAO vmInfoDao; - private VmMemoryStatDAO vmMemoryStatDao; - private VmGcStatDAO vmGcStatDao; private OSGIUtils serviceProvider; @@ -99,16 +94,6 @@ } @Override - public void setVmMemoryStatDao(VmMemoryStatDAO vmMemoryStatDao) { - this.vmMemoryStatDao = vmMemoryStatDao; - } - - @Override - public void setVmGcStatDao(VmGcStatDAO vmGcStatDao) { - this.vmGcStatDao = vmGcStatDao; - } - - @Override public MainWindowController getMainWindow() { MainView mainView = new MainWindow(); RegistryFactory registryFactory = new RegistryFactory(context); @@ -130,7 +115,7 @@ @Override public VmInformationController getVmController(VmRef ref) { VmInformationViewProvider viewProvider = serviceProvider.getService(VmInformationViewProvider.class); - return new VmInformationController(this, vmMemoryStatDao, vmGcStatDao, ref, viewProvider); + return new VmInformationController(this, ref, viewProvider); } @Override
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Tue Nov 27 14:51:18 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Tue Nov 27 14:54:58 2012 -0500 @@ -47,7 +47,6 @@ import com.redhat.thermostat.client.core.views.ClientConfigViewProvider; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.client.core.views.SummaryViewProvider; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; import com.redhat.thermostat.client.osgi.service.HostDecorator; import com.redhat.thermostat.client.swing.internal.GUIClientCommand; @@ -58,7 +57,6 @@ import com.redhat.thermostat.client.swing.views.SwingClientConfigurationViewProvider; import com.redhat.thermostat.client.swing.views.SwingHostInformationViewProvider; import com.redhat.thermostat.client.swing.views.SwingSummaryViewProvider; -import com.redhat.thermostat.client.swing.views.SwingVmGcViewProvider; import com.redhat.thermostat.client.swing.views.SwingVmInformationViewProvider; import com.redhat.thermostat.client.ui.UiFacadeFactory; import com.redhat.thermostat.common.cli.CommandRegistry; @@ -87,8 +85,6 @@ // Vm views VmInformationViewProvider vmInfoProvider = new SwingVmInformationViewProvider(); context.registerService(VmInformationViewProvider.class.getName(), vmInfoProvider, null); - VmGcViewProvider vmGcProvider = new SwingVmGcViewProvider(); - context.registerService(VmGcViewProvider.class.getName(), vmGcProvider, null); // Summary view SummaryViewProvider summaryViewProvider = new SwingSummaryViewProvider();
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/views/SwingVmGcViewProvider.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright 2012 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.client.swing.views; - -import com.redhat.thermostat.client.core.views.VmGcView; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; - -public class SwingVmGcViewProvider implements VmGcViewProvider { - - @Override - public VmGcView createView() { - return new VmGcPanel(); - } - -}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/views/VmGcPanel.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -/* - * Copyright 2012 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.client.swing.views; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.DateAxis; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.event.ChartProgressEvent; -import org.jfree.chart.event.ChartProgressListener; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.renderer.xy.StandardXYBarPainter; -import org.jfree.chart.renderer.xy.XYBarRenderer; -import org.jfree.data.RangeType; -import org.jfree.data.xy.IntervalXYDataset; - -import com.redhat.thermostat.client.core.views.VmGcView; -import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.swing.SwingComponent; -import com.redhat.thermostat.client.swing.components.Components; -import com.redhat.thermostat.client.swing.components.HeaderPanel; -import com.redhat.thermostat.client.swing.components.RecentTimeSeriesChartPanel; -import com.redhat.thermostat.client.ui.ComponentVisibleListener; -import com.redhat.thermostat.client.ui.RecentTimeSeriesChartController; -import com.redhat.thermostat.client.ui.SampledDataset; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.locale.Translate; -import com.redhat.thermostat.storage.model.IntervalTimeData; - -public class VmGcPanel extends VmGcView implements SwingComponent { - - private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); - - private HeaderPanel visiblePanel = new HeaderPanel(); - private JPanel realPanel = new JPanel(); - - private final Map<String, SampledDataset> dataset = new HashMap<>(); - private final Map<String, JPanel> subPanels = new HashMap<>(); - - private final GridBagConstraints gcPanelConstraints; - - public VmGcPanel() { - super(); - initializePanel(); - - gcPanelConstraints = new GridBagConstraints(); - gcPanelConstraints.gridx = 0; - gcPanelConstraints.gridy = 0; - gcPanelConstraints.fill = GridBagConstraints.BOTH; - gcPanelConstraints.weightx = 1; - gcPanelConstraints.weighty = 1; - - visiblePanel.addHierarchyListener(new ComponentVisibleListener() { - @Override - public void componentShown(Component component) { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void componentHidden(Component component) { - notifier.fireAction(Action.HIDDEN); - } - }); - } - - @Override - public void addActionListener(ActionListener<Action> listener) { - notifier.addActionListener(listener); - } - - @Override - public void removeActionListener(ActionListener<Action> listener) { - notifier.removeActionListener(listener); - } - - @Override - public Component getUiComponent() { - return visiblePanel; - } - - private void initializePanel() { - visiblePanel.setContent(realPanel); - visiblePanel.setHeader(translator.localize(LocaleResources.VM_GC_TITLE)); - realPanel.setLayout(new GridBagLayout()); - } - - private JPanel createCollectorDetailsPanel(IntervalXYDataset collectorData, String title, String units) { - JPanel detailsPanel = new JPanel(); - detailsPanel.setBorder(Components.smallBorder()); - detailsPanel.setLayout(new BorderLayout()); - - detailsPanel.add(Components.header(title), BorderLayout.NORTH); - - JFreeChart chart = ChartFactory.createHistogram( - null, - translator.localize(LocaleResources.VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL), - translator.localize(LocaleResources.VM_GC_COLLECTOR_CHART_GC_TIME_LABEL, units), - collectorData, - PlotOrientation.VERTICAL, - false, - false, - false); - - ((XYBarRenderer)(chart.getXYPlot().getRenderer())).setBarPainter(new StandardXYBarPainter()); - - setupPlotAxes(chart.getXYPlot()); - - chart.getXYPlot().setDomainCrosshairLockedOnData(true); - chart.getXYPlot().setDomainCrosshairVisible(true); - - final RecentTimeSeriesChartPanel chartPanel = new RecentTimeSeriesChartPanel(new RecentTimeSeriesChartController(chart)); - - chart.addProgressListener(new ChartProgressListener() { - - @Override - public void chartProgress(ChartProgressEvent event) { - if (event.getType() != ChartProgressEvent.DRAWING_FINISHED) { - return; - } - - double rangeCrossHairValue = event.getChart().getXYPlot().getRangeCrosshairValue(); - chartPanel.setDataInformationLabel(String.valueOf(rangeCrossHairValue)); - } - }); - - detailsPanel.add(chartPanel, BorderLayout.CENTER); - - return detailsPanel; - } - - private void setupPlotAxes(XYPlot plot) { - setupDomainAxis(plot); - setupRangeAxis(plot); - } - - private void setupDomainAxis(XYPlot plot) { - plot.setDomainAxis(new DateAxis()); - } - - private void setupRangeAxis(XYPlot plot) { - NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); - - rangeAxis.setRangeType(RangeType.POSITIVE); - rangeAxis.setAutoRange(true); - rangeAxis.setAutoRangeMinimumSize(1); - } - - @Override - public void addChart(final String tag, final String title, final String units) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - SampledDataset newData = new SampledDataset(); - dataset.put(tag, newData); - JPanel subPanel = createCollectorDetailsPanel(newData, title, units); - subPanels.put(tag, subPanel); - realPanel.add(subPanel, gcPanelConstraints); - gcPanelConstraints.gridy++; - realPanel.revalidate(); - } - }); - } - - @Override - public void removeChart(final String tag) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - dataset.remove(tag); - JPanel subPanel = subPanels.remove(tag); - realPanel.remove(subPanel); - realPanel.revalidate(); - gcPanelConstraints.gridy--; - } - }); - } - - @Override - public void addData(final String tag, List<IntervalTimeData<Double>> data) { - final List<IntervalTimeData<Double>> copy = new ArrayList<>(data); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - SampledDataset series = dataset.get(tag); - for (IntervalTimeData<Double> timeData: copy) { - series.add(timeData.getStartTimeInMillis(), timeData.getEndTimeInMillis(), timeData.getData()); - } - series.fireSeriesChanged(); - } - }); - } - - @Override - public void clearData(final String tag) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - SampledDataset series = dataset.get(tag); - series.clear(); - } - }); - } -}
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Tue Nov 27 14:51:18 2012 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Tue Nov 27 14:54:58 2012 -0500 @@ -45,7 +45,6 @@ import com.redhat.thermostat.client.core.views.ClientConfigViewProvider; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.client.core.views.SummaryViewProvider; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; import com.redhat.thermostat.client.osgi.service.HostDecorator; import com.redhat.thermostat.client.swing.internal.HostIconDecorator; @@ -53,7 +52,6 @@ import com.redhat.thermostat.client.swing.views.SwingClientConfigurationViewProvider; import com.redhat.thermostat.client.swing.views.SwingHostInformationViewProvider; import com.redhat.thermostat.client.swing.views.SwingSummaryViewProvider; -import com.redhat.thermostat.client.swing.views.SwingVmGcViewProvider; import com.redhat.thermostat.client.swing.views.SwingVmInformationViewProvider; import com.redhat.thermostat.test.StubBundleContext; @@ -71,10 +69,9 @@ assertTrue(ctx.isServiceRegistered(SummaryViewProvider.class.getName(), SwingSummaryViewProvider.class)); assertTrue(ctx.isServiceRegistered(HostInformationViewProvider.class.getName(), SwingHostInformationViewProvider.class)); assertTrue(ctx.isServiceRegistered(VmInformationViewProvider.class.getName(), SwingVmInformationViewProvider.class)); - assertTrue(ctx.isServiceRegistered(VmGcViewProvider.class.getName(), SwingVmGcViewProvider.class)); assertTrue(ctx.isServiceRegistered(AgentInformationViewProvider.class.getName(), SwingAgentInformationViewProvider.class)); assertTrue(ctx.isServiceRegistered(ClientConfigViewProvider.class.getName(), SwingClientConfigurationViewProvider.class)); - assertEquals(7, ctx.getAllServices().size()); + assertEquals(6, ctx.getAllServices().size()); } }
--- a/distribution/config/commands/gui.properties Tue Nov 27 14:51:18 2012 -0500 +++ b/distribution/config/commands/gui.properties Tue Nov 27 14:54:58 2012 -0500 @@ -17,6 +17,8 @@ thermostat-vm-overview-client-swing-@project.version@.jar, \ thermostat-vm-cpu-client-core-@project.version@.jar, \ thermostat-vm-cpu-client-swing-@project.version@.jar, \ + thermostat-vm-gc-client-core-@project.version@.jar, \ + thermostat-vm-gc-client-swing-@project.version@.jar, \ thermostat-client-heapdumper-core-@project.version@.jar, \ thermostat-client-heapdumper-swing-@project.version@.jar, \ thermostat-killvm-client-swing-@project.version@.jar, \
--- a/distribution/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ b/distribution/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -363,6 +363,16 @@ </dependency> <dependency> <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc-client-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc-client-swing</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> <artifactId>thermostat-client-vmclassstat-swing</artifactId> <version>${project.version}</version> </dependency>
--- a/eclipse/com.redhat.thermostat.client.feature/feature.xml Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.client.feature/feature.xml Tue Nov 27 14:54:58 2012 -0500 @@ -154,4 +154,11 @@ version="0.0.0" unpack="false"/> + <plugin + id="com.redhat.thermostat.vm.gc.client.core" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + </feature>
--- a/eclipse/com.redhat.thermostat.client.feature/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.client.feature/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -41,6 +41,11 @@ </dependency> <dependency> <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc-client-core</artifactId> + <version>0.5.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> <artifactId>thermostat-client-vmclassstat-core</artifactId> <version>0.5.0-SNAPSHOT</version> </dependency>
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF Tue Nov 27 14:54:58 2012 -0500 @@ -26,6 +26,8 @@ com.redhat.thermostat.storage.model, com.redhat.thermostat.vm.cpu.client.core, com.redhat.thermostat.vm.cpu.client.locale, + com.redhat.thermostat.vm.gc.client.core, + com.redhat.thermostat.vm.gc.client.locale, org.jfree.chart, org.jfree.chart.axis, org.jfree.chart.event,
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/Activator.java Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/Activator.java Tue Nov 27 14:54:58 2012 -0500 @@ -39,11 +39,11 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; public class Activator extends AbstractUIPlugin {
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcView.java Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcView.java Tue Nov 27 14:54:58 2012 -0500 @@ -63,12 +63,12 @@ import org.jfree.data.RangeType; import org.jfree.data.xy.IntervalXYDataset; -import com.redhat.thermostat.client.core.views.VmGcView; -import com.redhat.thermostat.client.locale.LocaleResources; import com.redhat.thermostat.client.ui.SampledDataset; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.storage.model.IntervalTimeData; +import com.redhat.thermostat.vm.gc.client.core.VmGcView; +import com.redhat.thermostat.vm.gc.client.locale.LocaleResources; public class SWTVmGcView extends VmGcView implements SWTComponent {
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcViewProvider.java Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcViewProvider.java Tue Nov 27 14:54:58 2012 -0500 @@ -36,9 +36,9 @@ package com.redhat.thermostat.eclipse.chart.common; -import com.redhat.thermostat.client.core.views.VmGcView; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; import com.redhat.thermostat.eclipse.SWTViewProvider; +import com.redhat.thermostat.vm.gc.client.core.VmGcView; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; public class SWTVmGcViewProvider extends SWTViewProvider implements VmGcViewProvider {
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java Tue Nov 27 14:54:58 2012 -0500 @@ -38,14 +38,14 @@ import org.eclipse.swt.widgets.Composite; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; -import com.redhat.thermostat.client.ui.VmGcController; import com.redhat.thermostat.common.dao.VmGcStatDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; import com.redhat.thermostat.eclipse.views.VmRefViewPart; +import com.redhat.thermostat.vm.gc.client.core.VmGcController; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; public class VmGcViewPart extends VmRefViewPart {
--- a/eclipse/com.redhat.thermostat.eclipse.test.ui/META-INF/MANIFEST.MF Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test.ui/META-INF/MANIFEST.MF Tue Nov 27 14:54:58 2012 -0500 @@ -24,6 +24,7 @@ com.redhat.thermostat.host.overview.client.core, com.redhat.thermostat.storage.model, com.redhat.thermostat.vm.cpu.client.core, + com.redhat.thermostat.vm.gc.client.core, org.apache.log4j;version="1.2.13", org.eclipse.swtbot.eclipse.finder, org.eclipse.swtbot.eclipse.finder.matchers,
--- a/eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF Tue Nov 27 14:54:58 2012 -0500 @@ -29,6 +29,7 @@ com.redhat.thermostat.host.memory.client.core, com.redhat.thermostat.host.overview.client.core, com.redhat.thermostat.vm.cpu.client.core, + com.redhat.thermostat.vm.gc.client.core, org.mockito, org.mockito.stubbing Export-Package: com.redhat.thermostat.eclipse.test.model,
--- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java Tue Nov 27 14:51:18 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java Tue Nov 27 14:54:58 2012 -0500 @@ -48,8 +48,6 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.views.VmGcViewProvider; -import com.redhat.thermostat.client.ui.VmGcController; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmGcStatDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; @@ -59,6 +57,8 @@ import com.redhat.thermostat.eclipse.chart.common.SWTVmGcViewProvider; import com.redhat.thermostat.eclipse.chart.common.VmGcViewPart; import com.redhat.thermostat.eclipse.internal.views.RefViewPart; +import com.redhat.thermostat.vm.gc.client.core.VmGcController; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; public class VmGcViewPartTest extends AbstractRefViewPartTest<VmRef> {
--- a/gc/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat</artifactId> - <version>0.5.0-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-gc</artifactId> - <packaging>pom</packaging> - - <name>Thermostat GC Analysis And Remote GC Plugin</name> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <modules> - <module>remote-collector-command</module> - <module>remote-collector-client-common</module> - <module>remote-collector-client-swing</module> - <module>remote-collector-common</module> - </modules> -</project> -
--- a/gc/remote-collector-client-common/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-gc</artifactId> - <version>0.5.0-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-gc-remote-collector-client-common</artifactId> - <packaging>bundle</packaging> - - <name>Thermostat GC Plugin Common Client API</name> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-common-core</artifactId> - <version>${project.version}</version> - </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> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-client-command</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-agent-command</artifactId> - <version>${project.version}</version> - </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-gc-remote-collector-common</artifactId> - <version>${project.version}</version> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> - <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.client.common</Bundle-SymbolicName> - <Bundle-Activator>com.redhat.thermostat.gc.remote.client.common.osgi.GCCommandActivator</Bundle-Activator> - <Export-Package> - com.redhat.thermostat.gc.remote.client.common, - com.redhat.thermostat.gc.remote.common, - </Export-Package> - <Private-Package> - com.redhat.thermostat.gc.remote.client.common.osgi, - </Private-Package> - <!-- Do not autogenerate uses clauses in Manifests --> - <_nouses>true</_nouses> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project>
--- a/gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/IconResources.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.client.common; - -import com.redhat.thermostat.client.ui.IconDescriptor; - -public class IconResources { - - private static IconDescriptor gcIconSmall; - - public synchronized static IconDescriptor getGCIconSmall() { - if (gcIconSmall == null) { - gcIconSmall = IconDescriptor.loadIcon("com/redhat/thermostat/gc/remote/client/common/gcSmall.png"); - } - return gcIconSmall; - } -}
--- a/gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/LocaleResources.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.client.common; - -import com.redhat.thermostat.common.locale.Translate; - -public enum LocaleResources { - - PERFORM_GC; - - static final String RESOURCE_BUNDLE = "com.redhat.thermostat.gc.remote.client.common.strings"; - - public static Translate<LocaleResources> createLocalizer() { - return new Translate<>(RESOURCE_BUNDLE, LocaleResources.class); - } -}
--- a/gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/RequestGCAction.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.client.common; - -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.ActionNotifier; -import com.redhat.thermostat.gc.remote.common.command.GCCommand; - -public class RequestGCAction { - - private final ActionNotifier<GCCommand> notifier; - - public RequestGCAction() { - notifier = new ActionNotifier<>(this); - } - - public void addActionListener(ActionListener<GCCommand> listener) { - this.notifier.addActionListener(listener); - } - - public void removeActionListener(ActionListener<GCCommand> listener) { - this.notifier.removeActionListener(listener); - } - - public void requestGC() { - notifier.fireAction(GCCommand.REQUEST_GC); - } -}
--- a/gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/osgi/GCCommandActivator.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.client.common.osgi; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -import com.redhat.thermostat.client.command.RequestQueue; -import com.redhat.thermostat.gc.remote.common.GCRequest; - -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class GCCommandActivator implements BundleActivator { - - private ServiceTracker tracker; - - @Override - public void start(final BundleContext context) throws Exception { - tracker = new ServiceTracker(context, RequestQueue.class, null) { - @Override - public Object addingService(ServiceReference reference) { - - RequestQueue requestqueue = (RequestQueue) context.getService(reference); - - GCRequest gcRequest = new GCRequest(requestqueue); - context.registerService(GCRequest.class, gcRequest, null); - return super.addingService(reference); - } - - @Override - public void removedService(ServiceReference reference, Object service) { - - context.ungetService(reference); - super.removedService(reference, service); - } - }; - - tracker.open(); - } - - @Override - public void stop(BundleContext context) throws Exception { - tracker.close(); - } -}
--- a/gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/common/GCRequest.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.common; - -import java.net.InetSocketAddress; - -import com.redhat.thermostat.client.command.RequestQueue; -import com.redhat.thermostat.common.command.Request; -import com.redhat.thermostat.common.command.Request.RequestType; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; -import com.redhat.thermostat.gc.remote.common.command.GCCommand; - -public class GCRequest { - - private RequestQueue queue; - public GCRequest(RequestQueue queue) { - this.queue = queue; - } - - public void sendGCRequestToAgent(VmRef vm, AgentInfoDAO agentDAO) { - - HostRef targetHostRef = vm.getAgent(); - - String address = agentDAO.getAgentInformation(targetHostRef).getConfigListenAddress(); - String [] host = address.split(":"); - - InetSocketAddress target = new InetSocketAddress(host[0], Integer.parseInt(host[1])); - Request gcRequest = createRequest(target); - - gcRequest.setReceiver(GCCommand.RECEIVER); - - gcRequest.setParameter(GCCommand.class.getName(), GCCommand.REQUEST_GC.name()); - gcRequest.setParameter(GCCommand.VM_ID, vm.getIdString()); - - queue.putRequest(gcRequest); - } - - // for testing - Request createRequest(InetSocketAddress target) { - return new Request(RequestType.NO_RESPONSE_EXPECTED, target); - } -}
--- a/gc/remote-collector-client-common/src/main/resources/com/redhat/thermostat/gc/remote/client/common/strings.properties Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -PERFORM_GC = Perform GC \ No newline at end of file
--- a/gc/remote-collector-client-common/src/test/java/com/redhat/thermostat/gc/remote/common/GCRequestTest.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.common; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.verify; - -import java.net.InetSocketAddress; - -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.client.command.RequestQueue; -import com.redhat.thermostat.common.command.Request; -import com.redhat.thermostat.common.dao.AgentInfoDAO; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.VmRef; -import com.redhat.thermostat.gc.remote.common.command.GCCommand; -import com.redhat.thermostat.storage.model.AgentInformation; - -public class GCRequestTest { - - private AgentInfoDAO agentDAO; - private RequestQueue queue; - private VmRef vm; - - private GCRequest gcRequest; - private Request request; - - @Before - public void setUp() { - agentDAO = mock(AgentInfoDAO.class); - vm = mock(VmRef.class); - - request = mock(Request.class); - - HostRef ref = mock(HostRef.class); - when(vm.getAgent()).thenReturn(ref); - when(vm.getIdString()).thenReturn("123456"); - - AgentInformation info = mock(AgentInformation.class); - when(info.getConfigListenAddress()).thenReturn("0.0.42.42:42"); - - when(agentDAO.getAgentInformation(ref)).thenReturn(info); - - queue = mock(RequestQueue.class); - } - - @Test - public void testSendGCRequestToAgent() { - - final boolean [] results = new boolean [3]; - gcRequest = new GCRequest(queue) { - @Override - Request createRequest(InetSocketAddress target) { - results[0] = true; - if (target.getHostString().equals("0.0.42.42")) { - results[1] = true; - } - if (target.getPort() == 42) { - results[2] = true; - } - - return request; - } - }; - - gcRequest.sendGCRequestToAgent(vm, agentDAO); - verify(vm).getAgent(); - verify(vm).getIdString(); - - assertTrue(results[0]); - assertTrue(results[1]); - assertTrue(results[2]); - - verify(request).setReceiver(GCCommand.RECEIVER); - verify(request).setParameter(GCCommand.class.getName(), GCCommand.REQUEST_GC.name()); - verify(request).setParameter(GCCommand.VM_ID, "123456"); - - verify(queue).putRequest(request); - } -}
--- a/gc/remote-collector-client-swing/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-gc</artifactId> - <version>0.5.0-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-gc-remote-collector-client-swing</artifactId> - <packaging>bundle</packaging> - - <name>Thermostat GC Plugin Swing Client</name> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-common-core</artifactId> - <version>${project.version}</version> - </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> - </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-client-swing</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-gc-remote-collector-client-common</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.easytesting</groupId> - <artifactId>fest-swing</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>net.java.openjdk.cacio</groupId> - <artifactId>cacio-tta</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito</artifactId> - <scope>test</scope> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> - <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.client.swing</Bundle-SymbolicName> - <Export-Package> - com.redhat.thermostat.gc.remote.client.swing, - </Export-Package> - <!-- Do not autogenerate uses clauses in Manifests --> - <_nouses>true</_nouses> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project>
--- a/gc/remote-collector-client-swing/src/main/java/com/redhat/thermostat/gc/remote/client/swing/ToolbarGCButton.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.client.swing; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.ImageIcon; - -import com.redhat.thermostat.client.swing.components.ActionButton; -import com.redhat.thermostat.common.locale.Translate; - -import com.redhat.thermostat.gc.remote.client.common.IconResources; -import com.redhat.thermostat.gc.remote.client.common.LocaleResources; -import com.redhat.thermostat.gc.remote.client.common.RequestGCAction; - -@SuppressWarnings("serial") -public class ToolbarGCButton extends ActionButton { - - private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); - - private RequestGCAction action; - public ToolbarGCButton(RequestGCAction action) { - this(action, translator.localize(LocaleResources.PERFORM_GC)); - } - - private ToolbarGCButton(RequestGCAction action, String text) { - super(new ImageIcon(IconResources.getGCIconSmall().getData().array()), text); - - setToolTipText(text); - this.action = action; - - addActionListener(new ToolbarGCButtonActionlistener()); - } - - private class ToolbarGCButtonActionlistener implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { - Thread actionThread = new Thread(new Runnable() { - @Override - public void run() { - action.requestGC(); - } - }, "ToolbarGCButton.ToolbarGCButtonActionlistener.RequestGCAction"); - actionThread.start(); - } - } -}
--- a/gc/remote-collector-client-swing/src/test/java/com/redhat/thermostat/gc/remote/client/swing/ToolbarGCButtonTest.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.client.swing; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import java.awt.Dimension; -import java.util.prefs.BackingStoreException; -import java.util.prefs.Preferences; - -import javax.swing.JFrame; -import javax.swing.JPanel; - -import net.java.openjdk.cacio.ctc.junit.CacioFESTRunner; - -import org.fest.swing.edt.FailOnThreadViolationRepaintManager; -import org.fest.swing.edt.GuiActionRunner; -import org.fest.swing.edt.GuiTask; -import org.fest.swing.fixture.FrameFixture; -import org.fest.swing.fixture.JButtonFixture; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.redhat.thermostat.client.swing.components.HeaderPanel; -import com.redhat.thermostat.gc.remote.client.common.RequestGCAction; - -@RunWith(CacioFESTRunner.class) -public class ToolbarGCButtonTest { - - private JFrame frame; - private FrameFixture frameFixture; - private ToolbarGCButton gcButton; - - private RequestGCAction action; - - @BeforeClass - public static void setUpOnce() { - FailOnThreadViolationRepaintManager.install(); - } - - @Before - public void setUp() { - - final Preferences prefs = mock(Preferences.class); - - action = mock(RequestGCAction.class); - - GuiActionRunner.execute(new GuiTask() { - @Override - protected void executeInEDT() throws Throwable { - frame = new JFrame(); - - HeaderPanel header = new HeaderPanel(prefs, "Test Panel"); - header.setName("headerPanel"); - - JPanel content = new JPanel(); - content.setName("contentPanel"); - - header.setContent(content); - - gcButton = new ToolbarGCButton(action); - gcButton.setName("gcButton"); - header.addToolBarButton(gcButton); - - frame.getContentPane().add(header); - - frame.setMinimumSize(new Dimension(800, 300)); - } - }); - frameFixture = new FrameFixture(frame); - } - - @After - public void tearDown() throws BackingStoreException { - frameFixture.cleanUp(); - frameFixture = null; - } - - @Test - public void testEventDelivered() throws InterruptedException { - frameFixture.show(); - - JButtonFixture button = frameFixture.button("gcButton"); - button.requireVisible(); - - button.click(); - - // timing dependent test... - Thread.sleep(250); - - verify(action).requestGC(); - } -}
--- a/gc/remote-collector-command/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-gc</artifactId> - <version>0.5.0-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-gc-remote-collector-command</artifactId> - <packaging>bundle</packaging> - - <name>Thermostat GC Plugin Command Channel</name> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-common-core</artifactId> - <version>${project.version}</version> - </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> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-gc-remote-collector-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-agent-core</artifactId> - <version>${project.version}</version> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> - <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.command</Bundle-SymbolicName> - <Bundle-Activator>com.redhat.thermostat.gc.remote.command.osgi.GCCommandReceiverActivator</Bundle-Activator> - <Export-Package> - com.redhat.thermostat.gc.remote.command, - </Export-Package> - <Private-Package> - com.redhat.thermostat.gc.remote.command.osgi, - com.redhat.thermostat.gc.remote.command.internal, - </Private-Package> - <!-- Do not autogenerate uses clauses in Manifests --> - <_nouses>true</_nouses> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project>
--- a/gc/remote-collector-command/src/main/java/com/redhat/thermostat/gc/remote/command/GCCommandReceiver.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.command; - -import com.redhat.thermostat.agent.command.RequestReceiver; -import com.redhat.thermostat.common.command.Request; -import com.redhat.thermostat.common.command.Response; -import com.redhat.thermostat.common.command.Response.ResponseType; -import com.redhat.thermostat.gc.remote.command.internal.GC; -import com.redhat.thermostat.gc.remote.common.command.GCCommand; -import com.redhat.thermostat.utils.management.MXBeanConnector; - -public class GCCommandReceiver implements RequestReceiver { - - @Override - public Response receive(Request request) { - - String command = request.getParameter(GCCommand.class.getName()); - switch (GCCommand.valueOf(command)) { - case REQUEST_GC: - String vmId = request.getParameter(GCCommand.VM_ID); - MXBeanConnector connector = new MXBeanConnector(vmId); - new GC(connector).gc(); - break; - - default: - break; - } - return new Response(ResponseType.OK); - } -}
--- a/gc/remote-collector-command/src/main/java/com/redhat/thermostat/gc/remote/command/internal/GC.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.command.internal; - -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryMXBean; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.redhat.thermostat.utils.management.MXBeanConnection; -import com.redhat.thermostat.utils.management.MXBeanConnector; - -public class GC { - - private static final Logger logger = Logger.getLogger(GC.class.getSimpleName()); - - private MXBeanConnector connector; - public GC(MXBeanConnector connector) { - this.connector = connector; - } - - public void gc() { - boolean closeAfter = false; - if (!connector.isAttached()) { - closeAfter = true; - try { - connector.attach(); - - } catch (Exception ex) { - logger.log(Level.SEVERE, "can't attach", ex); - if (closeAfter) { - closeConnection(); - } - } - } - - try (MXBeanConnection connection = connector.connect()) { - - MemoryMXBean bean = connection.createProxy(ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class); - bean.gc(); - - } catch (Exception ex) { - logger.log(Level.SEVERE, "can't get MXBeanConnection connection", ex); - } - - if (closeAfter) { - closeConnection(); - } - } - - private void closeConnection() { - try { - connector.close(); - } catch (Exception ex) { - logger.log(Level.SEVERE, "can't close connection to vm", ex); - } - } -}
--- a/gc/remote-collector-command/src/main/java/com/redhat/thermostat/gc/remote/command/osgi/GCCommandReceiverActivator.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.command.osgi; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.agent.command.ReceiverRegistry; -import com.redhat.thermostat.gc.remote.command.GCCommandReceiver; - -public class GCCommandReceiverActivator implements BundleActivator { - - @Override - public void start(BundleContext context) throws Exception { - ReceiverRegistry registry = new ReceiverRegistry(context); - registry.registerReceiver(new GCCommandReceiver()); - } - - @Override - public void stop(BundleContext context) throws Exception { - } -}
--- a/gc/remote-collector-common/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Copyright 2012 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-gc</artifactId> - <version>0.5.0-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-gc-remote-collector-common</artifactId> - <packaging>bundle</packaging> - - <name>Thermostat GC Plugin Common Client API</name> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-common-core</artifactId> - <version>${project.version}</version> - </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> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-client-command</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-agent-command</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-client-core</artifactId> - <version>${project.version}</version> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> - <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.common.command</Bundle-SymbolicName> - <Export-Package> - com.redhat.thermostat.gc.remote.common.command - </Export-Package> - <!-- Do not autogenerate uses clauses in Manifests --> - <_nouses>true</_nouses> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project>
--- a/gc/remote-collector-common/src/main/java/com/redhat/thermostat/gc/remote/common/command/GCCommand.java Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2012 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.gc.remote.common.command; - -public enum GCCommand { - - REQUEST_GC; - - public static final String VM_ID = "VM_ID"; - public static final String RECEIVER = "com.redhat.thermostat.gc.remote.command.GCCommandReceiver"; -}
Binary file gc/remote-collector-common/src/main/resources/com/redhat/thermostat/gc/remote/client/common/gcSmall.png has changed
--- a/gc/remote-collector-common/src/main/resources/com/redhat/thermostat/gc/remote/client/common/strings.properties Tue Nov 27 14:51:18 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -PERFORM_GC = Perform GC \ No newline at end of file
--- a/pom.xml Tue Nov 27 14:51:18 2012 -0500 +++ b/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -129,13 +129,13 @@ <module>killvm</module> <module>web</module> <module>system-backend</module> - <module>gc</module> <module>storage</module> <module>host-overview</module> <module>host-cpu</module> <module>host-memory</module> <module>vm-overview</module> <module>vm-cpu</module> + <module>vm-gc</module> <!-- development related modules --> <module>dev</module> </modules>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>thermostat-vm-gc</artifactId> + <groupId>com.redhat.thermostat</groupId> + <version>0.5.0-SNAPSHOT</version> + </parent> + <artifactId>thermostat-vm-gc-client-core</artifactId> + <packaging>bundle</packaging> + <name>Thermostat VM GC Core Client plugin</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Private-Package></Private-Package> + <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> + <Bundle-SymbolicName>com.redhat.thermostat.vm.gc.client.core</Bundle-SymbolicName> + <Export-Package> + com.redhat.thermostat.vm.gc.client.core, + com.redhat.thermostat.vm.gc.client.locale + </Export-Package> + <!-- Do not autogenerate uses clauses in Manifests --> + <_nouses>true</_nouses> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <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> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-common-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-client-core</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcController.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,201 @@ +/* + * Copyright 2012 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.vm.gc.client.core; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.concurrent.TimeUnit; + +import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +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.NotImplementedException; +import com.redhat.thermostat.common.Timer; +import com.redhat.thermostat.common.Timer.SchedulingType; +import com.redhat.thermostat.common.appctx.ApplicationContext; +import com.redhat.thermostat.common.dao.VmGcStatDAO; +import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.model.IntervalTimeData; +import com.redhat.thermostat.storage.model.TimeStampedPojoComparator; +import com.redhat.thermostat.storage.model.VmGcStat; +import com.redhat.thermostat.storage.model.VmMemoryStat; +import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; +import com.redhat.thermostat.vm.gc.client.locale.LocaleResources; + +public class VmGcController implements VmInformationServiceController { + + private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); + + private final VmRef ref; + private final VmGcView view; + + private final VmGcStatDAO gcDao; + private final VmMemoryStatDAO memDao; + + private final Set<String> addedCollectors = new TreeSet<>(); + // the last value seen for each collector + private final Map<String, VmGcStat> lastValueSeen = new TreeMap<>(); + + private final Timer timer; + + private long lastSeenTimeStamp = Long.MIN_VALUE; + + public VmGcController(VmMemoryStatDAO vmMemoryStatDao, VmGcStatDAO vmGcStatDao, VmRef ref, VmGcViewProvider provider) { + this.ref = ref; + this.view = provider.createView(); + this.timer = ApplicationContext.getInstance().getTimerFactory().createTimer(); + + gcDao = vmGcStatDao; + memDao = vmMemoryStatDao; + + view.addActionListener(new ActionListener<VmGcView.Action>() { + @Override + public void actionPerformed(ActionEvent<Action> actionEvent) { + switch (actionEvent.getActionId()) { + case HIDDEN: + stop(); + break; + case VISIBLE: + start(); + break; + default: + throw new NotImplementedException("unkonwn action: " + actionEvent.getActionId()); + } + } + }); + + timer.setAction(new Runnable() { + @Override + public void run() { + try { + doUpdateCollectorData(); + } catch (Throwable t) { + t.printStackTrace(); + throw t; + } + } + }); + timer.setSchedulingType(SchedulingType.FIXED_RATE); + timer.setInitialDelay(0); + timer.setDelay(5); + timer.setTimeUnit(TimeUnit.SECONDS); + } + + private void start() { + timer.start(); + } + + private void stop() { + timer.stop(); + } + + // FIXME + private String chartName(String collectorName, String generationName) { + return translator.localize(LocaleResources.VM_GC_COLLECTOR_OVER_GENERATION, + collectorName, generationName); + } + + private void doUpdateCollectorData() { + Map<String, List<IntervalTimeData<Double>>> dataToAdd = new HashMap<>(); + List<VmGcStat> sortedList = gcDao.getLatestVmGcStats(ref, lastSeenTimeStamp); + Collections.sort(sortedList, new TimeStampedPojoComparator<>()); + + for (VmGcStat stat : sortedList) { + String collector = stat.getCollectorName(); + List<IntervalTimeData<Double>> data = dataToAdd.get(collector); + if (data == null) { + data = new ArrayList<>(); + dataToAdd.put(collector, data); + } + if (lastValueSeen.containsKey(collector)) { + if (stat.getTimeStamp() <= lastValueSeen.get(collector).getTimeStamp()) { + System.out.println("new gc collector value is older than previous value"); + } + VmGcStat last = lastValueSeen.get(collector); + lastSeenTimeStamp = Math.max(lastSeenTimeStamp, stat.getTimeStamp()); + long diffInMicro = (stat.getWallTime() - last.getWallTime()); + double diffInMillis = diffInMicro / 1000.0; + // TODO there is not much point in adding data when diff is 0, + // but we need to make the chart scroll automatically based on + // the current time when we do that + // if (diff != 0) { + data.add(new IntervalTimeData<>(last.getTimeStamp(), stat.getTimeStamp(), diffInMillis)); + // } + } + lastValueSeen.put(collector, stat); + } + for (Map.Entry<String, List<IntervalTimeData<Double>>> entry : dataToAdd.entrySet()) { + String name = entry.getKey(); + if (!addedCollectors.contains(name)) { + view.addChart(name, chartName(name, getCollectorGeneration(name)), "ms"); + addedCollectors.add(name); + } + view.addData(entry.getKey(), entry.getValue()); + } + } + + public String getCollectorGeneration(String collectorName) { + VmMemoryStat info = memDao.getLatestMemoryStat(ref); + + for (Generation g: info.getGenerations()) { + if (g.getCollector().equals(collectorName)) { + return g.getName(); + } + } + return translator.localize(LocaleResources.UNKNOWN_GEN); + } + + public UIComponent getView() { + return (UIComponent) view; + } + + @Override + public String getLocalizedName() { + return translator.localize(LocaleResources.VM_INFO_TAB_GC); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,72 @@ +/* + * Copyright 2012 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.vm.gc.client.core; + +import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.common.dao.VmGcStatDAO; +import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.common.utils.OSGIUtils; + +public class VmGcService implements VmInformationService { + + private static final VmFilter FILTER = new AlwaysMatchFilter(); + + private VmMemoryStatDAO vmMemoryStatDAO; + private VmGcStatDAO vmGcStatDAO; + + public VmGcService(VmMemoryStatDAO vmMemoryStatDAO, VmGcStatDAO vmGcStatDAO) { + this.vmMemoryStatDAO = vmMemoryStatDAO; + this.vmGcStatDAO = vmGcStatDAO; + } + + @Override + public VmInformationServiceController getInformationServiceController( + VmRef ref) { + VmGcViewProvider provider = OSGIUtils.getInstance().getService(VmGcViewProvider.class); + return new VmGcController(vmMemoryStatDAO, vmGcStatDAO, ref, provider); + } + + @Override + public VmFilter getFilter() { + return FILTER; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcView.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,55 @@ +/* + * Copyright 2012 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.vm.gc.client.core; + +import java.util.List; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.core.views.UIComponent; +import com.redhat.thermostat.storage.model.IntervalTimeData; + +public abstract class VmGcView extends BasicView implements UIComponent { + + public abstract void addChart(String tag, String title, String valueUnit); + + public abstract void removeChart(String tag); + + public abstract void addData(String tag, List<IntervalTimeData<Double>> data); + + public abstract void clearData(String tag); + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcViewProvider.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,46 @@ +/* + * Copyright 2012 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.vm.gc.client.core; + +import com.redhat.thermostat.client.core.views.ViewProvider; + +public interface VmGcViewProvider extends ViewProvider { + + @Override + public VmGcView createView(); + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/locale/LocaleResources.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,66 @@ +/* + * Copyright 2012 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.vm.gc.client.locale; + +import com.redhat.thermostat.common.locale.Translate; + +public enum LocaleResources { + GARBAGE_COLLECTION, + YOUNG_GEN, + EDEN_GEN, + S0_GEN, + S1_GEN, + OLD_GEN, + PERM_GEN, + UNKNOWN_GEN, + SOME_GENERATION, + + VM_INFO_TAB_GC, + + VM_GC_TITLE, + VM_GC_COLLECTOR_OVER_GENERATION, + VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL, + VM_GC_COLLECTOR_CHART_GC_TIME_LABEL, + ; + + static final String RESOURCE_BUNDLE = + "com.redhat.thermostat.vm.gc.client.locale.strings"; + + public static Translate<LocaleResources> createLocalizer() { + return new Translate<>(RESOURCE_BUNDLE, LocaleResources.class); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/src/main/resources/com/redhat/thermostat/vm/gc/client/locale/strings.properties Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,16 @@ +GARBAGE_COLLECTION = Garbage Collection +YOUNG_GEN = Young +EDEN_GEN = Eden +S0_GEN = Survivor 0 +S1_GEN = Survivor 1 +OLD_GEN = Tenured +PERM_GEN = Permanent +UNKNOWN_GEN = Unknown +SOME_GENERATION = {0} Generation + +VM_INFO_TAB_GC = GC + +VM_GC_TITLE = Garbage Collection in the VM +VM_GC_COLLECTOR_OVER_GENERATION = Collector {0} running on {1} +VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL = Time +VM_GC_COLLECTOR_CHART_GC_TIME_LABEL = GC Time ({0}) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/VmGcControllerTest.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,166 @@ +/* + * Copyright 2012 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.vm.gc.client.core; + +import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.isA; +import static org.mockito.Matchers.isNotNull; +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 java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.junit.After; +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.common.Timer; +import com.redhat.thermostat.common.Timer.SchedulingType; +import com.redhat.thermostat.common.TimerFactory; +import com.redhat.thermostat.common.appctx.ApplicationContext; +import com.redhat.thermostat.common.appctx.ApplicationContextUtil; +import com.redhat.thermostat.common.dao.VmGcStatDAO; +import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.model.VmGcStat; +import com.redhat.thermostat.storage.model.VmMemoryStat; +import com.redhat.thermostat.storage.model.VmMemoryStat.Generation; +import com.redhat.thermostat.vm.gc.client.core.VmGcController; +import com.redhat.thermostat.vm.gc.client.core.VmGcView; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; + +public class VmGcControllerTest { + + private Timer timer; + private Runnable timerAction; + private VmGcView view; + private ActionListener<VmGcView.Action> viewListener; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Before + public void setUp() { + ApplicationContextUtil.resetApplicationContext(); + + // Setup Timer + timer = mock(Timer.class); + ArgumentCaptor<Runnable> timerActionCaptor = ArgumentCaptor.forClass(Runnable.class); + doNothing().when(timer).setAction(timerActionCaptor.capture()); + + TimerFactory timerFactory = mock(TimerFactory.class); + when(timerFactory.createTimer()).thenReturn(timer); + ApplicationContext.getInstance().setTimerFactory(timerFactory); + + // Set up fake data + List<VmGcStat> stats = new ArrayList<>(); + VmGcStat stat1 = new VmGcStat(42, 1, "collector1", 1, 10); + VmGcStat stat2 = new VmGcStat(42, 2, "collector1", 5, 20); + stats.add(stat1); + stats.add(stat2); + + Generation gen; + gen = new Generation(); + gen.setName("generation 1"); + gen.setCollector("collector1"); + VmMemoryStat memoryStat = new VmMemoryStat(1, 42, new Generation[] { gen }); + + // Setup DAO + VmGcStatDAO vmGcStatDAO = mock(VmGcStatDAO.class); + when(vmGcStatDAO.getLatestVmGcStats(isA(VmRef.class), eq(Long.MIN_VALUE))).thenReturn(stats); + VmMemoryStatDAO vmMemoryStatDAO = mock(VmMemoryStatDAO.class); + when(vmMemoryStatDAO.getLatestMemoryStat(isA(VmRef.class))).thenReturn(memoryStat); + + // Setup View + view = mock(VmGcView.class); + ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class); + doNothing().when(view).addActionListener(viewArgumentCaptor.capture()); + + VmGcViewProvider viewProvider = mock(VmGcViewProvider.class); + when(viewProvider.createView()).thenReturn(view); + + // Now start the controller + VmRef ref = mock(VmRef.class); + + new VmGcController(vmMemoryStatDAO, vmGcStatDAO, ref, viewProvider); + + // Extract relevant objects + viewListener = viewArgumentCaptor.getValue(); + timerAction = timerActionCaptor.getValue(); + } + + @After + public void tearDown() { + ApplicationContextUtil.resetApplicationContext(); + } + + @Test + public void verifyTimer() { + verify(timer).setAction(isNotNull(Runnable.class)); + verify(timer).setAction(isA(Runnable.class)); + verify(timer).setDelay(5); + verify(timer).setInitialDelay(0); + verify(timer).setTimeUnit(TimeUnit.SECONDS); + verify(timer).setSchedulingType(SchedulingType.FIXED_RATE); + + } + + @Test + public void verifyStartAndStop() { + viewListener.actionPerformed(new ActionEvent<>(view, VmGcView.Action.VISIBLE)); + + verify(timer).start(); + + viewListener.actionPerformed(new ActionEvent<>(view, VmGcView.Action.HIDDEN)); + + verify(timer).stop(); + } + + @SuppressWarnings("unchecked") + @Test + public void verifyAction() { + timerAction.run(); + + verify(view).addData(isA(String.class), isA(List.class)); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-swing/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>thermostat-vm-gc</artifactId> + <groupId>com.redhat.thermostat</groupId> + <version>0.5.0-SNAPSHOT</version> + </parent> + <artifactId>thermostat-vm-gc-client-swing</artifactId> + <packaging>bundle</packaging> + <name>Thermostat VM GC Swing Client plugin</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Private-Package>com.redhat.thermostat.vm.gc.client.swing</Private-Package> + <Bundle-Activator>com.redhat.thermostat.vm.gc.client.swing.Activator</Bundle-Activator> + <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> + <Bundle-SymbolicName>com.redhat.thermostat.vm.gc.client.swing</Bundle-SymbolicName> + <!-- Do not autogenerate uses clauses in Manifests --> + <_nouses>true</_nouses> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.easytesting</groupId> + <artifactId>fest-swing</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>net.java.openjdk.cacio</groupId> + <artifactId>cacio-tta</artifactId> + <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> + </dependency> + <dependency> + <groupId>org.jfree</groupId> + <artifactId>jfreechart</artifactId> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-common-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-client-swing</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc-client-core</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/Activator.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,96 @@ +/* + * Copyright 2012 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.vm.gc.client.swing; + +import java.util.Map; +import java.util.Objects; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.dao.VmGcStatDAO; +import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.vm.gc.client.core.VmGcService; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; + +public class Activator implements BundleActivator { + + private MultipleServiceTracker tracker; + private ServiceRegistration reg; + + @Override + public void start(final BundleContext context) throws Exception { + VmGcViewProvider viewProvider = new SwingVmGcViewProvider(); + context.registerService(VmGcViewProvider.class.getName(), viewProvider, null); + + Class<?>[] deps = new Class<?>[] { + VmMemoryStatDAO.class, + VmGcStatDAO.class, + }; + + tracker = new MultipleServiceTracker(context, deps, new Action() { + + @Override + public void dependenciesAvailable(Map<String, Object> services) { + VmMemoryStatDAO vmMemoryStatDAO = (VmMemoryStatDAO) services.get(VmMemoryStatDAO.class.getName()); + Objects.requireNonNull(vmMemoryStatDAO); + VmGcStatDAO vmGcStatDAO = (VmGcStatDAO) services.get(VmGcStatDAO.class.getName()); + Objects.requireNonNull(vmGcStatDAO); + VmGcService service = new VmGcService(vmMemoryStatDAO, vmGcStatDAO); + reg = context.registerService(VmInformationService.class.getName(), service, null); + } + + @Override + public void dependenciesUnavailable() { + reg.unregister(); + } + + }); + tracker.open(); + } + + @Override + public void stop(BundleContext context) throws Exception { + tracker.close(); + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/SwingVmGcViewProvider.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,49 @@ +/* + * Copyright 2012 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.vm.gc.client.swing; + +import com.redhat.thermostat.vm.gc.client.core.VmGcView; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; + +public class SwingVmGcViewProvider implements VmGcViewProvider { + + @Override + public VmGcView createView() { + return new VmGcPanel(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/VmGcPanel.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,250 @@ +/* + * Copyright 2012 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.vm.gc.client.swing; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.ChartProgressEvent; +import org.jfree.chart.event.ChartProgressListener; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.StandardXYBarPainter; +import org.jfree.chart.renderer.xy.XYBarRenderer; +import org.jfree.data.RangeType; +import org.jfree.data.xy.IntervalXYDataset; + +import com.redhat.thermostat.client.swing.SwingComponent; +import com.redhat.thermostat.client.swing.components.Components; +import com.redhat.thermostat.client.swing.components.HeaderPanel; +import com.redhat.thermostat.client.swing.components.RecentTimeSeriesChartPanel; +import com.redhat.thermostat.client.ui.ComponentVisibleListener; +import com.redhat.thermostat.client.ui.RecentTimeSeriesChartController; +import com.redhat.thermostat.client.ui.SampledDataset; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.storage.model.IntervalTimeData; +import com.redhat.thermostat.vm.gc.client.core.VmGcView; +import com.redhat.thermostat.vm.gc.client.locale.LocaleResources; + +public class VmGcPanel extends VmGcView implements SwingComponent { + + private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); + + private HeaderPanel visiblePanel = new HeaderPanel(); + private JPanel realPanel = new JPanel(); + + private final Map<String, SampledDataset> dataset = new HashMap<>(); + private final Map<String, JPanel> subPanels = new HashMap<>(); + + private final GridBagConstraints gcPanelConstraints; + + public VmGcPanel() { + super(); + initializePanel(); + + gcPanelConstraints = new GridBagConstraints(); + gcPanelConstraints.gridx = 0; + gcPanelConstraints.gridy = 0; + gcPanelConstraints.fill = GridBagConstraints.BOTH; + gcPanelConstraints.weightx = 1; + gcPanelConstraints.weighty = 1; + + visiblePanel.addHierarchyListener(new ComponentVisibleListener() { + @Override + public void componentShown(Component component) { + notifier.fireAction(Action.VISIBLE); + } + + @Override + public void componentHidden(Component component) { + notifier.fireAction(Action.HIDDEN); + } + }); + } + + @Override + public void addActionListener(ActionListener<Action> listener) { + notifier.addActionListener(listener); + } + + @Override + public void removeActionListener(ActionListener<Action> listener) { + notifier.removeActionListener(listener); + } + + @Override + public Component getUiComponent() { + return visiblePanel; + } + + private void initializePanel() { + visiblePanel.setContent(realPanel); + visiblePanel.setHeader(translator.localize(LocaleResources.VM_GC_TITLE)); + realPanel.setLayout(new GridBagLayout()); + } + + private JPanel createCollectorDetailsPanel(IntervalXYDataset collectorData, String title, String units) { + JPanel detailsPanel = new JPanel(); + detailsPanel.setBorder(Components.smallBorder()); + detailsPanel.setLayout(new BorderLayout()); + + detailsPanel.add(Components.header(title), BorderLayout.NORTH); + + JFreeChart chart = ChartFactory.createHistogram( + null, + translator.localize(LocaleResources.VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL), + translator.localize(LocaleResources.VM_GC_COLLECTOR_CHART_GC_TIME_LABEL, units), + collectorData, + PlotOrientation.VERTICAL, + false, + false, + false); + + ((XYBarRenderer)(chart.getXYPlot().getRenderer())).setBarPainter(new StandardXYBarPainter()); + + setupPlotAxes(chart.getXYPlot()); + + chart.getXYPlot().setDomainCrosshairLockedOnData(true); + chart.getXYPlot().setDomainCrosshairVisible(true); + + final RecentTimeSeriesChartPanel chartPanel = new RecentTimeSeriesChartPanel(new RecentTimeSeriesChartController(chart)); + + chart.addProgressListener(new ChartProgressListener() { + + @Override + public void chartProgress(ChartProgressEvent event) { + if (event.getType() != ChartProgressEvent.DRAWING_FINISHED) { + return; + } + + double rangeCrossHairValue = event.getChart().getXYPlot().getRangeCrosshairValue(); + chartPanel.setDataInformationLabel(String.valueOf(rangeCrossHairValue)); + } + }); + + detailsPanel.add(chartPanel, BorderLayout.CENTER); + + return detailsPanel; + } + + private void setupPlotAxes(XYPlot plot) { + setupDomainAxis(plot); + setupRangeAxis(plot); + } + + private void setupDomainAxis(XYPlot plot) { + plot.setDomainAxis(new DateAxis()); + } + + private void setupRangeAxis(XYPlot plot) { + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + + rangeAxis.setRangeType(RangeType.POSITIVE); + rangeAxis.setAutoRange(true); + rangeAxis.setAutoRangeMinimumSize(1); + } + + @Override + public void addChart(final String tag, final String title, final String units) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + SampledDataset newData = new SampledDataset(); + dataset.put(tag, newData); + JPanel subPanel = createCollectorDetailsPanel(newData, title, units); + subPanels.put(tag, subPanel); + realPanel.add(subPanel, gcPanelConstraints); + gcPanelConstraints.gridy++; + realPanel.revalidate(); + } + }); + } + + @Override + public void removeChart(final String tag) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + dataset.remove(tag); + JPanel subPanel = subPanels.remove(tag); + realPanel.remove(subPanel); + realPanel.revalidate(); + gcPanelConstraints.gridy--; + } + }); + } + + @Override + public void addData(final String tag, List<IntervalTimeData<Double>> data) { + final List<IntervalTimeData<Double>> copy = new ArrayList<>(data); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + SampledDataset series = dataset.get(tag); + for (IntervalTimeData<Double> timeData: copy) { + series.add(timeData.getStartTimeInMillis(), timeData.getEndTimeInMillis(), timeData.getData()); + } + series.fireSeriesChanged(); + } + }); + } + + @Override + public void clearData(final String tag) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + SampledDataset series = dataset.get(tag); + series.clear(); + } + }); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/client-swing/src/test/java/com/redhat/thermostat/vm/gc/client/swing/ActivatorTest.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,102 @@ +/* + * Copyright 2012 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.vm.gc.client.swing; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import org.junit.Test; + +import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.common.dao.VmGcStatDAO; +import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.test.StubBundleContext; +import com.redhat.thermostat.vm.gc.client.core.VmGcService; +import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; + +public class ActivatorTest { + + @Test + public void verifyActivatorDoesNotRegisterServiceOnMissingDeps() throws Exception { + StubBundleContext context = new StubBundleContext(); + + Activator activator = new Activator(); + + activator.start(context); + + // View provider registers unconditionally + assertEquals(1, context.getAllServices().size()); + assertNotSame(1, context.getServiceListeners().size()); + + activator.stop(context); + + assertEquals(0, context.getServiceListeners().size()); + } + + @Test + public void verifyActivatorRegistersServices() throws Exception { + StubBundleContext context = new StubBundleContext(); + VmMemoryStatDAO vmMemoryStatDAO = mock(VmMemoryStatDAO.class); + VmGcStatDAO vmGcStatDAO = mock(VmGcStatDAO.class); + + context.registerService(VmMemoryStatDAO.class, vmMemoryStatDAO, null); + context.registerService(VmGcStatDAO.class, vmGcStatDAO, null); + + Activator activator = new Activator(); + + activator.start(context); + + assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), VmGcService.class)); + + activator.stop(context); + + assertEquals(0, context.getServiceListeners().size()); + assertEquals(3, context.getAllServices().size()); + } + + @Test + public void verifyStartRegistersViewProvider() throws Exception { + StubBundleContext ctx = new StubBundleContext(); + Activator activator = new Activator(); + activator.start(ctx); + assertTrue(ctx.isServiceRegistered(VmGcViewProvider.class.getName(), SwingVmGcViewProvider.class)); + assertEquals(1, ctx.getAllServices().size()); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2012 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat</artifactId> + <version>0.5.0-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-vm-gc</artifactId> + <packaging>pom</packaging> + + <name>Thermostat VM GC plugin</name> + + <modules> + <module>client-core</module> + <module>client-swing</module> + <module>remote-collector-command</module> + <module>remote-collector-client-common</module> + <module>remote-collector-client-swing</module> + <module>remote-collector-common</module> + </modules> + +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2012 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc</artifactId> + <version>0.5.0-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-gc-remote-collector-client-common</artifactId> + <packaging>bundle</packaging> + + <name>Thermostat GC Plugin Common Client API</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-common-core</artifactId> + <version>${project.version}</version> + </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> + </dependency> + + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-client-command</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-agent-command</artifactId> + <version>${project.version}</version> + </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-gc-remote-collector-common</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> + <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.client.common</Bundle-SymbolicName> + <Bundle-Activator>com.redhat.thermostat.gc.remote.client.common.osgi.GCCommandActivator</Bundle-Activator> + <Export-Package> + com.redhat.thermostat.gc.remote.client.common, + com.redhat.thermostat.gc.remote.common, + </Export-Package> + <Private-Package> + com.redhat.thermostat.gc.remote.client.common.osgi, + </Private-Package> + <!-- Do not autogenerate uses clauses in Manifests --> + <_nouses>true</_nouses> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/IconResources.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,51 @@ +/* + * Copyright 2012 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.gc.remote.client.common; + +import com.redhat.thermostat.client.ui.IconDescriptor; + +public class IconResources { + + private static IconDescriptor gcIconSmall; + + public synchronized static IconDescriptor getGCIconSmall() { + if (gcIconSmall == null) { + gcIconSmall = IconDescriptor.loadIcon("com/redhat/thermostat/gc/remote/client/common/gcSmall.png"); + } + return gcIconSmall; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/LocaleResources.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,50 @@ +/* + * Copyright 2012 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.gc.remote.client.common; + +import com.redhat.thermostat.common.locale.Translate; + +public enum LocaleResources { + + PERFORM_GC; + + static final String RESOURCE_BUNDLE = "com.redhat.thermostat.gc.remote.client.common.strings"; + + public static Translate<LocaleResources> createLocalizer() { + return new Translate<>(RESOURCE_BUNDLE, LocaleResources.class); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/RequestGCAction.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,62 @@ +/* + * Copyright 2012 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.gc.remote.client.common; + +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.ActionNotifier; +import com.redhat.thermostat.gc.remote.common.command.GCCommand; + +public class RequestGCAction { + + private final ActionNotifier<GCCommand> notifier; + + public RequestGCAction() { + notifier = new ActionNotifier<>(this); + } + + public void addActionListener(ActionListener<GCCommand> listener) { + this.notifier.addActionListener(listener); + } + + public void removeActionListener(ActionListener<GCCommand> listener) { + this.notifier.removeActionListener(listener); + } + + public void requestGC() { + notifier.fireAction(GCCommand.REQUEST_GC); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/client/common/osgi/GCCommandActivator.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,80 @@ +/* + * Copyright 2012 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.gc.remote.client.common.osgi; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; + +import com.redhat.thermostat.client.command.RequestQueue; +import com.redhat.thermostat.gc.remote.common.GCRequest; + +@SuppressWarnings({ "rawtypes", "unchecked" }) +public class GCCommandActivator implements BundleActivator { + + private ServiceTracker tracker; + + @Override + public void start(final BundleContext context) throws Exception { + tracker = new ServiceTracker(context, RequestQueue.class, null) { + @Override + public Object addingService(ServiceReference reference) { + + RequestQueue requestqueue = (RequestQueue) context.getService(reference); + + GCRequest gcRequest = new GCRequest(requestqueue); + context.registerService(GCRequest.class, gcRequest, null); + return super.addingService(reference); + } + + @Override + public void removedService(ServiceReference reference, Object service) { + + context.ungetService(reference); + super.removedService(reference, service); + } + }; + + tracker.open(); + } + + @Override + public void stop(BundleContext context) throws Exception { + tracker.close(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/src/main/java/com/redhat/thermostat/gc/remote/common/GCRequest.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,78 @@ +/* + * Copyright 2012 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.gc.remote.common; + +import java.net.InetSocketAddress; + +import com.redhat.thermostat.client.command.RequestQueue; +import com.redhat.thermostat.common.command.Request; +import com.redhat.thermostat.common.command.Request.RequestType; +import com.redhat.thermostat.common.dao.AgentInfoDAO; +import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.gc.remote.common.command.GCCommand; + +public class GCRequest { + + private RequestQueue queue; + public GCRequest(RequestQueue queue) { + this.queue = queue; + } + + public void sendGCRequestToAgent(VmRef vm, AgentInfoDAO agentDAO) { + + HostRef targetHostRef = vm.getAgent(); + + String address = agentDAO.getAgentInformation(targetHostRef).getConfigListenAddress(); + String [] host = address.split(":"); + + InetSocketAddress target = new InetSocketAddress(host[0], Integer.parseInt(host[1])); + Request gcRequest = createRequest(target); + + gcRequest.setReceiver(GCCommand.RECEIVER); + + gcRequest.setParameter(GCCommand.class.getName(), GCCommand.REQUEST_GC.name()); + gcRequest.setParameter(GCCommand.VM_ID, vm.getIdString()); + + queue.putRequest(gcRequest); + } + + // for testing + Request createRequest(InetSocketAddress target) { + return new Request(RequestType.NO_RESPONSE_EXPECTED, target); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/src/main/resources/com/redhat/thermostat/gc/remote/client/common/strings.properties Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,1 @@ +PERFORM_GC = Perform GC \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-common/src/test/java/com/redhat/thermostat/gc/remote/common/GCRequestTest.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,118 @@ +/* + * Copyright 2012 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.gc.remote.common; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.verify; + +import java.net.InetSocketAddress; + +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.client.command.RequestQueue; +import com.redhat.thermostat.common.command.Request; +import com.redhat.thermostat.common.dao.AgentInfoDAO; +import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.gc.remote.common.command.GCCommand; +import com.redhat.thermostat.storage.model.AgentInformation; + +public class GCRequestTest { + + private AgentInfoDAO agentDAO; + private RequestQueue queue; + private VmRef vm; + + private GCRequest gcRequest; + private Request request; + + @Before + public void setUp() { + agentDAO = mock(AgentInfoDAO.class); + vm = mock(VmRef.class); + + request = mock(Request.class); + + HostRef ref = mock(HostRef.class); + when(vm.getAgent()).thenReturn(ref); + when(vm.getIdString()).thenReturn("123456"); + + AgentInformation info = mock(AgentInformation.class); + when(info.getConfigListenAddress()).thenReturn("0.0.42.42:42"); + + when(agentDAO.getAgentInformation(ref)).thenReturn(info); + + queue = mock(RequestQueue.class); + } + + @Test + public void testSendGCRequestToAgent() { + + final boolean [] results = new boolean [3]; + gcRequest = new GCRequest(queue) { + @Override + Request createRequest(InetSocketAddress target) { + results[0] = true; + if (target.getHostString().equals("0.0.42.42")) { + results[1] = true; + } + if (target.getPort() == 42) { + results[2] = true; + } + + return request; + } + }; + + gcRequest.sendGCRequestToAgent(vm, agentDAO); + verify(vm).getAgent(); + verify(vm).getIdString(); + + assertTrue(results[0]); + assertTrue(results[1]); + assertTrue(results[2]); + + verify(request).setReceiver(GCCommand.RECEIVER); + verify(request).setParameter(GCCommand.class.getName(), GCCommand.REQUEST_GC.name()); + verify(request).setParameter(GCCommand.VM_ID, "123456"); + + verify(queue).putRequest(request); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-swing/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2012 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc</artifactId> + <version>0.5.0-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-gc-remote-collector-client-swing</artifactId> + <packaging>bundle</packaging> + + <name>Thermostat GC Plugin Swing Client</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-common-core</artifactId> + <version>${project.version}</version> + </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> + </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-client-swing</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-gc-remote-collector-client-common</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.easytesting</groupId> + <artifactId>fest-swing</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>net.java.openjdk.cacio</groupId> + <artifactId>cacio-tta</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> + <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.client.swing</Bundle-SymbolicName> + <Export-Package> + com.redhat.thermostat.gc.remote.client.swing, + </Export-Package> + <!-- Do not autogenerate uses clauses in Manifests --> + <_nouses>true</_nouses> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-swing/src/main/java/com/redhat/thermostat/gc/remote/client/swing/ToolbarGCButton.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,82 @@ +/* + * Copyright 2012 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.gc.remote.client.swing; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.ImageIcon; + +import com.redhat.thermostat.client.swing.components.ActionButton; +import com.redhat.thermostat.common.locale.Translate; + +import com.redhat.thermostat.gc.remote.client.common.IconResources; +import com.redhat.thermostat.gc.remote.client.common.LocaleResources; +import com.redhat.thermostat.gc.remote.client.common.RequestGCAction; + +@SuppressWarnings("serial") +public class ToolbarGCButton extends ActionButton { + + private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); + + private RequestGCAction action; + public ToolbarGCButton(RequestGCAction action) { + this(action, translator.localize(LocaleResources.PERFORM_GC)); + } + + private ToolbarGCButton(RequestGCAction action, String text) { + super(new ImageIcon(IconResources.getGCIconSmall().getData().array()), text); + + setToolTipText(text); + this.action = action; + + addActionListener(new ToolbarGCButtonActionlistener()); + } + + private class ToolbarGCButtonActionlistener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + Thread actionThread = new Thread(new Runnable() { + @Override + public void run() { + action.requestGC(); + } + }, "ToolbarGCButton.ToolbarGCButtonActionlistener.RequestGCAction"); + actionThread.start(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-client-swing/src/test/java/com/redhat/thermostat/gc/remote/client/swing/ToolbarGCButtonTest.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,131 @@ +/* + * Copyright 2012 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.gc.remote.client.swing; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import java.awt.Dimension; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; + +import javax.swing.JFrame; +import javax.swing.JPanel; + +import net.java.openjdk.cacio.ctc.junit.CacioFESTRunner; + +import org.fest.swing.edt.FailOnThreadViolationRepaintManager; +import org.fest.swing.edt.GuiActionRunner; +import org.fest.swing.edt.GuiTask; +import org.fest.swing.fixture.FrameFixture; +import org.fest.swing.fixture.JButtonFixture; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.redhat.thermostat.client.swing.components.HeaderPanel; +import com.redhat.thermostat.gc.remote.client.common.RequestGCAction; + +@RunWith(CacioFESTRunner.class) +public class ToolbarGCButtonTest { + + private JFrame frame; + private FrameFixture frameFixture; + private ToolbarGCButton gcButton; + + private RequestGCAction action; + + @BeforeClass + public static void setUpOnce() { + FailOnThreadViolationRepaintManager.install(); + } + + @Before + public void setUp() { + + final Preferences prefs = mock(Preferences.class); + + action = mock(RequestGCAction.class); + + GuiActionRunner.execute(new GuiTask() { + @Override + protected void executeInEDT() throws Throwable { + frame = new JFrame(); + + HeaderPanel header = new HeaderPanel(prefs, "Test Panel"); + header.setName("headerPanel"); + + JPanel content = new JPanel(); + content.setName("contentPanel"); + + header.setContent(content); + + gcButton = new ToolbarGCButton(action); + gcButton.setName("gcButton"); + header.addToolBarButton(gcButton); + + frame.getContentPane().add(header); + + frame.setMinimumSize(new Dimension(800, 300)); + } + }); + frameFixture = new FrameFixture(frame); + } + + @After + public void tearDown() throws BackingStoreException { + frameFixture.cleanUp(); + frameFixture = null; + } + + @Test + public void testEventDelivered() throws InterruptedException { + frameFixture.show(); + + JButtonFixture button = frameFixture.button("gcButton"); + button.requireVisible(); + + button.click(); + + // timing dependent test... + Thread.sleep(250); + + verify(action).requestGC(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-command/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2012 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc</artifactId> + <version>0.5.0-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-gc-remote-collector-command</artifactId> + <packaging>bundle</packaging> + + <name>Thermostat GC Plugin Command Channel</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-common-core</artifactId> + <version>${project.version}</version> + </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> + </dependency> + + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-gc-remote-collector-common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-agent-core</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> + <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.command</Bundle-SymbolicName> + <Bundle-Activator>com.redhat.thermostat.gc.remote.command.osgi.GCCommandReceiverActivator</Bundle-Activator> + <Export-Package> + com.redhat.thermostat.gc.remote.command, + </Export-Package> + <Private-Package> + com.redhat.thermostat.gc.remote.command.osgi, + com.redhat.thermostat.gc.remote.command.internal, + </Private-Package> + <!-- Do not autogenerate uses clauses in Manifests --> + <_nouses>true</_nouses> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-command/src/main/java/com/redhat/thermostat/gc/remote/command/GCCommandReceiver.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,65 @@ +/* + * Copyright 2012 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.gc.remote.command; + +import com.redhat.thermostat.agent.command.RequestReceiver; +import com.redhat.thermostat.common.command.Request; +import com.redhat.thermostat.common.command.Response; +import com.redhat.thermostat.common.command.Response.ResponseType; +import com.redhat.thermostat.gc.remote.command.internal.GC; +import com.redhat.thermostat.gc.remote.common.command.GCCommand; +import com.redhat.thermostat.utils.management.MXBeanConnector; + +public class GCCommandReceiver implements RequestReceiver { + + @Override + public Response receive(Request request) { + + String command = request.getParameter(GCCommand.class.getName()); + switch (GCCommand.valueOf(command)) { + case REQUEST_GC: + String vmId = request.getParameter(GCCommand.VM_ID); + MXBeanConnector connector = new MXBeanConnector(vmId); + new GC(connector).gc(); + break; + + default: + break; + } + return new Response(ResponseType.OK); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-command/src/main/java/com/redhat/thermostat/gc/remote/command/internal/GC.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,92 @@ +/* + * Copyright 2012 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.gc.remote.command.internal; + +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryMXBean; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.redhat.thermostat.utils.management.MXBeanConnection; +import com.redhat.thermostat.utils.management.MXBeanConnector; + +public class GC { + + private static final Logger logger = Logger.getLogger(GC.class.getSimpleName()); + + private MXBeanConnector connector; + public GC(MXBeanConnector connector) { + this.connector = connector; + } + + public void gc() { + boolean closeAfter = false; + if (!connector.isAttached()) { + closeAfter = true; + try { + connector.attach(); + + } catch (Exception ex) { + logger.log(Level.SEVERE, "can't attach", ex); + if (closeAfter) { + closeConnection(); + } + } + } + + try (MXBeanConnection connection = connector.connect()) { + + MemoryMXBean bean = connection.createProxy(ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class); + bean.gc(); + + } catch (Exception ex) { + logger.log(Level.SEVERE, "can't get MXBeanConnection connection", ex); + } + + if (closeAfter) { + closeConnection(); + } + } + + private void closeConnection() { + try { + connector.close(); + } catch (Exception ex) { + logger.log(Level.SEVERE, "can't close connection to vm", ex); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-command/src/main/java/com/redhat/thermostat/gc/remote/command/osgi/GCCommandReceiverActivator.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,56 @@ +/* + * Copyright 2012 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.gc.remote.command.osgi; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +import com.redhat.thermostat.agent.command.ReceiverRegistry; +import com.redhat.thermostat.gc.remote.command.GCCommandReceiver; + +public class GCCommandReceiverActivator implements BundleActivator { + + @Override + public void start(BundleContext context) throws Exception { + ReceiverRegistry registry = new ReceiverRegistry(context); + registry.registerReceiver(new GCCommandReceiver()); + } + + @Override + public void stop(BundleContext context) throws Exception { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-common/pom.xml Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright 2012 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-vm-gc</artifactId> + <version>0.5.0-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-gc-remote-collector-common</artifactId> + <packaging>bundle</packaging> + + <name>Thermostat Remote GC Plugin Common Client API</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-common-core</artifactId> + <version>${project.version}</version> + </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> + </dependency> + + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-client-command</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-agent-command</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-client-core</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> + <Bundle-SymbolicName>com.redhat.thermostat.gc.remote.common.command</Bundle-SymbolicName> + <Export-Package> + com.redhat.thermostat.gc.remote.common.command + </Export-Package> + <!-- Do not autogenerate uses clauses in Manifests --> + <_nouses>true</_nouses> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm-gc/remote-collector-common/src/main/java/com/redhat/thermostat/gc/remote/common/command/GCCommand.java Tue Nov 27 14:54:58 2012 -0500 @@ -0,0 +1,45 @@ +/* + * Copyright 2012 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.gc.remote.common.command; + +public enum GCCommand { + + REQUEST_GC; + + public static final String VM_ID = "VM_ID"; + public static final String RECEIVER = "com.redhat.thermostat.gc.remote.command.GCCommandReceiver"; +}