@Test public void testGenerateSamples() { DbMonSampleGenerator collector = new DbMonSampleGeneratorEmul(); DbMonSampler instance = new DbMonSampler(new ConnectionEmul(), "poolName", null, true, null); instance.generateSamples(collector); }
public void generateSamples(DbMonSampleGenerator collector) { Statement stmt = null; ResultSet rs = null; try { stmt = connection.createStatement(); rs = stmt.executeQuery(sql); if (rs.next()) { final double val = rs.getDouble(1); if (sampleDeltaValue) { if (!Double.isNaN(oldValue)) { collector.generateSample(val - oldValue, metricName); } oldValue = val; } else { collector.generateSample(val, metricName); } } } catch (SQLException ex) { log.error("Error executing query: " + sql, ex); } finally { close(rs); close(stmt); } }
DbMonSampler { public void generateSamples(DbMonSampleGenerator collector) { Statement stmt = null; ResultSet rs = null; try { stmt = connection.createStatement(); rs = stmt.executeQuery(sql); if (rs.next()) { final double val = rs.getDouble(1); if (sampleDeltaValue) { if (!Double.isNaN(oldValue)) { collector.generateSample(val - oldValue, metricName); } oldValue = val; } else { collector.generateSample(val, metricName); } } } catch (SQLException ex) { log.error("Error executing query: " + sql, ex); } finally { close(rs); close(stmt); } } }
DbMonSampler { public void generateSamples(DbMonSampleGenerator collector) { Statement stmt = null; ResultSet rs = null; try { stmt = connection.createStatement(); rs = stmt.executeQuery(sql); if (rs.next()) { final double val = rs.getDouble(1); if (sampleDeltaValue) { if (!Double.isNaN(oldValue)) { collector.generateSample(val - oldValue, metricName); } oldValue = val; } else { collector.generateSample(val, metricName); } } } catch (SQLException ex) { log.error("Error executing query: " + sql, ex); } finally { close(rs); close(stmt); } } DbMonSampler(Connection conn, String poolName, String name, boolean sampleDeltaValue, String sql); }
DbMonSampler { public void generateSamples(DbMonSampleGenerator collector) { Statement stmt = null; ResultSet rs = null; try { stmt = connection.createStatement(); rs = stmt.executeQuery(sql); if (rs.next()) { final double val = rs.getDouble(1); if (sampleDeltaValue) { if (!Double.isNaN(oldValue)) { collector.generateSample(val - oldValue, metricName); } oldValue = val; } else { collector.generateSample(val, metricName); } } } catch (SQLException ex) { log.error("Error executing query: " + sql, ex); } finally { close(rs); close(stmt); } } DbMonSampler(Connection conn, String poolName, String name, boolean sampleDeltaValue, String sql); void generateSamples(DbMonSampleGenerator collector); String getMetricName(); void setMetricName(String metricName); String getSql(); void setSql(String sql); boolean isSampleDeltaValue(); void setSampleDeltaValue(boolean sampleDeltaValue); Connection getConnection(); String getPoolName(); void setPoolName(String poolName); }
DbMonSampler { public void generateSamples(DbMonSampleGenerator collector) { Statement stmt = null; ResultSet rs = null; try { stmt = connection.createStatement(); rs = stmt.executeQuery(sql); if (rs.next()) { final double val = rs.getDouble(1); if (sampleDeltaValue) { if (!Double.isNaN(oldValue)) { collector.generateSample(val - oldValue, metricName); } oldValue = val; } else { collector.generateSample(val, metricName); } } } catch (SQLException ex) { log.error("Error executing query: " + sql, ex); } finally { close(rs); close(stmt); } } DbMonSampler(Connection conn, String poolName, String name, boolean sampleDeltaValue, String sql); void generateSamples(DbMonSampleGenerator collector); String getMetricName(); void setMetricName(String metricName); String getSql(); void setSql(String sql); boolean isSampleDeltaValue(); void setSampleDeltaValue(boolean sampleDeltaValue); Connection getConnection(); String getPoolName(); void setPoolName(String poolName);  }