Skip to content

Commit 9718680

Browse files
authored
Dev/sl google java format15 (#341)
* Spotless apply on 'datasources/**/*.java', 'core/**/*.java', 'docs/**/*.java', 'doctest/**/*.java', 'relase-notes/**/*.java', 'spark/**/*.java' Signed-off-by: Mitchell Gale <[email protected]> * Added more directories to build.gradle Signed-off-by: Mitchell Gale <[email protected]> * spotless apply for plugin. Signed-off-by: Mitchell Gale <[email protected]> * Adding checkstyle ignorefailures. Signed-off-by: Mitchell Gale <[email protected]> --------- Signed-off-by: Mitchell Gale <[email protected]>
1 parent 491a73b commit 9718680

37 files changed

+566
-583
lines changed

build.gradle

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,16 @@ repositories {
8484
spotless {
8585
java {
8686
target fileTree('.') {
87-
include 'common/**/*.java',
88-
'datasources/**/*.java',
87+
include 'datasources/**/*.java',
8988
'core/**/*.java',
90-
'ppl/**/*.java'
89+
'common/**/*.java',
90+
'docs/**/*.java',
91+
'doctest/**/*.java',
92+
'relase-notes/**/*.java',
93+
'spark/**/*.java',
94+
'ppl/**/*.java',
95+
'spark/**/*.java',
96+
'plugin/**/*.java'
9197
exclude '**/build/**', '**/build-*/**'
9298
}
9399
importOrder()
@@ -116,9 +122,8 @@ allprojects {
116122
sourceCompatibility = targetCompatibility = "11"
117123
}
118124
configurations.all {
119-
resolutionStrategy.force "com.squareup.okio:okio:3.5.0"
120-
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:1.9.0"
121-
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0"
125+
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib:1.6.0"
126+
resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-common:1.6.0"
122127
}
123128
}
124129

plugin/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ publishing {
8585
}
8686
}
8787

88+
checkstyleTest.ignoreFailures = true
89+
checkstyleMain.ignoreFailures = true
90+
8891
javadoc.enabled = false
8992
loggerUsageCheck.enabled = false
9093
dependencyLicenses.enabled = false

plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ public class SQLPlugin extends Plugin implements ActionPlugin, ScriptPlugin {
9494
private static final Logger LOGGER = LogManager.getLogger(SQLPlugin.class);
9595

9696
private ClusterService clusterService;
97-
/**
98-
* Settings should be inited when bootstrap the plugin.
99-
*/
97+
98+
/** Settings should be inited when bootstrap the plugin. */
10099
private org.opensearch.sql.common.setting.Settings pluginSettings;
100+
101101
private NodeClient client;
102102
private DataSourceServiceImpl dataSourceService;
103103
private Injector injector;
@@ -134,23 +134,28 @@ public List<RestHandler> getRestHandlers(
134134
new RestDataSourceQueryAction());
135135
}
136136

137-
/**
138-
* Register action and handler so that transportClient can find proxy for action.
139-
*/
137+
/** Register action and handler so that transportClient can find proxy for action. */
140138
@Override
141139
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
142140
return Arrays.asList(
143141
new ActionHandler<>(
144142
new ActionType<>(PPLQueryAction.NAME, TransportPPLQueryResponse::new),
145143
TransportPPLQueryAction.class),
146-
new ActionHandler<>(new ActionType<>(TransportCreateDataSourceAction.NAME,
147-
CreateDataSourceActionResponse::new), TransportCreateDataSourceAction.class),
148-
new ActionHandler<>(new ActionType<>(TransportGetDataSourceAction.NAME,
149-
GetDataSourceActionResponse::new), TransportGetDataSourceAction.class),
150-
new ActionHandler<>(new ActionType<>(TransportUpdateDataSourceAction.NAME,
151-
UpdateDataSourceActionResponse::new), TransportUpdateDataSourceAction.class),
152-
new ActionHandler<>(new ActionType<>(TransportDeleteDataSourceAction.NAME,
153-
DeleteDataSourceActionResponse::new), TransportDeleteDataSourceAction.class));
144+
new ActionHandler<>(
145+
new ActionType<>(
146+
TransportCreateDataSourceAction.NAME, CreateDataSourceActionResponse::new),
147+
TransportCreateDataSourceAction.class),
148+
new ActionHandler<>(
149+
new ActionType<>(TransportGetDataSourceAction.NAME, GetDataSourceActionResponse::new),
150+
TransportGetDataSourceAction.class),
151+
new ActionHandler<>(
152+
new ActionType<>(
153+
TransportUpdateDataSourceAction.NAME, UpdateDataSourceActionResponse::new),
154+
TransportUpdateDataSourceAction.class),
155+
new ActionHandler<>(
156+
new ActionType<>(
157+
TransportDeleteDataSourceAction.NAME, DeleteDataSourceActionResponse::new),
158+
TransportDeleteDataSourceAction.class));
154159
}
155160

