Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix checkstyle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkrg committed Jul 24, 2019
1 parent 5bb0567 commit 30dc250
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public static String getCurrentTimeMetric() {
}

public static String generatePath(long startTime, String... keysPath) {
Path sDevShmLocationPath = Paths.get(sDevShmLocation).resolve(Paths.get(String.valueOf(PerformanceAnalyzerMetrics.getTimeInterval(startTime)), keysPath));
Path sDevShmLocationPath = Paths.get(sDevShmLocation)
.resolve(Paths.get(String.valueOf(PerformanceAnalyzerMetrics.getTimeInterval(startTime)), keysPath));
return sDevShmLocationPath.toString();
}

Expand Down Expand Up @@ -163,7 +164,7 @@ private static File writeToTmp(String keyPath, String value) throws Exception {
}

public static String getMetric(long startTime, String... keysPath) {
return getMetric(generatePath(startTime, keysPath));
return getMetric(generatePath(startTime, keysPath));
}

public static String getMetric(String keyPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,26 @@
import java.util.Map;
import java.util.Set;

import javax.net.ssl.HttpsURLConnection;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;

import org.jooq.Record;
import org.jooq.Result;

import com.amazon.opendistro.elasticsearch.performanceanalyzer.PerformanceAnalyzerApp;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.collectors.StatExceptionCode;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.collectors.StatsCollector;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PluginSettings;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metricsdb.MetricsDB;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.model.MetricAttributes;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.model.MetricsModel;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.reader.ClusterLevelMetricsReader;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.reader.ReaderMetricsProcessor;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.util.JsonConverter;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.collectors.StatsCollector;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.collectors.StatExceptionCode;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import javax.net.ssl.HttpsURLConnection;

/**
* Request handler that supports querying MetricsDB on every EC2 instance.
Expand Down Expand Up @@ -188,9 +185,10 @@ public boolean validParams(HttpExchange exchange, List<String> metricList, List<
}
}
}
for (String agg : aggList) {
for (String agg : aggList) {
if (!MetricsDB.AGG_VALUES.contains(agg)) {
sendResponse(exchange, String.format("{\"error\":\"%s is an invalid aggregation type.\"}", agg), HttpURLConnection.HTTP_BAD_REQUEST);
sendResponse(exchange, String.format("{\"error\":\"%s is an invalid aggregation type.\"}", agg),
HttpURLConnection.HTTP_BAD_REQUEST);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@


package com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PluginSettings;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.Before;
import static org.mockito.Mockito.when;
import org.mockito.Mock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;

@PowerMockIgnore({ "org.apache.logging.log4j.*" })
import com.amazon.opendistro.elasticsearch.performanceanalyzer.config.PluginSettings;
import static org.junit.Assert.assertEquals;

@PowerMockIgnore({"org.apache.logging.log4j.*"})
@RunWith(PowerMockRunner.class)
@PrepareForTest({ PerformanceAnalyzerMetrics.class, PluginSettings.class })
@SuppressStaticInitializationFor({ "PluginSettings" })
@PrepareForTest({PerformanceAnalyzerMetrics.class, PluginSettings.class})
@SuppressStaticInitializationFor({"PluginSettings"})
public class PerformanceAnalyzerMetricsTests {

@Before
Expand All @@ -59,7 +58,8 @@ public void testBasicMetric() {
public void testGeneratePath() {
long startTimeInMillis = 1553725339;
String generatedPath = PerformanceAnalyzerMetrics.generatePath(startTimeInMillis, "dir1", "id", "dir2");
String expectedPath = PerformanceAnalyzerMetrics.sDevShmLocation + "/" + String.valueOf(PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMillis)) + "/dir1/id/dir2";
String expectedPath = PerformanceAnalyzerMetrics.sDevShmLocation +
"/" + PerformanceAnalyzerMetrics.getTimeInterval(startTimeInMillis) + "/dir1/id/dir2";
assertEquals(expectedPath, generatedPath);
}
}

0 comments on commit 30dc250

Please sign in to comment.