TAO_CosNaming  2.3.3
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TAO_Persistent_Context_Index Class Reference

This class facilitates implementation of Persistent Naming Service. It keeps track, centrally, of several pieces of info for each Persistent Naming Context, allowing to perform the initialization necessary for each Naming Context to restore the state of the Naming Service from persistent storage on server start-up. More...

#include <Persistent_Context_Index.h>

Collaboration diagram for TAO_Persistent_Context_Index:
Collaboration graph
[legend]

Public Types

typedef ACE_Hash_Map_With_Allocator< TAO_Persistent_Index_ExtId, TAO_Persistent_Index_IntIdCONTEXT_INDEX
 Hash map in which we will store info about each Persistent Naming Context. More...
 
typedef ACE_Hash_Map_With_Allocator< TAO_Persistent_ExtId, TAO_Persistent_IntIdCONTEXT
 Hash map used by Persistent Naming Context to keep its state. More...
 
typedef ACE_Allocator_Adapter< ACE_Malloc< ACE_MMAP_MEMORY_POOL, TAO_SYNCH_MUTEX > > ALLOCATOR
 Allocator we will be using to make the Naming Service persistent. More...
 

Public Member Functions

 TAO_Persistent_Context_Index (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, TAO_Persistent_Naming_Context_Factory *context_impl_factory)
 Constructor. More...
 
int open (const ACE_TCHAR *file_name, void *base_address=TAO_NAMING_BASE_ADDR)
 
int init (size_t context_size)
 
TAO_Persistent_Naming_Contextcreate_naming_context_impl (PortableServer::POA_ptr poa, const char *poa_id)
 
 ~TAO_Persistent_Context_Index (void)
 
int bind (const char *poa_id, ACE_UINT32 *&counter, CONTEXT *hash_map)
 
int unbind (const char *poa_id)
 
ACE_Allocatorallocator (void)
 Return allocator. More...
 
CORBA::ORB_ptr orb (void)
 Return orb pointer. More...
 
CosNaming::NamingContext_ptr root_context (void)
 

Private Member Functions

int recreate_all (void)
 
int create_index (void)
 Helper for the <open> method. More...
 
int create_index_helper (void *buffer)
 

Private Attributes

TAO_SYNCH_MUTEX lock_
 
ALLOCATORallocator_
 
CONTEXT_INDEXindex_
 
const ACE_TCHARindex_file_
 Name of the memory-mapped file used by <allocator_>. More...
 
void * base_address_
 Base address for the memory-mapped file. More...
 
CORBA::ORB_var orb_
 
PortableServer::POA_var poa_
 
CosNaming::NamingContext_var root_context_
 The reference to the root Naming Context. More...
 
TAO_Persistent_Naming_Context_Factorycontext_impl_factory_
 The factory for constructing naming contexts within the index. More...
 

Detailed Description

This class facilitates implementation of Persistent Naming Service. It keeps track, centrally, of several pieces of info for each Persistent Naming Context, allowing to perform the initialization necessary for each Naming Context to restore the state of the Naming Service from persistent storage on server start-up.

This class creates a memory-mapped file, allocates a hash table from that file, and uses the hash table to store POA id, and table and counter pointers for each Persistent Naming Context. There are methods for adding and deleting entries from this hash table as new Persistent Naming Contexts are created and old ones are destroyed. This hash table facilitates Persistent Naming Context servant initialization upon Naming Server start-up.

Member Typedef Documentation

Allocator we will be using to make the Naming Service persistent.

Hash map used by Persistent Naming Context to keep its state.

Hash map in which we will store info about each Persistent Naming Context.

Constructor & Destructor Documentation

TAO_Persistent_Context_Index::TAO_Persistent_Context_Index ( CORBA::ORB_ptr  orb,
PortableServer::POA_ptr  poa,
TAO_Persistent_Naming_Context_Factory context_impl_factory 
)

Constructor.

