The Name Service
The Name Service allows users to associate a string with a piece of arbitrary data (often a HandleT).
All SAFplus API calls that accept a string name use the Name Service to resolve the string into the actual HandleT or object. Since components and services accept a strings in their "create" APIs, it is possible that the end user will never explicitly use the Name Service yet it be heavily utilized.
The name service can also be used independently of other SAFplus APIs by user applications. In this case, its use is a cluster wide name:value dictionary. For example, a handle to the "Active" server application could be stored under a name so that clients can discover which server is active easily.
Implementation
The Name Service is a client library that is linked with every component that uses it. It opens a cluster-wide, shared memory, non-persistent checkpoint using the name service's well-known HandleT.
The name service uses this checkpoint to resolve string names into objects.
APIs
#include <clNameApi.hpp>
- nameInitialize()
- Optional -- is called automatically on first use. Creates/connects to the Name checkpoint in memory checkpoint.
- nameSet(char* name, HandleT handle);
- nameSet(char* name, void* data, int length);
- Assigns a name into the service. Will overwrite any existing entry.
- HandleT nameGet(char* name)
- int nameGet(char* name, void* data, int maxLength)
returns the length of the data, 0 if the name does not exist or > maxLength (with maxLength bytes copied to data) if the data is longer than the supplied buffer.