156161
@Override
@@ -176,11 +181,12 @@ public Collection<Object> createComponents(
176181

177182
ModulesBuilder modules = new ModulesBuilder();
178183
modules.add(new OpenSearchPluginModule());
179-
modules.add(b -> {
180-
b.bind(NodeClient.class).toInstance((NodeClient) client);
181-
b.bind(org.opensearch.sql.common.setting.Settings.class).toInstance(pluginSettings);
182-
b.bind(DataSourceService.class).toInstance(dataSourceService);
183-
});
184+
modules.add(
185+
b -> {
186+
b.bind(NodeClient.class).toInstance((NodeClient) client);
187+
b.bind(org.opensearch.sql.common.setting.Settings.class).toInstance(pluginSettings);
188+
b.bind(DataSourceService.class).toInstance(dataSourceService);
189+
});
184190

185191
injector = modules.createInjector();
186192
return ImmutableList.of(dataSourceService);
@@ -212,30 +218,31 @@ public ScriptEngine getScriptEngine(Settings settings, Collection<ScriptContext<
212218
}
213219

214220
private DataSourceServiceImpl createDataSourceService() {
215-
String masterKey = OpenSearchSettings
216-
.DATASOURCE_MASTER_SECRET_KEY.get(clusterService.getSettings());
221+
String masterKey =
222+
OpenSearchSettings.DATASOURCE_MASTER_SECRET_KEY.get(clusterService.getSettings());
217223
if (StringUtils.isEmpty(masterKey)) {
218-
LOGGER.warn("Master key is a required config for using create and update datasource APIs. "
219-
+ "Please set plugins.query.datasources.encryption.masterkey config "
220-
+ "in opensearch.yml in all the cluster nodes. "
221-
+ "More details can be found here: "
222-
+ "https://github.com/opensearch-project/sql/blob/main/docs/user/ppl/"
223-
+ "admin/datasources.rst#master-key-config-for-encrypting-credential-information");
224+
LOGGER.warn(
225+
"Master key is a required config for using create and update datasource APIs. "
226+
+ "Please set plugins.query.datasources.encryption.masterkey config "
227+
+ "in opensearch.yml in all the cluster nodes. "
228+
+ "More details can be found here: "
229+
+ "https://github.com/opensearch-project/sql/blob/main/docs/user/ppl/"
230+
+ "admin/datasources.rst#master-key-config-for-encrypting-credential-information");
224231
}
225-
DataSourceMetadataStorage dataSourceMetadataStorage
226-
= new OpenSearchDataSourceMetadataStorage(client, clusterService,
227-
new EncryptorImpl(masterKey));
228-
DataSourceUserAuthorizationHelper dataSourceUserAuthorizationHelper
229-
= new DataSourceUserAuthorizationHelperImpl(client);
232+
DataSourceMetadataStorage dataSourceMetadataStorage =
233+
new OpenSearchDataSourceMetadataStorage(
234+
client, clusterService, new EncryptorImpl(masterKey));
235+
DataSourceUserAuthorizationHelper dataSourceUserAuthorizationHelper =
236+
new DataSourceUserAuthorizationHelperImpl(client);
230237
return new DataSourceServiceImpl(
231238
new ImmutableSet.Builder<DataSourceFactory>()
232-
.add(new OpenSearchDataSourceFactory(
233-
new OpenSearchNodeClient(this.client), pluginSettings))
239+
.add(
240+
new OpenSearchDataSourceFactory(
241+
new OpenSearchNodeClient(this.client), pluginSettings))
234242
.add(new PrometheusStorageFactory(pluginSettings))
235243
.add(new SparkStorageFactory(this.client, pluginSettings))
236244
.build(),
237245
dataSourceMetadataStorage,
238246
dataSourceUserAuthorizationHelper);
239247
}
240-
241248
}

