├── .gitignore ├── .travis.yml ├── COPYRIGHT ├── LICENSE ├── README.md ├── pom.xml └── src └── main ├── assembly.xml └── java ├── gchisto ├── Main.java ├── gcactivity │ ├── GCActivity.java │ ├── GCActivitySet.java │ └── package-info.java ├── gctrace │ ├── GCActivityNames.java │ ├── GCTrace.java │ ├── GCTraceCheckpoint.java │ ├── GCTraceListener.java │ ├── GCTraceListenerSet.java │ ├── GCTraceSet.java │ ├── GCTraceSetListener.java │ ├── GCTraceSetListenerSet.java │ ├── RCWithGCTraceCheckpoint.java │ ├── RCWithGCTraceCheckpointCallback.java │ └── package-info.java ├── gctracegenerator │ ├── GCTraceGenerator.java │ ├── GCTraceGeneratorForFiles.java │ ├── GCTraceGeneratorListener.java │ ├── GCTraceGeneratorSet.java │ ├── NopGCTraceGeneratorListener.java │ └── file │ │ ├── DynamicFileGCTrace.java │ │ ├── FileGCTrace.java │ │ ├── FileGCTraceGenerator.java │ │ ├── GCLogFileReader.java │ │ ├── GCLogFileReaderThrottle.java │ │ ├── NopGCLogFileReaderThrottle.java │ │ ├── PlaybackFrame.form │ │ ├── PlaybackFrame.java │ │ ├── hotspot │ │ ├── DynamicGCTraceGenerator.java │ │ ├── GCLogFileReader.java │ │ └── GCTraceGenerator.java │ │ └── simple │ │ ├── DynamicGCTraceGenerator.java │ │ ├── GCLogFileReader.java │ │ └── GCTraceGenerator.java ├── gui │ ├── AboutFrame.form │ ├── AboutFrame.java │ ├── MainFrame.form │ ├── MainFrame.java │ ├── MainPanel.form │ ├── MainPanel.java │ ├── package-info.java │ ├── panels │ │ ├── TraceManagementPanel.java │ │ ├── VisualizationPanel.java │ │ ├── gcdata │ │ │ ├── DataPanel.form │ │ │ ├── DataPanel.java │ │ │ └── Panel.java │ │ ├── gcdistribution │ │ │ ├── ChartPanelAll.java │ │ │ ├── ChartPanelSingle.java │ │ │ ├── Dataset.java │ │ │ ├── Panel.java │ │ │ └── package-info.java │ │ ├── gcstats │ │ │ ├── AbstractRefresherCallback.java │ │ │ ├── AllStatsTableMulti.form │ │ │ ├── AllStatsTableMulti.java │ │ │ ├── AllStatsTablePanelMulti.java │ │ │ ├── AllStatsTablePanelSingle.java │ │ │ ├── AllStatsTableSingle.form │ │ │ ├── AllStatsTableSingle.java │ │ │ ├── BreakdownChartPanelMulti.java │ │ │ ├── BreakdownChartPanelSingle.java │ │ │ ├── DatasetGenerator.java │ │ │ ├── GCStatsChartPanel.java │ │ │ ├── MetricChartPanel.java │ │ │ ├── Panel.form │ │ │ ├── Panel.java │ │ │ └── package-info.java │ │ ├── gctimeline │ │ │ ├── ChartPanel.java │ │ │ ├── Dataset.java │ │ │ ├── Panel.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ └── tracemanagement │ │ │ ├── Panel.form │ │ │ ├── Panel.java │ │ │ └── package-info.java │ └── utils │ │ ├── AbstractChartPanel.form │ │ ├── AbstractChartPanel.java │ │ ├── GUIUtilities.java │ │ ├── GroupActivatingPanel.form │ │ ├── GroupActivatingPanel.java │ │ ├── StatusLabelManager.java │ │ ├── TabbedPane.form │ │ ├── TabbedPane.java │ │ └── package-info.java ├── jfreechart │ └── extensions │ │ ├── AbstractChangingDataset.java │ │ ├── AbstractDatasetWithGroups.java │ │ ├── ChangingCategoryDataset.java │ │ ├── ChangingCategoryDatasetWithTTG.java │ │ ├── ChangingDataset.java │ │ ├── ChangingPieDataset.java │ │ ├── ChangingPieDatasetWithTTG.java │ │ ├── ChartLocker.java │ │ ├── ConsolidatingXYDatasetWithGroups.java │ │ ├── DatasetWithGroups.java │ │ ├── IntervalXYDatasetWithGroups.java │ │ ├── SwappingCategoryDatasetWithTTG.java │ │ ├── XYDatasetWithGroups.java │ │ └── package-info.java ├── package-info.java └── utils │ ├── ArrayUtils.java │ ├── Calculations.java │ ├── Comparisons.java │ ├── Conversions.java │ ├── Copyright.java │ ├── Formatter.java │ ├── Formatting.java │ ├── ListenerSet.java │ ├── Locker.java │ ├── MessageReporter.java │ ├── NumberSeq.java │ ├── Refresher.java │ ├── RefresherCallback.java │ ├── WorkerTask.java │ ├── WorkerThread.java │ ├── errorchecking │ ├── ArgumentChecking.java │ ├── ErrorReporting.java │ ├── FatalErrorException.java │ ├── IllegalArgumentException.java │ ├── NotImplementedException.java │ ├── ShouldNotReachHereException.java │ └── package-info.java │ └── package-info.java └── gcparser ├── CMSGCParser.java ├── FWFullGCParser.java ├── FWOldGCParser.java ├── FWYoungGCParser.java ├── GCDataStore.java ├── GCMetric.java ├── GCParser.java ├── GCParserDriver.java ├── GCStats.java ├── NumberIterator.java ├── ParCompactPhaseGCParser.java ├── ParGCFullGCParser.java ├── ParGCYoungGCParser.java ├── Stats.java ├── TimingWindowData.java └── VerboseGCParser.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | target 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright © 2007 Sun Microsystems, Inc., 4150 Network Circle, Santa 2 | Clara, California 95054, U.S.A. All rights reserved. 3 | 4 | U.S. Government Rights - Commercial software. Government users are 5 | subject to the Sun Microsystems, Inc. standard license agreement and 6 | applicable provisions of the FAR and its supplements. 7 | 8 | Use is subject to license terms. 9 | 10 | Sun, Sun Microsystems, the Sun logo, Java and NetBeans are trademarks 11 | or registered trademarks of Sun Microsystems, Inc. in the U.S. and 12 | other countries. 13 | 14 | This product is covered and controlled by U.S. Export Control laws and 15 | may be subject to the export or import laws in other 16 | countries. Nuclear, missile, chemical biological weapons or nuclear 17 | maritime end uses or end users, whether direct or indirect, are 18 | strictly prohibited. Export or reexport to countries subject to 19 | U.S. embargo or to entities identified on U.S. export exclusion lists, 20 | including, but not limited to, the denied persons and specially 21 | designated nationals lists is strictly prohibited. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gchisto 2 | A Hotspot JVM garbage collection log visualisation tool. Originally hosted at https://java.net/projects/gchisto. Moved it to github and mavenized it. 3 | 4 | # travis-ci build status 5 | [![Build Status](https://travis-ci.org/jewes/gchisto.svg?branch=master)](https://travis-ci.org/jewes/gchisto) 6 | 7 | # How to build gchisto 8 | mvn clean install 9 | 10 | It will creates target/gchisto-\.tar.gz which includes gchisto binary and its dependencies. 11 | 12 | # How to run it 13 | Extract the tar.gz and run the following command to launch gchisto: 14 | 15 | java -jar gchisto-\.jar 16 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.gu 5 | gchisto 6 | GChisto 7 | jar 8 | 1.0.1-SNAPSHOT 9 | 10 | 11 | jfree 12 | jcommon 13 | 1.0.12 14 | 15 | 16 | net.java.dev.swing-layout 17 | swing-layout 18 | 1.0.2 19 | 20 | 21 | jfree 22 | jfreechart 23 | 1.0.0 24 | 25 | 26 | 27 | 28 | 29 | maven-dependency-plugin 30 | 31 | 32 | package 33 | 34 | copy-dependencies 35 | 36 | 37 | ${project.build.directory}/lib 38 | 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-jar-plugin 45 | 46 | 47 | 48 | true 49 | lib/ 50 | gchisto.Main 51 | 52 | 53 | 54 | 55 | 56 | maven-assembly-plugin 57 | 58 | 59 | package 60 | 61 | single 62 | 63 | 64 | gchisto-${project.version} 65 | false 66 | 67 | src/main/assembly.xml 68 | 69 | 70 | 71 | 72 | 73 | 74 | maven-compiler-plugin 75 | 76 | 1.6 77 | 1.6 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tgz 7 | 8 | tar.gz 9 | 10 | 11 | 12 | target 13 | 14 | 15 | lib/** 16 | gchisto-*.jar 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/gchisto/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto; 25 | 26 | import gchisto.gui.MainFrame; 27 | import gchisto.utils.errorchecking.ErrorReporting; 28 | import java.awt.Dimension; 29 | 30 | /** 31 | * The main class of the application. It parses the command line parameters and 32 | * launches the main window. 33 | * 34 | * @author Tony Printezis 35 | */ 36 | public class Main { 37 | 38 | /** 39 | * Private constructor so that the class is not instantiated. 40 | */ 41 | private Main() { 42 | } 43 | 44 | /** 45 | * The main method of the application. It parses the command line parameters 46 | * and launches the main window. 47 | * 48 | * @param args The command line parameters of the application. 49 | */ 50 | public static void main(String[] args) { 51 | ErrorReporting.setShowWarnings(true); 52 | 53 | MainFrame frame = new MainFrame(); 54 | frame.setSize(new Dimension(1024, 680)); 55 | frame.setVisible(true); 56 | frame.loadGCTraces(args); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gcactivity/GCActivitySet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gcactivity; 25 | 26 | import gchisto.utils.NumberSeq; 27 | import gchisto.utils.errorchecking.NotImplementedException; 28 | import java.util.ArrayList; 29 | 30 | /** 31 | * A set of GC activities. All GC activities in the set share the same name, 32 | * i.e.. they are of the same "kind". The set should be ordered in increasing 33 | * order based on the startSec() value of the included GC activities. 34 | * GC activities in the set should not overlap. 35 | *

