Codacy fixes

This commit is contained in:
Ann Priestman 2018-05-10 08:04:53 -04:00
parent d606c99305
commit 8495e6e204
2 changed files with 23 additions and 24 deletions

View File

@ -603,7 +603,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
* and enable/disable as needed. * and enable/disable as needed.
* @throws HealthMonitorException * @throws HealthMonitorException
*/ */
final synchronized void updateFromGlobalEnabledStatus() throws HealthMonitorException { synchronized void updateFromGlobalEnabledStatus() throws HealthMonitorException {
boolean previouslyEnabled = monitorIsEnabled(); boolean previouslyEnabled = monitorIsEnabled();
@ -645,10 +645,8 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
} }
boolean currentlyEnabled = getGlobalEnabledStatusFromDB(); boolean currentlyEnabled = getGlobalEnabledStatusFromDB();
if( currentlyEnabled == previouslyEnabled) { if( currentlyEnabled != previouslyEnabled) {
// Nothing needs to be done if( ! currentlyEnabled ) {
} else {
if(currentlyEnabled == false) {
isEnabled.set(false); isEnabled.set(false);
deactivateMonitorLocally(); deactivateMonitorLocally();
} else { } else {
@ -845,7 +843,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
* It will delete all current timing data and replace it with randomly generated values. * It will delete all current timing data and replace it with randomly generated values.
* If there is more than one node, the second node's times will trend upwards. * If there is more than one node, the second node's times will trend upwards.
*/ */
final void populateDatabaseWithSampleData(int nDays, int nNodes, boolean createVerificationData) throws HealthMonitorException { void populateDatabaseWithSampleData(int nDays, int nNodes, boolean createVerificationData) throws HealthMonitorException {
if(! isEnabled.get()) { if(! isEnabled.get()) {
throw new HealthMonitorException("Can't populate database - monitor not enabled"); throw new HealthMonitorException("Can't populate database - monitor not enabled");
@ -900,6 +898,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
break; break;
default: default:
minIndexTimeNanos = baseIndex * 1000 * 1000; minIndexTimeNanos = baseIndex * 1000 * 1000;
break;
} }
long maxIndexTimeOverMin = minIndexTimeNanos * 3; long maxIndexTimeOverMin = minIndexTimeNanos * 3;
@ -1169,12 +1168,12 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
* All times will be in milliseconds. * All times will be in milliseconds.
*/ */
static class DatabaseTimingResult { static class DatabaseTimingResult {
private long timestamp; // Time the metric was recorded private final long timestamp; // Time the metric was recorded
private String hostname; // Host that recorded the metric private final String hostname; // Host that recorded the metric
private long count; // Number of metrics collected private final long count; // Number of metrics collected
private double average; // Average of the durations collected (milliseconds) private final double average; // Average of the durations collected (milliseconds)
private double max; // Maximum value found (milliseconds) private final double max; // Maximum value found (milliseconds)
private double min; // Minimum value found (milliseconds) private final double min; // Minimum value found (milliseconds)
DatabaseTimingResult(ResultSet resultSet) throws SQLException { DatabaseTimingResult(ResultSet resultSet) throws SQLException {
this.timestamp = resultSet.getLong("timestamp"); this.timestamp = resultSet.getLong("timestamp");

View File

@ -48,19 +48,19 @@ class TimingMetricGraphPanel extends JPanel {
private final static Logger logger = Logger.getLogger(TimingMetricGraphPanel.class.getName()); private final static Logger logger = Logger.getLogger(TimingMetricGraphPanel.class.getName());
private int padding = 25; private final int padding = 25;
private int labelPadding = 25; private final int labelPadding = 25;
private Color lineColor = new Color(0x12, 0x20, 0xdb, 180); private final Color lineColor = new Color(0x12, 0x20, 0xdb, 180);
private Color gridColor = new Color(200, 200, 200, 200); private final Color gridColor = new Color(200, 200, 200, 200);
private Color trendLineColor = new Color(150, 10, 10, 200); private final Color trendLineColor = new Color(150, 10, 10, 200);
private static final Stroke GRAPH_STROKE = new BasicStroke(2f); private static final Stroke GRAPH_STROKE = new BasicStroke(2f);
private static final Stroke NARROW_STROKE = new BasicStroke(1f); private static final Stroke NARROW_STROKE = new BasicStroke(1f);
private int pointWidth = 4; private final int pointWidth = 4;
private int numberYDivisions = 10; private final int numberYDivisions = 10;
private List<DatabaseTimingResult> timingResults; private List<DatabaseTimingResult> timingResults;
private TimingMetricType timingMetricType; private final TimingMetricType timingMetricType;
private String metricName; private final String metricName;
private boolean doLineGraph; private final boolean doLineGraph;
private String yUnitString; private String yUnitString;
private TrendLine trendLine; private TrendLine trendLine;
private final long MILLISECONDS_PER_DAY = 1000 * 60 * 60 * 24; private final long MILLISECONDS_PER_DAY = 1000 * 60 * 60 * 24;
@ -264,7 +264,7 @@ class TimingMetricGraphPanel extends JPanel {
int y0 = getHeight() - ((i * graphHeight) / numberYDivisions + bottomGraphPadding); int y0 = getHeight() - ((i * graphHeight) / numberYDivisions + bottomGraphPadding);
int y1 = y0; int y1 = y0;
if (timingResults.size() > 0) { if ( ! timingResults.isEmpty()) {
// Draw the grid line // Draw the grid line
g2.setColor(gridColor); g2.setColor(gridColor);
g2.drawLine(leftGraphPadding + 1 + pointWidth, y0, getWidth() - rightGraphPadding, y1); g2.drawLine(leftGraphPadding + 1 + pointWidth, y0, getWidth() - rightGraphPadding, y1);
@ -272,7 +272,7 @@ class TimingMetricGraphPanel extends JPanel {
// Create the label // Create the label
g2.setColor(Color.BLACK); g2.setColor(Color.BLACK);
double yValue = minValueOnYAxis + ((maxValueOnYAxis - minValueOnYAxis) * ((i * 1.0) / numberYDivisions)); double yValue = minValueOnYAxis + ((maxValueOnYAxis - minValueOnYAxis) * ((i * 1.0) / numberYDivisions));
String yLabel = ((int) (yValue * 100 * yLabelScale)) / 100.0 + ""; String yLabel = Double.toString(((int) (yValue * 100 * yLabelScale)) / 100.0);
FontMetrics fontMetrics = g2.getFontMetrics(); FontMetrics fontMetrics = g2.getFontMetrics();
labelWidth = fontMetrics.stringWidth(yLabel); labelWidth = fontMetrics.stringWidth(yLabel);
g2.drawString(yLabel, x0 - labelWidth - 5, y0 + (fontMetrics.getHeight() / 2) - 3); g2.drawString(yLabel, x0 - labelWidth - 5, y0 + (fontMetrics.getHeight() / 2) - 3);