Package org.apache.solr.rest
Class ManagedResource
- java.lang.Object
- 
- org.apache.solr.rest.ManagedResource
 
- 
- Direct Known Subclasses:
- ManagedSynonymFilterFactory.SynonymManager,- ManagedSynonymGraphFilterFactory.SynonymManager,- ManagedWordSetResource
 
 public abstract class ManagedResource extends Object Supports Solr components that have external data that needs to be managed using the REST API.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceManagedResource.ChildResourceSupportMarker interface to indicate a ManagedResource implementation class also supports managing child resources at path: /<resource>/{child}
 - 
Field SummaryFields Modifier and Type Field Description static StringINIT_ARGS_JSON_FIELDstatic StringINITIALIZED_ON_JSON_FIELDprotected DateinitializedOnprotected DatelastUpdateSinceInitializationstatic StringMANAGED_JSON_LIST_FIELDstatic StringMANAGED_JSON_MAP_FIELDprotected org.apache.solr.common.util.NamedList<Object>managedInitArgsprotected SolrResourceLoadersolrResourceLoaderprotected ManagedResourceStoragestoragestatic StringUPDATED_SINCE_INIT_JSON_FIELD
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedManagedResource(String resourceId, SolrResourceLoader loader, ManagedResourceStorage.StorageIO storageIO)Initializes this managed resource, including setting up JSON-based storage using the provided storageIO implementation, such as ZK.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ObjectapplyUpdatesToManagedData(Object updates)Called during PUT/POST processing to apply updates to the managed data passed from the client.protected Map<String,Object>buildMapToStore(Object managedData)Builds the JSON object to be stored, containing initArgs and managed data fields.protected Map<String,Object>convertNamedListToMap(org.apache.solr.common.util.NamedList<?> args)Converts a NamedList<?> into an ordered Map for returning as JSON.protected ManagedResourceStoragecreateStorage(ManagedResourceStorage.StorageIO storageIO, SolrResourceLoader loader)Potential extension point allowing concrete implementations to supply their own storage implementation.abstract voiddoDeleteChild(BaseSolrResource endpoint, String childId)Called to delete a named part (the given childId) of the resource at the given endpointabstract voiddoGet(BaseSolrResource endpoint, String childId)Called to retrieve a named part (the given childId) of the resource at the given endpointvoiddoPost(BaseSolrResource endpoint, Object json)Just callsdoPut(BaseSolrResource,Object); override to change the behavior of POST handling.voiddoPut(BaseSolrResource endpoint, Object json)Applies changes to initArgs or managed data.StringgetInitializedOn()Returns this resource's initialization timestamp.StringgetResourceId()Gets the resource ID for this managed resource.SolrResourceLoadergetResourceLoader()Returns the resource loader used by this resource.Class<? extends BaseSolrResource>getServerResourceClass()Gets the ServerResource class to register this endpoint with the Rest API router; in most cases, the default RestManager.ManagedEndpoint class is sufficient but ManagedResource implementations can override this method if a different ServerResource class is needed.StringgetUpdatedSinceInitialization()Returns the timestamp of the most recent update, or null if this resource has not been updated since initialization.booleanhasChangesSinceInitialization()Returns true if this resource has been changed since initialization.voidloadManagedDataAndNotify(Collection<ManagedResourceObserver> observers)Called once during core initialization to get the managed data loaded from storage and notify observers.protected voidnotifyObserversDuringInit(org.apache.solr.common.util.NamedList<?> args, Collection<ManagedResourceObserver> observers)Notifies all registered observers that the ManagedResource is initialized.protected abstract voidonManagedDataLoadedFromStorage(org.apache.solr.common.util.NamedList<?> managedInitArgs, Object managedData)Method called after data has been loaded from storage to give the concrete implementation a chance to post-process the data.voidonResourceDeleted()Called by the RestManager framework after this resource has been deleted to allow this resource to close and clean-up any resources used by this.protected ObjectprocessStoredData(Object data)Processes the stored data.protected voidreloadFromStorage()Invoked when this object determines it needs to reload the stored data.voidstoreManagedData(Object managedData)Persists managed data to the configured storage IO as a JSON object.protected booleanupdateInitArgs(org.apache.solr.common.util.NamedList<?> updatedArgs)Called fromdoPut(BaseSolrResource,Object)to update this resource's init args using the given updatedArgs
 
- 
- 
- 
Field Detail- 
INIT_ARGS_JSON_FIELDpublic static final String INIT_ARGS_JSON_FIELD - See Also:
- Constant Field Values
 
 - 
MANAGED_JSON_LIST_FIELDpublic static final String MANAGED_JSON_LIST_FIELD - See Also:
- Constant Field Values
 
 - 
MANAGED_JSON_MAP_FIELDpublic static final String MANAGED_JSON_MAP_FIELD - See Also:
- Constant Field Values
 
 - 
INITIALIZED_ON_JSON_FIELDpublic static final String INITIALIZED_ON_JSON_FIELD - See Also:
- Constant Field Values
 
 - 
UPDATED_SINCE_INIT_JSON_FIELDpublic static final String UPDATED_SINCE_INIT_JSON_FIELD - See Also:
- Constant Field Values
 
 - 
solrResourceLoaderprotected final SolrResourceLoader solrResourceLoader 
 - 
storageprotected final ManagedResourceStorage storage 
 - 
managedInitArgsprotected org.apache.solr.common.util.NamedList<Object> managedInitArgs 
 - 
initializedOnprotected Date initializedOn 
 - 
lastUpdateSinceInitializationprotected Date lastUpdateSinceInitialization 
 
- 
 - 
Constructor Detail- 
ManagedResourceprotected ManagedResource(String resourceId, SolrResourceLoader loader, ManagedResourceStorage.StorageIO storageIO) throws org.apache.solr.common.SolrException Initializes this managed resource, including setting up JSON-based storage using the provided storageIO implementation, such as ZK.- Throws:
- org.apache.solr.common.SolrException
 
 
- 
 - 
Method Detail- 
loadManagedDataAndNotifypublic void loadManagedDataAndNotify(Collection<ManagedResourceObserver> observers) throws org.apache.solr.common.SolrException Called once during core initialization to get the managed data loaded from storage and notify observers.- Throws:
- org.apache.solr.common.SolrException
 
 - 
notifyObserversDuringInitprotected void notifyObserversDuringInit(org.apache.solr.common.util.NamedList<?> args, Collection<ManagedResourceObserver> observers) throws org.apache.solr.common.SolrExceptionNotifies all registered observers that the ManagedResource is initialized. This event only occurs once when the core is loaded. Thus, you need to reload the core to get updates applied to the analysis components that depend on the ManagedResource data.- Throws:
- org.apache.solr.common.SolrException
 
 - 
createStorageprotected ManagedResourceStorage createStorage(ManagedResourceStorage.StorageIO storageIO, SolrResourceLoader loader) throws org.apache.solr.common.SolrException Potential extension point allowing concrete implementations to supply their own storage implementation. The default implementation uses JSON as the storage format and delegates the loading and saving of JSON bytes to the supplied StorageIO class.- Throws:
- org.apache.solr.common.SolrException
 
 - 
getResourceLoaderpublic SolrResourceLoader getResourceLoader() Returns the resource loader used by this resource.
 - 
getResourceIdpublic String getResourceId() Gets the resource ID for this managed resource.
 - 
getServerResourceClasspublic Class<? extends BaseSolrResource> getServerResourceClass() Gets the ServerResource class to register this endpoint with the Rest API router; in most cases, the default RestManager.ManagedEndpoint class is sufficient but ManagedResource implementations can override this method if a different ServerResource class is needed.
 - 
updateInitArgsprotected boolean updateInitArgs(org.apache.solr.common.util.NamedList<?> updatedArgs) Called fromdoPut(BaseSolrResource,Object)to update this resource's init args using the given updatedArgs
 - 
reloadFromStorageprotected void reloadFromStorage() throws org.apache.solr.common.SolrExceptionInvoked when this object determines it needs to reload the stored data.- Throws:
- org.apache.solr.common.SolrException
 
 - 
processStoredDataprotected Object processStoredData(Object data) throws org.apache.solr.common.SolrException Processes the stored data.- Throws:
- org.apache.solr.common.SolrException
 
 - 
onManagedDataLoadedFromStorageprotected abstract void onManagedDataLoadedFromStorage(org.apache.solr.common.util.NamedList<?> managedInitArgs, Object managedData) throws org.apache.solr.common.SolrExceptionMethod called after data has been loaded from storage to give the concrete implementation a chance to post-process the data.- Throws:
- org.apache.solr.common.SolrException
 
 - 
storeManagedDatapublic void storeManagedData(Object managedData) Persists managed data to the configured storage IO as a JSON object.
 - 
getInitializedOnpublic String getInitializedOn() Returns this resource's initialization timestamp.
 - 
getUpdatedSinceInitializationpublic String getUpdatedSinceInitialization() Returns the timestamp of the most recent update, or null if this resource has not been updated since initialization.
 - 
hasChangesSinceInitializationpublic boolean hasChangesSinceInitialization() Returns true if this resource has been changed since initialization.
 - 
buildMapToStoreprotected Map<String,Object> buildMapToStore(Object managedData) Builds the JSON object to be stored, containing initArgs and managed data fields.
 - 
convertNamedListToMapprotected Map<String,Object> convertNamedListToMap(org.apache.solr.common.util.NamedList<?> args) Converts a NamedList<?> into an ordered Map for returning as JSON.
 - 
doPostpublic void doPost(BaseSolrResource endpoint, Object json) Just callsdoPut(BaseSolrResource,Object); override to change the behavior of POST handling.
 - 
doPutpublic void doPut(BaseSolrResource endpoint, Object json) Applies changes to initArgs or managed data.
 - 
onResourceDeletedpublic void onResourceDeleted() throws IOExceptionCalled by the RestManager framework after this resource has been deleted to allow this resource to close and clean-up any resources used by this.- Throws:
- IOException- if an error occurs in the underlying storage when trying to delete
 
 - 
applyUpdatesToManagedDataprotected abstract Object applyUpdatesToManagedData(Object updates) Called during PUT/POST processing to apply updates to the managed data passed from the client.
 - 
doDeleteChildpublic abstract void doDeleteChild(BaseSolrResource endpoint, String childId) Called to delete a named part (the given childId) of the resource at the given endpoint
 - 
doGetpublic abstract void doGet(BaseSolrResource endpoint, String childId) Called to retrieve a named part (the given childId) of the resource at the given endpoint
 
- 
 
-