Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TAO::Transport_Cache_Manager Class Reference

The Transport Cache Manager for TAO. More...

#include <Transport_Cache_Manager.h>

Collaboration diagram for TAO::Transport_Cache_Manager:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Hash_Map_Manager_Ex<
Cache_ExtId, Cache_IntId,
ACE_Hash< Cache_ExtId >,
ACE_Equal_To< Cache_ExtId >,
ACE_Null_Mutex
HASH_MAP
typedef HASH_MAP::iterator HASH_MAP_ITER
typedef ACE_Hash_Map_Entry<
Cache_ExtId, Cache_IntId
HASH_MAP_ENTRY
typedef TAO_Condition< TAO_SYNCH_MUTEX > CONDITION

Public Member Functions

 Transport_Cache_Manager (TAO_ORB_Core &orb_core)
 Constructor.
virtual ~Transport_Cache_Manager (void)
 Destructor.
int cache_transport (TAO_Transport_Descriptor_Interface *prop, TAO_Transport *transport)
 Add the transport to the cache.
int cache_idle_transport (TAO_Transport_Descriptor_Interface *prop, TAO_Transport *transport)
int find_transport (TAO_Transport_Descriptor_Interface *prop, TAO_Transport *&transport)
int purge (void)
 Remove entries from the cache depending upon the strategy.
int purge_entry (HASH_MAP_ENTRY *&)
 Purge the entry from the Cache Map.
void mark_invalid (HASH_MAP_ENTRY *&)
 Mark the entry as invalid for use but keep it in cache.
int make_idle (HASH_MAP_ENTRY *&entry)
 Make the entry idle and ready for use.
int update_entry (HASH_MAP_ENTRY *&entry)
int close (Connection_Handler_Set &handlers)
bool blockable_client_transports (Connection_Handler_Set &handlers)
size_t current_size (void) const
 Return the current size of the cache.
size_t total_size (void) const
 Return the total size of the cache.
HASH_MAPmap (void)
 Return the underlying cache map.

Private Types

typedef HASH_MAP_ENTRY ** DESCRIPTOR_SET

Private Member Functions

int bind (Cache_ExtId &ext_id, Cache_IntId &int_id)
int find (const Cache_ExtId &key, Cache_IntId &value)
int bind_i (Cache_ExtId &ext_id, Cache_IntId &int_id)
int find_i (const Cache_ExtId &key, Cache_IntId &value)
int make_idle_i (HASH_MAP_ENTRY *&entry)
 Non-locking version and actual implementation of make_idle ().
int close_i (Connection_Handler_Set &handlers)
 Non-locking version and actual implementation of close ().
int purge_entry_i (HASH_MAP_ENTRY *&entry)
 Purge the entry from the Cache Map.
void mark_invalid_i (HASH_MAP_ENTRY *&)
 Mark the entry as invalid for use but keep it in cache.
int get_last_index_bind (Cache_ExtId &key, Cache_IntId &val, HASH_MAP_ENTRY *&entry)
bool is_entry_idle (HASH_MAP_ENTRY *&entry)
void sort_set (DESCRIPTOR_SET &entries, int size)
 Sort the list of entries.
int fill_set_i (DESCRIPTOR_SET &sorted_set)
int wait_for_connection (Cache_ExtId &extid)
int is_wakeup_useful (Cache_ExtId &extid)
 Is the wakeup useful todo some work?
bool blockable_client_transports_i (Connection_Handler_Set &handlers)
 Non-locking version of blockable_client_transports ().

Static Private Member Functions

int cpscmp (const void *a, const void *b)
 Used by qsort.

Private Attributes

int percent_
 The percentage of the cache to purge at one time.
TAO_Connection_Purging_Strategypurging_strategy_
 The underlying connection purging strategy.
HASH_MAP cache_map_
 The hash map that has the connections.
CONDITIONcondition_
 The condition variable.
ACE_Lockcache_lock_
 The lock that is used by the cache map.
CORBA::ULong muxed_number_
 Number of allowed muxed connections.
int no_waiting_threads_
 Number of threads waiting for connections.
Cache_ExtIdlast_entry_returned_

Detailed Description

The Transport Cache Manager for TAO.

This class provides interfaces associating a TAO_Cache_ExtId & TAO_Cache_IntId. This class is wrapper around the ACE_Hash_Map_Manager class which is used as a container to Cache the connections. This class protects the entries with a lock. The map is updated only by holding the lock. The more compelling reason to have the lock in this class and not in the Hash_Map is that, we do quite a bit of work in this class for which we need a lock.


