Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
2b484ce
Create empty SolrJ build module for api/model classes
gerlowskija Jul 10, 2023
3741fb4
Move sample API and models to solrj-model
gerlowskija Jul 12, 2023
4d180d3
Move spec generation to solrj-model
gerlowskija Jul 12, 2023
b8b75eb
Introduce Java codegen to solrj module
gerlowskija Jul 12, 2023
2e6f9cb
Limit files generated by openapi-generator
gerlowskija Jul 12, 2023
1894bb1
Add template override directory
gerlowskija Jul 12, 2023
4731a61
Move additional API to solrj-model
gerlowskija Jul 12, 2023
d540add
Readd swagger-annotations to core
gerlowskija Jul 13, 2023
616b2ab
Remove method annotations from DeleteCollAPI
gerlowskija Jul 13, 2023
74adc27
Add Operation annotation to model definition
gerlowskija Jul 13, 2023
23bda9d
Initial pass at SolrRequest generation
gerlowskija Jul 13, 2023
4834130
Initial pass at SolrRequest javadocs
gerlowskija Jul 13, 2023
a0c1650
Add Jackson and solrj-model deps to solrj
gerlowskija Jul 13, 2023
6e2aede
Provide strongly-typed responses using Jackson
gerlowskija Jul 17, 2023
9bfc619
Remove placeholder java file
gerlowskija Jul 17, 2023
1cf71e6
Extract AddReplicaProperty interface to solrj-models
gerlowskija Jul 17, 2023
03b471b
Add templating for request entity generation
gerlowskija Jul 17, 2023
b540acd
Cosmetic improvements to code generation templates
gerlowskija Jul 18, 2023
83c74b3
Cleanup api template
gerlowskija Jul 18, 2023
9f39281
Ensure 'tidy' cleans up generated code
gerlowskija Jul 19, 2023
fdb184c
Tidy cleanup
gerlowskija Jul 19, 2023
204470c
Slight tidy fix
gerlowskija Jul 19, 2023
dfbd268
Add new generated-file-specific spotless tasks
gerlowskija Jul 19, 2023
a24998a
Cleanup spotless code for solrj generated files
HoustonPutman Jul 19, 2023
499e38c
Restructure packages in solrj-model
gerlowskija Jul 21, 2023
7a2bf01
Disable model generation
gerlowskija Jul 21, 2023
533e55e
Small build fixes
gerlowskija Jul 21, 2023
00fe00d
Move solrj-model to api, fix some hacks
HoustonPutman Jul 26, 2023
4f060da
Fix warning for gradle build
HoustonPutman Jul 26, 2023
6aeb4cf
Remove unused task
HoustonPutman Jul 26, 2023
cda5e86
Make spotless work again
HoustonPutman Jul 26, 2023
e97c15c
Tidy
gerlowskija Jul 26, 2023
664cf7c
Add copyright header to generated files
gerlowskija Jul 26, 2023
2acd411
Replace I- prefix to -Api suffix on interfaces
gerlowskija Jul 27, 2023
d4ff21c
Fix 'check'
gerlowskija Jul 27, 2023
7a08b29
'check' fix 2
gerlowskija Jul 27, 2023
6b4aa89
More check fixes
HoustonPutman Jul 27, 2023
f035a32
Fix log4j, and solrj generated classpath now knows its build dependency
HoustonPutman Jul 27, 2023
f1c9b88
Move SolrVersion to 'api' module
gerlowskija Jul 27, 2023
4173109
Fix 'check'
gerlowskija Jul 27, 2023
0baaedb
remove hack for task depenency
HoustonPutman Jul 27, 2023
22f7ebf
Resolve split packages
gerlowskija Jul 27, 2023
d12c498
Misc review feedback and cleanup
gerlowskija Jul 27, 2023
6a1e802
Remove NOCOMMIT around shading Jackson
gerlowskija Jul 28, 2023
3c195a2
Revert "Resolve split packages"
gerlowskija Jul 31, 2023
1ad9fbc
Remove split package issues
gerlowskija Jul 31, 2023
6a2dd43
Ensure 'api' model classes remain serializable for Javabin
gerlowskija Jul 31, 2023
16002db
Revert "Ensure 'api' model classes remain serializable for Javabin"
gerlowskija Aug 1, 2023
1cb2d7b
Revert "Revert "Ensure 'api' model classes remain serializable for Ja…
gerlowskija Aug 1, 2023
ec090a2
Second pass on serialization headaches
gerlowskija Aug 1, 2023
aafde25
Remove unnecessary test
gerlowskija Aug 1, 2023
ebd7476
Revert "Remove split package issues"
gerlowskija Aug 1, 2023
e776456
Tweak 'api' module packages
gerlowskija Aug 1, 2023
eaba943
Merge branch 'main' into SOLR-16825-java-binding-poc
gerlowskija Aug 1, 2023
f0e9c79
Post-merge cleanup
gerlowskija Aug 1, 2023
10ab55a
Merge branch 'main' into SOLR-16825-java-binding-poc
gerlowskija Aug 8, 2023
5f61a80
Post-merge cleanup
gerlowskija Aug 8, 2023
ae5e18d
Make check happy
gerlowskija Aug 8, 2023
8252820
Add missing @Override annotations
gerlowskija Aug 8, 2023
f996919
CHANGES.txt entry
gerlowskija Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev-tools/scripts/smokeTestRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
expected_src_root_folders = ['buildSrc', 'dev-docs', 'dev-tools', 'gradle', 'help', 'solr']
expected_src_root_files = ['build.gradle', 'gradlew', 'gradlew.bat', 'settings.gradle', 'versions.lock', 'versions.props']
expected_src_solr_files = ['build.gradle']
expected_src_solr_folders = ['benchmark', 'bin', 'modules', 'core', 'docker', 'documentation', 'example', 'licenses', 'packaging', 'distribution', 'prometheus-exporter', 'server', 'solr-ref-guide', 'solrj', 'solrj-streaming', 'solrj-zookeeper', 'test-framework', 'webapp', '.gitignore', '.gitattributes']
expected_src_solr_folders = ['benchmark', 'bin', 'modules', 'api', 'core', 'docker', 'documentation', 'example', 'licenses', 'packaging', 'distribution', 'prometheus-exporter', 'server', 'solr-ref-guide', 'solrj', 'solrj-streaming', 'solrj-zookeeper', 'test-framework', 'webapp', '.gitignore', '.gitattributes']
is_in_list(in_root_folder, expected_src_root_folders)
is_in_list(in_root_folder, expected_src_root_files)
is_in_list(in_solr_folder, expected_src_solr_folders)
Expand Down
1 change: 1 addition & 0 deletions gradle/maven/defaults-maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
configure(rootProject) {
ext {
published = [
":solr:api",
":solr:core",
":solr:solrj",
":solr:solrj-streaming",
Expand Down
1 change: 1 addition & 0 deletions gradle/solr/packaging.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ configure(allprojects.findAll {project -> project.path.startsWith(":solr:modules
dependencies {
solrPlatformLibs project(":solr:core")
solrPlatformLibs project(":solr:solrj")
solrPlatformLibs project(":solr:api")
solrPlatformLibs project(":solr:solrj-zookeeper")
// libExt has logging libs, which we don't want. Lets users decide what they want.
solrPlatformLibs project(path: ":solr:server", configuration: 'libExt')
Expand Down
36 changes: 21 additions & 15 deletions gradle/validation/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,32 @@ configure(project(":solr").subprojects) { prj ->
plugins.withType(JavaPlugin) {
prj.apply plugin: 'com.diffplug.spotless'

spotless {
java {
toggleOffOn() // obviously, only to be used sparingly.
ext {
spotlessJavaSetup = (Action){
it.toggleOffOn() // obviously, only to be used sparingly.
// TODO: Work out how to support multiple different header files (we have
// classes in the codebase that have original headers). We currently use
// Apache RAT to enforce headers so this is of lesser priority.
//
// licenseHeaderFile file("${resources}/asl-header.txt"), '^(\\s*package)'
// it.licenseHeaderFile(file("${resources}/asl-header.txt"), '^(\\s*package)')
it.setLineEndings(Enum.valueOf(rootProject.buildscript.classLoader.loadClass("com.diffplug.spotless.LineEnding"), "UNIX"))
it.endWithNewline()
it.googleJavaFormat('1.15.0')

lineEndings 'UNIX'
endWithNewline()
googleJavaFormat('1.15.0')
it.custom('Refuse wildcard imports', { line ->
// Wildcard imports can't be resolved by spotless itself.
// This will require the developer themselves to adhere to best practices.
if (line =~ /\nimport .*\*;/) {
throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
}
line
})
}
}

spotless {
java {
prj.ext.spotlessJavaSetup.execute(it)

// Apply to all Java sources
target "src/**/*.java"
Expand All @@ -62,14 +76,6 @@ configure(project(":solr").subprojects) { prj ->
target "modules/**/examples/*.java"
break
}

custom 'Refuse wildcard imports', {
// Wildcard imports can't be resolved by spotless itself.
// This will require the developer themselves to adhere to best practices.
if (it =~ /\nimport .*\*;/) {
throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ rootProject.name = "solr-root"

includeBuild("dev-tools/solr-missing-doclet")

include "solr:api"
include "solr:solrj"
include "solr:solrj-zookeeper"
include "solr:solrj-streaming"
Expand Down
5 changes: 5 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ Improvements
a HTTP 503 status. Switched to 510 so that CloudSolrClient will auto-retry it and probably succeed.
(David Smiley, Alex Deparvu)

* SOLR-16825: Solr now offers `SolrRequest` implementations for a subset of its v2 APIs. These implementations
are experimental and should be used with caution, but may be preferable to their v1 counterparts in some
circumstances as they are generated and more likely to remain up-to-date with future API changes.
(Jason Gerlowski, David Smiley, Houston Putman)

Optimizations
---------------------

Expand Down
61 changes: 61 additions & 0 deletions solr/api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.2.2'
}

apply plugin: 'java-library'

description = 'API - Interfaces and classes used to represent Solrs APIs'

ext {
openApiSpecDir = "${buildDir}/generated/openapi"
openApiSpecFile = "${project.openApiSpecDir}/openapi.json"
}

configurations {
openapiSpec {
canBeConsumed = true
canBeResolved = false
}
}

resolve {
classpath = sourceSets.main.runtimeClasspath
outputDir = file(project.openApiSpecDir)
prettyPrint = true
}

dependencies {
runtimeOnly 'org.slf4j:slf4j-api'

implementation 'jakarta.ws.rs:jakarta.ws.rs-api'
implementation 'com.fasterxml.jackson.core:jackson-annotations'
api 'io.swagger.core.v3:swagger-annotations'
implementation 'org.semver4j:semver4j'

testImplementation project(':solr:test-framework')
testImplementation project(':solr:api')
testImplementation 'org.apache.lucene:lucene-test-framework'
}

artifacts {
openapiSpec resolve.outputDir, {
builtBy resolve
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.solr.client.api.endpoint;

import static org.apache.solr.client.api.util.Constants.BINARY_CONTENT_TYPE_V2;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.apache.solr.client.api.model.AddReplicaPropertyRequestBody;
import org.apache.solr.client.api.model.SolrJerseyResponse;

@Path("/collections/{collName}/shards/{shardName}/replicas/{replicaName}/properties/{propName}")
public interface AddReplicaPropertyApi {

@PUT
@Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
@Operation(
summary = "Adds a property to the specified replica",
tags = {"replicas"})
public SolrJerseyResponse addReplicaProperty(
@Parameter(
description = "The name of the collection the replica belongs to.",
required = true)
@PathParam("collName")
String collName,
@Parameter(description = "The name of the shard the replica belongs to.", required = true)
@PathParam("shardName")
String shardName,
@Parameter(description = "The replica, e.g., `core_node1`.", required = true)
@PathParam("replicaName")
String replicaName,
@Parameter(description = "The name of the property to add.", required = true)
@PathParam("propName")
String propertyName,
@RequestBody(
description = "The value of the replica property to create or update",
required = true)
AddReplicaPropertyRequestBody requestBody)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.solr.client.api.endpoint;

import static org.apache.solr.client.api.util.Constants.BINARY_CONTENT_TYPE_V2;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import javax.ws.rs.DELETE;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import org.apache.solr.client.api.model.SolrJerseyResponse;

@Path("/aliases/{aliasName}")
public interface DeleteAliasApi {

@DELETE
@Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
@Operation(
summary = "Deletes an alias by its name",
tags = {"aliases"})
SolrJerseyResponse deleteAlias(
@Parameter(description = "The name of the alias to delete", required = true)
@PathParam("aliasName")
String aliasName,
@QueryParam("async") String asyncId)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.solr.client.api.endpoint;

import static org.apache.solr.client.api.util.Constants.BINARY_CONTENT_TYPE_V2;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import javax.ws.rs.DELETE;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse;

@Path("/collections/{collectionName}")
public interface DeleteCollectionApi {

@DELETE
@Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
@Operation(
summary = "Deletes a collection from SolrCloud",
tags = {"collections"})
SubResponseAccumulatingJerseyResponse deleteCollection(
@Parameter(description = "The name of the collection to be deleted.", required = true)
@PathParam("collectionName")
String collectionName,
@QueryParam("followAliases") Boolean followAliases,
@Parameter(description = "An ID to track the request asynchronously") @QueryParam("async")
String asyncId)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/** Interfaces representing individual Solr v2 APIs. */
package org.apache.solr.client.api.endpoint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.solr.client.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.solr.client.api.util.ReflectWritable;

public class AddReplicaPropertyRequestBody implements ReflectWritable {
public AddReplicaPropertyRequestBody() {}

public AddReplicaPropertyRequestBody(String value) {
this.value = value;
}

@Schema(description = "The value to assign to the property.", required = true)
@JsonProperty("value")
public String value;

@Schema(
description =
"If `true`, then setting this property in one replica will remove the property from all other replicas in that shard. The default is `false`.\\nThere is one pre-defined property `preferredLeader` for which `shardUnique` is forced to `true` and an error returned if `shardUnique` is explicitly set to `false`.",
defaultValue = "false")
@JsonProperty("shardUnique")
public Boolean shardUnique;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.solr.jersey;
package org.apache.solr.client.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down
Loading