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

Commit

Permalink
Changes for java 8 compatibility (#424)
Browse files Browse the repository at this point in the history
* Changes for java 8 target compatibility

* Use different substring fn
  • Loading branch information
vigyasharma authored Sep 11, 2020
1 parent 10d8781 commit 9a2624c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public static Set<Long> listOnDiskFiles() {
.map(path -> path.toString())
.forEach(s -> {
try {
found.add(Long.parseUnsignedLong(s, prefixLength, s.length(), 10));
found.add(Long.parseUnsignedLong(s.substring(prefixLength), 10));
} catch (IndexOutOfBoundsException | NumberFormatException e) {
LOG.error("Unexpected file in metricsdb directory - {}", s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ synchronized int insertRow(String tableName, List<Object> row) throws SQLExcepti
String nestedTableName = columnName.replace(NESTED_OBJECT_COLUMN_PREFIX, "");
if (jooqField.getType() == String.class) {
String value = (String) jooqField.getValue(record);
JsonArray array = JsonParser.parseString(value).getAsJsonArray();
JsonArray array = new JsonParser().parse(value).getAsJsonArray();
Method setter = fieldNameToGetterSetterMap.get(nestedTableName).setter;

List<Object> collection = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import com.google.common.collect.ImmutableSet;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -455,13 +457,13 @@ public void testDeleteOnDiskFile_notExists() throws Exception {
@Test
public void testListOnDiskFiles_empty() throws Exception {
deleteAll();
assertEquals(Set.of(), MetricsDB.listOnDiskFiles());
assertEquals(Collections.EMPTY_SET, MetricsDB.listOnDiskFiles());
}

@Test
public void testListOnDiskFiles_one() throws Exception {
deleteAll();
Set<Long> expected = Set.of(1000000000L);
Set<Long> expected = ImmutableSet.of(1000000000L);
for (Long ts : expected) {
(new MetricsDB(ts)).remove();
}
Expand All @@ -471,7 +473,7 @@ public void testListOnDiskFiles_one() throws Exception {
@Test
public void testListOnDiskFiles_two() throws Exception {
deleteAll();
Set<Long> expected = Set.of(1000000000L, 500L);
Set<Long> expected = ImmutableSet.of(1000000000L, 500L);
for (Long ts : expected) {
(new MetricsDB(ts)).remove();
}
Expand All @@ -481,7 +483,7 @@ public void testListOnDiskFiles_two() throws Exception {
@Test
public void testListOnDiskFiles_many() throws Exception {
deleteAll();
Set<Long> expected = Set.of(1000000000L, 500L, 0L);
Set<Long> expected = ImmutableSet.of(1000000000L, 500L, 0L);
for (Long ts : expected) {
(new MetricsDB(ts)).remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void readRcaEnabledFromConf() throws IOException {
@Test
public void readAndUpdateMutedRcasBeforeGraphCreation() throws Exception {
Method readAndUpdateMutesRcas = rcaController.getClass()
.getDeclaredMethod("readAndUpdateMutedComponents", null);
.getDeclaredMethod("readAndUpdateMutedComponents");
readAndUpdateMutesRcas.setAccessible(true);

String rcaConfPath = Paths.get(RcaConsts.TEST_CONFIG_PATH, "rca_muted.conf").toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.MetricsConfiguration;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.PerformanceAnalyzerMetrics;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metricsdb.MetricsDB;
import com.google.common.collect.ImmutableSet;
import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.Files;
Expand Down Expand Up @@ -584,26 +585,26 @@ public void testCleanupMetricsDBFiles_empty() throws Exception {
deleteAll();
PluginSettings.instance().setShouldCleanupMetricsDBFiles(true);
ReaderMetricsProcessor mp = new ReaderMetricsProcessor(rootLocation, true, new AppContext());
assertEquals(Set.of(), MetricsDB.listOnDiskFiles());
assertEquals(ImmutableSet.of(), MetricsDB.listOnDiskFiles());
}

@Test
public void testCleanupMetricsDBFiles_enabled() throws Exception {
deleteAll();
Set<Long> expected = Set.of(1000000000L, 500L, 0L);
Set<Long> expected = ImmutableSet.of(1000000000L, 500L, 0L);
for (Long ts : expected) {
(new MetricsDB(ts)).remove();
}
assertEquals(expected, MetricsDB.listOnDiskFiles());
PluginSettings.instance().setShouldCleanupMetricsDBFiles(true);
ReaderMetricsProcessor mp = new ReaderMetricsProcessor(rootLocation, true, new AppContext());
assertEquals(Set.of(), MetricsDB.listOnDiskFiles());
assertEquals(ImmutableSet.of(), MetricsDB.listOnDiskFiles());
}

@Test
public void testCleanupMetricsDBFiles_disabled() throws Exception {
deleteAll();
Set<Long> expected = Set.of(1000000000L, 500L, 0L);
Set<Long> expected = ImmutableSet.of(1000000000L, 500L, 0L);
for (Long ts : expected) {
(new MetricsDB(ts)).remove();
}
Expand Down

0 comments on commit 9a2624c

Please sign in to comment.