Member Typedef Documentation

typedef TAO_Condition<TAO_SYNCH_MUTEX> TAO::Transport_Cache_Manager::CONDITION
 

typedef HASH_MAP_ENTRY** TAO::Transport_Cache_Manager::DESCRIPTOR_SET [private]
 

typedef ACE_Hash_Map_Manager_Ex<Cache_ExtId, Cache_IntId, ACE_Hash<Cache_ExtId>, ACE_Equal_To<Cache_ExtId>, ACE_Null_Mutex> TAO::Transport_Cache_Manager::HASH_MAP
 

typedef ACE_Hash_Map_Entry<Cache_ExtId, Cache_IntId> TAO::Transport_Cache_Manager::HASH_MAP_ENTRY
 

typedef HASH_MAP::iterator TAO::Transport_Cache_Manager::HASH_MAP_ITER
 


Constructor & Destructor Documentation

TAO::Transport_Cache_Manager::Transport_Cache_Manager TAO_ORB_Core orb_core  ) 
 

Constructor.

If the cache is not going to be locked then dont create a condition variable. Make the <muxed_number_> to 0, else a single thread could get into waiting mode

TAO::Transport_Cache_Manager::~Transport_Cache_Manager void   )  [virtual]
 

Destructor.


Member Function Documentation

ACE_INLINE int TAO::Transport_Cache_Manager::bind Cache_ExtId ext_id,
Cache_IntId int_id
[private]
 

Associate ext_id with int_id. Grabs the lock and calls the implementation function bind_i.

int TAO::Transport_Cache_Manager::bind_i Cache_ExtId ext_id,
Cache_IntId int_id
[private]
 

Non-Locking version and actual implementation of bind () call. Calls bind on the Hash_Map_Manager that it holds. If the bind succeeds, it adds the Hash_Map_Entry in to the Transport for its reference. If the bind fails because of an exiting entry, this method calls the get_last_index_bind ().

ACE_INLINE bool TAO::Transport_Cache_Manager::blockable_client_transports Connection_Handler_Set handlers  ) 
 

This call is used for a specific use case by the ORB_Core during shutdown. The only way the ORB can wake up threads waiting on these sockstes for replies is to iterate over these blockable transports and close the socket handles. Without these the threads will continue to wait there for ever.

bool TAO::Transport_Cache_Manager::blockable_client_transports_i Connection_Handler_Set handlers  )  [private]
 

Non-locking version of blockable_client_transports ().

ACE_INLINE int TAO::Transport_Cache_Manager::cache_idle_transport TAO_Transport_Descriptor_Interface prop,
TAO_Transport transport
 

Similar to the one above, but the transport is left in ENTRY_IDLE_AND_PURGABLE state.

ACE_INLINE int TAO::Transport_Cache_Manager::cache_transport TAO_Transport_Descriptor_Interface prop,
TAO_Transport transport
 

Add the transport to the cache.

The transport has the property definition based on which caching can be done. This method marks the transport ACE_RECYCLABLE_BUSY which helps the threads opening up connections to use the transport immediately.

ACE_INLINE int TAO::Transport_Cache_Manager::close Connection_Handler_Set handlers  ) 
 

Close the underlying hash map manager and return any handlers still registered

int TAO::Transport_Cache_Manager::close_i Connection_Handler_Set handlers  )  [private]
 

Non-locking version and actual implementation of close ().

int TAO::Transport_Cache_Manager::cpscmp const void *  a,
const void *  b
[static, private]
 

Used by qsort.

ACE_INLINE size_t TAO::Transport_Cache_Manager::current_size void   )  const
 

Return the current size of the cache.

int TAO::Transport_Cache_Manager::fill_set_i DESCRIPTOR_SET sorted_set  )  [private]
 

Fill sorted_set in with the TAO_Transport_Descriptor_Interface's in a sorted order.

int TAO::Transport_Cache_Manager::find const Cache_ExtId key,
Cache_IntId value
[private]
 

Lookup entry<key,value> in the cache. Grabs the lock and calls the implementation function find_i.

int TAO::Transport_Cache_Manager::find_i const Cache_ExtId key,
Cache_IntId value
[private]
 

Non-locking version and actual implementation of find () call. This calls the find () on the underlying Hash_Map_Manager. If the find succeeds, it calls the get_idle_transport ().