plugin/src/main/java/org/opensearch/sql/plugin/config/OpenSearchPluginModule.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public class OpenSearchPluginModule extends AbstractModule {
4545
BuiltinFunctionRepository.getInstance();
4646

4747
@Override
48-
protected void configure() {
49-
}
48+
protected void configure() {}
5049

5150
@Provides
5251
public OpenSearchClient openSearchClient(NodeClient nodeClient) {
@@ -59,8 +58,8 @@ public StorageEngine storageEngine(OpenSearchClient client, Settings settings) {
5958
}
6059

6160
@Provides
62-
public ExecutionEngine executionEngine(OpenSearchClient client, ExecutionProtector protector,
63-
PlanSerializer planSerializer) {
61+
public ExecutionEngine executionEngine(
62+
OpenSearchClient client, ExecutionProtector protector, PlanSerializer planSerializer) {
6463
return new OpenSearchExecutionEngine(client, protector, planSerializer);
6564
}
6665

@@ -95,18 +94,15 @@ public SQLService sqlService(QueryManager queryManager, QueryPlanFactory queryPl
9594
return new SQLService(new SQLSyntaxParser(), queryManager, queryPlanFactory);
9695
}
9796

98-
/**
99-
* {@link QueryPlanFactory}.
100-
*/
97+
/** {@link QueryPlanFactory}. */
10198
@Provides
102-
public QueryPlanFactory queryPlanFactory(DataSourceService dataSourceService,
103-
ExecutionEngine executionEngine) {
99+
public QueryPlanFactory queryPlanFactory(
100+
DataSourceService dataSourceService, ExecutionEngine executionEngine) {
104101
Analyzer analyzer =
105102
new Analyzer(
106103
new ExpressionAnalyzer(functionRepository), dataSourceService, functionRepository);
107104
Planner planner = new Planner(LogicalPlanOptimizer.create());
108-
QueryService queryService = new QueryService(
109-
analyzer, executionEngine, planner);
105+
QueryService queryService = new QueryService(analyzer, executionEngine, planner);
110106
return new QueryPlanFactory(queryService);
111107
}
112108
}

plugin/src/main/java/org/opensearch/sql/plugin/request/PPLQueryRequestFactory.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.plugin.request;
87

98
import java.util.Map;
@@ -15,9 +14,7 @@
1514
import org.opensearch.sql.protocol.response.format.Format;
1615
import org.opensearch.sql.protocol.response.format.JsonResponseFormatter;
1716

18-
/**
19-
* Factory of {@link PPLQueryRequest}.
20-
*/
17+
/** Factory of {@link PPLQueryRequest}. */
2118
public class PPLQueryRequestFactory {
2219
private static final String PPL_URL_PARAM_KEY = "ppl";
2320
private static final String PPL_FIELD_NAME = "query";
@@ -28,6 +25,7 @@ public class PPLQueryRequestFactory {
2825

2926
/**
3027
* Build {@link PPLQueryRequest} from {@link RestRequest}.
28+
*
3129
* @param request {@link PPLQueryRequest}
3230
* @return {@link RestRequest}
3331
*/
@@ -63,8 +61,12 @@ private static PPLQueryRequest parsePPLRequestFromPayload(RestRequest restReques
6361
} catch (JSONException e) {
6462
throw new IllegalArgumentException("Failed to parse request payload", e);
6563
}
66-
PPLQueryRequest pplRequest = new PPLQueryRequest(jsonContent.getString(PPL_FIELD_NAME),
67-
jsonContent, restRequest.path(), format.getFormatName());
64+
PPLQueryRequest pplRequest =
65+
new PPLQueryRequest(
66+
jsonContent.getString(PPL_FIELD_NAME),
67+
jsonContent,
68+
restRequest.path(),
69+
format.getFormatName());
6870
// set sanitize option if csv format
6971
if (format.equals(Format.CSV)) {
7072
pplRequest.sanitize(getSanitizeOption(restRequest.params()));

plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,17 @@ protected Set<String> responseParams() {
102102
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient nodeClient) {
103103
// TODO: need move to transport Action
104104
if (!pplEnabled.get()) {
105-
return channel -> reportError(channel, new IllegalAccessException(
106-
"Either plugins.ppl.enabled or rest.action.multi.allow_explicit_index setting is false"),
107-
BAD_REQUEST);
105+
return channel ->
106+
reportError(
107+
channel,
108+
new IllegalAccessException(
109+
"Either plugins.ppl.enabled or rest.action.multi.allow_explicit_index setting is"
110+
+ " false"),
111+
BAD_REQUEST);
108112
}
109113

110-
TransportPPLQueryRequest transportPPLQueryRequest = new TransportPPLQueryRequest(
111-
PPLQueryRequestFactory.getPPLRequest(request)
112-
);
114+
TransportPPLQueryRequest transportPPLQueryRequest =
115+
new TransportPPLQueryRequest(PPLQueryRequestFactory.getPPLRequest(request));
113116

114117
return channel ->
115118
nodeClient.execute(

plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLStatsAction.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.plugin.rest;
87

98
import static org.opensearch.core.rest.RestStatus.SERVICE_UNAVAILABLE;
@@ -26,17 +25,14 @@
2625
import org.opensearch.sql.legacy.executor.format.ErrorMessageFactory;
2726
import org.opensearch.sql.legacy.metrics.Metrics;
2827

29-
/**
30-
* PPL Node level status.
31-
*/
28+
/** PPL Node level status. */
3229
public class RestPPLStatsAction extends BaseRestHandler {
3330

3431
private static final Logger LOG = LogManager.getLogger(RestPPLStatsAction.class);
3532

36-
/**
37-
* API endpoint path.
38-
*/
33+
/** API endpoint path. */
3934
public static final String PPL_STATS_API_ENDPOINT = "/_plugins/_ppl/stats";
35+
4036
public static final String PPL_LEGACY_STATS_API_ENDPOINT = "/_opendistro/_ppl/stats";
4137

4238
public RestPPLStatsAction(Settings settings, RestController restController) {
@@ -70,13 +66,18 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
7066
QueryContext.addRequestId();
7167

7268
try {
73-
return channel -> channel.sendResponse(new BytesRestResponse(RestStatus.OK,
74-
Metrics.getInstance().collectToJSON()));
69+
return channel ->
70+
channel.sendResponse(
71+
new BytesRestResponse(RestStatus.OK, Metrics.getInstance().collectToJSON()));
7572
} catch (Exception e) {
7673
LOG.error("Failed during Query PPL STATS Action.", e);
7774

78-
return channel -> channel.sendResponse(new BytesRestResponse(SERVICE_UNAVAILABLE,
79-
ErrorMessageFactory.createErrorMessage(e, SERVICE_UNAVAILABLE.getStatus()).toString()));
75+
return channel ->
76+
channel.sendResponse(
77+
new BytesRestResponse(
78+
SERVICE_UNAVAILABLE,
79+
ErrorMessageFactory.createErrorMessage(e, SERVICE_UNAVAILABLE.getStatus())
80+
.toString()));
8081
}
8182
}
8283

0 commit comments

Comments
 (0)