36 | * Because it extends java.util.ArrayList, an iteration over the GC 37 | * activities in it can be easily done using the standard for-loop over 38 | * collections. 39 | * 40 | * @author Tony Printezis 41 | * @see gchisto.gcactivityset.GCActivity 42 | * @see gchisto.gcactivityset.GCActivitySetListener 43 | * @see java.util.ArrayList 44 | */ 45 | public class GCActivitySet extends ArrayList { 46 | 47 | /** 48 | * The name of the GC activities in the set. This name is the "kind" 49 | * of the GC activities in the set. 50 | * 51 | * @see #getGCActivityName() 52 | */ 53 | final private String gcActivityName; 54 | 55 | final private NumberSeq numberSeq = new NumberSeq(); 56 | 57 | /** 58 | * It adds a new GC activity to the set. After adding it, it will call the 59 | * added() method on the listeners of this set. 60 | * 61 | * @param gcActivity The GC activity to be added to the set. 62 | */ 63 | public void addGCActivity(GCActivity gcActivity) { 64 | assert gcActivity != null; 65 | 66 | add(gcActivity); 67 | numberSeq.add(gcActivity.getDurationSec()); 68 | } 69 | 70 | /** 71 | * It returns the name of the GC activities in the set. This name is 72 | * the "kind" of the GC activities in the set. 73 | * 74 | * @return The name of the GC activities in the set. 75 | */ 76 | public String getGCActivityName() { 77 | return gcActivityName; 78 | } 79 | 80 | public NumberSeq getNumberSeq() { 81 | return numberSeq; 82 | } 83 | 84 | /** 85 | * It verifies the correctness of the contents in the set. 86 | */ 87 | public void verify() { 88 | throw new NotImplementedException(); 89 | } 90 | 91 | /** 92 | * It creates a new GC activity set instance. 93 | * 94 | * @param gcActivityName The name of the GC activites in the set. This 95 | * name is the "kind" of the GC activities in the set. 96 | */ 97 | public GCActivitySet(String gcActivityName) { 98 | this.gcActivityName = gcActivityName; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gcactivity/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains the GC activity set class, as well as all its supporting classes. 26 | */ 27 | package gchisto.gcactivity; 28 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/GCActivityNames.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctrace; 25 | 26 | import gchisto.utils.errorchecking.ArgumentChecking; 27 | import java.util.ArrayList; 28 | 29 | /** 30 | * It is a map that keeps track of GC activity names associated with a GC trace. 31 | * It can produce a unique string for each GC activity name, to avoid 32 | * replication and fast string comparison. It also associates a unique ID with 33 | * each GC activity name. The allocated IDs start from 0 and then monotonically 34 | * increase as new GC activity names are added to the map. 35 | * 36 | * @author Tony Printezis 37 | * @see gchisto.gctraceset.GCTrace 38 | * @see gchisto.gctraceset.GCTraceSet 39 | */ 40 | public class GCActivityNames extends ArrayList { 41 | 42 | /** 43 | * It returns an array that contains all the unique strings of the GC 44 | * activity names that have been added to this map. The index of each 45 | * GC activity name in the array is the same as its ID in the map. 46 | * 47 | * @return An array that contains all the unique strings of the GC activity 48 | * names that have been added to this map. 49 | */ 50 | public String[] getNames() { 51 | return toArray(new String[size()]); 52 | } 53 | 54 | /** 55 | * It iterates over the GC activity names of the parameter and, any of 56 | * them which do not exist in this map, it will add them. 57 | * 58 | * @param gcActivityNames The GC activity names that will be merged 59 | * with this map. 60 | */ 61 | public void merge(GCActivityNames gcActivityNames) { 62 | ArgumentChecking.notNull(gcActivityNames, "gcActivityNames"); 63 | 64 | for (String activityName : gcActivityNames.getNames()) { 65 | if (!contains((activityName))) { 66 | add(activityName); 67 | } 68 | } 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/GCTraceCheckpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctrace; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public class GCTraceCheckpoint { 34 | 35 | private GCTrace gcTrace; 36 | private int gcTraceSize; 37 | private List prevCheckpointedSizes = new ArrayList(); 38 | private List checkpointedSizes = new ArrayList(); 39 | private int prevAllSize; 40 | private int allSize; 41 | 42 | synchronized public void checkpoint() { 43 | assert prevCheckpointedSizes.size() == gcTraceSize; 44 | assert checkpointedSizes.size() == gcTraceSize; 45 | 46 | for (int i = 0; i < gcTraceSize; ++i) { 47 | int size = checkpointedSizes.get(i); 48 | prevCheckpointedSizes.set(i, size); 49 | } 50 | prevAllSize = allSize; 51 | 52 | for (int i = 0; i < gcTraceSize; ++i) { 53 | int size = gcTrace.get(i).size(); 54 | checkpointedSizes.set(i, size); 55 | } 56 | allSize = gcTrace.getAllGCActivities().size(); 57 | } 58 | 59 | public int gcTraceSize() { 60 | return gcTraceSize; 61 | } 62 | 63 | public int prevSize(int index) { 64 | return prevCheckpointedSizes.get(index); 65 | } 66 | 67 | public int size(int index) { 68 | return checkpointedSizes.get(index); 69 | } 70 | 71 | public int prevAllGCActivitiesSize() { 72 | return prevAllSize; 73 | } 74 | 75 | public int allGCActivitiesSize() { 76 | return allSize; 77 | } 78 | 79 | public boolean needsCheckpoint() { 80 | for (int i = 0; i < gcTraceSize; ++i) { 81 | if (checkpointedSizes.get(i) != gcTrace.get(i).size()) { 82 | return true; 83 | } 84 | } 85 | if (allSize != gcTrace.getAllGCActivities().size()) { 86 | return true; 87 | } 88 | return false; 89 | } 90 | 91 | public void extend(int id) { 92 | assert id == gcTraceSize; 93 | int newGCTraceSize = gcTraceSize + 1; 94 | assert prevCheckpointedSizes.size() == newGCTraceSize - 1; 95 | assert checkpointedSizes.size() == newGCTraceSize - 1; 96 | prevCheckpointedSizes.add(id, 0); 97 | checkpointedSizes.add(id, 0); 98 | assert prevCheckpointedSizes.size() == newGCTraceSize; 99 | assert checkpointedSizes.size() == newGCTraceSize; 100 | gcTraceSize = newGCTraceSize; 101 | } 102 | 103 | private void extendSizes() { 104 | assert gcTraceSize == 0; 105 | 106 | int newGCTraceSize = gcTrace.size(); 107 | for (int i = 0; i < newGCTraceSize; ++i) { 108 | extend(i); 109 | } 110 | 111 | assert gcTraceSize == newGCTraceSize; 112 | } 113 | 114 | public GCTraceCheckpoint(GCTrace gcTrace) { 115 | this.gcTrace = gcTrace; 116 | this.gcTraceSize = 0; 117 | this.prevAllSize = 0; 118 | this.allSize = 0; 119 | 120 | extendSizes(); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/GCTraceListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctrace; 25 | 26 | import gchisto.gcactivity.GCActivity; 27 | import gchisto.gcactivity.GCActivitySet; 28 | 29 | public interface GCTraceListener { 30 | 31 | /** 32 | * TODO 33 | */ 34 | public void gcActivityAdded( 35 | GCTrace gcTrace, 36 | GCActivitySet gcActivitySet, 37 | GCActivity gcActivity); 38 | 39 | public void gcActivityNameAdded( 40 | GCTrace gcTrace, 41 | int id, 42 | String gcActivityName); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/GCTraceListenerSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctrace; 25 | 26 | import gchisto.gcactivity.GCActivity; 27 | import gchisto.gcactivity.GCActivitySet; 28 | import gchisto.utils.ListenerSet; 29 | import gchisto.utils.errorchecking.ArgumentChecking; 30 | 31 | public class GCTraceListenerSet extends ListenerSet { 32 | 33 | /** 34 | * TODO 35 | */ 36 | public void callGCActivityAdded(GCTrace gcTrace, 37 | GCActivitySet gcActivitySet, 38 | GCActivity gcActivity) { 39 | ArgumentChecking.notNull(gcTrace, "gcTrace"); 40 | ArgumentChecking.notNull(gcActivitySet, "gcActivitySet"); 41 | 42 | for (GCTraceListener listener : listeners()) { 43 | listener.gcActivityAdded(gcTrace, gcActivitySet, gcActivity); 44 | } 45 | } 46 | 47 | public void callGCActivityNameAdded( 48 | GCTrace gcTrace, 49 | int id, 50 | String gcActivityName) { 51 | ArgumentChecking.notNull(gcTrace, "gcTrace"); 52 | ArgumentChecking.notNull(gcActivityName, "gcActivityName"); 53 | 54 | for (GCTraceListener listener : listeners()) { 55 | listener.gcActivityNameAdded(gcTrace, id, gcActivityName); 56 | } 57 | } 58 | 59 | /** 60 | * It creates a new GC trace listener set. 61 | */ 62 | public GCTraceListenerSet() { 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/GCTraceSetListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctrace; 25 | 26 | /** 27 | * A listener for changes in a GC trace set. 28 | * 29 | * @author Tony Printezis 30 | * @see gchisto.gctraceset.GCTraceSet 31 | */ 32 | public interface GCTraceSetListener { 33 | 34 | /** 35 | * Called after a GC trace has been added to the GC trace set. 36 | * 37 | * @param gcTrace The GC trace added to the GC trace set. 38 | */ 39 | public void gcTraceAdded(GCTrace gcTrace); 40 | 41 | /** 42 | * Called after a GC trace has been renamed in the GC trace set. 43 | * 44 | * @param gcTrace The GC trace renamed in the GC trace set. 45 | */ 46 | public void gcTraceRenamed(GCTrace gcTrace); 47 | 48 | /** 49 | * Called after a GC trace has been removed from the GC trace set. 50 | * 51 | * @param gcTrace The GC trace removed from the GC trace set. 52 | */ 53 | public void gcTraceRemoved(GCTrace gcTrace); 54 | 55 | /** 56 | * Called after a GC trace has been moved up in the GC trace set. 57 | * 58 | * @param gcTrace The GC trace moved up in the GC trace set. 59 | */ 60 | public void gcTraceMovedUp(GCTrace gcTrace); 61 | 62 | /** 63 | * Called after a GC trace has been moved down in the GC trace set. 64 | * 65 | * @param gcTrace The GC trace moved down in the GC trace set. 66 | */ 67 | public void gcTraceMovedDown(GCTrace gcTrace); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/RCWithGCTraceCheckpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctrace; 25 | 26 | import gchisto.utils.Locker; 27 | import gchisto.utils.RefresherCallback; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public class RCWithGCTraceCheckpoint implements RefresherCallback { 34 | 35 | final private GCTraceCheckpoint checkpoint; 36 | final private Locker locker; 37 | final private RCWithGCTraceCheckpointCallback callback; 38 | 39 | public boolean shouldRefresh() { 40 | return checkpoint.needsCheckpoint(); 41 | } 42 | 43 | public void beforeAddingTask() { 44 | locker.doWhileLocked(new Runnable() { 45 | 46 | public void run() { 47 | checkpoint.checkpoint(); 48 | } 49 | }); 50 | } 51 | 52 | public void refresh() { 53 | callback.refresh(checkpoint); 54 | } 55 | 56 | public RCWithGCTraceCheckpoint( 57 | GCTraceCheckpoint checkpoint, 58 | Locker locker, 59 | RCWithGCTraceCheckpointCallback callback) { 60 | this.checkpoint = checkpoint; 61 | this.locker = locker; 62 | this.callback = callback; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/RCWithGCTraceCheckpointCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctrace; 25 | 26 | /** 27 | * 28 | * @author tony 29 | */ 30 | public interface RCWithGCTraceCheckpointCallback { 31 | 32 | public void refresh(GCTraceCheckpoint checkpoint); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctrace/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains the GC trace set class, as well as all its supporting classes. 26 | */ 27 | package gchisto.gctrace; 28 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/GCTraceGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator; 25 | 26 | import javax.swing.JComponent; 27 | 28 | public interface GCTraceGenerator { 29 | 30 | public String getGCTraceType(); 31 | 32 | public void createNewGCTrace(JComponent component, 33 | GCTraceGeneratorListener listener); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/GCTraceGeneratorForFiles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | import java.io.File; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public interface GCTraceGeneratorForFiles extends GCTraceGenerator { 34 | 35 | public void createNewGCTrace(File file, 36 | GCTraceGeneratorListener listener); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/GCTraceGeneratorListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | 28 | /** 29 | * TODO 30 | */ 31 | public interface GCTraceGeneratorListener { 32 | 33 | /** 34 | * TODO 35 | */ 36 | public void started(); 37 | 38 | /** 39 | * TODO 40 | */ 41 | public void finished(GCTrace gcTrace); 42 | 43 | /** 44 | * TODO 45 | */ 46 | public void failed(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/GCTraceGeneratorSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator; 25 | 26 | import gchisto.utils.errorchecking.ErrorReporting; 27 | import java.util.LinkedList; 28 | 29 | public class GCTraceGeneratorSet extends LinkedList { 30 | 31 | static private final int GCTRACE_GENERATOR_FOR_FILES_INDEX = 0; 32 | static private final String[] GCTRACE_GENERATOR_CLASS_NAMES = { 33 | "gchisto.gctracegenerator.file.hotspot.GCTraceGenerator", 34 | "gchisto.gctracegenerator.file.hotspot.DynamicGCTraceGenerator", 35 | "gchisto.gctracegenerator.file.simple.GCTraceGenerator", 36 | "gchisto.gctracegenerator.file.simple.DynamicGCTraceGenerator" 37 | }; 38 | private GCTraceGeneratorForFiles gcTraceGeneratorForFiles; 39 | 40 | public GCTraceGeneratorForFiles gcTraceGeneratorForFiles() { 41 | return gcTraceGeneratorForFiles; 42 | } 43 | 44 | public GCTraceGeneratorSet() { 45 | for (int i = 0; i < GCTRACE_GENERATOR_CLASS_NAMES.length; ++i) { 46 | String className = GCTRACE_GENERATOR_CLASS_NAMES[i]; 47 | try { 48 | Class c = Class.forName(className); 49 | Object s = c.newInstance(); 50 | GCTraceGenerator gcTraceGenerator = (GCTraceGenerator) s; 51 | add(gcTraceGenerator); 52 | } catch (ClassNotFoundException e) { 53 | ErrorReporting.warning("could not instantiate " + className); 54 | } catch (InstantiationException e) { 55 | ErrorReporting.warning("could not instantiate " + className); 56 | } catch (IllegalAccessException e) { 57 | ErrorReporting.warning("could not access constructor of " + className); 58 | } catch (ClassCastException e) { 59 | ErrorReporting.warning("could not cast " + className + " to GCTraceGenerator"); 60 | } 61 | } 62 | ErrorReporting.fatalError(size() > 0, 63 | "There must be at least one GC trace generator set up"); 64 | 65 | try { 66 | gcTraceGeneratorForFiles = 67 | (GCTraceGeneratorForFiles) get(GCTRACE_GENERATOR_FOR_FILES_INDEX); 68 | } catch (ClassCastException e) { 69 | ErrorReporting.fatalError("could not cast GC trace generator with index " + 70 | GCTRACE_GENERATOR_FOR_FILES_INDEX + " to GCTraceGeneratorForFiles"); 71 | } 72 | ErrorReporting.fatalError(gcTraceGeneratorForFiles != null, 73 | "The GC trace generator for files should not be null"); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/NopGCTraceGeneratorListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | 28 | public class NopGCTraceGeneratorListener implements GCTraceGeneratorListener { 29 | 30 | public void started() { 31 | } 32 | 33 | public void finished(GCTrace gcTrace) { 34 | } 35 | 36 | public void failed() { 37 | } 38 | 39 | public NopGCTraceGeneratorListener() { 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/FileGCTrace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | import gchisto.gctracegenerator.GCTraceGeneratorListener; 28 | import gchisto.utils.MessageReporter; 29 | import java.io.File; 30 | import java.io.IOException; 31 | import java.util.Date; 32 | 33 | /** 34 | * 35 | * @author tony 36 | */ 37 | public class FileGCTrace extends GCTrace { 38 | 39 | final protected File file; 40 | final protected Date lastModifiedDate; 41 | final protected GCLogFileReader reader; 42 | 43 | private class ConcurrentFileReader extends Thread { 44 | private GCTraceGeneratorListener listener; 45 | private GCLogFileReaderThrottle throttle; 46 | 47 | public void run() { 48 | MessageReporter.showMessage("Started reading file " + file.getAbsolutePath()); 49 | listener.started(); 50 | try { 51 | readFile(throttle); 52 | MessageReporter.showMessage("Finished reading file " + file.getAbsolutePath()); 53 | listener.finished(FileGCTrace.this); 54 | } catch (IOException e) { 55 | MessageReporter.showError("Error reading file " + file.getAbsolutePath()); 56 | listener.failed(); 57 | } 58 | } 59 | 60 | public ConcurrentFileReader(GCTraceGeneratorListener listener, 61 | GCLogFileReaderThrottle throttle) { 62 | this.listener = listener; 63 | this.throttle = throttle; 64 | } 65 | } 66 | 67 | protected void readFileConcurrently(GCTraceGeneratorListener listener) { 68 | readFileConcurrently(listener, new NopGCLogFileReaderThrottle()); 69 | } 70 | 71 | protected void readFileConcurrently(GCTraceGeneratorListener listener, 72 | GCLogFileReaderThrottle throttle) { 73 | ConcurrentFileReader reader = new ConcurrentFileReader(listener, throttle); 74 | reader.start(); 75 | } 76 | 77 | public String getLongName() { 78 | return "File : " + file.getAbsolutePath(); 79 | } 80 | 81 | public File getFile() { 82 | return file; 83 | } 84 | 85 | private void readFile(GCLogFileReaderThrottle throttle) 86 | throws IOException { 87 | reader.readFile(file, this, throttle); 88 | } 89 | 90 | public void init(GCTraceGeneratorListener listener) { 91 | readFileConcurrently(listener); 92 | } 93 | 94 | public String getSuggestedName() { 95 | return "File : " + file.getName(); 96 | } 97 | 98 | public String getInfoString() { 99 | return getName() + "\n" + 100 | "\n" + 101 | "Path : " + file.getAbsolutePath() + "\n" + 102 | "Read On : " + getAddedDate() + "\n" + 103 | "Last Modified On : " + lastModifiedDate; 104 | } 105 | 106 | public FileGCTrace(File file, GCLogFileReader reader) { 107 | reader.setupGCActivityNames(this); 108 | 109 | this.file = file; 110 | this.lastModifiedDate = new Date(file.lastModified()); 111 | this.reader = reader; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/FileGCTraceGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file; 25 | 26 | import gchisto.gctracegenerator.GCTraceGeneratorForFiles; 27 | import gchisto.gctracegenerator.GCTraceGeneratorListener; 28 | import gchisto.utils.errorchecking.ArgumentChecking; 29 | import java.io.File; 30 | import javax.swing.JComponent; 31 | import javax.swing.JFileChooser; 32 | 33 | /** 34 | * 35 | * @author tony 36 | */ 37 | abstract public class FileGCTraceGenerator implements GCTraceGeneratorForFiles { 38 | 39 | static private File currDir = new File("."); 40 | 41 | protected File getFileFromDialog(JComponent component) { 42 | assert component != null; 43 | 44 | JFileChooser chooser = new JFileChooser(); 45 | chooser.setCurrentDirectory(currDir); 46 | chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 47 | chooser.setAcceptAllFileFilterUsed(false); 48 | int ret = chooser.showOpenDialog(component); 49 | if (ret == JFileChooser.APPROVE_OPTION) { 50 | File file = chooser.getSelectedFile(); 51 | return file; 52 | } else { 53 | return null; 54 | } 55 | } 56 | 57 | abstract protected FileGCTrace newFileGCTrace(File file); 58 | 59 | public void createNewGCTrace(File file, 60 | GCTraceGeneratorListener listener) { 61 | FileGCTrace gcTrace = newFileGCTrace(file); 62 | gcTrace.init(listener); 63 | currDir = file; 64 | } 65 | 66 | public void createNewGCTrace(JComponent component, 67 | GCTraceGeneratorListener listener) { 68 | ArgumentChecking.notNull(component, "component"); 69 | 70 | File file = getFileFromDialog(component); 71 | if (file != null) { 72 | createNewGCTrace(file, listener); 73 | } 74 | } 75 | 76 | public FileGCTraceGenerator() { 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/GCLogFileReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | import java.io.File; 28 | import java.io.IOException; 29 | 30 | /** 31 | * 32 | * @author tony 33 | */ 34 | public interface GCLogFileReader { 35 | 36 | public void setupGCActivityNames(GCTrace gcTrace); 37 | 38 | public void readFile(File file, 39 | GCTrace gcTrace, 40 | GCLogFileReaderThrottle throttle) 41 | throws IOException; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/GCLogFileReaderThrottle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file; 25 | 26 | /** 27 | * TODO 28 | */ 29 | public interface GCLogFileReaderThrottle { 30 | 31 | /** 32 | * TODO 33 | */ 34 | public void started(); 35 | 36 | /** 37 | * TODO 38 | */ 39 | public boolean shouldContinue(); 40 | 41 | /** 42 | * TODO 43 | */ 44 | public void beforeAddingGCActivity(double startSec); 45 | 46 | /** 47 | * TODO 48 | */ 49 | public void afterAddingGCActivity(double startSec); 50 | 51 | /** 52 | * TODO 53 | */ 54 | public void finished(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/NopGCLogFileReaderThrottle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file; 25 | 26 | /** 27 | * 28 | * @author tony 29 | */ 30 | public class NopGCLogFileReaderThrottle implements GCLogFileReaderThrottle { 31 | 32 | public void started() { 33 | } 34 | 35 | public void beforeAddingGCActivity(double startSec) { 36 | } 37 | 38 | public void afterAddingGCActivity(double startSec) { 39 | } 40 | 41 | public boolean shouldContinue() { 42 | return true; 43 | } 44 | 45 | public void finished() { 46 | } 47 | 48 | public NopGCLogFileReaderThrottle() { 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/hotspot/DynamicGCTraceGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file.hotspot; 25 | 26 | import gchisto.gctracegenerator.file.DynamicFileGCTrace; 27 | import gchisto.gctracegenerator.file.FileGCTrace; 28 | import gchisto.gctracegenerator.file.FileGCTraceGenerator; 29 | import java.io.File; 30 | 31 | /** 32 | * 33 | * @author tony 34 | */ 35 | public class DynamicGCTraceGenerator extends FileGCTraceGenerator { 36 | 37 | public String getGCTraceType() { 38 | return "Dynamic HotSpot GC Log"; 39 | } 40 | 41 | protected FileGCTrace newFileGCTrace(File file) { 42 | return new DynamicFileGCTrace(file, new GCLogFileReader()); 43 | } 44 | 45 | public DynamicGCTraceGenerator() { 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/hotspot/GCTraceGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file.hotspot; 25 | 26 | import gchisto.gctracegenerator.file.FileGCTrace; 27 | import gchisto.gctracegenerator.file.FileGCTraceGenerator; 28 | import java.io.File; 29 | 30 | /** 31 | * 32 | * @author tony 33 | */ 34 | public class GCTraceGenerator extends FileGCTraceGenerator { 35 | 36 | public String getGCTraceType() { 37 | return "HotSpot GC Log"; 38 | } 39 | 40 | protected FileGCTrace newFileGCTrace(File file) { 41 | return new FileGCTrace(file, new GCLogFileReader()); 42 | } 43 | 44 | public GCTraceGenerator() { 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/simple/DynamicGCTraceGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file.simple; 25 | 26 | import gchisto.gctracegenerator.file.DynamicFileGCTrace; 27 | import gchisto.gctracegenerator.file.FileGCTrace; 28 | import gchisto.gctracegenerator.file.FileGCTraceGenerator; 29 | import java.io.File; 30 | 31 | /** 32 | * 33 | * @author tony 34 | */ 35 | public class DynamicGCTraceGenerator extends FileGCTraceGenerator { 36 | 37 | public String getGCTraceType() { 38 | return "Dynamic Simple GC Log"; 39 | } 40 | 41 | protected FileGCTrace newFileGCTrace(File file) { 42 | return new DynamicFileGCTrace(file, new GCLogFileReader()); 43 | } 44 | 45 | public DynamicGCTraceGenerator() { 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gctracegenerator/file/simple/GCTraceGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gctracegenerator.file.simple; 25 | 26 | import gchisto.gctracegenerator.file.FileGCTrace; 27 | import gchisto.gctracegenerator.file.FileGCTraceGenerator; 28 | import java.io.File; 29 | 30 | /** 31 | * 32 | * @author tony 33 | */ 34 | public class GCTraceGenerator extends FileGCTraceGenerator { 35 | 36 | public String getGCTraceType() { 37 | return "Simple GC Log"; 38 | } 39 | 40 | protected FileGCTrace newFileGCTrace(File file) { 41 | return new FileGCTrace(file, new GCLogFileReader()); 42 | } 43 | 44 | public GCTraceGenerator() { 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/MainFrame.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
56 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/MainFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui; 25 | 26 | import java.awt.BorderLayout; 27 | import java.awt.Dimension; 28 | 29 | public class MainFrame extends javax.swing.JFrame { 30 | 31 | /** 32 | * TODO 33 | */ 34 | private MainPanel mainPanel = new MainPanel(); 35 | 36 | /** 37 | * It attempts to load a GC trace with the given file name. 38 | * 39 | * @param fileName The file name of the GC trace to be loaded. 40 | * 41 | * TODO 42 | */ 43 | public void loadGCTraces(String[] fileNames) { 44 | mainPanel.loadGCTraces(fileNames); 45 | } 46 | 47 | /** 48 | * TODO 49 | */ 50 | public MainFrame() { 51 | setTitle("GC Histogram Tool (GChisto)"); 52 | initComponents(); 53 | 54 | getContentPane().setLayout(new BorderLayout()); 55 | getContentPane().add(mainPanel, BorderLayout.CENTER); 56 | } 57 | 58 | /** This method is called from within the constructor to 59 | * initialize the form. 60 | * WARNING: Do NOT modify this code. The content of this method is 61 | * always regenerated by the Form Editor. 62 | */ 63 | // //GEN-BEGIN:initComponents 64 | private void initComponents() { 65 | 66 | jMenuBar1 = new javax.swing.JMenuBar(); 67 | jMenu1 = new javax.swing.JMenu(); 68 | aboutMenuItem = new javax.swing.JMenuItem(); 69 | 70 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 71 | 72 | jMenu1.setText("Help"); 73 | 74 | aboutMenuItem.setText("About"); 75 | aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { 76 | public void actionPerformed(java.awt.event.ActionEvent evt) { 77 | aboutMenuItemActionPerformed(evt); 78 | } 79 | }); 80 | jMenu1.add(aboutMenuItem); 81 | 82 | jMenuBar1.add(jMenu1); 83 | 84 | setJMenuBar(jMenuBar1); 85 | 86 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 87 | getContentPane().setLayout(layout); 88 | layout.setHorizontalGroup( 89 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 90 | .addGap(0, 400, Short.MAX_VALUE) 91 | ); 92 | layout.setVerticalGroup( 93 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 94 | .addGap(0, 277, Short.MAX_VALUE) 95 | ); 96 | 97 | pack(); 98 | }// //GEN-END:initComponents 99 | 100 | private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed 101 | // TODO add your handling code here: 102 | AboutFrame frame = new AboutFrame(); 103 | frame.setSize(new Dimension(500, 400)); 104 | frame.setVisible(true); 105 | }//GEN-LAST:event_aboutMenuItemActionPerformed 106 | 107 | // Variables declaration - do not modify//GEN-BEGIN:variables 108 | private javax.swing.JMenuItem aboutMenuItem; 109 | private javax.swing.JMenu jMenu1; 110 | private javax.swing.JMenuBar jMenuBar1; 111 | // End of variables declaration//GEN-END:variables 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/MainPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * The top-level package for all GUI-related classes. 26 | */ 27 | package gchisto.gui; 28 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/TraceManagementPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels; 25 | 26 | import gchisto.gui.*; 27 | import java.io.File; 28 | 29 | /** 30 | * The interface that the trace management panel has to implement. This is 31 | * a special panel that does all the GC trace set manipulation (GC trace 32 | * loading, removal, updating, etc.). 33 | * 34 | * @author Tony Printezis 35 | * @see gchisto.gui.MainFrame 36 | */ 37 | public interface TraceManagementPanel extends VisualizationPanel { 38 | 39 | /** 40 | * Load a GC trace after prompting the user for its file name. 41 | * 42 | * TODO 43 | */ 44 | public void addGCTrace(); 45 | 46 | /** 47 | * TODO 48 | */ 49 | public void addGCTrace(File file); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/VisualizationPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels; 25 | 26 | import gchisto.gctrace.GCTraceSet; 27 | import gchisto.gctrace.GCTraceSetListener; 28 | import javax.swing.JPanel; 29 | 30 | /** 31 | * This is the interface that all panels that can be added to the tabbed 32 | * pane of the main frame need to implement. 33 | * 34 | * @author Tony Printezis 35 | * @see gchisto.gui.MainFrame 36 | */ 37 | public interface VisualizationPanel { 38 | 39 | /** 40 | * It returns the panel that will be added to the tabbed pane of 41 | * the main frame. 42 | * 43 | * @return The panel that will be added to the tabbed pane of 44 | * the main frame. 45 | */ 46 | public JPanel getPanel(); 47 | 48 | /** 49 | * It returns the name of this panel. 50 | * 51 | * @return The name of this panel. 52 | */ 53 | public String getPanelName(); 54 | 55 | /** 56 | * It returns the GC trace set listener associated with this panel. 57 | * 58 | * @return The GC trace set listener associated with this panel. 59 | */ 60 | public GCTraceSetListener getListener(); 61 | 62 | /** 63 | * It installs the GC trace set of the application in the panel. 64 | * 65 | * @param gcTraceSet The GC trace set of the application. 66 | */ 67 | public void setGCTraceSet(GCTraceSet gcTraceSet); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcdata/DataPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcdata/Panel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcdata; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | import gchisto.gui.utils.TabbedPane; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public class Panel extends TabbedPane { 34 | 35 | protected DataPanel newPanel(GCTrace gcTrace) { 36 | DataPanel panel = new DataPanel(gcTrace); 37 | gcTrace.addListener(panel); 38 | return panel; 39 | } 40 | 41 | protected void updatePanel(DataPanel panel) { 42 | panel.possiblyRefresh(); 43 | } 44 | 45 | public String getPanelName() { 46 | return "GC Data"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcdistribution/ChartPanelAll.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcdistribution; 25 | 26 | import gchisto.gui.utils.AbstractChartPanel; 27 | import gchisto.gui.utils.GroupActivatingPanel; 28 | import gchisto.jfreechart.extensions.XYDatasetWithGroups; 29 | import java.awt.BorderLayout; 30 | import javax.swing.JSplitPane; 31 | import org.jfree.chart.ChartFactory; 32 | import org.jfree.chart.JFreeChart; 33 | import org.jfree.chart.plot.PlotOrientation; 34 | 35 | /** 36 | * A panel that contains a bar chart that compares the GC distribution 37 | * of all GC traces. This panel will be added to the tabbed pane of the main 38 | * GC distribution panel. 39 | * 40 | * @author Tony Printezis 41 | */ 42 | public class ChartPanelAll extends AbstractChartPanel { 43 | 44 | /** 45 | * It creates a chart for the given dataset and adds the chart to the panel. 46 | * 47 | * @param dataset The dataset that will provide the values for the chart. 48 | */ 49 | private void addChart(XYDatasetWithGroups dataset) { 50 | assert dataset != null; 51 | 52 | JFreeChart chart = ChartFactory.createXYAreaChart(getTitle(), 53 | "Buckets (sec)", "Count", dataset, PlotOrientation.VERTICAL, 54 | true, true, false); 55 | 56 | // null so that we can get it compiled; we'll get back to this... 57 | GroupActivatingPanel table = new GroupActivatingPanel(dataset, null); 58 | 59 | JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, 60 | table, new org.jfree.chart.ChartPanel(chart)); 61 | splitPane.setDividerLocation(200); 62 | mainPanel().add(BorderLayout.CENTER, splitPane); 63 | } 64 | 65 | /** 66 | * It creates a new instance of this panel and adds a chart into it. 67 | * 68 | * @param title The name of the metric. 69 | * @param unitName The name of the unit of the metric. 70 | * @param dataset The dataset that will provide the values for the chart. 71 | */ 72 | public ChartPanelAll( 73 | String title, String unitName, 74 | XYDatasetWithGroups dataset) { 75 | super(title, unitName); 76 | addChart(dataset); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcdistribution/Panel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcdistribution; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | import gchisto.gctrace.GCTraceCheckpoint; 28 | import gchisto.gui.utils.TabbedPane; 29 | 30 | /** 31 | * 32 | * @author tony 33 | */ 34 | public class Panel extends TabbedPane { 35 | 36 | protected ChartPanelSingle newPanel(GCTrace gcTrace) { 37 | GCTraceCheckpoint checkpoint = new GCTraceCheckpoint(gcTrace); 38 | checkpoint.checkpoint(); 39 | 40 | Dataset dataset = new Dataset(gcTrace, checkpoint); 41 | 42 | String unitName = String.format("%1.0f ms buckets", 43 | Dataset.bucketDurationMS()); 44 | String name = gcTrace.getName(); 45 | ChartPanelSingle panel = new ChartPanelSingle( 46 | name, unitName, dataset, checkpoint); 47 | gcTrace.addListener(panel); 48 | 49 | return panel; 50 | } 51 | 52 | protected void updatePanel(ChartPanelSingle panel) { 53 | panel.possiblyRefresh(); 54 | } 55 | 56 | public String getPanelName() { 57 | return "GC Pause Distribution"; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcdistribution/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains the classes that are related to the panel that contains 26 | * GC distribution charts. 27 | */ 28 | package gchisto.gui.panels.gcdistribution; 29 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/AbstractRefresherCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcstats; 25 | 26 | import gchisto.utils.RefresherCallback; 27 | 28 | /** 29 | * 30 | * @author tony 31 | */ 32 | abstract public class AbstractRefresherCallback implements RefresherCallback { 33 | 34 | public boolean shouldRefresh() { 35 | return true; 36 | } 37 | 38 | public void beforeAddingTask() { 39 | } 40 | 41 | abstract public void refresh(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/AllStatsTableMulti.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 |
53 |
54 |
55 |
56 |
57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
66 |
67 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/AllStatsTablePanelMulti.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcstats; 25 | 26 | import gchisto.utils.Locker; 27 | import java.awt.BorderLayout; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public class AllStatsTablePanelMulti extends GCStatsChartPanel { 34 | 35 | private AllStatsTableMulti panel; 36 | 37 | /** 38 | * It adds the appropriate table to this panel. The table is implemented 39 | * differently, depending whether there is a a single loaded GC trace, or 40 | * multiple ones. In the former case the table only contains the values 41 | * in the latter case the table contains the values, as well as comparative 42 | * stats between the GC traces. 43 | * 44 | * @param datasetGenerator The datasetGenerator generator of this package which 45 | * will provide all the values and metadata for the table. 46 | * @param single It determines whether there is one GC trace loaded, 47 | * or multiple ones. 48 | */ 49 | private void addTable(DatasetGenerator datasetGenerator, 50 | Locker locker) { 51 | panel = new AllStatsTableMulti(datasetGenerator, locker); 52 | mainPanel().add(BorderLayout.CENTER, panel); 53 | } 54 | 55 | public void refreshDataset() { 56 | panel.refresh(); 57 | } 58 | 59 | public void updateDataset() { 60 | panel.update(); 61 | } 62 | 63 | /** 64 | * It creates a new instance of this panel and adds the table into it. 65 | * 66 | * @param datasetGenerator The datasetGenerator generator of this package which 67 | * will provide all the values and metadata for the table. 68 | * @param single It determines whether there is one GC trace loaded, 69 | * or multiple ones. 70 | */ 71 | public AllStatsTablePanelMulti( 72 | DatasetGenerator datasetGenerator, 73 | Locker locker) { 74 | super("All GC Stats"); 75 | 76 | addTable(datasetGenerator, locker); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/AllStatsTablePanelSingle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcstats; 25 | 26 | import gchisto.utils.Locker; 27 | import java.awt.BorderLayout; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public class AllStatsTablePanelSingle extends GCStatsChartPanel { 34 | 35 | private AllStatsTableSingle panel; 36 | 37 | /** 38 | * It adds the appropriate table to this panel. The table is implemented 39 | * differently, depending whether there is a a single loaded GC trace, or 40 | * multiple ones. In the former case the table only contains the values 41 | * in the latter case the table contains the values, as well as comparative 42 | * stats between the GC traces. 43 | * 44 | * @param datasetGenerator The datasetGenerator generator of this package which 45 | * will provide all the values and metadata for the table. 46 | * @param single It determines whether there is one GC trace loaded, 47 | * or multiple ones. 48 | */ 49 | private void addTable(DatasetGenerator datasetGenerator, 50 | Locker locker) { 51 | panel = new AllStatsTableSingle(datasetGenerator, locker); 52 | mainPanel().add(BorderLayout.CENTER, panel); 53 | } 54 | 55 | public void refreshDataset() { 56 | panel.refresh(); 57 | } 58 | 59 | public void updateDataset() { 60 | panel.update(); 61 | } 62 | 63 | /** 64 | * It creates a new instance of this panel and adds the table into it. 65 | * 66 | * @param datasetGenerator The datasetGenerator generator of this package which 67 | * will provide all the values and metadata for the table. 68 | * @param single It determines whether there is one GC trace loaded, 69 | * or multiple ones. 70 | */ 71 | public AllStatsTablePanelSingle( 72 | DatasetGenerator datasetGenerator, 73 | Locker locker) { 74 | super("All GC Stats"); 75 | 76 | addTable(datasetGenerator, locker); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/AllStatsTableSingle.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/BreakdownChartPanelMulti.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcstats; 25 | 26 | import gchisto.jfreechart.extensions.ChangingCategoryDatasetWithTTG; 27 | import gchisto.jfreechart.extensions.ChartLocker; 28 | import gchisto.jfreechart.extensions.SwappingCategoryDatasetWithTTG; 29 | import java.awt.BorderLayout; 30 | import org.jfree.chart.ChartFactory; 31 | import org.jfree.chart.ChartPanel; 32 | import org.jfree.chart.JFreeChart; 33 | import org.jfree.chart.axis.CategoryAxis; 34 | import org.jfree.chart.axis.CategoryLabelPositions; 35 | import org.jfree.chart.plot.CategoryPlot; 36 | import org.jfree.chart.plot.PlotOrientation; 37 | import org.jfree.chart.renderer.category.CategoryItemRenderer; 38 | 39 | /** 40 | * A panel that contains a chart that shows the breakdown of a particular 41 | * metric over all GC activities. This panel should be used when more than 42 | * one GC traces have been loaded. The chart is implemented as a stacked bar 43 | * chart, one bar per GC trace. Each such panel will be added to the tabbed 44 | * pane of the main GC stats panel. 45 | * 46 | * @author Tony Printezis 47 | * @see BreakdownChartPanelSingle 48 | */ 49 | public class BreakdownChartPanelMulti extends GCStatsChartPanel { 50 | 51 | final ChangingCategoryDatasetWithTTG dataset; 52 | final ChartLocker locker; 53 | 54 | /** 55 | * It creates a chart for the given dataset and adds the chart to the panel. 56 | * 57 | * @param dataset The dataset that will provide the values for the chart. 58 | */ 59 | private void addChart() { 60 | JFreeChart chart = ChartFactory.createStackedBarChart3D( 61 | getTitle(), null, "Breakdown" + unitSuffix(), 62 | dataset, PlotOrientation.VERTICAL, true, true, false); 63 | CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); 64 | domainAxis.setCategoryLabelPositions( 65 | CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); 66 | chart.addProgressListener(locker); 67 | CategoryPlot plot = (CategoryPlot) chart.getPlot(); 68 | CategoryItemRenderer renderer = plot.getRenderer(); 69 | renderer.setToolTipGenerator(dataset); 70 | 71 | mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart)); 72 | } 73 | 74 | public void refreshDataset() { 75 | updateDataset(); 76 | } 77 | 78 | public void updateDataset() { 79 | locker.doWhileLocked(new Runnable() { 80 | 81 | public void run() { 82 | dataset.datasetChanged(); 83 | } 84 | }); 85 | } 86 | 87 | /** 88 | * It creates a new instance of this panel and adds a chart into it. 89 | * 90 | * @param title The name of the metric name. 91 | * @param unitName The name of the unit of the metric. 92 | * @param dataset The dataset that will provide the values for the chart. 93 | */ 94 | public BreakdownChartPanelMulti( 95 | String title, String unitName, 96 | ChangingCategoryDatasetWithTTG dataset, 97 | ChartLocker locker) { 98 | super(title, unitName); 99 | 100 | this.dataset = new SwappingCategoryDatasetWithTTG(dataset); 101 | this.locker = locker; 102 | 103 | addChart(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/BreakdownChartPanelSingle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcstats; 25 | 26 | import gchisto.jfreechart.extensions.ChangingPieDatasetWithTTG; 27 | import gchisto.jfreechart.extensions.ChartLocker; 28 | import gchisto.jfreechart.extensions.ChartLocker; 29 | import java.awt.BorderLayout; 30 | import org.jfree.chart.ChartFactory; 31 | import org.jfree.chart.ChartPanel; 32 | import org.jfree.chart.JFreeChart; 33 | import org.jfree.chart.plot.PiePlot; 34 | 35 | /** 36 | * A panel that contains a chart that shows the breakdown of a particular 37 | * metric over all GC activities. This panel should be used when only one 38 | * GC trace have been loaded. The chart is implemented as a pie chart. 39 | * Each such panel will be added to the tabbed pane of the main GC stats panel. 40 | * 41 | * @author Tony Printezis 42 | * @see BreakdownChartPanelMulti 43 | */ 44 | public class BreakdownChartPanelSingle extends GCStatsChartPanel { 45 | 46 | final private ChangingPieDatasetWithTTG dataset; 47 | final private ChartLocker locker; 48 | 49 | /** 50 | * It creates a chart for the given dataset and adds the chart to the panel. 51 | * 52 | * @param dataset The dataset that will provide the values for the chart. 53 | */ 54 | private void addChart() { 55 | JFreeChart chart = ChartFactory.createPieChart( 56 | getTitle(), dataset, false, true, false); 57 | chart.addProgressListener(locker); 58 | PiePlot plot = (PiePlot) chart.getPlot(); 59 | plot.setToolTipGenerator(dataset); 60 | 61 | mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart)); 62 | } 63 | 64 | public void refreshDataset() { 65 | updateDataset(); 66 | } 67 | 68 | public void updateDataset() { 69 | locker.doWhileLocked(new Runnable() { 70 | 71 | public void run() { 72 | dataset.datasetChanged(); 73 | } 74 | }); 75 | } 76 | 77 | /** 78 | * It creates a new instance of this panel and adds a chart into it. 79 | * 80 | * @param title The name of the metric name. 81 | * @param unitName The name of the unit of the metric. 82 | * @param dataset The dataset that will provide the values for the chart. 83 | */ 84 | public BreakdownChartPanelSingle( 85 | String title, String unitName, 86 | ChangingPieDatasetWithTTG dataset, 87 | ChartLocker locker) { 88 | super(title, unitName); 89 | 90 | this.dataset = dataset; 91 | this.locker = locker; 92 | 93 | addChart(); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/GCStatsChartPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcstats; 25 | 26 | import gchisto.gui.utils.AbstractChartPanel; 27 | import gchisto.utils.Refresher; 28 | import gchisto.utils.WorkerThread; 29 | 30 | /** 31 | * 32 | * @author tony 33 | */ 34 | abstract public class GCStatsChartPanel extends AbstractChartPanel { 35 | 36 | private class RefreshCallback extends AbstractRefresherCallback { 37 | 38 | public void refresh() { 39 | refreshDataset(); 40 | } 41 | } 42 | 43 | private class UpdateCallback extends AbstractRefresherCallback { 44 | 45 | public void refresh() { 46 | updateDataset(); 47 | } 48 | } 49 | final private Refresher refreshRefresher; 50 | final private Refresher updateRefresher; 51 | 52 | public void refresh() { 53 | refreshRefresher.possiblyRefresh(); 54 | } 55 | 56 | public void update() { 57 | updateRefresher.possiblyRefresh(); 58 | } 59 | 60 | abstract public void refreshDataset(); 61 | 62 | abstract public void updateDataset(); 63 | 64 | public GCStatsChartPanel(String title) { 65 | this(title, null); 66 | } 67 | 68 | public GCStatsChartPanel(String title, String unitName) { 69 | super(title, unitName); 70 | 71 | this.refreshRefresher = new Refresher(WorkerThread.instance(), new RefreshCallback()); 72 | this.updateRefresher = new Refresher(WorkerThread.instance(), new UpdateCallback()); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/MetricChartPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gcstats; 25 | 26 | import gchisto.jfreechart.extensions.ChangingCategoryDatasetWithTTG; 27 | import gchisto.jfreechart.extensions.ChartLocker; 28 | import java.awt.BorderLayout; 29 | import org.jfree.chart.ChartFactory; 30 | import org.jfree.chart.ChartPanel; 31 | import org.jfree.chart.JFreeChart; 32 | import org.jfree.chart.plot.CategoryPlot; 33 | import org.jfree.chart.plot.PlotOrientation; 34 | import org.jfree.chart.renderer.category.CategoryItemRenderer; 35 | 36 | /** 37 | * A panel that contains a bar chart that shows the values of a metric over 38 | * all loaded GC traces and al GC activities. Each such panel will be added 39 | * to the tabbed pane of the main GC stats panel. 40 | * 41 | * @author Tony Printezis 42 | */ 43 | public class MetricChartPanel extends GCStatsChartPanel { 44 | 45 | final private ChangingCategoryDatasetWithTTG dataset; 46 | final private ChartLocker locker; 47 | 48 | /** 49 | * It creates a chart for the given dataset and adds the chart to the panel. 50 | * 51 | * @param dataset The dataset that will provide the values for the chart. 52 | */ 53 | private void addChart() { 54 | JFreeChart chart = ChartFactory.createBarChart3D(getTitle(), 55 | null, "Time" + unitSuffix(), 56 | dataset, PlotOrientation.VERTICAL, 57 | true, true, false); 58 | chart.addProgressListener(locker); 59 | CategoryPlot plot = (CategoryPlot) chart.getPlot(); 60 | CategoryItemRenderer renderer = plot.getRenderer(); 61 | renderer.setToolTipGenerator(dataset); 62 | 63 | mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart)); 64 | } 65 | 66 | public void refreshDataset() { 67 | updateDataset(); 68 | } 69 | 70 | public void updateDataset() { 71 | locker.doWhileLocked(new Runnable() { 72 | 73 | public void run() { 74 | dataset.datasetChanged(); 75 | } 76 | }); 77 | } 78 | 79 | /** 80 | * It creates a new instance of this panel and adds a chart into it. 81 | * 82 | * @param title The name of the metric. 83 | * @param unitName The name of the unit of the metric. 84 | * @param dataset The dataset that will provide the values for the chart. 85 | */ 86 | public MetricChartPanel( 87 | String title, String unitName, 88 | ChangingCategoryDatasetWithTTG dataset, 89 | ChartLocker locker) { 90 | super(title, unitName); 91 | 92 | this.dataset = dataset; 93 | this.locker = locker; 94 | 95 | addChart(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/Panel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
41 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gcstats/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains the classes that are related to the panel that contains summary 26 | * GC statistics for the loaded GC traces, in both tables and bar charts. 27 | */ 28 | package gchisto.gui.panels.gcstats; 29 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gctimeline/Panel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.gui.panels.gctimeline; 25 | 26 | import gchisto.gctrace.GCTrace; 27 | import gchisto.gctrace.GCTraceCheckpoint; 28 | import gchisto.gui.utils.TabbedPane; 29 | 30 | /** 31 | * 32 | * @author tony 33 | */ 34 | public class Panel extends TabbedPane { 35 | 36 | protected ChartPanel newPanel(GCTrace gcTrace) { 37 | GCTraceCheckpoint checkpoint = new GCTraceCheckpoint(gcTrace); 38 | checkpoint.checkpoint(); 39 | 40 | Dataset dataset = 41 | new Dataset(gcTrace, checkpoint, Dataset.METRIC_DURATION); 42 | 43 | String name = gcTrace.getName(); 44 | ChartPanel panel = new ChartPanel(name, "ms", dataset, checkpoint); 45 | gcTrace.addListener(panel); 46 | 47 | return panel; 48 | } 49 | 50 | protected void updatePanel(ChartPanel panel) { 51 | panel.possiblyRefresh(); 52 | } 53 | 54 | public String getPanelName() { 55 | return "GC Timeline"; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/gctimeline/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains the classes that are related to the panel that contains 26 | * GC timelines (i.e., how different aspects of the GC behaved over time). 27 | */ 28 | package gchisto.gui.panels.gctimeline; 29 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains all the subpackages that are used for the different panels 26 | * that can be added to the tabbed panes of the main frame, as well as 27 | * the interfaces that those panels should implement. 28 | */ 29 | package gchisto.gui.panels; 30 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/panels/tracemanagement/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains all the classes related to the GC trace management panel. 26 | */ 27 | package gchisto.gui.panels.tracemanagement; 28 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/utils/AbstractChartPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
41 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/utils/GroupActivatingPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/utils/TabbedPane.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | -------------------------------------------------------------------------------- /src/main/java/gchisto/gui/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains miscellaneous GUI-related utilities used by the 26 | * gchisto.gui.* packages 27 | */ 28 | package gchisto.gui.utils; 29 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/AbstractChangingDataset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import org.jfree.data.general.AbstractDataset; 27 | import org.jfree.data.general.DatasetChangeEvent; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | abstract public class AbstractChangingDataset extends AbstractDataset 34 | implements ChangingDataset { 35 | 36 | public void datasetChanged() { 37 | notifyListeners(new DatasetChangeEvent(this, this)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/AbstractDatasetWithGroups.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public class AbstractDatasetWithGroups extends AbstractChangingDataset 34 | implements DatasetWithGroups { 35 | 36 | /** 37 | * A list that contains the names of all the GC activites in all the 38 | * loaded traces, as well as the aggregate GC activity. 39 | */ 40 | final private List groupNames = new ArrayList(); 41 | /** 42 | * An array with one entry per GC activity in the GC trace that 43 | * dictates whether that GC activity is groupActive (i.e., whether 44 | * it will be displayed in the chart). 45 | */ 46 | final private List groupActive = new ArrayList(); 47 | 48 | private int groupNum; 49 | 50 | public int getGroupCount() { 51 | return groupNum; 52 | } 53 | 54 | public String getGroupName(int group) { 55 | assert 0 <= group && group < groupNum; 56 | 57 | return groupNames.get(group); 58 | } 59 | 60 | protected int indexOfGroupName(String groupName) { 61 | return groupNames.indexOf(groupName); 62 | } 63 | 64 | public boolean isGroupActive(int group) { 65 | assert 0 <= group && group < groupNum; 66 | 67 | return groupActive.get(group); 68 | } 69 | 70 | public void setGroupActive(int group, boolean active) { 71 | assert 0 <= group && group < groupNames.size(); 72 | 73 | groupActive.set(group, active); 74 | datasetChanged(); 75 | } 76 | 77 | synchronized public void addGroup(int id, String groupName) { 78 | groupNames.add(id, groupName); 79 | groupActive.add(id, true); 80 | groupNum += 1; 81 | 82 | assert groupNames.size() == groupNum; 83 | assert groupActive.size() == groupNum; 84 | } 85 | 86 | public AbstractDatasetWithGroups() { 87 | groupNum = 0; 88 | } 89 | 90 | public AbstractDatasetWithGroups(String[] groupNames) { 91 | this(); 92 | for (int i = 0; i < groupNames.length; ++i) { 93 | addGroup(i, groupNames[i]); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/ChangingCategoryDataset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import org.jfree.data.category.CategoryDataset; 27 | 28 | /** 29 | * 30 | * @author tony 31 | */ 32 | public interface ChangingCategoryDataset 33 | extends CategoryDataset, ChangingDataset { 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/ChangingCategoryDatasetWithTTG.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import org.jfree.chart.labels.CategoryToolTipGenerator; 27 | 28 | /** 29 | * 30 | * @author tony 31 | */ 32 | public interface ChangingCategoryDatasetWithTTG 33 | extends ChangingCategoryDataset, CategoryToolTipGenerator { 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/ChangingDataset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | /** 27 | * 28 | * @author tony 29 | */ 30 | public interface ChangingDataset { 31 | 32 | public void datasetChanged(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/ChangingPieDataset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import org.jfree.data.general.PieDataset; 27 | 28 | /** 29 | * 30 | * @author tony 31 | */ 32 | public interface ChangingPieDataset 33 | extends PieDataset, ChangingDataset { 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/ChangingPieDatasetWithTTG.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import org.jfree.chart.labels.PieToolTipGenerator; 27 | 28 | /** 29 | * 30 | * @author tony 31 | */ 32 | public interface ChangingPieDatasetWithTTG 33 | extends ChangingPieDataset, PieToolTipGenerator { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/ChartLocker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import gchisto.utils.Locker; 27 | import org.jfree.chart.event.ChartProgressEvent; 28 | import org.jfree.chart.event.ChartProgressListener; 29 | 30 | /** 31 | * 32 | * @author tony 33 | */ 34 | public class ChartLocker extends Locker implements ChartProgressListener { 35 | 36 | public void chartProgress(ChartProgressEvent event) { 37 | switch (event.getType()) { 38 | case ChartProgressEvent.DRAWING_STARTED: 39 | lock(); 40 | break; 41 | case ChartProgressEvent.DRAWING_FINISHED: 42 | unlock(); 43 | break; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/DatasetWithGroups.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | /** 27 | * An interface that represents a dataset that can be partitioned into 28 | * groups and each group can be activated / de-activated. Groups can 29 | * correpond to series that JFreeChart datasets have. However, they are 30 | * a more general abstraction to allow different dataset subdivisions. 31 | * It is up to the implementing class to keep track of whether each group 32 | * is active or not. 33 | * 34 | * @author Tony Printezis 35 | */ 36 | public interface DatasetWithGroups { 37 | 38 | /** 39 | * It returns the number of groups in the dataset. 40 | * 41 | * @return The number of groups in the dataset. 42 | */ 43 | public int getGroupCount(); 44 | 45 | /** 46 | * It returns the name of the group with the given index. 47 | * 48 | * @param group The index of the group to be returned. 49 | * @return The name of the group with the givan index. 50 | */ 51 | public String getGroupName(int group); 52 | 53 | /** 54 | * It determines whether the group with the given index is active. 55 | * 56 | * @param group The index of the group to be determined whether it is 57 | * active. 58 | * @return Whether the group with the given index is active. 59 | */ 60 | public boolean isGroupActive(int group); 61 | 62 | /** 63 | * It sets whether the group with the given index is active or not. 64 | * 65 | * @param group The index of the group to be set as active or not active. 66 | * @param active Whether the group will be set as active or not. 67 | */ 68 | public void setGroupActive(int group, boolean active); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/IntervalXYDatasetWithGroups.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import org.jfree.data.xy.IntervalXYDataset; 27 | 28 | /** 29 | * An IntervalXYDataset extended with the DatasetWithGroups 30 | * interface. 31 | * 32 | * @author Tony Printezis 33 | * 34 | * @see org.jfree.data.xy.IntervalXYDataset 35 | * @see gchisto.jfreechart.extensions.DatasetWithGroups 36 | */ 37 | public interface IntervalXYDatasetWithGroups 38 | extends DatasetWithGroups, IntervalXYDataset, XYDatasetWithGroups { 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/XYDatasetWithGroups.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.jfreechart.extensions; 25 | 26 | import org.jfree.data.xy.XYDataset; 27 | 28 | /** 29 | * An XYDataset extended with the DatasetWithGroups 30 | * interface. 31 | * 32 | * @author Tony Printezis 33 | * 34 | * @see org.jfree.data.xy.XYDataset 35 | * @see gchisto.jfreechart.extensions.DatasetWithGroups 36 | */ 37 | public interface XYDatasetWithGroups 38 | extends DatasetWithGroups, XYDataset { 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/gchisto/jfreechart/extensions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains useful extensions to the JFreeChart classes. 26 | */ 27 | package gchisto.jfreechart.extensions; 28 | -------------------------------------------------------------------------------- /src/main/java/gchisto/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * The top-level package of the application. 26 | */ 27 | package gchisto; 28 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | import gchisto.utils.errorchecking.ArgumentChecking; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | /** 31 | * A convenience class that includes array-related utility methods. 32 | * All methods are static and this class cannot be instantiated. 33 | * 34 | * @author Tony Printezis 35 | */ 36 | public class ArrayUtils { 37 | 38 | /** 39 | * It returns an ArrayList that contains the elements of the given 40 | * array, in the same order. 41 | * 42 | * @param array The array whose contents will be used to populate 43 | * the new array list. 44 | * @return An ArrayList that contains the elements of the given 45 | * array, in the same order. 46 | */ 47 | static public ArrayList generateArrayList(String[] array) { 48 | ArgumentChecking.notNull(array, "array"); 49 | 50 | ArrayList list = new ArrayList(array.length); 51 | for (int i = 0; i < array.length; ++i) { 52 | list.add(i, array[i]); 53 | } 54 | return list; 55 | } 56 | 57 | /** 58 | * Private constructor to avoid the instantiation of this class. 59 | */ 60 | private ArrayUtils() { 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/Conversions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | /** 27 | * A convenience class that includes methods that perform frequently-used 28 | * conversions. All methods are static and this class cannot be instantiated. 29 | * 30 | * @author Tony Printezis 31 | */ 32 | public class Conversions { 33 | 34 | /** 35 | * It converts seconds to millis. 36 | * 37 | * @param sec The seconds to be converted in millis. 38 | * @return The millis amount that equals the sec argument. 39 | * 40 | * @see gchisto.utils.Conversions#msToSec(double) 41 | */ 42 | static public double secToMS(double sec) { 43 | return sec * 1000.0; 44 | } 45 | 46 | /** 47 | * It converts millis to seconds. 48 | * 49 | * @param ms The millis to be converted in seconds. 50 | * @return The seconds amount that equals the ms argument. 51 | * 52 | * @see gchisto.utils.Conversions#secToMS(double) 53 | */ 54 | static public double msToSec(double ms) { 55 | return ms / 1000.0; 56 | } 57 | 58 | /** 59 | * Private constructor to avoid the instantiation of this class. 60 | */ 61 | private Conversions() { 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/Copyright.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public Copyright version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Copyright 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public Copyright version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | /** 27 | * 28 | * @author Tony Printezis 29 | */ 30 | public class Copyright { 31 | 32 | static final private String COPYRIGHT_TEXT = 33 | "Copyright (c) 2007 Sun Microsystems, Inc., 4150 Network Circle, \n" + 34 | "Santa Clara, California 95054, USA All rights reserved.\n" + 35 | "\n" + 36 | "U.S. Government Rights - Commercial software. Government users are\n" + 37 | "subject to the Sun Microsystems, Inc. standard license agreement and\n" + 38 | "applicable provisions of the FAR and its supplements.\n" + 39 | "\n" + 40 | "Use is subject to license terms.\n" + 41 | "\n" + 42 | "Sun, Sun Microsystems, the Sun logo, Java and NetBeans are trademarks\n" + 43 | "or registered trademarks of Sun Microsystems, Inc. in the U.S. and\n" + 44 | "other countries.\n" + 45 | "\n" + 46 | "This product is covered and controlled by U.S. Export Control laws and\n" + 47 | "may be subject to the export or import laws in other\n" + 48 | "countries. Nuclear, missile, chemical biological weapons or nuclear\n" + 49 | "maritime end uses or end users, whether direct or indirect, are\n" + 50 | "strictly prohibited. Export or reexport to countries subject to\n" + 51 | "U.S. embargo or to entities identified on U.S. export exclusion lists,\n" + 52 | "including, but not limited to, the denied persons and specially\n" + 53 | "designated nationals lists is strictly prohibited.\n"; 54 | 55 | static public String text() { 56 | return COPYRIGHT_TEXT; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/Formatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | /** 27 | * An interface that allows a particular number formatter to format a number 28 | * into a string, according to the formatter's requirements. For several 29 | * reasons it was not straightforward to use java.text.NumberFormat. 30 | * This interface is similar, but more straightforward. The Formatting 31 | * class provides Formatter factories. 32 | * 33 | * @author Tony Printezis 34 | * @see java.text.NumberFormat 35 | */ 36 | public interface Formatter { 37 | 38 | /** 39 | * It formats the given number into a string, according to the formatter's 40 | * requirements. 41 | * 42 | * @param number The number to be formatted into a string. 43 | * @return The given number, formatted according to the formatter's 44 | * requirements. 45 | * 46 | * @see gchisto.utils.Formatting 47 | */ 48 | public String format(Number number); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/ListenerSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | import gchisto.utils.errorchecking.ArgumentChecking; 27 | import java.util.LinkedList; 28 | import java.util.List; 29 | 30 | /** 31 | * A convenience class that keeps track of listener objects. It is used by 32 | * all the listener sets used in this application. 33 | * 34 | * @author Tony Printezis 35 | */ 36 | abstract public class ListenerSet { 37 | 38 | /** 39 | * The list that contains the added listener objects. 40 | */ 41 | final private List listeners = new LinkedList(); 42 | 43 | /** 44 | * It returns the linked list that holds the listeners. 45 | * 46 | * @return The linked list that holds the listeners. 47 | */ 48 | protected List listeners() { 49 | return listeners; 50 | } 51 | 52 | /** 53 | * It adds a listener to this set. 54 | * 55 | * @param listener The listener to be added to this set. 56 | */ 57 | public void add(L listener) { 58 | ArgumentChecking.notNull(listener, "listener"); 59 | 60 | assert !listeners.contains(listener) : 61 | "listener " + listener + " should not already exist in the listener set."; 62 | listeners.add(listener); 63 | } 64 | 65 | /** 66 | * It removes a listener from this set. 67 | * 68 | * @param listener The listener to the removed from this set. 69 | */ 70 | public void remove(L listener) { 71 | ArgumentChecking.notNull(listener, "listener"); 72 | 73 | assert listeners.contains(listener) : 74 | "listener " + listener + " should already exist in the listener set."; 75 | listeners.remove(listener); 76 | } 77 | 78 | /** 79 | * It creates a listener set instance. 80 | */ 81 | protected ListenerSet() { 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/Locker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | import java.util.concurrent.locks.ReentrantLock; 27 | 28 | /** 29 | * 30 | * @author tony 31 | */ 32 | public class Locker { 33 | 34 | final private ReentrantLock lock = new ReentrantLock(); 35 | private int count = 0; 36 | 37 | protected void lock() { 38 | lock.lock(); 39 | assert count >= 0; 40 | count += 1; 41 | } 42 | 43 | protected void unlock() { 44 | assert lock.isHeldByCurrentThread(); 45 | 46 | assert count > 0; 47 | count -= 1; 48 | lock.unlock(); 49 | } 50 | 51 | public boolean isLockedByCurrentThread() { 52 | return lock.isHeldByCurrentThread(); 53 | } 54 | 55 | public void doWhileLocked(Runnable runnable) { 56 | lock(); 57 | try { 58 | runnable.run(); 59 | } finally { 60 | unlock(); 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/MessageReporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | import gchisto.gui.utils.StatusLabelManager; 27 | import gchisto.utils.errorchecking.ArgumentChecking; 28 | 29 | /** 30 | * A class that is used to report messages and errors to the user. All methods 31 | * are static and this class cannot be instantiated. 32 | * 33 | * @author Tony Printezis 34 | */ 35 | public class MessageReporter { 36 | 37 | /** 38 | * The object that moanages the behavior of the status label. 39 | */ 40 | static private StatusLabelManager statusLabel; 41 | 42 | /** 43 | * It sets the object that manages the behavior of the status label. 44 | * 45 | * @param statusLabel The object that manages the behavior of the status 46 | * label. 47 | */ 48 | static public void setStatusLabel(StatusLabelManager statusLabel) { 49 | ArgumentChecking.notNull(statusLabel, "statusLabel"); 50 | 51 | MessageReporter.statusLabel = statusLabel; 52 | } 53 | 54 | /** 55 | * It shows a message in the status label. 56 | * 57 | * @param str The message to be shown in the status label. 58 | */ 59 | static public void showMessage(String str) { 60 | if (statusLabel==null) { 61 | System.out.println(str); 62 | return; 63 | } 64 | ArgumentChecking.notNull(str, "str"); 65 | 66 | statusLabel.showMessage(str); 67 | } 68 | 69 | /** 70 | * It shows an error in the status label. 71 | * 72 | * @param str The error to be shown in the status label. 73 | */ 74 | static public void showError(String str) { 75 | if (statusLabel==null) { 76 | System.out.println(str); 77 | return; 78 | } 79 | ArgumentChecking.notNull(str, "str"); 80 | 81 | statusLabel.showError(str); 82 | } 83 | 84 | /** 85 | * Private constructor to avoid the instantiation of this class. 86 | */ 87 | private MessageReporter() { 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/Refresher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | /** 27 | * 28 | * @author tony 29 | */ 30 | public class Refresher { 31 | 32 | private class Task implements WorkerTask { 33 | 34 | public void doIt() { 35 | callback.refresh(); 36 | completeTask(); 37 | } 38 | } 39 | final private WorkerThread workerThread; 40 | final private RefresherCallback callback; 41 | boolean inProgress = false; 42 | boolean pending = false; 43 | 44 | private void addTask() { 45 | inProgress = true; 46 | callback.beforeAddingTask(); 47 | workerThread.add(new Task()); 48 | } 49 | 50 | synchronized private void completeTask() { 51 | if (pending) { 52 | addTask(); 53 | pending = false; 54 | } else { 55 | inProgress = false; 56 | } 57 | } 58 | 59 | public void possiblyRefresh() { 60 | if (!pending) { 61 | possiblyRefreshInternal(); 62 | } 63 | } 64 | 65 | synchronized public void possiblyRefreshInternal() { 66 | if (callback.shouldRefresh()) { 67 | if (!inProgress) { 68 | addTask(); 69 | } else { 70 | pending = true; 71 | } 72 | } 73 | } 74 | 75 | public Refresher( 76 | WorkerThread workerThread, 77 | RefresherCallback callback) { 78 | this.workerThread = workerThread; 79 | this.callback = callback; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/RefresherCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | /** 27 | * 28 | * @author tony 29 | */ 30 | public interface RefresherCallback { 31 | 32 | public boolean shouldRefresh(); 33 | public void beforeAddingTask(); 34 | public void refresh(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/WorkerTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | /** 27 | * 28 | * @author tony 29 | */ 30 | public interface WorkerTask { 31 | 32 | public void doIt(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/WorkerThread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils; 25 | 26 | import java.util.LinkedList; 27 | import java.util.Queue; 28 | 29 | /** 30 | * 31 | * @author tony 32 | */ 33 | public class WorkerThread extends Thread { 34 | 35 | private Queue queue = new LinkedList(); 36 | 37 | static final private WorkerThread instance; 38 | 39 | static { 40 | instance = new WorkerThread(); 41 | instance.start(); 42 | } 43 | 44 | static public WorkerThread instance() { 45 | return instance; 46 | } 47 | 48 | public void run() { 49 | while (true) { 50 | WorkerTask task; 51 | synchronized (this) { 52 | task = queue.poll(); 53 | while (task == null) { 54 | try { 55 | wait(); 56 | } catch (InterruptedException e) { 57 | } 58 | task = queue.poll(); 59 | } 60 | } 61 | 62 | task.doIt(); 63 | } 64 | } 65 | 66 | synchronized public void add(WorkerTask task) { 67 | queue.offer(task); 68 | notifyAll(); 69 | } 70 | 71 | private WorkerThread() { 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/errorchecking/ErrorReporting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils.errorchecking; 25 | 26 | /** 27 | * A convenience class that includes methods that check and/or report fatal 28 | * errors and warnings. All methods are static and this class cannot be 29 | * instantiated. 30 | * 31 | * @author Tony Printezis 32 | */ 33 | public class ErrorReporting { 34 | 35 | /** 36 | * If it is true, then warnings are reported. 37 | * 38 | * @see #setShowWarnings(boolean) 39 | */ 40 | static private boolean showWarnings = false; 41 | 42 | /** 43 | * It unconditionally throws a FatalErrorException with the 44 | * given message. 45 | * 46 | * @param str The message to be attached to the exception to be thrown. 47 | * @exception FatalErrorException The exception that is unconditionally 48 | * thrown. 49 | * 50 | * @see #fatalError(boolean, String) 51 | */ 52 | static public void fatalError(String str) { 53 | fatalError(false, str); 54 | } 55 | 56 | /** 57 | * It throws a FatalErrorException with the given message if 58 | * the given assertion does not hold. 59 | * 60 | * @param assertion The assertion to be checked. 61 | * @param str The message to be attached to the exception to be thrown. 62 | * @exception FatalErrorException The exception that is conditionally 63 | * thrown. 64 | * 65 | * @see #fatalError(String) 66 | */ 67 | static public void fatalError(boolean assertion, String str) { 68 | if (!assertion) { 69 | throw new FatalErrorException(str); 70 | } 71 | } 72 | 73 | /** 74 | * It sets whether warnings will be shown or not. 75 | * 76 | * @param showWarnings It determines whether warnings will be shown or not. 77 | * @see #warning(String) 78 | * @see #warning(boolean, String) 79 | */ 80 | static public void setShowWarnings(boolean showWarnings) { 81 | ErrorReporting.showWarnings = showWarnings; 82 | } 83 | 84 | /** 85 | * It unconditionally shows a warning with the given message, as long 86 | * as warnings are being shown. 87 | * 88 | * @param str The message of the warning to be shown. 89 | * 90 | * @see #setShowWarnings(boolean) 91 | * @see #warning(boolean, String) 92 | */ 93 | static public void warning(String str) { 94 | warning(false, str); 95 | } 96 | 97 | /** 98 | * It shows a warning with the given message if the given assertion 99 | * does not hold and as long as warnings are being shown. 100 | * 101 | * @param assertion The assertion to be checked. 102 | * @param str The message of the warning to be shown. 103 | * 104 | * @see #setShowWarnings(boolean) 105 | * @see #warning(String) 106 | */ 107 | static public void warning(boolean assertion, String str) { 108 | if (showWarnings && !assertion) { 109 | System.out.println("warning : " + str); 110 | } 111 | } 112 | 113 | /** 114 | * Private constructor to avoid the instantiation of this class. 115 | */ 116 | private ErrorReporting() { 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/errorchecking/FatalErrorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils.errorchecking; 25 | 26 | /** 27 | * An exception that denotes a fatal error has been raised by the application. 28 | * 29 | * @author Tony Printezis 30 | * @see gchisto.utils.errorchecking#ErrorReporting.fatalError(String) 31 | * @see gchisto.utils.errorchecking#ErrorReporting.fatalError(boolean, String) 32 | */ 33 | public class FatalErrorException extends RuntimeException { 34 | 35 | /** 36 | * Private constructor so that it is not called. 37 | */ 38 | private FatalErrorException() { 39 | } 40 | 41 | /** 42 | * It creates a new instance of this exception and attaches the given 43 | * message to it. 44 | * 45 | * @param str The message to be associated with the new instance 46 | * of this exception. 47 | */ 48 | public FatalErrorException(String str) { 49 | super("Fatal Error : " + str); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/errorchecking/IllegalArgumentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils.errorchecking; 25 | 26 | /** 27 | * An exception that denotes that an illegal argument has been passed to a 28 | * method. 29 | * 30 | * @author Tony Printezis 31 | * @see gchisto.utils.errorchecking.ArgumentChecking 32 | */ 33 | public class IllegalArgumentException extends RuntimeException { 34 | 35 | /** 36 | * Private constructor so that it is not called. 37 | */ 38 | private IllegalArgumentException() { 39 | } 40 | 41 | /** 42 | * It creates a new instance of this exception and attaches the given 43 | * message to it. 44 | * 45 | * @param str The message to be associated with the new instance 46 | * of this exception. 47 | */ 48 | public IllegalArgumentException(String str) { 49 | super("Illegal Argument : " + str); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/errorchecking/NotImplementedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils.errorchecking; 25 | 26 | /** 27 | * An exception that denotes that a method that has not been implemented 28 | * yet has been called. 29 | * 30 | * @author Tony Printezis 31 | */ 32 | public class NotImplementedException extends RuntimeException { 33 | 34 | /** 35 | * It creates a new instance of this exception. 36 | */ 37 | public NotImplementedException() { 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/errorchecking/ShouldNotReachHereException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gchisto.utils.errorchecking; 25 | 26 | /** 27 | * An exception that denotes that the application has reached a position 28 | * in the code that it should not have reached. 29 | * 30 | * @author Tony Printezis 31 | */ 32 | public class ShouldNotReachHereException extends RuntimeException { 33 | 34 | /** 35 | * It creates a new instance of this exception. 36 | */ 37 | public ShouldNotReachHereException() { 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/errorchecking/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains classes that used for detecting and reporting errors. 26 | */ 27 | package gchisto.utils.errorchecking; 28 | -------------------------------------------------------------------------------- /src/main/java/gchisto/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | /** 25 | * It contains miscellaneous utilities shared by other packages. 26 | */ 27 | package gchisto.utils; 28 | -------------------------------------------------------------------------------- /src/main/java/gcparser/FWYoungGCParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gcparser; 25 | 26 | import java.util.regex.*; 27 | 28 | public class FWYoungGCParser extends GCParser 29 | { 30 | public FWYoungGCParser(GCStats gcstats, boolean verbose) 31 | { 32 | super(gcstats, verbose); 33 | // _debug = System.err; // XXX 34 | } 35 | 36 | public boolean parse(String filename, int line, String s) 37 | { 38 | Matcher m = _pattern.matcher(s); 39 | if (m.find()) 40 | { 41 | save_match_state(filename, line, s); 42 | debug(s, m); // XXX 43 | add_young_gc(m, timestamp_grp, 44 | yg_used_beg_grp, yg_used_end_grp, 45 | yg_commit_end_grp, th_used_beg_grp, 46 | th_used_end_grp, th_commit_end_grp, 47 | gc_time_grp); 48 | return true; 49 | } 50 | 51 | return false; 52 | } 53 | 54 | // XXX 55 | private void debug(String s, Matcher m) 56 | { 57 | if (_debug == null) return; 58 | debug(s); debug(); 59 | debug(m, yg_used_beg_grp, "yub"); 60 | debug(m, yg_used_end_grp, " yue"); 61 | debug(m, yg_commit_end_grp, " yco"); 62 | debug(); 63 | debug(m, th_used_beg_grp, "tub"); 64 | debug(m, th_used_end_grp, " tue"); 65 | debug(m, th_commit_end_grp, " tco"); 66 | debug(); 67 | } 68 | 69 | // 0.246: [GC 0.246: [DefNew: 1403K->105K(1984K), 0.0109275 secs] 1403K->1277K(6080K), 0.0110143 secs] 70 | private static Pattern _pattern = Pattern.compile( 71 | timestamp_re + "\\[GC " + timestamp_re + "\\[" + 72 | fw_young_gen_re + ": " + heap_report_re + "\\] " + 73 | heap_report_re + "\\]"); 74 | 75 | private static final int timestamp_grp = timestamp_re_time_group; 76 | 77 | private static final int yg_used_beg_grp = 78 | timestamp_re_groups * 2 + fw_young_gen_re_groups + 1; 79 | private static final int yg_used_end_grp = 80 | yg_used_beg_grp + heap_size_re_groups; 81 | private static final int yg_commit_end_grp = 82 | yg_used_end_grp + heap_size_re_groups; 83 | 84 | private static final int th_used_beg_grp = 85 | yg_used_beg_grp + heap_report_re_groups; 86 | private static final int th_used_end_grp = 87 | th_used_beg_grp + heap_size_re_groups; 88 | private static final int th_commit_end_grp = 89 | th_used_end_grp + heap_size_re_groups; 90 | 91 | private static final int gc_time_grp = 92 | th_commit_end_grp + heap_size_re_groups; 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/gcparser/GCDataStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gcparser; 25 | 26 | import java.io.File; 27 | import java.io.BufferedWriter; 28 | import java.io.FileWriter; 29 | import java.io.IOException; 30 | import java.util.ArrayList; 31 | import java.util.EnumMap; 32 | import java.util.Iterator; 33 | 34 | public class GCDataStore extends GCStats 35 | { 36 | GCDataStore(EnumMap enabled_map, int cpu_count, 37 | boolean has_time_zero) 38 | { 39 | super(enabled_map, cpu_count, has_time_zero); 40 | 41 | Class c = GCMetric.class; 42 | _data_map = new EnumMap>(c); 43 | _time_map = new EnumMap>(c); 44 | 45 | ArrayList tlist = null; 46 | for (GCMetric metric: GCMetric.values()) 47 | { 48 | _data_map.put(metric, new ArrayList()); 49 | switch (metric.timestamp_type()) 50 | { 51 | case 0: tlist = null; break; 52 | case 1: tlist = new ArrayList(); break; 53 | } 54 | _time_map.put(metric, tlist); 55 | } 56 | } 57 | 58 | public void add(GCMetric metric, double val) 59 | { 60 | super.add(metric, val); 61 | _data_map.get(metric).add(new Double(val)); 62 | } 63 | 64 | public void add(GCMetric metric, String s) 65 | { 66 | Double val = Double.parseDouble(s); 67 | add(metric, val); 68 | } 69 | 70 | public void add_timestamp(GCMetric metric, double beg, double end) 71 | { 72 | super.add_timestamp(metric, beg, end); 73 | ArrayList tlist = _time_map.get(metric); 74 | if (tlist != null) 75 | { 76 | tlist.add(timestamp_offset() + beg); 77 | } 78 | } 79 | 80 | public ArrayList data(GCMetric metric) 81 | { 82 | return _data_map.get(metric); 83 | } 84 | 85 | public ArrayList time(GCMetric metric) 86 | { 87 | return _time_map.get(metric); 88 | } 89 | 90 | public void save(String prefix, String suffix) throws IOException 91 | { 92 | for (GCMetric metric: GCMetric.values()) 93 | { 94 | save(metric, prefix, suffix); 95 | } 96 | } 97 | 98 | public void save(GCMetric metric, String prefix, String suffix) 99 | throws IOException 100 | { 101 | if (disabled(metric)) return; 102 | 103 | ArrayList d = data(metric); 104 | if (d.size() == 0) return; 105 | Iterator diter = d.iterator(); 106 | 107 | ArrayList t = time(metric); 108 | Iterator titer = t.iterator(); 109 | // t != null ? t.iterator() : new NumberIterator(0.0, 1.0); 110 | 111 | String name = filename(metric, prefix, suffix); 112 | FileWriter fw = new FileWriter(name); 113 | BufferedWriter w = new BufferedWriter(fw); 114 | 115 | while (diter.hasNext()) 116 | { 117 | w.write(titer.next().toString()); 118 | w.write(' '); 119 | w.write(diter.next().toString()); 120 | w.write(eol); 121 | } 122 | w.close(); 123 | } 124 | 125 | protected String filename(GCMetric metric, String prefix, String suffix) 126 | { 127 | StringBuilder filename = new StringBuilder(); 128 | if (prefix != null) filename.append(prefix); 129 | filename.append(metric); 130 | if (suffix != null) filename.append(suffix); 131 | return filename.toString(); 132 | } 133 | 134 | private EnumMap> _data_map; 135 | private EnumMap> _time_map; 136 | } 137 | -------------------------------------------------------------------------------- /src/main/java/gcparser/NumberIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gcparser; 25 | 26 | import java.util.Iterator; 27 | 28 | // XXX - this should be generified. 29 | 30 | public class NumberIterator implements Iterator 31 | { 32 | public NumberIterator(double start, double increment) 33 | { 34 | _cur = start; 35 | _inc = increment; 36 | } 37 | 38 | public boolean hasNext() { return true; } 39 | public Double next() 40 | { 41 | Double tmp = new Double(_cur); 42 | _cur += _inc; 43 | return tmp; 44 | } 45 | public void remove() { throw new UnsupportedOperationException(); } 46 | 47 | private double _cur; 48 | private double _inc; 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/gcparser/ParCompactPhaseGCParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gcparser; 25 | 26 | import java.util.regex.*; 27 | 28 | public class ParCompactPhaseGCParser extends GCParser 29 | { 30 | public ParCompactPhaseGCParser(GCStats gcstats, boolean verbose) 31 | { 32 | super(gcstats, verbose); 33 | // _debug = System.err; // XXX 34 | if (_debug == null) return; 35 | } 36 | 37 | public boolean parse(String filename, int line, String s) 38 | { 39 | for (int i = 0; i < _patterns.length; ++i) 40 | { 41 | Matcher m = _patterns[i].matcher(s); 42 | if (m.find()) 43 | { 44 | save_match_state(filename, line, s); 45 | debug(s, m, _metrics[i]); // XXX 46 | 47 | String str = m.group(m.groupCount() - 1); 48 | double len = Double.parseDouble(str); 49 | add_dp(_metrics[i], len); 50 | 51 | double ts = get_ts(m, timestamp_re_time_group); 52 | add_ts(_metrics[i], ts, ts + len); 53 | 54 | return true; 55 | } 56 | } 57 | 58 | return false; 59 | } 60 | 61 | // XXX 62 | private void debug(String s, Matcher m, GCMetric metric) 63 | { 64 | if (_debug == null) return; 65 | debug(s); debug(); 66 | debug(m, m.groupCount() - 1, metric.toString()); 67 | debug(); 68 | } 69 | 70 | private static Pattern phase_pattern(String phase_name_re) 71 | { 72 | return Pattern.compile(timestamp_re + "\\[" + phase_name_re + 73 | " *[,:] *" + gc_time_secs_re + "\\]"); 74 | } 75 | 76 | // Regular expressions to match the phase names printed by 77 | // -XX:+PrinParallelOldGCPhaseTimes. 78 | private static String _phase_name_res[] = 79 | { 80 | // [pre compact, 0.0000078 secs] 81 | // [par mark, 0.0096726 secs] 82 | // [reference processing, 0.0000857 secs] 83 | // [class unloading, 0.0013404 secs] 84 | // [marking phase, 0.0112408 secs] 85 | // [summary phase, 0.0017760 secs] 86 | // [adjust roots, 0.0012449 secs] 87 | // [compact perm gen, 0.0103245 secs] 88 | // [drain task setup, 0.0000919 secs] 89 | // [dense prefix task setup, 0.0000043 secs] 90 | // [steal task setup, 0.0000013 secs] 91 | // [par compact, 0.0074996 secs] 92 | // [deferred updates, 0.0026894 secs] 93 | // [compaction phase, 0.0105486 secs] 94 | // [post compact, 0.0015983 secs] 95 | "pre compact", 96 | "par mark", 97 | "marking flush", 98 | "reference processing", 99 | "class unloading", 100 | "(par )?marking phase", 101 | "summary phase", 102 | "adjust roots", 103 | "compact perm gen", 104 | "drain(ing)? task setup", 105 | "dense prefix task setup", 106 | "steal task setup", 107 | "par compact", 108 | "deferred updates", 109 | "compaction phase", 110 | "post compact" 111 | }; 112 | 113 | // The metrics that correspond to the above phase names. 114 | private static GCMetric _metrics[] = 115 | { 116 | GCMetric.pc_pre_comp, 117 | GCMetric.pc_par_mark, 118 | GCMetric.pc_mark_flush, 119 | GCMetric.pc_ref_proc, 120 | GCMetric.pc_cls_unload, 121 | GCMetric.pc_mark, 122 | GCMetric.pc_summary, 123 | GCMetric.pc_adj_roots, 124 | GCMetric.pc_perm_gen, 125 | GCMetric.pc_drain_ts, 126 | GCMetric.pc_dpre_ts, 127 | GCMetric.pc_steal_ts, 128 | GCMetric.pc_par_comp, 129 | GCMetric.pc_deferred, 130 | GCMetric.pc_compact, 131 | GCMetric.pc_post_comp, 132 | }; 133 | 134 | private static Pattern _patterns[]; 135 | 136 | static 137 | { 138 | final int n = _phase_name_res.length; 139 | _patterns = new Pattern[n]; 140 | for (int i = 0; i < n; ++i) 141 | { 142 | _patterns[i] = phase_pattern(_phase_name_res[i]); 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/main/java/gcparser/ParGCFullGCParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gcparser; 25 | 26 | import java.util.regex.*; 27 | 28 | public class ParGCFullGCParser extends GCParser 29 | { 30 | public ParGCFullGCParser(GCStats gcstats, boolean verbose) 31 | { 32 | super(gcstats, verbose); 33 | // _debug = System.err; // XXX 34 | } 35 | 36 | public boolean parse(String filename, int line, String s) 37 | { 38 | Matcher m = _pattern.matcher(s); 39 | if (m.find()) 40 | { 41 | save_match_state(filename, line, s); 42 | debug(s, m); // XXX 43 | add_full_gc(m, timestamp_grp, 44 | og_used_beg_grp, og_used_end_grp, 45 | og_commit_end_grp, th_used_beg_grp, 46 | th_used_end_grp, th_commit_end_grp, 47 | pg_used_beg_grp, pg_used_end_grp, 48 | pg_commit_end_grp, gc_time_grp); 49 | return true; 50 | } 51 | 52 | return false; 53 | } 54 | 55 | // XXX 56 | private void debug(String s, Matcher m) 57 | { 58 | if (_debug == null) return; 59 | debug(s); debug(); 60 | debug(m, yg_used_beg_grp, "yub"); 61 | debug(m, yg_used_end_grp, " yue"); 62 | debug(m, yg_commit_end_grp, " yco"); 63 | debug(); 64 | debug(m, og_used_beg_grp, "oub"); 65 | debug(m, og_used_end_grp, " oue"); 66 | debug(m, og_commit_end_grp, " oco"); 67 | debug(); 68 | debug(m, th_used_beg_grp, "tub"); 69 | debug(m, th_used_end_grp, " tue"); 70 | debug(m, th_commit_end_grp, " tco"); 71 | debug(); 72 | } 73 | 74 | private static Pattern _pattern = Pattern.compile( 75 | timestamp_re + full_gc_re + 76 | "\\[" + pargc_young_gen_name_re + ": +" + 77 | heap_size_status_re + "\\] " + 78 | "\\[" + pargc_old_gen_name_re + ": +" + 79 | heap_size_status_re + "\\] " + 80 | heap_size_status_re + " " + 81 | "\\[" + pargc_perm_gen_name_re + ": +" + 82 | heap_size_status_re + "\\], " + 83 | gc_time_secs_re + "\\]"); 84 | 85 | private static final int timestamp_grp = timestamp_re_time_group; 86 | 87 | private static final int yg_used_beg_grp = 88 | timestamp_re_groups + full_gc_re_groups + 89 | pargc_young_gen_name_re_groups + 1; 90 | private static final int yg_used_end_grp = 91 | yg_used_beg_grp + heap_size_re_groups; 92 | private static final int yg_commit_end_grp = 93 | yg_used_end_grp + heap_size_re_groups; 94 | 95 | private static final int og_used_beg_grp = 96 | yg_commit_end_grp + heap_size_re_groups + 97 | pargc_old_gen_name_re_groups; 98 | private static final int og_used_end_grp = 99 | og_used_beg_grp + heap_size_re_groups; 100 | private static final int og_commit_end_grp = 101 | og_used_end_grp + heap_size_re_groups; 102 | 103 | private static final int th_used_beg_grp = 104 | og_commit_end_grp + heap_size_re_groups; 105 | private static final int th_used_end_grp = 106 | th_used_beg_grp + heap_size_re_groups; 107 | private static final int th_commit_end_grp = 108 | th_used_end_grp + heap_size_re_groups; 109 | 110 | private static final int pg_used_beg_grp = 111 | th_commit_end_grp + heap_size_re_groups + 112 | pargc_perm_gen_name_re_groups; 113 | private static final int pg_used_end_grp = 114 | pg_used_beg_grp + heap_size_re_groups; 115 | private static final int pg_commit_end_grp = 116 | pg_used_end_grp + heap_size_re_groups; 117 | 118 | private static final int gc_time_grp = 119 | pg_commit_end_grp + heap_size_re_groups; 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/gcparser/ParGCYoungGCParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gcparser; 25 | 26 | import java.util.regex.*; 27 | 28 | public class ParGCYoungGCParser extends GCParser 29 | { 30 | public ParGCYoungGCParser(GCStats gcstats, boolean verbose) 31 | { 32 | super(gcstats, verbose); 33 | // _debug = System.err; // XXX 34 | } 35 | 36 | public boolean parse(String filename, int line, String s) 37 | { 38 | Matcher m = _pattern.matcher(s); 39 | if (m.find()) 40 | { 41 | save_match_state(filename, line, s); 42 | // debug(s, m); // XXX 43 | add_young_gc(m, timestamp_grp, 44 | yg_used_beg_grp, yg_used_end_grp, 45 | yg_commit_end_grp, th_used_beg_grp, 46 | th_used_end_grp, th_commit_end_grp, 47 | gc_time_grp); 48 | return true; 49 | } 50 | 51 | return false; 52 | } 53 | 54 | // XXX 55 | private void debug(String s, Matcher m) 56 | { 57 | if (_debug == null) return; 58 | debug(s); debug(); 59 | debug(m, yg_used_beg_grp, "yub"); 60 | debug(m, yg_used_end_grp, " yue"); 61 | debug(m, yg_commit_end_grp, " yco"); 62 | debug(); 63 | debug(m, th_used_beg_grp, "tub"); 64 | debug(m, th_used_end_grp, " tue"); 65 | debug(m, th_commit_end_grp, " tco"); 66 | debug(); 67 | } 68 | 69 | private static Pattern _pattern = Pattern.compile( 70 | timestamp_re + pargc_young_gc_re + 71 | "\\[" + pargc_young_gen_name_re + ": +" + 72 | heap_size_status_re + "\\] " + 73 | heap_size_status_re + ", " + 74 | gc_time_secs_re + "\\]"); 75 | 76 | private static final int timestamp_grp = timestamp_re_time_group; 77 | 78 | private static final int yg_used_beg_grp = 79 | timestamp_re_groups + pargc_young_gc_re_groups + 80 | pargc_young_gen_name_re_groups + 1; 81 | private static final int yg_used_end_grp = 82 | yg_used_beg_grp + heap_size_re_groups; 83 | private static final int yg_commit_end_grp = 84 | yg_used_end_grp + heap_size_re_groups; 85 | 86 | private static final int th_used_beg_grp = 87 | yg_commit_end_grp + heap_size_re_groups; 88 | private static final int th_used_end_grp = 89 | th_used_beg_grp + heap_size_re_groups; 90 | private static final int th_commit_end_grp = 91 | th_used_end_grp + heap_size_re_groups; 92 | 93 | private static final int gc_time_grp = 94 | th_commit_end_grp + heap_size_re_groups; 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/gcparser/TimingWindowData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. 8 | * 9 | * This code is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | * version 2 for more details (a copy is included in the LICENSE file that 13 | * accompanied this code). 14 | * 15 | * You should have received a copy of the GNU General Public License version 16 | * 2 along with this work; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 | * CA 95054 USA or visit www.sun.com if you need additional information or 21 | * have any questions. 22 | * 23 | */ 24 | package gcparser; 25 | 26 | public class TimingWindowData 27 | { 28 | public TimingWindowData(int cpu_count) { _cpu_count = cpu_count; } 29 | 30 | public double th_alloc() { return _th_alloc; } 31 | 32 | // The various times that are tracked. 33 | public double elapsed_time() { return _end - _beg; } 34 | public double pause_time() { return _pause_time; } 35 | public double concurrent_time() { return _concurrent_time; } 36 | public double mutator_time() 37 | { 38 | return elapsed_time() - _pause_time - _concurrent_time; 39 | } 40 | 41 | // The various times, scaled by the number of cpus. 42 | public double elapsed_cpu_time() { return elapsed_time() * _cpu_count; } 43 | public double concurrent_cpu_time() { return _concurrent_cpu_time; } 44 | public double pause_cpu_time() { return _pause_time * _cpu_count; } 45 | public double mutator_cpu_time() 46 | { 47 | return (elapsed_time() - _pause_time) * _cpu_count - 48 | _concurrent_cpu_time; 49 | } 50 | 51 | public void add_pause_time(double end_timestamp, double t) 52 | { 53 | _end = end_timestamp; 54 | _pause_time += t; 55 | } 56 | 57 | public void 58 | add_concurrent_time(double end_timestamp, double t, int thread_cnt) 59 | { 60 | _end = end_timestamp; 61 | _concurrent_time += t; 62 | _concurrent_cpu_time += t * thread_cnt; 63 | } 64 | 65 | public void reset(double timestamp, double th_alloc) 66 | { 67 | _pause_time = _concurrent_time = _concurrent_cpu_time = 0.0; 68 | _beg = _end = timestamp; 69 | _th_alloc = th_alloc; 70 | } 71 | 72 | private double _th_alloc; 73 | 74 | // Time accumulated over a short window during the run. 75 | private double _pause_time; 76 | private double _concurrent_time; 77 | private double _concurrent_cpu_time; 78 | private double _beg; 79 | private double _end; 80 | private final int _cpu_count; 81 | } 82 | --------------------------------------------------------------------------------