int TAO::Transport_Cache_Manager::find_transport TAO_Transport_Descriptor_Interface prop,
TAO_Transport *&  transport
 

Check the Transport Cache to check whether the connection exists in the Cache and return the connection

int TAO::Transport_Cache_Manager::get_last_index_bind Cache_ExtId key,
Cache_IntId val,
HASH_MAP_ENTRY *&  entry
[private]
 

This is called by the bind () call when a bind fails with a available entry. When a new connection is created in TAO with an already existing endpoint, in addition to an exisitng one, we mark the connections with an index. This method, finds out the last highest index and binds the entry with an index = (last highest index + 1).

bool TAO::Transport_Cache_Manager::is_entry_idle HASH_MAP_ENTRY *&  entry  )  [private]
 

Tries to find if the <int_id_> in entry is idle for use. If it is idle it is immediately markes as busy and returns a value of 1, else it returns a value of 0

int TAO::Transport_Cache_Manager::is_wakeup_useful Cache_ExtId extid  )  [private]
 

Is the wakeup useful todo some work?

ACE_INLINE int TAO::Transport_Cache_Manager::make_idle HASH_MAP_ENTRY *&  entry  ) 
 

Make the entry idle and ready for use.

int TAO::Transport_Cache_Manager::make_idle_i HASH_MAP_ENTRY *&  entry  )  [private]
 

Non-locking version and actual implementation of make_idle ().

ACE_INLINE Transport_Cache_Manager::HASH_MAP & TAO::Transport_Cache_Manager::map void   ) 
 

Return the underlying cache map.

ACE_INLINE void TAO::Transport_Cache_Manager::mark_invalid HASH_MAP_ENTRY *&   ) 
 

Mark the entry as invalid for use but keep it in cache.

void TAO::Transport_Cache_Manager::mark_invalid_i HASH_MAP_ENTRY *&   )  [private]
 

Mark the entry as invalid for use but keep it in cache.

int TAO::Transport_Cache_Manager::purge void   ) 
 

Remove entries from the cache depending upon the strategy.

ACE_INLINE int TAO::Transport_Cache_Manager::purge_entry HASH_MAP_ENTRY *&   ) 
 

Purge the entry from the Cache Map.

int TAO::Transport_Cache_Manager::purge_entry_i HASH_MAP_ENTRY *&  entry  )  [private]
 

Purge the entry from the Cache Map.

void TAO::Transport_Cache_Manager::sort_set DESCRIPTOR_SET entries,
int  size
[private]
 

Sort the list of entries.

ACE_INLINE size_t TAO::Transport_Cache_Manager::total_size void   )  const
 

Return the total size of the cache.

int TAO::Transport_Cache_Manager::update_entry HASH_MAP_ENTRY *&  entry  ) 
 

Mark the entry as touched. This call updates the purging strategy policy information.

int TAO::Transport_Cache_Manager::wait_for_connection Cache_ExtId extid  )  [private]
 

Wait for connections if we have reached the limit on the number of muxed connections. If not (ie. if we dont use a muxed connection or if we have not reached the limit) this just behaves as a no-op. <extid> has all the information about the connection that is being searched.


Member Data Documentation

ACE_Lock* TAO::Transport_Cache_Manager::cache_lock_ [private]
 

The lock that is used by the cache map.

HASH_MAP TAO::Transport_Cache_Manager::cache_map_ [private]
 

The hash map that has the connections.

CONDITION* TAO::Transport_Cache_Manager::condition_ [private]
 

The condition variable.

Cache_ExtId* TAO::Transport_Cache_Manager::last_entry_returned_ [private]
 

This is for optimization purposes. In a situation where number of threads are waiting for connections, the last connection that is put back is cached here. This should prevent all th threads trying to search for their required entry.

CORBA::ULong TAO::Transport_Cache_Manager::muxed_number_ [private]
 

Number of allowed muxed connections.

int TAO::Transport_Cache_Manager::no_waiting_threads_ [private]
 

Number of threads waiting for connections.

int TAO::Transport_Cache_Manager::percent_ [private]
 

The percentage of the cache to purge at one time.

TAO_Connection_Purging_Strategy* TAO::Transport_Cache_Manager::purging_strategy_ [private]
 

The underlying connection purging strategy.


The documentation for this class was generated from the following files:
Generated on Thu Jun 9 00:19:23 2005 for TAO by  doxygen 1.3.9.1