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.

  • Field Details

  • Constructor Details

  • Method Details

    • 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 by load(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