Skip to content

Commit

Permalink
Spotless and compile issue
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Feb 5, 2024
1 parent d45fcb9 commit 2832b24
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@

package org.opensearch.action.admin.indices.view;

import static org.hamcrest.Matchers.is;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;

import java.util.List;

import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.test.BackgroundIndexer;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
import org.opensearch.test.OpenSearchIntegTestCase.Scope;
import org.opensearch.test.junit.annotations.TestLogging;

import java.util.List;

import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.is;

@ClusterScope(scope = Scope.TEST, numDataNodes = 2)
public class ViewIT extends OpenSearchIntegTestCase {
Expand All @@ -40,15 +39,19 @@ private int createIndexWithDocs(final String indexName) throws Exception {
}

private CreateViewAction.Response createView(final String name, final String indexPattern) throws Exception {
final CreateViewAction.Request request = new CreateViewAction.Request(name, null, List.of(new CreateViewAction.Request.Target(indexPattern)));
final CreateViewAction.Request request = new CreateViewAction.Request(
name,
null,
List.of(new CreateViewAction.Request.Target(indexPattern))
);
final CreateViewAction.Response response = client().admin().indices().createView(request).actionGet();
performRemoteStoreTestAction();
return response;
}

private SearchResponse searchView(final String viewName) throws Exception {
final SearchViewAction.Request request = SearchViewAction.createRequestWith(viewName, new SearchRequest());
final SearchResponse response = client().searchView(request).actionGet();
final SearchResponse response = client().admin().indices().searchView(request).actionGet();
return response;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package org.opensearch.action.admin.indices.view;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionType;
import org.opensearch.action.ValidateActions;
Expand Down Expand Up @@ -34,6 +29,11 @@
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/** Action to create a view */
public class CreateViewAction extends ActionType<CreateViewAction.Response> {

Expand Down Expand Up @@ -83,11 +83,9 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Request that = (Request) o;
return name.equals(that.name)
&& description.equals(that.description)
&& targets.equals(that.targets);
return name.equals(that.name) && description.equals(that.description) && targets.equals(that.targets);
}

@Override
public int hashCode() {
return Objects.hash(name, description, targets);
Expand Down Expand Up @@ -142,7 +140,7 @@ public boolean equals(Object o) {
Target that = (Target) o;
return indexPattern.equals(that.indexPattern);
}

@Override
public int hashCode() {
return Objects.hash(indexPattern);
Expand Down Expand Up @@ -170,7 +168,7 @@ public ActionRequestValidationException validate() {
static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), View.Target.INDEX_PATTERN_FIELD);
}

public static Target fromXContent(final XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}
Expand All @@ -187,7 +185,7 @@ public static Target fromXContent(final XContentParser parser) throws IOExceptio
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), View.DESCRIPTION_FIELD);
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), (p, c) -> Target.fromXContent(p), View.TARGETS_FIELD);
}

public static Request fromXContent(final XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}
Expand All @@ -197,7 +195,7 @@ public static Request fromXContent(final XContentParser parser) throws IOExcepti
@ExperimentalApi
public static class Response extends ActionResponse implements ToXContentObject {

private final View createdView;
private final View createdView;

public Response(final View createdView) {
this.createdView = createdView;
Expand All @@ -220,7 +218,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
builder.endObject();
return builder;
}

private static final ConstructingObjectParser<Response, Void> PARSER = new ConstructingObjectParser<>(
"create_view_response",
args -> new Response((View) args[0])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.opensearch.action.admin.indices.view;

import java.io.IOException;
import java.util.Objects;
import java.util.function.Function;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionType;
import org.opensearch.action.search.SearchRequest;
Expand All @@ -21,6 +17,10 @@
import org.opensearch.tasks.Task;
import org.opensearch.transport.TransportService;

import java.io.IOException;
import java.util.Objects;
import java.util.function.Function;

import static org.opensearch.action.ValidateActions.addValidationError;

/** Action to create a view */
Expand All @@ -34,15 +34,15 @@ private SearchViewAction() {
}

/** Given a search request, creates a ViewSearchRequest */
public static Request createRequestWith(final String view, final SearchRequest searchRequest)
throws IOException {
public static Request createRequestWith(final String view, final SearchRequest searchRequest) throws IOException {
final BytesStreamOutput savedSearchRequest = new BytesStreamOutput();
searchRequest.writeTo(savedSearchRequest);
savedSearchRequest.writeString(view);

final BytesStreamInput input = new BytesStreamInput(savedSearchRequest.bytes().toBytesRef().bytes);
return new Request(input);
}

/**
* Wraps the functionality of search requests and tailors for what is available
* when searching through views
Expand Down Expand Up @@ -71,10 +71,9 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Request that = (Request) o;
return view.equals(that.view)
&& super.equals(that);
return view.equals(that.view) && super.equals(that);
}

@Override
public int hashCode() {
return Objects.hash(view, super.hashCode());
Expand Down Expand Up @@ -118,10 +117,7 @@ public static class TransportAction extends HandledTransportAction<Request, Sear
private final ViewService viewService;

@Inject
public TransportAction(
final TransportService transportService,
final ActionFilters actionFilters,
final ViewService viewService) {
public TransportAction(final TransportService transportService, final ActionFilters actionFilters, final ViewService viewService) {
super(NAME, transportService, actionFilters, Request::new);
this.viewService = viewService;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.opensearch.action.admin.indices.view;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.ResourceNotFoundException;
Expand All @@ -17,6 +13,10 @@
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.core.action.ActionListener;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/** Service to interact with views, create, retrieve, update, and delete */
public class ViewService {

Expand Down Expand Up @@ -72,7 +72,8 @@ public void searchView(final SearchViewAction.Request request, final ActionListe
}
final View view = optView.get();

final String[] indices = view.getTargets().stream()
final String[] indices = view.getTargets()
.stream()
.map(View.Target::getIndexPattern)
.collect(Collectors.toList())
.toArray(new String[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public View(final StreamInput in) throws IOException {
this(in.readString(), in.readOptionalString(), in.readVLong(), in.readVLong(), in.readList(Target::new));
}


public String getName() {
return name;
}
Expand Down Expand Up @@ -113,7 +112,7 @@ public boolean equals(Object o) {
Target that = (Target) o;
return indexPattern.equals(that.indexPattern);
}

@Override
public int hashCode() {
return Objects.hash(indexPattern);
Expand Down
5 changes: 1 addition & 4 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,7 @@ protected Node(
metadataCreateIndexService
);

final ViewService viewService = new ViewService(
clusterService,
client
);
final ViewService viewService = new ViewService(clusterService, client);

Collection<Object> pluginComponents = pluginsService.filterPlugins(Plugin.class)
.stream()
Expand Down
Loading

0 comments on commit 2832b24

Please sign in to comment.