diff options
| author | Phil Harvey <philharveyonline@apache.org> | 2013-02-09 06:41:36 +0000 |
|---|---|---|
| committer | Phil Harvey <philharveyonline@apache.org> | 2013-02-09 06:41:36 +0000 |
| commit | 6f92f232febc736ee89dc390510077c38e78a326 (patch) | |
| tree | a08a103358f1c1632908668c8e32fc50366a4c62 /qpid/java/perftests/visualisation-jfc/src/main | |
| parent | ea58b84cd08114053c009ddca9b3057a895d1b7d (diff) | |
| download | qpid-python-6f92f232febc736ee89dc390510077c38e78a326.tar.gz | |
QPID-4533: Java Performance Tests - addressed bug in JdbcSeriesBuilder that caused it to ignore the CSV series directory.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1444335 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/perftests/visualisation-jfc/src/main')
4 files changed, 111 insertions, 13 deletions
diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java index e1403be397..91eafe324b 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java @@ -31,6 +31,7 @@ import org.apache.qpid.disttest.charting.chartbuilder.ChartBuilderFactory; import org.apache.qpid.disttest.charting.definition.ChartingDefinition; import org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator; import org.apache.qpid.disttest.charting.seriesbuilder.JdbcSeriesBuilder; +import org.apache.qpid.disttest.charting.seriesbuilder.JdbcUrlGenerator; import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; import org.apache.qpid.disttest.charting.writer.ChartWriter; import org.jfree.chart.JFreeChart; @@ -69,11 +70,11 @@ public class ChartingUtil /** the class name of the JDBC driver to use for reading the chart data */ public static final String JDBC_DRIVER_NAME_PROP = "jdbcDriverClass"; - public static final String JDBC_DRIVER_NAME_DEFAULT = JdbcSeriesBuilder.DEFAULT_JDBC_DRIVER_NAME; + public static final String JDBC_DRIVER_NAME_DEFAULT = JdbcUrlGenerator.DEFAULT_JDBC_DRIVER_NAME; /** the JDBC URL of the data to be charted */ public static final String JDBC_URL_PROP = "jdbcUrl"; - public static final String JDBC_URL_DEFAULT = JdbcSeriesBuilder.DEFAULT_JDBC_URL; + public static final String JDBC_URL_DEFAULT = null; private Map<String,String> _cliOptions = new HashMap<String, String>(); diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java index 61373e0ebb..d89ff855e2 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java @@ -19,6 +19,9 @@ */ package org.apache.qpid.disttest.charting.definition; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + public class SeriesDefinition { private final String _seriesStatement; @@ -60,4 +63,13 @@ public class SeriesDefinition { return _seriesStrokeWidth; } + + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("seriesLegend", _seriesLegend) + .append("seriesStatement", _seriesStatement) + .append("seriesDirectory", _seriesDirectory).toString(); + } } diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java index 2cd8d9951f..525d29151a 100644 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java @@ -35,24 +35,25 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * A {@link SeriesBuilder} that uses JDBC to read series data + * A {@link SeriesBuilder} that uses JDBC to read series data. + * The actual JDBC URL used is determined by my {@link JdbcUrlGenerator}. */ public class JdbcSeriesBuilder implements SeriesBuilder { private static final Logger LOGGER = LoggerFactory.getLogger(JdbcSeriesBuilder.class); - public static final String DEFAULT_JDBC_DRIVER_NAME = "org.relique.jdbc.csv.CsvDriver"; - - /** the dot at the end denotes the current directory */ - public static final String DEFAULT_JDBC_URL = "jdbc:relique:csv:."; - - private final String _jdbcUrl; private SeriesBuilderCallback _callback; - public JdbcSeriesBuilder(String jdbcDriverClass, String jdbcUrl) + private final JdbcUrlGenerator _jdbcUrlGenerator; + + /** + * @param providedJdbcUrl the JDBC URL. Provide null if the value should be + * inferred by {@link #_jdbcUrlGenerator}. + */ + public JdbcSeriesBuilder(String jdbcDriverClass, String providedJdbcUrl) { registerDriver(jdbcDriverClass); - _jdbcUrl = jdbcUrl; + _jdbcUrlGenerator = new JdbcUrlGenerator(providedJdbcUrl); LOGGER.info("Created: " + this); } @@ -78,7 +79,8 @@ public class JdbcSeriesBuilder implements SeriesBuilder Statement stmt = null; try { - conn = DriverManager.getConnection(_jdbcUrl); + String jdbcUrl = _jdbcUrlGenerator.getJdbcUrl(seriesDefinition); + conn = DriverManager.getConnection(jdbcUrl); final String seriesStatement = seriesDefinition.getSeriesStatement(); @@ -146,6 +148,8 @@ public class JdbcSeriesBuilder implements SeriesBuilder @Override public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("jdbcUrl", _jdbcUrl).toString(); + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("jdbcUrlGenerator", _jdbcUrlGenerator) + .toString(); } } diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java new file mode 100644 index 0000000000..77f367b0f1 --- /dev/null +++ b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.qpid.disttest.charting.seriesbuilder; + +import static org.apache.commons.lang.StringUtils.isBlank; +import static org.apache.commons.lang.StringUtils.isNotBlank; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.qpid.disttest.charting.definition.SeriesDefinition; + +public class JdbcUrlGenerator +{ + private String _providedJdbdUrl; + + public static final String DEFAULT_JDBC_DRIVER_NAME = "org.relique.jdbc.csv.CsvDriver"; + + /** + * Used to create the JDBC URL if one has not been passed in. + */ + private static final String CSV_JDBC_URL_BASE = "jdbc:relique:csv:"; + + /** + * @param providedJdbcUrl the JDBC URL. Provide null if the value should be + * inferred. + */ + public JdbcUrlGenerator(String providedJdbcUrl) + { + _providedJdbdUrl = providedJdbcUrl; + } + + /** + * Returns either the provided value ({@link #_providedJdbdUrl}) + * or a CSV JDBC URL pointing at {@link SeriesDefinition#getSeriesDirectory()} value. + */ + public String getJdbcUrl(SeriesDefinition seriesDefinition) + { + String seriesDir = seriesDefinition.getSeriesDirectory(); + + if(_providedJdbdUrl == null) + { + if(isBlank(seriesDir)) + { + throw new IllegalArgumentException("Neither a series directory nor a JDBC url have been specified. Series definition: " + seriesDefinition); + } + return CSV_JDBC_URL_BASE + seriesDir; + } + else + { + if(isNotBlank(seriesDir)) + { + throw new IllegalArgumentException("Both a series directory '" + seriesDir + "' and a JDBC url have been specified. Series definition: " + seriesDefinition); + } + return _providedJdbdUrl; + } + } + + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("providedJdbdUrl", _providedJdbdUrl) + .toString(); + } +}
\ No newline at end of file |
