Skip to content

Commit

Permalink
Remove unused private methods
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Nuyanzin <snuyanzin@gmail.com>
  • Loading branch information
snuyanzin committed Oct 25, 2022
1 parent 8c9ca4e commit 9837ce1
Show file tree
Hide file tree
Showing 26 changed files with 0 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -220,14 +219,6 @@ private List<JavaHome> getAvailableJavaVersions(JavaVersion minimumCompilerVersi
return javaVersions;
}

private static boolean isCurrentJavaHome(File javaHome) {
try {
return Files.isSameFile(javaHome.toPath(), Jvm.current().getJavaHome().toPath());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

private static String getTestSeed() {
String testSeedProperty = System.getProperty("tests.seed");
final String testSeed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ private ForbiddenPatternsTask createTask(Project project) {
return project.getTasks().create("forbiddenPatterns", ForbiddenPatternsTask.class);
}

private ForbiddenPatternsTask createTask(Project project, String taskName) {
return project.getTasks().create(taskName, ForbiddenPatternsTask.class);
}

private void writeSourceFile(Project project, String name, String... lines) throws IOException {
File file = new File(project.getProjectDir(), name);
file.getParentFile().mkdirs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ private Location location(ParserRuleContext ctx) {
return new Location(sourceName, ctx.getStart().getStartIndex());
}

private Location location(TerminalNode tn) {
return new Location(sourceName, tn.getSymbol().getStartIndex());
}

@Override
public ANode visitSource(SourceContext ctx) {
List<SFunction> functions = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,6 @@ private void randomRequest(AbstractBulkIndexByScrollRequest<?> request) {
request.setScript(random().nextBoolean() ? null : randomScript());
}

private void assertRequestEquals(Version version, ReindexRequest request, ReindexRequest tripped) {
assertRequestEquals((AbstractBulkIndexByScrollRequest<?>) request, (AbstractBulkIndexByScrollRequest<?>) tripped);
assertEquals(request.getDestination().version(), tripped.getDestination().version());
assertEquals(request.getDestination().index(), tripped.getDestination().index());
if (request.getRemoteInfo() == null) {
assertNull(tripped.getRemoteInfo());
} else {
assertNotNull(tripped.getRemoteInfo());
assertEquals(request.getRemoteInfo().getScheme(), tripped.getRemoteInfo().getScheme());
assertEquals(request.getRemoteInfo().getHost(), tripped.getRemoteInfo().getHost());
assertEquals(request.getRemoteInfo().getQuery(), tripped.getRemoteInfo().getQuery());
assertEquals(request.getRemoteInfo().getUsername(), tripped.getRemoteInfo().getUsername());
assertEquals(request.getRemoteInfo().getPassword(), tripped.getRemoteInfo().getPassword());
assertEquals(request.getRemoteInfo().getHeaders(), tripped.getRemoteInfo().getHeaders());
assertEquals(request.getRemoteInfo().getSocketTimeout(), tripped.getRemoteInfo().getSocketTimeout());
assertEquals(request.getRemoteInfo().getConnectTimeout(), tripped.getRemoteInfo().getConnectTimeout());
}
}

private void assertRequestEquals(AbstractBulkIndexByScrollRequest<?> request, AbstractBulkIndexByScrollRequest<?> tripped) {
assertRequestEquals((AbstractBulkByScrollRequest<?>) request, (AbstractBulkByScrollRequest<?>) tripped);
assertEquals(request.getScript(), tripped.getScript());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.threadpool.TestThreadPool;
import org.opensearch.threadpool.ThreadPool;
import org.apache.hc.core5.http.HttpStatus;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -484,28 +483,4 @@ private static Optional<Integer> getRangeEnd(HttpExchange exchange) {
return Optional.of(Math.toIntExact(rangeEnd));
}

private static void sendIncompleteContent(HttpExchange exchange, byte[] bytes) throws IOException {
final int rangeStart = getRangeStart(exchange);
assertThat(rangeStart, lessThan(bytes.length));
final Optional<Integer> rangeEnd = getRangeEnd(exchange);
final int length;
if (rangeEnd.isPresent()) {
// adapt range end to be compliant to https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
final int effectiveRangeEnd = Math.min(rangeEnd.get(), bytes.length - 1);
length = effectiveRangeEnd - rangeStart;
} else {
length = bytes.length - rangeStart - 1;
}
exchange.getResponseHeaders().add("Content-Type", "application/octet-stream");
exchange.getResponseHeaders().add("x-ms-blob-content-length", String.valueOf(length));
exchange.getResponseHeaders().add("x-ms-blob-type", "blockblob");
exchange.sendResponseHeaders(HttpStatus.SC_OK, length);
final int bytesToSend = randomIntBetween(0, length - 1);
if (bytesToSend > 0) {
exchange.getResponseBody().write(bytes, rangeStart, bytesToSend);
}
if (randomBoolean()) {
exchange.getResponseBody().flush();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ public void testDieWithDignity() throws Exception {
}
}

private boolean containsAll(String line, String... subStrings) {
for (String subString : subStrings) {
if (line.matches(subString) == false) {
return false;
}
}
return true;
}

private void debugLogs(Path path) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(path)) {
reader.lines().forEach(line -> logger.info(line));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,25 +195,6 @@ public void testRecoveryWithConcurrentIndexing() throws Exception {
}
}

private void assertDocCountOnAllCopies(String index, int expectedCount) throws Exception {
assertBusy(() -> {
Map<String, ?> state = entityAsMap(client().performRequest(new Request("GET", "/_cluster/state")));
String xpath = "routing_table.indices." + index + ".shards.0.node";
@SuppressWarnings("unchecked") List<String> assignedNodes = (List<String>) XContentMapValues.extractValue(xpath, state);
assertNotNull(state.toString(), assignedNodes);
for (String assignedNode : assignedNodes) {
try {
assertCount(index, "_only_nodes:" + assignedNode, expectedCount);
} catch (ResponseException e) {
if (e.getMessage().contains("no data nodes with criteria [" + assignedNode + "found for shard: [" + index + "][0]")) {
throw new AssertionError(e); // shard is relocating - ask assert busy to retry
}
throw e;
}
}
});
}

private void assertCount(final String index, final String preference, final int expectedCount) throws IOException {
final int actualDocs;
try {
Expand Down Expand Up @@ -530,17 +511,6 @@ public void testClosedIndexNoopRecovery() throws Exception {
break;
}
}
/**
* Returns the version in which the given index has been created
*/
private static Version indexVersionCreated(final String indexName) throws IOException {
final Request request = new Request("GET", "/" + indexName + "/_settings");
final String versionCreatedSetting = indexName + ".settings.index.version.created";
request.addParameter("filter_path", versionCreatedSetting);

final Response response = client().performRequest(request);
return Version.fromId(Integer.parseInt(ObjectPath.createFromResponse(response).evaluate(versionCreatedSetting)));
}

/**
* Asserts that an index is closed in the cluster state. If `checkRoutingTable` is true, it also asserts
Expand Down Expand Up @@ -587,20 +557,6 @@ private void assertClosedIndex(final String index, final boolean checkRoutingTab
}
}

@SuppressWarnings("unchecked")
private void assertPeerRecoveredFiles(String reason, String index, String targetNode, Matcher<Integer> sizeMatcher) throws IOException {
Map<?, ?> recoveryStats = entityAsMap(client().performRequest(new Request("GET", index + "/_recovery")));
List<Map<?, ?>> shards = (List<Map<?, ?>>) XContentMapValues.extractValue(index + "." + "shards", recoveryStats);
for (Map<?, ?> shard : shards) {
if (Objects.equals(XContentMapValues.extractValue("type", shard), "PEER")) {
if (Objects.equals(XContentMapValues.extractValue("target.name", shard), targetNode)) {
Integer recoveredFileSize = (Integer) XContentMapValues.extractValue("index.files.recovered", shard);
assertThat(reason + " target node [" + targetNode + "] stats [" + recoveryStats + "]", recoveredFileSize, sizeMatcher);
}
}
}
}

@SuppressWarnings("unchecked")
private void ensureGlobalCheckpointSynced(String index) throws Exception {
assertBusy(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.queries.spans.SpanNearQuery;
import org.apache.lucene.queries.spans.SpanTermQuery;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.CollectorManager;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldComparator;
Expand All @@ -76,7 +74,6 @@
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.search.TotalHitCountCollector;
import org.apache.lucene.search.TotalHits;
import org.apache.lucene.search.Weight;
Expand Down Expand Up @@ -1178,75 +1175,6 @@ public void search(List<LeafReaderContext> leaves, Weight weight, Collector coll
};
}

// used to check that numeric long or date sort optimization was run
private static ContextIndexSearcher newOptimizedContextSearcher(IndexReader reader, int queryType, ExecutorService executor)
throws IOException {
return new ContextIndexSearcher(
reader,
IndexSearcher.getDefaultSimilarity(),
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
executor
) {

@Override
public void search(
Query query,
CollectorManager<?, TopFieldDocs> manager,
QuerySearchResult result,
DocValueFormat[] formats,
TotalHits totalHits
) throws IOException {
assertTrue(query instanceof BooleanQuery);
List<BooleanClause> clauses = ((BooleanQuery) query).clauses();
assertTrue(clauses.size() == 2);
assertTrue(clauses.get(0).getOccur() == Occur.FILTER);
assertTrue(clauses.get(1).getOccur() == Occur.SHOULD);
if (queryType == 0) {
assertTrue(
clauses.get(1).getQuery().getClass() == LongPoint.newDistanceFeatureQuery("random_field", 1, 1, 1).getClass()
);
}
if (queryType == 1) assertTrue(clauses.get(1).getQuery() instanceof DocValuesFieldExistsQuery);
super.search(query, manager, result, formats, totalHits);
}

@Override
public void search(
List<LeafReaderContext> leaves,
Weight weight,
@SuppressWarnings("rawtypes") CollectorManager manager,
QuerySearchResult result,
DocValueFormat[] formats,
TotalHits totalHits
) throws IOException {
final Query query = weight.getQuery();
assertTrue(query instanceof BooleanQuery);
List<BooleanClause> clauses = ((BooleanQuery) query).clauses();
assertTrue(clauses.size() == 2);
assertTrue(clauses.get(0).getOccur() == Occur.FILTER);
assertTrue(clauses.get(1).getOccur() == Occur.SHOULD);
if (queryType == 0) {
assertTrue(
clauses.get(1).getQuery().getClass() == LongPoint.newDistanceFeatureQuery("random_field", 1, 1, 1).getClass()
);
}
if (queryType == 1) assertTrue(clauses.get(1).getQuery() instanceof DocValuesFieldExistsQuery);
super.search(leaves, weight, manager, result, formats, totalHits);
}

@Override
public void search(List<LeafReaderContext> leaves, Weight weight, Collector collector) throws IOException {
if (getExecutor() == null) {
assert (false); // should not be there, expected to search with CollectorManager
} else {
super.search(leaves, weight, collector);
}
}
};
}

private static class TestTotalHitCountCollectorManager extends TotalHitCountCollectorManager {
private int totalHits;
private final TotalHitCountCollector collector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.ByteSizeUnit;
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.core.internal.io.IOUtils;
import org.opensearch.env.Environment;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.index.IndexSettings;
Expand Down Expand Up @@ -486,12 +485,5 @@ TestFileStore getTestFileStore(Path path) {
assertThat(path + " not contained in a unique tracked path", containingPaths, hasSize(1));
return trackedPaths.get(containingPaths.iterator().next());
}

void clearTrackedPaths() throws IOException {
for (Path path : trackedPaths.keySet()) {
IOUtils.rm(path);
}
trackedPaths.clear();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,4 @@ public void testMultiValuedFieldWithValueScript() throws Exception {
assertThat(bucket.getDocCount(), equalTo(2L));
}

private MultiTermsValuesSourceConfig field(String name) {
return new MultiTermsValuesSourceConfig.Builder().setFieldName(name).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,15 @@
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.SortedNumericSortField;
import org.apache.lucene.search.SortedSetSortField;
import org.apache.lucene.util.Accountable;
import org.opensearch.action.support.DefaultShardOperationFailedException;
import org.opensearch.action.support.broadcast.BroadcastResponse;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.index.engine.Segment;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -197,21 +194,6 @@ private static void toXContent(XContentBuilder builder, Sort sort) throws IOExce
builder.endArray();
}

private static void toXContent(XContentBuilder builder, Accountable tree) throws IOException {
builder.startObject();
builder.field(Fields.DESCRIPTION, tree.toString());
builder.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(tree.ramBytesUsed()));
Collection<Accountable> children = tree.getChildResources();
if (children.isEmpty() == false) {
builder.startArray(Fields.CHILDREN);
for (Accountable child : children) {
toXContent(builder, child);
}
builder.endArray();
}
builder.endObject();
}

/**
* Fields for parsing and toXContent
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,25 +605,4 @@ public static Set<String> getPossibleRoleNames() {
return roleMap.keySet();
}

/**
* Enum that holds all the possible roles that a node can fulfill in a cluster.
* Each role has its name and a corresponding abbreviation used by cat apis.
*/
private enum LegacyRole {
MASTER("master"),
DATA("data"),
INGEST("ingest");

private final String roleName;

LegacyRole(final String roleName) {
this.roleName = roleName;
}

public String roleName() {
return roleName;
}

}

}
Loading

0 comments on commit 9837ce1

Please sign in to comment.