TAO_Persistent_Context_Index::~TAO_Persistent_Context_Index ( void  )

Destructor. The memory mapped file that was opened/created is not deleted, since we want it to keep the state of the Naming Service until the next run.

Member Function Documentation

ACE_Allocator * TAO_Persistent_Context_Index::allocator ( void  )

Return allocator.

int TAO_Persistent_Context_Index::bind ( const char *  poa_id,
ACE_UINT32 *&  counter,
TAO_Persistent_Context_Index::CONTEXT hash_map 
)

Create an entry for a Persistent Naming Context in <index_>, i.e., a context with <poa_id>, <counter> and <hash_map> has just been created, and is registering with us.

int TAO_Persistent_Context_Index::create_index ( void  )
private

Helper for the <open> method.

int TAO_Persistent_Context_Index::create_index_helper ( void *  buffer)
private

Helper for <create_index> method: places hash table into an allocated space.

TAO_Persistent_Naming_Context * TAO_Persistent_Context_Index::create_naming_context_impl ( PortableServer::POA_ptr  poa,
const char *  poa_id 
)

Create a naming context implementation to be used for this index using the naming context factory that was provided in the ctor for the index.

int TAO_Persistent_Context_Index::init ( size_t  context_size)

If <index_> contains no entries (i.e., was just created), create a root Persistent Naming Context servant with table of size <context_size>, and make an entry for it in the <index_>. If <index_> contains entries, create a Persistent Naming Context servant for each entry. Return 0 on success and -1 on failure.

int TAO_Persistent_Context_Index::open ( const ACE_TCHAR file_name,
void *  base_address = TAO_NAMING_BASE_ADDR 
)

Create ACE_Allocator, open/create memory-mapped file with the specified file name/base address. Find or allocate <index_>. Return 0 on success or -1 on failure.

CORBA::ORB_ptr TAO_Persistent_Context_Index::orb ( void  )

Return orb pointer.

int TAO_Persistent_Context_Index::recreate_all ( void  )
private

Helper for the <init> method. Iterates over <index_>, and creates a servant for each entry.

CosNaming::NamingContext_ptr TAO_Persistent_Context_Index::root_context ( void  )

Return a pointer to the root Naming Context (returns a copy - must be deallocated by the user).

int TAO_Persistent_Context_Index::unbind ( const char *  poa_id)

Remove an entry for the Persistent Naming Context with <poa_id> from <index_> (i.e., this context has just been destroyed).

Member Data Documentation

ALLOCATOR* TAO_Persistent_Context_Index::allocator_
private

Allocator that deals out memory from a memory-mapped file. We use it here, and in TAO_Persistent_Naming_Context, whenever we deal with data that should be kept in persistent store.

void* TAO_Persistent_Context_Index::base_address_
private

Base address for the memory-mapped file.

TAO_Persistent_Naming_Context_Factory* TAO_Persistent_Context_Index::context_impl_factory_
private

The factory for constructing naming contexts within the index.

CONTEXT_INDEX* TAO_Persistent_Context_Index::index_
private

Hash map where we keep entries for all Persistent Naming Contexts.

const ACE_TCHAR* TAO_Persistent_Context_Index::index_file_
private

Name of the memory-mapped file used by <allocator_>.

TAO_SYNCH_MUTEX TAO_Persistent_Context_Index::lock_
private

Lock to prevent multiple threads from modifying entries in the <index_> simultanneously.

CORBA::ORB_var TAO_Persistent_Context_Index::orb_
private

ORB. We use it for several object_to_string conversions, and keep it around for Persistent Naming Contexts' use.

PortableServer::POA_var TAO_Persistent_Context_Index::poa_
private

POA under which to register Persistent Naming Context servants during start-up.

CosNaming::NamingContext_var TAO_Persistent_Context_Index::root_context_
private

The reference to the root Naming Context.


The documentation for this class was generated from the following files: