Package org.apache.solr.rest
Class ManagedResourceStorage
- java.lang.Object
-
- org.apache.solr.rest.ManagedResourceStorage
-
- Direct Known Subclasses:
ManagedResourceStorage.JsonStorage
public abstract class ManagedResourceStorage extends Object
Abstract base class that provides most of the functionality needed to store arbitrary data for managed resources. Concrete implementations need to decide the underlying format that data is stored in, such as JSON.The underlying storage I/O layer will be determined by the environment Solr is running in, e.g. in cloud mode, data will be stored and loaded from ZooKeeper.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classManagedResourceStorage.FileStorageIOLocal file-based storage implementation.static classManagedResourceStorage.InMemoryStorageIOMemory-backed storage IO; not really intended for storage large amounts of data in production, but useful for testing and other transient workloads.static classManagedResourceStorage.JsonStorageDefault storage implementation that uses JSON as the storage format for managed data.static interfaceManagedResourceStorage.StorageIOHides the underlying storage implementation for data being managed by a ManagedResource.static classManagedResourceStorage.ZooKeeperStorageIOZooKeeper based storage implementation that uses the SolrZkClient provided by the CoreContainer.
-
Field Summary
Fields Modifier and Type Field Description protected SolrResourceLoaderloaderstatic StringSTORAGE_DIR_INIT_ARGstatic StringSTORAGE_IO_CLASS_INIT_ARGprotected ManagedResourceStorage.StorageIOstorageIOstatic CharsetUTF_8
-
Constructor Summary
Constructors Modifier Constructor Description protectedManagedResourceStorage(ManagedResourceStorage.StorageIO storageIO, SolrResourceLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleandelete(String resourceId)Removes the given resourceId's persisted representation.SolrResourceLoadergetResourceLoader()Returns the resource loader used by this storage instanceManagedResourceStorage.StorageIOgetStorageIO()Returns the storageIO instance used by this storage instanceabstract StringgetStoredResourceId(String resourceId)Gets the unique identifier for a stored resource, typically based on the resourceId and some storage-specific information, such as file extension and storage root directory.Objectload(String resourceId)Loads a resource from storage; the default implementation makes the assumption that the data is stored as UTF-8 encoded text, such as JSON.static ManagedResourceStorage.StorageIOnewStorageIO(String collection, SolrResourceLoader resourceLoader, org.apache.solr.common.util.NamedList<String> initArgs)Creates a new StorageIO instance for a Solr core, taking into account whether the core is running in cloud mode as well as initArgs.protected ObjectparseText(Reader reader, String resourceId)Called byload(String)to convert the serialized resource into its in-memory representation.abstract voidstore(String resourceId, Object toStore)Persists the given toStore object with the given resourceId.
-
-
-
Field Detail
-
STORAGE_IO_CLASS_INIT_ARG
public static final String STORAGE_IO_CLASS_INIT_ARG
- See Also:
- Constant Field Values
-
STORAGE_DIR_INIT_ARG
public static final String STORAGE_DIR_INIT_ARG
- See Also:
- Constant Field Values
-
UTF_8
public static final Charset UTF_8
-
storageIO
protected ManagedResourceStorage.StorageIO storageIO
-
loader
protected SolrResourceLoader loader
-
-
Constructor Detail
-
ManagedResourceStorage
protected ManagedResourceStorage(ManagedResourceStorage.StorageIO storageIO, SolrResourceLoader loader)
-
-
Method Detail
-
newStorageIO
public static ManagedResourceStorage.StorageIO newStorageIO(String collection, SolrResourceLoader resourceLoader, org.apache.solr.common.util.NamedList<String> initArgs)
Creates a new StorageIO instance for a Solr core, taking into account whether the core is running in cloud mode as well as initArgs.
-
getResourceLoader
public SolrResourceLoader getResourceLoader()
Returns the resource loader used by this storage instance
-
getStorageIO
public ManagedResourceStorage.StorageIO getStorageIO()
Returns the storageIO instance used by this storage instance
-
getStoredResourceId
public abstract String getStoredResourceId(String resourceId)
Gets the unique identifier for a stored resource, typically based on the resourceId and some storage-specific information, such as file extension and storage root directory.
-
load
public Object load(String resourceId) throws IOException
Loads a resource from storage; the default implementation makes the assumption that the data is stored as UTF-8 encoded text, such as JSON. This method should be overridden if that assumption is invalid.- Throws:
IOException
-
parseText
protected Object parseText(Reader reader, String resourceId) throws IOException
Called byload(String)to convert the serialized resource into its in-memory representation.- Throws:
IOException
-
store
public abstract void store(String resourceId, Object toStore) throws IOException
Persists the given toStore object with the given resourceId.- Throws:
IOException
-
delete
public boolean delete(String resourceId) throws IOException
Removes the given resourceId's persisted representation.- Throws:
IOException
-
-