Package org.apache.solr.rest
Class RestManager
- java.lang.Object
-
- org.apache.solr.rest.RestManager
-
public class RestManager extends Object
Supports runtime mapping of REST API endpoints to ManagedResource implementations; endpoints can be registered at either the /schema or /config base paths, depending on which base path is more appropriate for the type of managed resource.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RestManager.ManagedEndpoint
The Restlet router needs a lightweight extension of ServerResource to delegate a request to.static class
RestManager.Registry
Per-core registry of ManagedResources found during core initialization.
-
Field Summary
Fields Modifier and Type Field Description protected org.restlet.routing.Router
configRouter
protected org.apache.solr.rest.RestManager.RestManagerManagedResource
endpoint
protected SolrResourceLoader
loader
protected Map<String,ManagedResource>
managed
static String
MANAGED_ENDPOINT
protected RestManager.Registry
registry
static String
SCHEMA_BASE_PATH
protected org.restlet.routing.Router
schemaRouter
protected ManagedResourceStorage.StorageIO
storageIO
-
Constructor Summary
Constructors Constructor Description RestManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ManagedResource
addManagedResource(String resourceId, Class<? extends ManagedResource> clazz)
If not already registered, registers the givenManagedResource
subclass at the given resourceId, creates an instance, and attaches it to the appropriate Restlet router.protected void
attachManagedResource(ManagedResource res, String path, org.restlet.routing.Router router)
Attaches a ManagedResource and optionally a path for child resources to the given Restlet Router.void
attachManagedResources(String routerPath, org.restlet.routing.Router router)
Attach managed resource paths to the given Restlet Router.protected ManagedResource
createManagedResource(org.apache.solr.rest.RestManager.ManagedResourceRegistration reg)
Creates a ManagedResource using registration information.void
deleteManagedResource(ManagedResource res)
Deletes a managed resource if it is not being used by any Solr components.ManagedResource
getManagedResource(String resourceId)
Returns theManagedResource
subclass instance corresponding to the given resourceId from the registry.ManagedResource
getManagedResourceOrNull(String resourceId)
Returns theManagedResource
subclass instance corresponding to the given resourceId from the registry, or null if no resource has been registered with the given resourceId.static RestManager
getRestManager(SolrRequestInfo solrRequestInfo)
Locates the RestManager using ThreadLocal SolrRequestInfo.void
init(SolrResourceLoader loader, NamedList<String> initArgs, ManagedResourceStorage.StorageIO storageIO)
Initializes the RestManager with the storageIO being optionally created outside of this implementation such as to use ZooKeeper instead of the local FS.
-
-
-
Field Detail
-
SCHEMA_BASE_PATH
public static final String SCHEMA_BASE_PATH
- See Also:
- Constant Field Values
-
MANAGED_ENDPOINT
public static final String MANAGED_ENDPOINT
- See Also:
- Constant Field Values
-
storageIO
protected ManagedResourceStorage.StorageIO storageIO
-
registry
protected RestManager.Registry registry
-
managed
protected Map<String,ManagedResource> managed
-
endpoint
protected org.apache.solr.rest.RestManager.RestManagerManagedResource endpoint
-
loader
protected SolrResourceLoader loader
-
schemaRouter
protected org.restlet.routing.Router schemaRouter
-
configRouter
protected org.restlet.routing.Router configRouter
-
-
Method Detail
-
getRestManager
public static RestManager getRestManager(SolrRequestInfo solrRequestInfo)
Locates the RestManager using ThreadLocal SolrRequestInfo.
-
init
public void init(SolrResourceLoader loader, NamedList<String> initArgs, ManagedResourceStorage.StorageIO storageIO) throws SolrException
Initializes the RestManager with the storageIO being optionally created outside of this implementation such as to use ZooKeeper instead of the local FS.- Throws:
SolrException
-
addManagedResource
public ManagedResource addManagedResource(String resourceId, Class<? extends ManagedResource> clazz)
If not already registered, registers the givenManagedResource
subclass at the given resourceId, creates an instance, and attaches it to the appropriate Restlet router. Returns the corresponding instance.
-
createManagedResource
protected ManagedResource createManagedResource(org.apache.solr.rest.RestManager.ManagedResourceRegistration reg) throws SolrException
Creates a ManagedResource using registration information.- Throws:
SolrException
-
getManagedResource
public ManagedResource getManagedResource(String resourceId)
Returns theManagedResource
subclass instance corresponding to the given resourceId from the registry.- Throws:
org.restlet.resource.ResourceException
- if no managed resource is registered with the given resourceId.
-
getManagedResourceOrNull
public ManagedResource getManagedResourceOrNull(String resourceId)
Returns theManagedResource
subclass instance corresponding to the given resourceId from the registry, or null if no resource has been registered with the given resourceId.
-
deleteManagedResource
public void deleteManagedResource(ManagedResource res)
Deletes a managed resource if it is not being used by any Solr components.
-
attachManagedResources
public void attachManagedResources(String routerPath, org.restlet.routing.Router router)
Attach managed resource paths to the given Restlet Router.- Parameters:
router
- - Restlet Router
-
attachManagedResource
protected void attachManagedResource(ManagedResource res, String path, org.restlet.routing.Router router)
Attaches a ManagedResource and optionally a path for child resources to the given Restlet Router.
-
-