1402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/******************************************************************************* 2402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Copyright (c) 2000, 2009 IBM Corporation and others. 3402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * All rights reserved. This program and the accompanying materials 4402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * are made available under the terms of the Eclipse Public License v1.0 5402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * which accompanies this distribution, and is available at 6402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * http://www.eclipse.org/legal/epl-v10.html 7402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 8402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Contributors: 9402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * IBM Corporation - initial API and implementation 10402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *******************************************************************************/ 11402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpackage org.eclipse.test.internal.performance.results.db; 12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.File; 14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.PrintWriter; 15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.StringWriter; 16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.math.BigDecimal; 17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.sql.Connection; 18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.sql.DriverManager; 19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.sql.ResultSet; 20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.sql.SQLException; 21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.ArrayList; 22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Arrays; 23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.HashMap; 24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.List; 25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Map; 26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.StringTokenizer; 27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.Assert; 29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.PerformanceTestPlugin; 30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.data.Dim; 31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.db.DB; 32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.utils.IPerformancesConstants; 33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.utils.Util; 34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.performance.Dimension; 35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Specific and private implementation of {@link org.eclipse.test.internal.performance.db.DB} class 38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * to get massive results from performance results database. 39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * TODO (frederic) Should be at least a subclass of {@link DB}... 40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic class DB_Results { 42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final String DEFAULT_DB_BASELINE_PREFIX = "R-"; 45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final Dim[] NO_DIMENSION = new Dim[0]; 46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final String[] EMPTY_LIST = new String[0]; 47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final boolean DEBUG = false; 48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static final boolean LOG = false; 49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // the two supported DB types 51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final String DERBY= "derby"; //$NON-NLS-1$ 52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static final String CLOUDSCAPE= "cloudscape"; //$NON-NLS-1$ 53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static DB_Results fgDefault; 55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private Connection fConnection; 57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private SQL_Results fSQL; 58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// private boolean fIsEmbedded; 59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private String fDBType; // either "derby" or "cloudscape" 60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Preferences info 62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static boolean DB_CONNECTION = false; 63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String DB_NAME; 64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String DB_LOCATION; 65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String DB_BASELINE_PREFIX = DEFAULT_DB_BASELINE_PREFIX; 66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String DB_VERSION; 67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String DB_VERSION_REF; 68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get the name of the database. 71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The name as a string. 73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static String getDbName() { 75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_NAME == null) initDbContants(); 76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DB_NAME; 77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the name of the database. 81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param dbName The name as a string. 83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static void setDbName(String dbName) { 85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Assert.isNotNull(dbName); 86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_NAME = dbName; 87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get the location of the database. 91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The location as a string. 93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static String getDbLocation() { 95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!DB_CONNECTION) return null; 96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_LOCATION == null) initDbContants(); 97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DB_LOCATION; 98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the location of the database. 102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param dbLocation The location as a string. 104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static void setDbLocation(String dbLocation) { 106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Assert.isNotNull(dbLocation); 107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_LOCATION = dbLocation; 108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get the default baseline prefix. 112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The prefix as a string. 114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static String getDbBaselinePrefix() { 116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DB_BASELINE_PREFIX; 117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the baseline prefix of the database. 121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param baselinePrefix The prefix as a string. 123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static void setDbDefaultBaselinePrefix(String baselinePrefix) { 125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Assert.isNotNull(baselinePrefix); 126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Assert.isTrue(baselinePrefix.startsWith(DEFAULT_DB_BASELINE_PREFIX)); 127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_BASELINE_PREFIX = baselinePrefix; 128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get the baseline reference version of the database. 132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The version as a string. 134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static String getDbBaselineRefVersion() { 136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_VERSION_REF == null) initDbContants(); 137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DB_VERSION_REF; 138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get the version of the database. 142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The version as a string. 144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static String getDbVersion() { 146402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_VERSION == null) initDbContants(); 147402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DB_VERSION; 148402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 149402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 150402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 151402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the version of the database. 152402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 153402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param version The version as a string. 154402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 155402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static void setDbVersion(String version) { 156402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Assert.isNotNull(version); 157402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Assert.isTrue(version.startsWith("v3")); 158402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_VERSION = version; 159402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 160402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 161402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 162402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Update the database constants from a new database location. 163402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param connected Tells whether the database should be connected or not. 164402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param databaseLocation The database location. 165402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * May be a path to a local folder or a net address 166402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (see {@link IPerformancesConstants#NETWORK_DATABASE_LOCATION}). 167402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 168402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static boolean updateDbConstants(boolean connected, int eclipseVersion, String databaseLocation) { 169402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_CONNECTION != connected || DB_LOCATION == null || DB_NAME == null || 170402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ((databaseLocation == null && !DB_LOCATION.equals(IPerformancesConstants.NETWORK_DATABASE_LOCATION)) || 171402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll !DB_LOCATION.equals(databaseLocation)) || 172402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll !DB_NAME.equals(IPerformancesConstants.DATABASE_NAME_PREFIX + eclipseVersion)) { 173402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll shutdown(); 174402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_CONNECTION = connected; 175402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_LOCATION = databaseLocation == null ? IPerformancesConstants.NETWORK_DATABASE_LOCATION : databaseLocation; 176402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_NAME = IPerformancesConstants.DATABASE_NAME_PREFIX + eclipseVersion; 177402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_VERSION = "v" + eclipseVersion; 178402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_VERSION_REF = "R-3." + (eclipseVersion % 10 - 1); 179402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (connected) { 180402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getDefault().fSQL != null; 181402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 182402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 183402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return true; 184402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 185402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 186402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 187402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Returns a title including DB version and name. 188402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 189402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A title as a string. 190402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 191402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static String getDbTitle() { 192402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!DB_CONNECTION) return null; 193402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String title = "Eclipse " + DB_VERSION + " - "; 194402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_LOCATION.startsWith("net:")) { 195402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll title += " Network DB"; 196402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 197402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll title += " Local DB"; 198402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 199402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return title; 200402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 201402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 202402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 203402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of all the configurations (i.e. machine) stored in the database. 204402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 205402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] CONFIGS; 206402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 207402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 208402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of all the components stored in the database. 209402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 210402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] COMPONENTS; 211402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 212402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 213402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of all the builds stored in the database. 214402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 215402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] BUILDS; 216402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 217402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 218402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of all the dimensions stored in the database. 219402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 220402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static int[] DIMENSIONS; 221402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 222402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 223402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The default dimension used to display results (typically in fingerprints). 224402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 225402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static Dim DEFAULT_DIM; 226402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static int DEFAULT_DIM_INDEX; 227402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 228402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 229402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of all the dimensions displayed while generating results. 230402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 231402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static Dim[] RESULTS_DIMENSIONS; 232402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 233402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 234402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of all the VMs stored in the database. 235402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 236402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] VMS; 237402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 238402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 239402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of possible test boxes. 240402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <p> 241402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Only used if no specific configurations are specified 242402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (see {@link PerformanceResults#readAll(String, String[][], String, File, int, org.eclipse.core.runtime.IProgressMonitor)}. 243402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * </p> 244402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that this is a copy of the the property "eclipse.perf.config.descriptors" 245402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * defined in org.eclipse.releng.eclipsebuilder/eclipse/helper.xml file 246402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 247402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] CONFIG_DESCRIPTIONS; 248402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 249402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 250402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list of known Eclipse components. 251402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 252402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private final static String[] ECLIPSE_COMPONENTS = { 253402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.ant", //$NON-NLS-1$ 254402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.compare", //$NON-NLS-1$ 255402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.core", //$NON-NLS-1$ 256402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.help", //$NON-NLS-1$ 257402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.jdt.core", //$NON-NLS-1$ 258402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.jdt.debug", //$NON-NLS-1$ 259402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.jdt.text", //$NON-NLS-1$ 260402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.jdt.ui", //$NON-NLS-1$ 261402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.jface", //$NON-NLS-1$ 262402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.osgi", //$NON-NLS-1$ 263402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.pde.api.tools", //$NON-NLS-1$ 264402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.pde.ui", //$NON-NLS-1$ 265402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.swt", //$NON-NLS-1$ 266402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.team", //$NON-NLS-1$ 267402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.ua", //$NON-NLS-1$ 268402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll "org.eclipse.ui" //$NON-NLS-1$ 269402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll }; 270402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] KNOWN_COMPONENTS = ECLIPSE_COMPONENTS; 271402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 272402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 273402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Store debug info 274402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final static StringWriter DEBUG_STR_WRITER; 275402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final static PrintWriter DEBUG_WRITER; 276402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static { 277402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) { 278402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_STR_WRITER= new StringWriter(); 279402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER= new PrintWriter(DEBUG_STR_WRITER); 280402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 281402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_STR_WRITER= null; 282402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER= null; 283402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 284402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 285402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 286402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Store log info 287402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final static StringWriter LOG_STR_WRITER = new StringWriter(); 288402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll final static LogWriter LOG_WRITER = new LogWriter(); 289402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static class LogWriter extends PrintWriter { 290402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long[] starts = new long[10]; 291402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long[] times = new long[10]; 292402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringBuffer[] buffers = new StringBuffer[10]; 293402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int depth = -1, max = -1; 294402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public LogWriter() { 295402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll super(LOG_STR_WRITER); 296402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 297402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll void starts(String log) { 298402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (++this.depth >= this.buffers.length) { 299402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(this.times, 0, this.times = new long[this.depth+10], 0, this.depth); 300402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(this.buffers, 0, this.buffers= new StringBuffer[this.depth+10], 0, this.depth); 301402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 302402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringBuffer buffer = this.buffers[this.depth]; 303402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.buffers[this.depth] == null) buffer = this.buffers[this.depth] = new StringBuffer(); 304402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(log); 305402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.starts[this.depth] = System.currentTimeMillis(); 306402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.depth > this.max) this.max = this.depth; 307402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 308402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll void ends(String log) { 309402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.depth < 0) 310402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll throw new RuntimeException("Invalid call to ends (missing corresponding starts call)!"); //$NON-NLS-1$ 311402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.buffers[this.depth].append(log); 312402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.depth > 0) { 313402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.times[this.depth] += System.currentTimeMillis() - this.starts[this.depth]; 314402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.depth--; 315402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return; 316402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 317402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<this.max; i++) { 318402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll print(this.buffers[i].toString()); 319402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll print(" ( in "); //$NON-NLS-1$ 320402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll print(this.times[this.depth]); 321402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll println("ms)"); //$NON-NLS-1$ 322402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 323402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.depth = this.max = -1; 324402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.starts = new long[10]; 325402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.times = new long[10]; 326402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.buffers = new StringBuffer[10]; 327402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 328402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public String toString() { 329402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return LOG_STR_WRITER.toString(); 330402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 331402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 332402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 333402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Data storage from queries 334402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll static String LAST_CURRENT_BUILD, LAST_BASELINE_BUILD; 335402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static int BUILDS_LENGTH; 336402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] SCENARII; 337402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private static String[] COMMENTS; 338402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 339402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll //---- private implementation 340402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 341402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /** 342402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Private constructor to block instance creation. 343402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 344402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll private DB_Results() { 345402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // empty implementation 346402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 347402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 348402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll synchronized static DB_Results getDefault() { 349402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (fgDefault == null) { 350402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll fgDefault= new DB_Results(); 351402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll fgDefault.connect(); 352402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (PerformanceTestPlugin.getDefault() == null) { 353402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // not started as plugin 354402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Runtime.getRuntime().addShutdownHook( 355402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll new Thread() { 356402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public void run() { 357402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll shutdown(); 358402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 359402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 360402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ); 361402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 362402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else if (fgDefault.fSQL == null) { 363402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll fgDefault.connect(); 364402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 365402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return fgDefault; 366402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 367402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 368402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll public static void shutdown() { 369402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (fgDefault != null) { 370402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll fgDefault.disconnect(); 371402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll fgDefault= null; 372402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS = null; 373402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LAST_BASELINE_BUILD = null; 374402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LAST_CURRENT_BUILD = null; 375402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIMENSIONS = null; 376402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIGS = null; 377402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll COMPONENTS = null; 378402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll SCENARII = null; 379402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll COMMENTS = null; 380402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_VERSION = null; 381402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_VERSION_REF = null; 382402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEFAULT_DIM =null; 383402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEFAULT_DIM_INDEX = -1; 384402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll RESULTS_DIMENSIONS = null; 385402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll VMS = null; 386402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIG_DESCRIPTIONS = null; 387402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll KNOWN_COMPONENTS = ECLIPSE_COMPONENTS; 388402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 389402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) { 390402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("DB.shutdown"); //$NON-NLS-1$ 391402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println(DEBUG_STR_WRITER.toString()); 392402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 393402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (LOG) { 394402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.out.println(LOG_STR_WRITER.toString()); 395402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 396402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 397402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 398402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 399402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the build id from a given name. 400402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 401402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param name The build name (eg. I20070615-1200) 402402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The id of the build (ie. the index in the {@link #BUILDS} list) 403402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 404402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic int getBuildId(String name) { 405402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS == null) return -1; 406402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return Arrays.binarySearch(BUILDS, name, Util.BUILD_DATE_COMPARATOR); 407402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 408402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 409402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 410402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the build name from a given id. 411402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 412402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param id The build id 413402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The name of the build (eg. I20070615-1200) 414402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 415402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic String getBuildName(int id) { 416402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS == null) return null; 417402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return BUILDS[id]; 418402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 419402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 420402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 421402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Returns all the builds names read from the database. 422402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 423402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The list of all builds names matching the scenario pattern used while reading data 424402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 425402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static String[] getBuilds() { 426402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS == null) { 427402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll queryAllVariations("%"); //$NON-NLS-1$ 428402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 429402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS_LENGTH == 0) return EMPTY_LIST; 430402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] builds = new String[BUILDS_LENGTH]; 431402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(BUILDS, 0, builds, 0, BUILDS_LENGTH); 432402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return builds; 433402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 434402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 435402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 436402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Returns the number of builds stored int the database. 437402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 438402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The number of builds stored in the database. 439402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 440402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static int getBuildsNumber() { 441402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS == null) { 442402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll queryAllVariations("%"); //$NON-NLS-1$ 443402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 444402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return BUILDS_LENGTH; 445402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 446402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 447402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 448402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get component name from a scenario. 449402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 450402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param scenarioName The name of the scenario 451402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The component name 452402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 453402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic String getComponentNameFromScenario(String scenarioName) { 454402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = KNOWN_COMPONENTS.length; 455402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<length; i++) { 456402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (scenarioName.startsWith(KNOWN_COMPONENTS[i])) { 457402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return KNOWN_COMPONENTS[i]; 458402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 459402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 460402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringTokenizer tokenizer = new StringTokenizer(scenarioName, "."); 461402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringBuffer buffer = new StringBuffer(tokenizer.nextToken()); 462402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (tokenizer.hasMoreTokens()) { 463402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append('.'); 464402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(tokenizer.nextToken()); 465402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (tokenizer.hasMoreTokens()) { 466402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append('.'); 467402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll buffer.append(tokenizer.nextToken()); 468402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 469402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 470402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String componentName = buffer.toString(); 471402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.err.println(scenarioName+" does not belongs to a known Eclipse component. So use scenario prefix "+componentName+" as component name by default and add it to the know components"); //$NON-NLS-1$ 472402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(KNOWN_COMPONENTS, 0, KNOWN_COMPONENTS = new String[length+1], 0, length); 473402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll KNOWN_COMPONENTS[length] = componentName; 474402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return componentName; 475402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 476402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 477402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 478402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all components read from database. 479402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 480402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A list of component names matching the given pattern 481402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 482402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static String[] getComponents() { 483402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (COMPONENTS == null) return EMPTY_LIST; 484402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = COMPONENTS.length; 485402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] components = new String[length]; 486402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(COMPONENTS, 0, components, 0, length); 487402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return components; 488402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 489402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 490402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 491402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the name of the configuration from the given id. 492402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 493402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param id The index of the configuration in the stored list. 494402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The name of the configuration (eg. eclipseperflnx1_R3.3) 495402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 496402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic String getConfig(int id) { 497402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return CONFIGS[id]; 498402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 499402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 500402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 501402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all configurations read from the database. 502402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 503402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A list of configuration names 504402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 505402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static String[] getConfigs() { 506402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (CONFIGS == null) return EMPTY_LIST; 507402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = CONFIGS.length; 508402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] configs = new String[length]; 509402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(CONFIGS, 0, configs, 0, length); 510402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return configs; 511402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 512402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 513402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 514402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the default dimension used for performance results. 515402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 516402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static void setConfigs(String[] configs) { 517402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIGS = configs; 518402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 519402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 520402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 521402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all configurations read from the database. 522402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 523402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A list of configuration names 524402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 525402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static String[] getConfigDescriptions() { 526402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (CONFIG_DESCRIPTIONS == null) { 527402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (CONFIGS == null) return null; 528402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = CONFIGS.length; 529402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIG_DESCRIPTIONS = new String[length]; 530402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[][] configDescriptors = PerformanceTestPlugin.getConfigDescriptors(); 531402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int cdLength = configDescriptors.length; 532402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i = 0; i < length; i++) { 533402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll boolean found = false; 534402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int j = 0; j < cdLength; j++) { 535402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (configDescriptors[j][0].equals(CONFIGS[i])) { 536402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIG_DESCRIPTIONS[i] = configDescriptors[j][1]; 537402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll found = true; 538402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll break; 539402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 540402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 541402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (!found) { 542402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String kind = CONFIGS[i].indexOf("epwin") < 0 ? "Linux" : "Win XP"; 543402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIG_DESCRIPTIONS[i] = kind+" perf test box "+CONFIGS[i].substring(5); 544402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 545402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 546402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 547402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = CONFIG_DESCRIPTIONS.length; 548402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] descriptions = new String[length]; 549402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(CONFIG_DESCRIPTIONS, 0, descriptions, 0, length); 550402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return descriptions; 551402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 552402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 553402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 554402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the default dimension used for performance results. 555402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 556402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static void setConfigDescriptions(String[] descriptions) { 557402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIG_DESCRIPTIONS = descriptions; 558402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 559402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 560402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 561402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all dimensions read from the database. 562402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 563402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A list of dimensions. 564402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 565402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static Dim[] getDimensions() { 566402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DIMENSIONS == null) return NO_DIMENSION; 567402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = DIMENSIONS.length; 568402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Dim[] dimensions = new Dim[length]; 569402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i = 0; i < length; i++) { 570402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Dimension dimension = PerformanceTestPlugin.getDimension(DIMENSIONS[i]); 571402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (dimension == null) { 572402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll throw new RuntimeException("There is an unsupported dimension stored in the database: " +DIMENSIONS[i]); 573402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 574402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll dimensions[i] = (Dim) dimension; 575402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 576402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return dimensions; 577402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 578402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 579402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 580402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the default dimension used for performance results. 581402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 582402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The {@link Dim default dimension}. 583402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 584402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static Dim getDefaultDimension() { 585402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEFAULT_DIM == null) { 586402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEFAULT_DIM = (Dim) PerformanceTestPlugin.getDefaultDimension(); 587402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 588402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DEFAULT_DIM; 589402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 590402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 591402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 592402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the default dimension used for performance results. 593402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 594402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static void setDefaultDimension(String dim) { 595402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEFAULT_DIM = (Dim) PerformanceTestPlugin.getDimension(dim); 596402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DIMENSIONS != null) { 597402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEFAULT_DIM_INDEX = Arrays.binarySearch(DIMENSIONS, DEFAULT_DIM.getId()); 598402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 599402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 600402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 601402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static Dim[] getResultsDimensions() { 602402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (RESULTS_DIMENSIONS == null) { 603402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Dimension[] resultsDimensions = PerformanceTestPlugin.getResultsDimensions(); 604402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = resultsDimensions.length; 605402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll RESULTS_DIMENSIONS = new Dim[length]; 606402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i = 0; i < length; i++) { 607402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll RESULTS_DIMENSIONS[i] = (Dim) resultsDimensions[i]; 608402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 609402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 610402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return RESULTS_DIMENSIONS; 611402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 612402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 613402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 614402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Set the default dimension used for performance results. 615402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 616402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static void setResultsDimensions(String[] dimensions) { 617402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = dimensions.length; 618402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll RESULTS_DIMENSIONS = new Dim[length]; 619402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i = 0; i < length; i++) { 620402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll RESULTS_DIMENSIONS[i] = (Dim) PerformanceTestPlugin.getDimension(dimensions[i]); 621402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 622402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 623402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 624402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 625402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the default dimension used for performance results. 626402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 627402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The {@link Dim default dimension}. 628402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 629402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static int getDefaultDimensionIndex() { 630402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEFAULT_DIM == null || DEFAULT_DIM_INDEX == -1) { 631402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getDefaultDimension(); // init default dimension 632402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getDimensions(); // init dimensions 633402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEFAULT_DIM_INDEX = Arrays.binarySearch(DIMENSIONS, DEFAULT_DIM.getId()); 634402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 635402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return DEFAULT_DIM_INDEX; 636402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 637402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 638402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 639402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the ID of the last baseline build before the given date. 640402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 641402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param date The date the baseline must be run before. If <code>null</code> 642402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * return the last baseline build stored in the DB. 643402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 644402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the ID of the last baseline build before the given date or 645402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <code>null</code> if none was run before it... 646402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 647402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static String getLastBaselineBuild(String date) { 648402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS == null) { 649402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll queryAllVariations("%"); //$NON-NLS-1$ 650402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 651402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (date == null) { 652402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (LAST_BASELINE_BUILD == null) { 653402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return BUILDS[0]; 654402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 655402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return LAST_BASELINE_BUILD; 656402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 657402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String lastBaselineBuild = null; 658402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i=0; i<BUILDS_LENGTH; i++) { 659402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String build = BUILDS[i]; 660402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (build.startsWith(DB_VERSION_REF)) { 661402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String buildDate = build.substring(build.indexOf('_')+1); 662402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (buildDate.compareTo(date) < 0) { 663402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (lastBaselineBuild == null || build.compareTo(lastBaselineBuild) > 0) { 664402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll lastBaselineBuild = build; 665402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 666402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 667402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 668402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 669402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (lastBaselineBuild == null) { 670402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return BUILDS[0]; 671402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 672402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return lastBaselineBuild; 673402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 674402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 675402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 676402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the ID of the last baseline build. 677402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 678402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the ID of the last baseline build. 679402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 680402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static String getLastCurrentBuild() { 681402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS == null) { 682402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll queryAllVariations("%"); //$NON-NLS-1$ 683402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 684402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return LAST_CURRENT_BUILD; 685402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 686402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 687402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 688402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Returns all the scenarios names read from the database. 689402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 690402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The list of all scenarios matching the pattern for a given build. 691402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @see #internalQueryBuildScenarios(String, String) 692402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 693402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static List getScenarios() { 694402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return Arrays.asList(SCENARII); 695402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 696402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 697402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 698402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Init the constants if necessary. 699402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 700402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static void initDbContants() { 701402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_LOCATION == null) { 702402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_LOCATION = PerformanceTestPlugin.getDBLocation(); 703402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_LOCATION == null) { 704402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll new RuntimeException("Cannot connect to the DB without a location!"); 705402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 706402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 707402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_NAME == null) { 708402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_NAME = PerformanceTestPlugin.getDBName(); 709402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_NAME == null) { 710402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll new RuntimeException("Cannot connect to the DB without a name!"); 711402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 712402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 713402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_VERSION == null) { 714402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_VERSION = "v" + DB_NAME.substring(DB_NAME.length()-2); 715402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DB_VERSION_REF = "R-3."+(Character.digit(DB_NAME.charAt(DB_NAME.length()-1), 10)-1); 716402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 717402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 718402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 719402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 720402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all scenarios read from database. 721402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 722402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A list of all scenario names matching the default pattern 723402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 724402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static Map queryAllScenarios() { 725402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getDefault().internalQueryBuildScenarios("%", null); //$NON-NLS-1$ 726402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 727402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 728402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 729402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all scenarios read from database matching a given pattern. 730402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that all scenarios are returned if the pattern is <code>null</code>. 731402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 732402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param scenarioPattern The pattern of the requested scenarios 733402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A map of all scenarios matching the given pattern. 734402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The map keys are component names and values are the scenarios list for 735402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * each component. 736402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 737402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic Map queryAllScenarios(String scenarioPattern) { 738402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String pattern = scenarioPattern==null ? "%" : scenarioPattern; //$NON-NLS-1$ 739402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getDefault().internalQueryBuildScenarios(pattern, null); 740402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 741402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 742402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 743402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all scenarios read from database matching a given pattern. 744402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that all scenarios are returned if the pattern is <code>null</code>. 745402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 746402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param scenarioPattern The pattern of the requested scenarios 747402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param buildName The build name 748402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return A list of scenario names matching the given pattern 749402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 750402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic Map queryAllScenarios(String scenarioPattern, String buildName) { 751402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return getDefault().internalQueryBuildScenarios(scenarioPattern, buildName); 752402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 753402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 754402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 755402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all variations read from database matching a given configuration pattern. 756402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 757402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param configPattern The pattern of the requested configurations 758402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 759402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic void queryAllVariations(String configPattern) { 760402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getDefault().internalQueryAllVariations(configPattern); 761402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 762402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 763402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 764402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get all summaries from DB for a given scenario and configuration pattern 765402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 766402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param scenarioResults The scenario results where to store data 767402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param configPattern The configuration pattern concerned by the query 768402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param builds All builds to get summaries, if <code>null</code>, then all DB 769402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * builds will be concerned. 770402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 771402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic void queryScenarioSummaries(ScenarioResults scenarioResults, String configPattern, String[] builds) { 772402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getDefault().internalQueryScenarioSummaries(scenarioResults, configPattern, builds); 773402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 774402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 775402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 776402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Query and store all values for given scenario results 777402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 778402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param scenarioResults The scenario results where the values has to be put 779402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param configPattern The pattern of the configuration concerned by the query 780402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param buildName Name of the last build on which data were stored locally 781402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * 782402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll*/ 783402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollstatic void queryScenarioValues(ScenarioResults scenarioResults, String configPattern, String buildName) { 784402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll getDefault().internalQueryScenarioValues(scenarioResults, configPattern, buildName); 785402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 786402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 787402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/** 788402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * dbloc= embed in home directory 789402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * dbloc=/tmp/performance embed given location 790402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * dbloc=net://localhost connect to local server 791402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * dbloc=net://www.eclipse.org connect to remove server 792402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 793402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void connect() { 794402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 795402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fConnection != null || !DB_CONNECTION) 796402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return; 797402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 798402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) DriverManager.setLogWriter(new PrintWriter(System.out)); 799402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 800402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Init DB location and name if not already done 801402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_LOCATION == null) { 802402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll initDbContants(); 803402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 804402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 805402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String url = null; 806402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll java.util.Properties info = new java.util.Properties(); 807402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 808402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) { 809402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println(); 810402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("==========================================================="); //$NON-NLS-1$ 811402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("Database debug information stored while processing"); //$NON-NLS-1$ 812402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 813402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (LOG) { 814402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LOG_WRITER.println(); 815402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LOG_WRITER.println("==========================================================="); //$NON-NLS-1$ 816402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LOG_WRITER.println("Database log information stored while processing"); //$NON-NLS-1$ 817402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 818402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 819402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fDBType = DERBY; // assume we are using Derby 820402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 821402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_LOCATION.startsWith("net://")) { //$NON-NLS-1$ 822402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // remote 823402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// fIsEmbedded = false; 824402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // connect over network 825402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) 826402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("Trying to connect over network..."); //$NON-NLS-1$ 827402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Class.forName("com.ibm.db2.jcc.DB2Driver"); //$NON-NLS-1$ 828402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("user", PerformanceTestPlugin.getDBUser()); //$NON-NLS-1$ 829402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("password", PerformanceTestPlugin.getDBPassword()); //$NON-NLS-1$ 830402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("retrieveMessagesFromServerOnGetMessage", "true"); //$NON-NLS-1$ //$NON-NLS-2$ 831402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("create", "true"); //$NON-NLS-1$ //$NON-NLS-2$ 832402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll url = DB_LOCATION + '/' + DB_NAME; 833402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else if (DB_LOCATION.startsWith("//")) { //$NON-NLS-1$ 834402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // remote 835402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// fIsEmbedded = false; 836402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // connect over network 837402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) 838402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("Trying to connect over network..."); //$NON-NLS-1$ 839402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Class.forName("org.apache.derby.jdbc.ClientDriver"); //$NON-NLS-1$ 840402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("user", PerformanceTestPlugin.getDBUser()); //$NON-NLS-1$ 841402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("password", PerformanceTestPlugin.getDBPassword()); //$NON-NLS-1$ 842402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("create", "true"); //$NON-NLS-1$ //$NON-NLS-2$ 843402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll url = DB_LOCATION + '/' + DB_NAME; 844402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 845402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // workaround for Derby issue: 846402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // http://nagoya.apache.org/jira/browse/DERBY-1 847402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if ("Mac OS X".equals(System.getProperty("os.name"))) //$NON-NLS-1$//$NON-NLS-2$ 848402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.setProperty("derby.storage.fileSyncTransactionLog", "true"); //$NON-NLS-1$ //$NON-NLS-2$ 849402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 850402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // embedded 851402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 852402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); //$NON-NLS-1$ 853402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll// fIsEmbedded = true; 854402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (ClassNotFoundException e) { 855402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Class.forName("com.ihost.cs.jdbc.CloudscapeDriver"); //$NON-NLS-1$ 856402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fDBType = CLOUDSCAPE; 857402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 858402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) 859402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("Loaded embedded " + this.fDBType); //$NON-NLS-1$ 860402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll File f; 861402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DB_LOCATION.length() == 0) { 862402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String user_home = System.getProperty("user.home"); //$NON-NLS-1$ 863402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (user_home == null) 864402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return; 865402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll f = new File(user_home, this.fDBType); 866402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else 867402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll f = new File(DB_LOCATION); 868402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll url = new File(f, DB_NAME).getAbsolutePath(); 869402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("user", PerformanceTestPlugin.getDBUser()); //$NON-NLS-1$ 870402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("password", PerformanceTestPlugin.getDBPassword()); //$NON-NLS-1$ 871402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll info.put("create", "true"); //$NON-NLS-1$ //$NON-NLS-2$ 872402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 873402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 874402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fConnection = DriverManager.getConnection("jdbc:" + this.fDBType + ":" + url, info); //$NON-NLS-1$ //$NON-NLS-2$ 875402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 876402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if ("08001".equals(e.getSQLState()) && DERBY.equals(this.fDBType)) { //$NON-NLS-1$ 877402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) 878402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("DriverManager.getConnection failed; retrying for cloudscape"); //$NON-NLS-1$ 879402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // try Cloudscape 880402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fDBType = CLOUDSCAPE; 881402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fConnection = DriverManager.getConnection("jdbc:" + this.fDBType + ":" + url, info); //$NON-NLS-1$ //$NON-NLS-2$ 882402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else 883402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll throw e; 884402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 885402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) 886402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("connect succeeded!"); //$NON-NLS-1$ 887402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 888402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fConnection.setAutoCommit(false); 889402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fSQL = new SQL_Results(this.fConnection); 890402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fConnection.commit(); 891402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 892402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException ex) { 893402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.logError(ex.getMessage()); 894402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 895402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (ClassNotFoundException e) { 896402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 897402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 898402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 899402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 900402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void disconnect() { 901402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) 902402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.println("disconnecting from DB"); //$NON-NLS-1$ 903402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fSQL != null) { 904402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 905402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fSQL.dispose(); 906402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e1) { 907402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e1); 908402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 909402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fSQL = null; 910402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 911402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fConnection != null) { 912402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 913402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fConnection.commit(); 914402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 915402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 916402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 917402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 918402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fConnection.close(); 919402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 920402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 921402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 922402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll this.fConnection = null; 923402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 924402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 925402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll /* 926402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (fIsEmbedded) { 927402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 928402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DriverManager.getConnection("jdbc:" + fDBType + ":;shutdown=true"); //$NON-NLS-1$ //$NON-NLS-2$ 929402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 930402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String message = e.getMessage(); 931402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (message.indexOf("system shutdown.") < 0) //$NON-NLS-1$ 932402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll e.printStackTrace(); 933402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 934402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 935402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 936402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 937402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 938402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 939402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Return the index of the given configuration in the stored list. 940402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 941402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate int getConfigId(String config) { 942402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (CONFIGS == null) return -1; 943402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return Arrays.binarySearch(CONFIGS, config); 944402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 945402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 946402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollSQL_Results getSQL() { 947402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return this.fSQL; 948402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 949402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 950402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 951402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Query all comments from database 952402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 953402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void internalQueryAllComments() { 954402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fSQL == null) return; 955402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (COMMENTS != null) return; 956402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long start = System.currentTimeMillis(); 957402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) DEBUG_WRITER.print(" [DB query all comments..."); //$NON-NLS-1$ 958402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ResultSet result = null; 959402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 960402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] comments = null; 961402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result = this.fSQL.queryAllComments(); 962402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (result.next()) { 963402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int commentID = result.getInt(1); 964402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // Ignore kind as there's only one 965402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // int commentKind = result.getInt(2); 966402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String comment = result.getString(3); 967402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (comments == null) { 968402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll comments = new String[commentID+10]; 969402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else if (commentID >= comments.length) { 970402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = comments.length; 971402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(comments, 0, comments = new String[commentID+10], 0, length); 972402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 973402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll comments[commentID] = comment; 974402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 975402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll COMMENTS = comments; 976402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 977402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 978402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } finally { 979402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (result != null) { 980402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 981402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result.close(); 982402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e1) { 983402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // ignored 984402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 985402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 986402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) DEBUG_WRITER.println("done in " + (System.currentTimeMillis() - start) + "ms]"); //$NON-NLS-1$ //$NON-NLS-2$ 987402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 988402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 989402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 990402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 991402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Query all variations. This method stores all config and build names. 992402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 993402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void internalQueryAllVariations(String configPattern) { 994402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fSQL == null) return; 995402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS != null) return; 996402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long start = System.currentTimeMillis(); 997402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) { 998402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.print(" - DB query all variations for configuration pattern: "+configPattern); //$NON-NLS-1$ 999402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.print("..."); //$NON-NLS-1$ 1000402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1001402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ResultSet result = null; 1002402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1003402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIGS = null; 1004402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS = null; 1005402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS_LENGTH = 0; 1006402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result = this.fSQL.queryAllVariations(configPattern); 1007402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (result.next()) { 1008402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String variation = result.getString(1); // something like "||build=I20070615-1200||config=eclipseperfwin2_R3.3||jvm=sun|" 1009402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringTokenizer tokenizer = new StringTokenizer(variation, "=|"); //$NON-NLS-1$ 1010402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll tokenizer.nextToken(); // 'build' 1011402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll storeBuildName(tokenizer.nextToken()); // 'I20070615-1200' 1012402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll tokenizer.nextToken(); // 'config' 1013402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll storeConfig(tokenizer.nextToken()); // 'eclipseperfwin2_R3.3' 1014402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll tokenizer.nextToken(); // 'jvm' 1015402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll storeVm(tokenizer.nextToken()); // 'sun' 1016402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1017402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS_LENGTH == 0) { 1018402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS = EMPTY_LIST; 1019402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1020402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 1021402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 1022402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } finally { 1023402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (result != null) { 1024402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1025402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result.close(); 1026402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e1) { 1027402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // ignored 1028402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1029402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1030402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) DEBUG_WRITER.println("done in " + (System.currentTimeMillis() - start) + "ms]"); //$NON-NLS-1$ //$NON-NLS-2$ 1031402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1032402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1033402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1034402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Map internalQueryBuildScenarios(String scenarioPattern, String buildName) { 1035402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fSQL == null) return null; 1036402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long start = System.currentTimeMillis(); 1037402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) { 1038402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.print(" - DB query all scenarios"); //$NON-NLS-1$ 1039402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (scenarioPattern != null) DEBUG_WRITER.print(" with pattern "+scenarioPattern); //$NON-NLS-1$ 1040402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (buildName != null) DEBUG_WRITER.print(" for build: "+buildName); //$NON-NLS-1$ 1041402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1042402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ResultSet result = null; 1043402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Map allScenarios = new HashMap(); 1044402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1045402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (buildName == null) { 1046402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result = this.fSQL.queryBuildAllScenarios(scenarioPattern); 1047402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 1048402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result = this.fSQL.queryBuildScenarios(scenarioPattern, buildName); 1049402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1050402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int previousId = -1; 1051402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll List scenarios = null; 1052402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll List scenariosNames = new ArrayList(); 1053402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll for (int i = 0; result.next(); i++) { 1054402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int id = result.getInt(1); 1055402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String name = result.getString(2); 1056402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll scenariosNames.add(name); 1057402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String shortName = result.getString(3); 1058402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int component_id = storeComponent(getComponentNameFromScenario(name)); 1059402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (component_id != previousId) { 1060402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll allScenarios.put(COMPONENTS[component_id], scenarios = new ArrayList()); 1061402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll previousId = component_id; 1062402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1063402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll scenarios.add(new ScenarioResults(id, name, shortName)); 1064402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1065402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll SCENARII = new String[scenariosNames.size()]; 1066402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll scenariosNames.toArray(SCENARII); 1067402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 1068402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 1069402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } finally { 1070402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (result != null) { 1071402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1072402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result.close(); 1073402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e1) { // ignored 1074402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1075402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1076402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) DEBUG_WRITER.println("done in " + (System.currentTimeMillis() - start) + "ms]"); //$NON-NLS-1$ //$NON-NLS-2$ 1077402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1078402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return allScenarios; 1079402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1080402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1081402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void internalQueryScenarioValues(ScenarioResults scenarioResults, String configPattern, String buildName) { 1082402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fSQL == null) return; 1083402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) { 1084402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.print(" - DB query all data points for config pattern: "+configPattern+" for scenario: " + scenarioResults.getShortName()); //$NON-NLS-1$ //$NON-NLS-2$ 1085402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (buildName != null) DEBUG_WRITER.print(" for build: "+buildName); //$NON-NLS-1$ 1086402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1087402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll internalQueryAllVariations(configPattern); // need to read all variations to have all build names 1088402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ResultSet result = null; 1089402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1090402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int count = 0; 1091402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1092402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result = buildName == null 1093402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ? this.fSQL.queryScenarioDataPoints(configPattern, scenarioResults.getId()) 1094402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll : this.fSQL.queryScenarioBuildDataPoints(configPattern, scenarioResults.getId(), buildName); 1095402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (result.next()) { 1096402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int dp_id = result.getInt(1); 1097402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int step = result.getInt(2); 1098402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String variation = result.getString(3); // something like "|build=I20070615-1200||config=eclipseperfwin2_R3.3||jvm=sun|" 1099402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringTokenizer tokenizer = new StringTokenizer(variation, "=|"); //$NON-NLS-1$ 1100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll tokenizer.nextToken(); // 'build' 1101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int build_id = getBuildId(tokenizer.nextToken()); // 'I20070615-1200' 1102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll tokenizer.nextToken(); // 'config' 1103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int config_id = getConfigId(tokenizer.nextToken()); // 'eclipseperflnx3' 1104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ResultSet rs2 = this.fSQL.queryDimScalars(dp_id); 1105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (rs2.next()) { 1106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int dim_id = rs2.getInt(1); 1107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll storeDimension(dim_id); 1108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BigDecimal decimalValue = rs2.getBigDecimal(2); 1109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long value = decimalValue.longValue(); 1110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (build_id >= 0) { // build id may be negative (i.e. not stored in the array) if new run starts while we're getting results 1111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll scenarioResults.setValue(build_id, dim_id, config_id, step, value); 1112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll count++; 1114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (LOG) LOG_WRITER.ends(" -> " + count + " values read"); //$NON-NLS-1$ //$NON-NLS-2$ 1117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 1118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 1119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } finally { 1120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (result != null) { 1121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result.close(); 1123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e1) { 1124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // ignored 1125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void internalQueryScenarioSummaries(ScenarioResults scenarioResults, String config, String[] builds) { 1131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (this.fSQL == null) return; 1132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll long start = System.currentTimeMillis(); 1133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) { 1134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DEBUG_WRITER.print(" - DB query all summaries for scenario '"+scenarioResults.getShortName()+"' of '"+config+"' config"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 1135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll internalQueryAllComments(); 1137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll ResultSet result = null; 1138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int scenarioID = scenarioResults.getId(); 1140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // First try to get summaries of elapsed process dimension 1141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result = this.fSQL.queryScenarioSummaries(scenarioID, config, builds); 1142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll while (result.next()) { 1143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String variation = result.getString(1); // something like "|build=I20070615-1200||config=eclipseperfwin2_R3.3||jvm=sun|" 1144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int summaryKind = result.getShort(2); 1145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int comment_id = result.getInt(3); 1146402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int dim_id = result.getInt(4); 1147402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (dim_id != 0) storeDimension(dim_id); 1148402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll StringTokenizer tokenizer = new StringTokenizer(variation, "=|"); //$NON-NLS-1$ 1149402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll tokenizer.nextToken(); // 'build' 1150402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String buildName = tokenizer.nextToken(); // 'I20070615-1200' 1151402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll tokenizer.nextToken(); // 'config' 1152402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int config_id = getConfigId(tokenizer.nextToken()); // 'eclipseperflnx3' 1153402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int build_id = getBuildId(buildName); 1154402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (build_id >= 0) { 1155402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll scenarioResults.setInfos(config_id, build_id, dim_id==0?-1:summaryKind, COMMENTS[comment_id]); 1156402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1157402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1158402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e) { 1159402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll PerformanceTestPlugin.log(e); 1160402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } finally { 1161402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (result != null) { 1162402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll try { 1163402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll result.close(); 1164402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } catch (SQLException e1) { 1165402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll // ignored 1166402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1167402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1168402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DEBUG) DEBUG_WRITER.println("done in " + (System.currentTimeMillis() - start) + "ms]"); //$NON-NLS-1$ //$NON-NLS-2$ 1169402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1170402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1171402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1172402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 1173402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Store a build name in the dynamic list. 1174402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list is sorted alphabetically. 1175402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 1176402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate int storeBuildName(String build) { 1177402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll boolean isVersion = build.startsWith(DB_BASELINE_PREFIX); 1178402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS == null) { 1179402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS = new String[1]; 1180402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS[BUILDS_LENGTH++] = build; 1181402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (isVersion) { 1182402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LAST_BASELINE_BUILD = build; 1183402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 1184402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LAST_CURRENT_BUILD = build; 1185402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1186402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return 0; 1187402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1188402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int idx = Arrays.binarySearch(BUILDS, build, Util.BUILD_DATE_COMPARATOR); 1189402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (idx >= 0) return idx; 1190402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int index = -idx-1; 1191402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = BUILDS.length; 1192402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (BUILDS_LENGTH == length) { 1193402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String[] array = new String[length+1]; 1194402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (index > 0) System.arraycopy(BUILDS, 0, array, 0, index); 1195402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll array[index] = build; 1196402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (index < length) { 1197402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(BUILDS, index, array, index+1, length-index); 1198402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1199402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS = array; 1200402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1201402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll BUILDS_LENGTH++; 1202402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (isVersion) { 1203402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (LAST_BASELINE_BUILD == null || LAST_CURRENT_BUILD == null) { 1204402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LAST_BASELINE_BUILD = build; 1205402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 1206402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String buildDate = LAST_CURRENT_BUILD.substring(1, 9)+LAST_CURRENT_BUILD.substring(10, LAST_CURRENT_BUILD.length()); 1207402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll String baselineDate = LAST_BASELINE_BUILD.substring(LAST_BASELINE_BUILD.indexOf('_')+1); 1208402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (build.compareTo(LAST_BASELINE_BUILD) > 0 && baselineDate.compareTo(buildDate) < 0) { 1209402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LAST_BASELINE_BUILD = build; 1210402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1211402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1212402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } else { 1213402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (LAST_CURRENT_BUILD == null || build.substring(1).compareTo(LAST_CURRENT_BUILD.substring(1)) >= 0) { 1214402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll LAST_CURRENT_BUILD = build; 1215402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1216402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1217402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return index; 1218402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1219402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1220402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 1221402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Store a configuration in the dynamic list. 1222402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The list is sorted alphabetically. 1223402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 1224402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate int storeConfig(String config) { 1225402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (CONFIGS== null) { 1226402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIGS= new String[1]; 1227402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIGS[0] = config; 1228402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return 0; 1229402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1230402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int idx = Arrays.binarySearch(CONFIGS, config); 1231402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (idx >= 0) return idx; 1232402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = CONFIGS.length; 1233402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(CONFIGS, 0, CONFIGS = new String[length+1], 0, length); 1234402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll CONFIGS[length] = config; 1235402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Arrays.sort(CONFIGS); 1236402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return length; 1237402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1238402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1239402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 1240402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Store a component in the dynamic list. The list is sorted alphabetically. 1241402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that the array is rebuilt each time a new component is discovered 1242402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * as this does not happen so often (e.g. eclipse only has 10 components). 1243402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 1244402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate int storeComponent(String component) { 1245402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (COMPONENTS== null) { 1246402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll COMPONENTS= new String[1]; 1247402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll COMPONENTS[0] = component; 1248402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return 0; 1249402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1250402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int idx = Arrays.binarySearch(COMPONENTS, component); 1251402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (idx >= 0) return idx; 1252402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = COMPONENTS.length; 1253402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(COMPONENTS, 0, COMPONENTS = new String[length+1], 0, length); 1254402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll COMPONENTS[length] = component; 1255402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Arrays.sort(COMPONENTS); 1256402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return length; 1257402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1258402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1259402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 1260402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Store a dimension in the dynamic list. The list is sorted in ascending order. 1261402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that the array is rebuilt each time a new dimension is discovered 1262402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * as this does not happen so often (e.g. eclipse only stores two dimensions). 1263402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 1264402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic static int storeDimension(int id) { 1265402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (DIMENSIONS == null) { 1266402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIMENSIONS = new int[1]; 1267402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIMENSIONS[0] = id; 1268402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return 0; 1269402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1270402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int idx = Arrays.binarySearch(DIMENSIONS, id); 1271402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (idx >= 0) return idx; 1272402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = DIMENSIONS.length; 1273402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(DIMENSIONS, 0, DIMENSIONS = new int[length+1], 0, length); 1274402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll DIMENSIONS[length] = id; 1275402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Arrays.sort(DIMENSIONS); 1276402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return length; 1277402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1278402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1279402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/* 1280402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Store a dimension in the dynamic list. The list is sorted alphabetically. 1281402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Note that the array is rebuilt each time a new dimension is discovered 1282402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * as this does not happen so often (e.g. eclipse only stores two dimensions). 1283402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */ 1284402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate int storeVm(String vm) { 1285402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (VMS == null) { 1286402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll VMS = new String[1]; 1287402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll VMS[0] = vm; 1288402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return 0; 1289402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll } 1290402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int idx = Arrays.binarySearch(VMS, vm); 1291402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll if (idx >= 0) return idx; 1292402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll int length = VMS.length; 1293402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll System.arraycopy(VMS, 0, VMS = new String[length+1], 0, length); 1294402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll VMS[length] = vm; 1295402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll Arrays.sort(VMS); 1296402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll return length; 1297402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1298402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll 1299402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll} 1300