|
Persistence strategy that uses a rest server as its data sink. More...
#include <RobotAPI/libraries/armem/server/ltm/persistence/rest/RestPersistence.h>
Public Member Functions | |
bool | checkConnection () |
Checks if the server is up. More... | |
bool | containsContainer (const armarx::armem::MemoryID &id, std::string key) override |
bool | containsItem (const armarx::armem::MemoryID &id, std::string key) override |
void | createPropertyDefinitions (PropertyDefinitionsPtr &defs, const std::string &prefix) override |
std::vector< std::string > | getContainerKeys (const armarx::armem::MemoryID &id) override |
Returns keys that allow use to move a step further in the hierarchy (e.g. More... | |
std::vector< std::string > | getItemKeys (const armarx::armem::MemoryID &id) override |
Keys of the actual items containing data stored for the memory id. More... | |
RestPersistence () | |
RestPersistence (const std::string &identifier, const std::string &exportName) | |
RestPersistence (const std::string &identifier, const std::string &exportName, const std::string &host, int port, bool disableIfNotAvailable=false) | |
std::vector< unsigned char > | retrieveItem (const armarx::armem::MemoryID &id, std::string key) override |
Retrieve the actual data of an item stored for the memory id. More... | |
void | storeItem (const armarx::armem::MemoryID &id, std::string key, std::vector< unsigned char > &data) override |
Stores an item containing actual data for the current memory id. More... | |
![]() | |
virtual void | disable () |
virtual void | enable () |
std::string | getExportName () |
std::string | getIdentifier () |
virtual bool | isEnabled () |
MemoryPersistenceStrategy () | |
MemoryPersistenceStrategy (const std::string &identifier, const std::string &exportName, bool enabled=true) | |
std::vector< unsigned char > | retrieveItem (const armarx::armem::MemoryID &memoryId, ItemIdentifier itemIdentifier) |
virtual ItemResult | retrieveItemWithOrigin (const armarx::armem::MemoryID &id, std::string &key) |
Retrieves the actual data but also appends the origin which is in this case the strategy identifier. More... | |
virtual void | setExportName (const std::string &exportName) |
void | setIdentifier (const std::string &identifier) |
void | storeItem (const armarx::armem::MemoryID &memoryId, ItemIdentifier itemIdentifer, std::vector< unsigned char > &data) |
virtual | ~MemoryPersistenceStrategy ()=default |
Static Public Attributes | |
const static std::string | DEFAULT_HOST = "localhost" |
const static int | DEFAULT_PORT = 8080 |
![]() | |
static const constexpr char * | DATA_FILENAME = "data.aron" |
static const int | DEPTH_TO_DATA_FILES = 7 |
static const constexpr char * | MEMORY_EXPORT_SUFFIX = "_" |
static const constexpr char * | METADATA_FILENAME = "metadata.aron" |
static const constexpr char * | TYPE_FILENAME = "type.aron" |
Additional Inherited Members | |
![]() | |
bool | enabled_ = true |
If false, the strategy is not writing or reading anything. More... | |
std::string | exportName_ |
Name of the specific memory export where our items should be stored. More... | |
std::string | identifier_ |
Name of the strategy. More... | |
Persistence strategy that uses a rest server as its data sink.
How the data is stored on the rest server is up to the server.
The structure of rest endpoints are very similar to a directory structure.
General endpoint: /endpoint GET: /endpoint?containers: return all container keys of the endpoint GET: /endpoint?container=key: check if a container with key exists (true = Status Code 200, false = Status Code 404) GET: /endpoint?items: return all item keys of the endpoint GET: /endpoint?item=key: return Status Code 200 with item data OR Status Code 404 if the item is not inside of the container PUT: /endpoint?item: store item data (data = http body content) DELETE: /endpoint?item=key: removes item with key, return Status Code 200 on success and Status Code 404 if item not found DELETE: /endpoint?container=key: removes container with key, return Status Code 200 on success and Status Code 404 if container not found
NOTE: DELETE-methods are implemented, but the curren memory system does not use it in general.
Available endpoints: /ltm/:exportName -> memories /ltm/:exportName/:memoryName -> core segments /ltm/:exportName/:memoryName/:coreSegmentName -> provider segments /ltm/:exportName/:memoryName/:coreSegmentName/:providerSegmentName -> entities /ltm/:exportName/:memoryName/:coreSegmentName/:providerSegmentName/:entityName -> entity snapshots /ltm/:exportName/:memoryName/:coreSegmentName/:providerSegmentName/:entityName/:timestamp -> entity instances /ltm/:exportName/:memoryName/:coreSegmentName/:providerSegmentName/:entityName/:timestamp/:instanceIndex -> entity instance (here you will definitely find some items)
Definition at line 51 of file RestPersistence.h.
|
inline |
Definition at line 54 of file RestPersistence.h.
|
inline |
Definition at line 56 of file RestPersistence.h.
|
inline |
identifier | basically a unique name for the strategy (important if you use different strategies |
exportName | identifier for the exported memory where any items are written. Changes http endpoints. |
id | memory id, gives us the hierarchy depth to store some items for it (e.g. a core segment) |
host | rest server address (e.g. localhost or a specific ip or a domain) |
port | network port where the rest server runs |
Definition at line 65 of file RestPersistence.h.
bool checkConnection | ( | ) |
Checks if the server is up.
Definition at line 92 of file RestPersistence.cpp.
|
overridevirtual |
Implements MemoryPersistenceStrategy.
Definition at line 33 of file RestPersistence.cpp.
|
overridevirtual |
Implements MemoryPersistenceStrategy.
Definition at line 45 of file RestPersistence.cpp.
|
overridevirtual |
Implements MemoryPersistenceStrategy.
Definition at line 86 of file RestPersistence.cpp.
|
overridevirtual |
Returns keys that allow use to move a step further in the hierarchy (e.g.
if our memory id ends in a core segment it gives us the provider segment keys).
Implements MemoryPersistenceStrategy.
Definition at line 9 of file RestPersistence.cpp.
|
overridevirtual |
Keys of the actual items containing data stored for the memory id.
Implements MemoryPersistenceStrategy.
Definition at line 21 of file RestPersistence.cpp.
|
overridevirtual |
Retrieve the actual data of an item stored for the memory id.
Implements MemoryPersistenceStrategy.
Definition at line 69 of file RestPersistence.cpp.
|
overridevirtual |
Stores an item containing actual data for the current memory id.
How it is stored depends on the implementation of a concrete strategy (e.g. on disk in a specific directory).
key | unique identifier of our item for the specific id (e.g. filename). Note the keys can be equal for different id levels. So you might find the same key on the core segment level as well as on the entity level. |
data | actual data written to the persistent item |
Implements MemoryPersistenceStrategy.
Definition at line 57 of file RestPersistence.cpp.
|
static |
Definition at line 77 of file RestPersistence.h.
|
static |
Definition at line 78 of file RestPersistence.h.