-
Notifications
You must be signed in to change notification settings - Fork 814
SOLR-18091: Separate out core specific info into CoreInfoHandler #4084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
926bdb1
Seperate out into two end points
epugh e662b0d
use better path name
epugh a0345d7
remove commented code
epugh 25419e4
add some docs
epugh 7d82015
finally chase out remnants
epugh 9576ad4
Merge remote-tracking branch 'upstream/main' into SOLR-18091
epugh 587f980
Introduce a test to support new handler
epugh 96b553b
lint
epugh 0d4064f
lint
epugh a02dcdf
More robust test to pass precheck
epugh 01ce123
Use the new endpoints for a core.
epugh ea51ef6
Now supporting the host name
epugh c96a8e3
rework the docs to reflect the new handler.
epugh 84c94b0
pass forbiddenapi check
epugh 9c2c628
Merge remote-tracking branch 'upstream/main' into SOLR-18091
epugh 0cf7766
fix tests and small improvements
epugh b330edd
Remove unused methods and simplify lambda
epugh 670f6ea
respond to feedback
epugh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc | ||
| title: Provide seperate request handler SystemInfoHandler for /solr/admin/info/system from CoreInfoHandler for /solr/<collection-name>/admin/info | ||
| type: other # added, changed, fixed, deprecated, removed, dependency_update, security, other | ||
| authors: | ||
| - name: Eric Pugh | ||
| links: | ||
| - name: SOLR-18091 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18091 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
solr/core/src/java/org/apache/solr/handler/admin/CoreInfoHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * 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.handler.admin; | ||
|
|
||
| import java.io.IOException; | ||
| import java.lang.invoke.MethodHandles; | ||
| import java.nio.file.Path; | ||
| import java.util.Date; | ||
| import org.apache.solr.common.util.SimpleOrderedMap; | ||
| import org.apache.solr.core.SolrCore; | ||
| import org.apache.solr.handler.RequestHandlerBase; | ||
| import org.apache.solr.request.SolrQueryRequest; | ||
| import org.apache.solr.response.SolrQueryResponse; | ||
| import org.apache.solr.schema.IndexSchema; | ||
| import org.apache.solr.security.AuthorizationContext; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * This handler returns core level info. See {@link org.apache.solr.handler.admin.SystemInfoHandler} | ||
| */ | ||
| public class CoreInfoHandler extends RequestHandlerBase { | ||
| private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
|
|
||
| @Override | ||
| public String getDescription() { | ||
| return "Get Core Info"; | ||
| } | ||
|
|
||
| @Override | ||
| public Category getCategory() { | ||
| return Category.ADMIN; | ||
| } | ||
|
|
||
| @Override | ||
| public Name getPermissionName(AuthorizationContext request) { | ||
| return Name.CONFIG_READ_PERM; | ||
| } | ||
|
|
||
| @Override | ||
| public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { | ||
| rsp.setHttpCaching(false); | ||
| SolrCore core = req.getCore(); | ||
|
|
||
| rsp.add("core", getCoreInfo(core, req.getSchema())); | ||
| } | ||
|
|
||
| private SimpleOrderedMap<Object> getCoreInfo(SolrCore core, IndexSchema schema) { | ||
| SimpleOrderedMap<Object> info = new SimpleOrderedMap<>(); | ||
|
|
||
| info.add("schema", schema != null ? schema.getSchemaName() : "no schema!"); | ||
|
|
||
| // Now | ||
| info.add("now", new Date()); | ||
|
|
||
| // Start Time | ||
| info.add("start", core.getStartTimeStamp()); | ||
|
|
||
| // Solr Home | ||
| SimpleOrderedMap<Object> dirs = new SimpleOrderedMap<>(); | ||
| dirs.add("cwd", Path.of(System.getProperty("user.dir")).toAbsolutePath().toString()); | ||
| dirs.add("instance", core.getInstancePath().toString()); | ||
| try { | ||
| dirs.add("data", core.getDirectoryFactory().normalize(core.getDataDir())); | ||
| } catch (IOException e) { | ||
| log.warn("Problem getting the normalized data directory path", e); | ||
| } | ||
| dirs.add("dirimpl", core.getDirectoryFactory().getClass().getName()); | ||
| try { | ||
| dirs.add("index", core.getDirectoryFactory().normalize(core.getIndexDir())); | ||
| } catch (IOException e) { | ||
| log.warn("Problem getting the normalized index directory path", e); | ||
| } | ||
| info.add("directory", dirs); | ||
| return info; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this request handler need
if (AdminHandlersProxy.maybeProxyToNodes(req, rsp, getCoreContainer(req))) {likeSystemInfoHandlerhas? Is that soemthing every class needs?