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 and Description
    --- | ---
    `static class` | `ManagedResourceStorage.FileStorageIO` Local file-based storage implementation.
    `static class` | `ManagedResourceStorage.InMemoryStorageIO` Memory-backed storage IO; not really intended for storage large amounts of data in production, but useful for testing and other transient workloads.
    `static class` | `ManagedResourceStorage.JsonStorage` Default storage implementation that uses JSON as the storage format for managed data.
    `static interface` | `ManagedResourceStorage.StorageIO` Hides the underlying storage implementation for data being managed by a ManagedResource.
    `static class` | `ManagedResourceStorage.ZooKeeperStorageIO` ZooKeeper based storage implementation that uses the SolrZkClient provided by the CoreContainer.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SolrResourceLoader` | `loader`
    `static String` | `STORAGE_DIR_INIT_ARG`
    `static String` | `STORAGE_IO_CLASS_INIT_ARG`
    `protected ManagedResourceStorage.StorageIO` | `storageIO`
    `static Charset` | `UTF_8`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ManagedResourceStorage(ManagedResourceStorage.StorageIO storageIO, SolrResourceLoader loader)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `delete(String resourceId)` Removes the given resourceId's persisted representation.
    `SolrResourceLoader` | `getResourceLoader()` Returns the resource loader used by this storage instance
    `ManagedResourceStorage.StorageIO` | `getStorageIO()` Returns the storageIO instance used by this storage instance
    `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.
    `Object` | `load(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.StorageIO` | `newStorageIO(String collection, SolrResourceLoader resourceLoader, 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 Object` | `parseText(Reader reader, String resourceId)` Called by `load(String)` to convert the serialized resource into its in-memory representation.
    `abstract void` | `store(String resourceId, Object toStore)` Persists the given toStore object with the given resourceId.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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,
                                                                      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`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.