Skip to content

Commit

Permalink
Adds import order to formatting.gradle and fixes the import order in …
Browse files Browse the repository at this point in the history
…current files (#929)

Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura authored Aug 22, 2023
1 parent 9be4229 commit 89ccfc2
Show file tree
Hide file tree
Showing 58 changed files with 319 additions and 316 deletions.
15 changes: 15 additions & 0 deletions gradle/formatting.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ allprojects {
target '**/*.java'

removeUnusedImports()
importOrder(
'de.thetaphi',
'com.carrotsearch',
'com.fasterxml',
'com.avast',
'com.sun',
'com.maxmind|com.github|com.networknt|groovy|nebula',
'org.antlr',
'software.amazon',
'com.azure|com.microsoft|com.ibm|com.google|joptsimple|org.apache|org.bouncycastle|org.codehaus|org.opensearch|org.objectweb|org.joda|org.hamcrest|org.openjdk|org.gradle|org.junit',
'javax',
'java',
'',
'\\#java|\\#org.opensearch|\\#org.hamcrest|\\#'
)
eclipse().configFile rootProject.file('formatter/formatterConfig.xml')
trimTrailingWhitespace()
endWithNewline();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/opensearch/sdk/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

package org.opensearch.sdk;

import java.util.Collections;
import java.util.Collection;
import java.util.List;

import org.opensearch.common.io.stream.NamedWriteableRegistry;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.threadpool.ExecutorBuilder;
import org.opensearch.common.settings.Settings;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
* This interface defines methods which an extension must provide. Extensions
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/opensearch/sdk/ExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.opensearch.action.support.TransportAction;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.common.io.stream.NamedWriteableRegistry;
import org.opensearch.extensions.rest.ExtensionRestRequest;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.xcontent.NamedXContentRegistry;
Expand All @@ -28,6 +27,7 @@
import org.opensearch.extensions.ExtensionsManager;
import org.opensearch.extensions.UpdateSettingsRequest;
import org.opensearch.extensions.action.ExtensionActionRequest;
import org.opensearch.extensions.rest.ExtensionRestRequest;
import org.opensearch.sdk.action.SDKActionModule;
import org.opensearch.sdk.api.ActionExtension;
import org.opensearch.sdk.handlers.ExtensionActionRequestHandler;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/opensearch/sdk/NettyTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

package org.opensearch.sdk;

import java.nio.file.Path;
import java.util.Collections;

import org.opensearch.Version;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.network.NetworkService;
Expand All @@ -29,6 +26,9 @@
import org.opensearch.transport.TransportService;
import org.opensearch.transport.netty4.Netty4Transport;

import java.nio.file.Path;
import java.util.Collections;

import static java.util.Collections.emptySet;
import static org.opensearch.common.UUIDs.randomBase64UUID;

Expand Down
25 changes: 13 additions & 12 deletions src/main/java/org/opensearch/sdk/SDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@

package org.opensearch.sdk;

import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.opensearch.action.ActionListener;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionResponse;
Expand Down Expand Up @@ -58,14 +54,12 @@
import org.opensearch.client.GetAliasesResponse;
import org.opensearch.client.IndicesClient;
import org.opensearch.client.Node;
import org.opensearch.client.Request;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.Requests;
import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.opensearch.client.RestClient;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseListener;
import org.opensearch.client.RestClient;
import org.opensearch.client.RestClientBuilder;
import org.opensearch.client.RestHighLevelClient;
import org.opensearch.client.indices.CreateIndexRequest;
Expand All @@ -86,6 +80,13 @@
import org.opensearch.index.reindex.BulkByScrollResponse;
import org.opensearch.index.reindex.DeleteByQueryRequest;

import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* This class creates SDKClient for an extension to make requests to OpenSearch
*/
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/opensearch/sdk/SDKClusterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@

package org.opensearch.sdk;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.ClusterState;
import org.opensearch.common.settings.AbstractScopedSettings;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Setting.Property;
import org.opensearch.common.settings.SettingUpgrader;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.settings.AbstractScopedSettings;
import org.opensearch.common.settings.Setting.Property;
import org.opensearch.extensions.DiscoveryExtensionNode;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

/**
* This class simulates methods normally called from OpenSearch ClusterService class.
*/
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/opensearch/sdk/SDKNamedXContentRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@

package org.opensearch.sdk;

import static java.util.stream.Collectors.toList;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;

import org.opensearch.cluster.ClusterModule;
import org.opensearch.common.network.NetworkModule;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.NamedXContentRegistry.Entry;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.indices.IndicesModule;
import org.opensearch.search.SearchModule;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

/**
* Combines Extension NamedXContent with core OpenSearch NamedXContent
*/
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/org/opensearch/sdk/SDKTransportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@

package org.opensearch.sdk;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import com.google.protobuf.ByteString;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -36,9 +26,9 @@
import org.opensearch.extensions.proto.ExtensionRequestProto;
import org.opensearch.extensions.rest.RegisterRestActionsRequest;
import org.opensearch.extensions.settings.RegisterCustomSettingsRequest;
import org.opensearch.sdk.api.ActionExtension.ActionHandler;
import org.opensearch.sdk.action.RemoteExtensionActionRequest;
import org.opensearch.sdk.action.SDKActionModule;
import org.opensearch.sdk.api.ActionExtension.ActionHandler;
import org.opensearch.sdk.handlers.AcknowledgedResponseHandler;
import org.opensearch.sdk.handlers.ClusterSettingsResponseHandler;
import org.opensearch.sdk.handlers.ClusterStateResponseHandler;
Expand All @@ -51,6 +41,16 @@
import org.opensearch.transport.TransportResponseHandler;
import org.opensearch.transport.TransportService;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.stream.Collectors;

/**
* Wrapper class for {@link TransportService} and associated methods.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

package org.opensearch.sdk.action;

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

import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionResponse;
Expand All @@ -22,6 +19,9 @@
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.extensions.action.ExtensionTransportActionsHandler;

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

/**
* A request class to request an action be executed on another extension
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.opensearch.sdk.action;

import com.google.inject.Inject;
import org.opensearch.action.ActionListener;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.TransportAction;
Expand All @@ -17,8 +18,6 @@
import org.opensearch.tasks.Task;
import org.opensearch.tasks.TaskManager;

import com.google.inject.Inject;

/**
* Sends a request to OpenSearch for a remote extension to execute an action.
*/
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/org/opensearch/sdk/action/SDKActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@

package org.opensearch.sdk.action;

import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.MapBinder;
import org.opensearch.action.ActionType;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.TransportAction;
import org.opensearch.common.NamedRegistry;
import org.opensearch.sdk.api.ActionExtension.ActionHandler;
import org.opensearch.sdk.Extension;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.MapBinder;

import org.opensearch.sdk.api.ActionExtension;
import org.opensearch.sdk.api.ActionExtension.ActionHandler;

import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;

import static java.util.Collections.unmodifiableMap;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/opensearch/sdk/api/ActionExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

package org.opensearch.sdk.api;

import org.opensearch.action.ActionType;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionResponse;
import org.opensearch.action.ActionType;
import org.opensearch.action.RequestValidators;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.opensearch.action.support.ActionFilter;
import org.opensearch.action.support.TransportAction;
import org.opensearch.action.support.TransportActions;
import org.opensearch.core.common.Strings;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.common.Strings;
import org.opensearch.rest.RestHeaderDefinition;
import org.opensearch.sdk.Extension;
import org.opensearch.sdk.rest.ExtensionRestHandler;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/opensearch/sdk/api/SearchExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.opensearch.common.CheckedFunction;
import org.opensearch.core.ParseField;
import org.opensearch.common.io.stream.NamedWriteable;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.common.lucene.search.function.ScoreFunction;
import org.opensearch.core.ParseField;
import org.opensearch.core.xcontent.ContextParser;
import org.opensearch.core.xcontent.XContent;
import org.opensearch.core.xcontent.XContentParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.env.EnvironmentSettingsResponse;
import org.opensearch.extensions.ExtensionsManager;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.settings.Settings;
import org.opensearch.env.EnvironmentSettingsResponse;
import org.opensearch.extensions.ExtensionsManager;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportException;
import org.opensearch.transport.TransportResponseHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@

package org.opensearch.sdk.handlers;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionListener;
Expand All @@ -33,6 +26,13 @@
import org.opensearch.sdk.SDKTransportService;
import org.opensearch.sdk.action.RemoteExtensionActionRequest;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

/**
* This class handles a request from OpenSearch from another extension's {@link SDKTransportService#sendRemoteExtensionActionRequest} call.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.extensions.ExtensionsManager;
import org.opensearch.extensions.action.RemoteExtensionActionResponse;
import org.opensearch.sdk.SDKTransportService;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportException;
import org.opensearch.transport.TransportResponseHandler;
Expand Down
Loading

0 comments on commit 89ccfc2

Please sign in to comment.