xorp

FinderClient Class Reference

Class that represents clients of the Finder. More...

#include <finder_client.hh>

Inheritance diagram for FinderClient:
FinderMessengerManager FinderClientXrlCommandInterface

List of all members.

Classes

class  InstanceInfo

Public Types

typedef XorpCallback2< void,
const XrlError &, const
FinderDBEntry * >::RefPtr 
QueryCallback
typedef ref_ptr< FinderClientOpOperation
typedef list< OperationOperationQueue
typedef map< string,
FinderDBEntry
ResolvedTable
typedef map< string, string > LocalResolvedTable
typedef vector< InstanceInfoInstanceList

Public Member Functions

 FinderClient ()
 Constructor.
virtual ~FinderClient ()
 Destructor.
bool register_xrl_target (const string &instance_name, const string &class_name, const XrlDispatcher *dispatcher)
 Register an Xrl Target with the FinderClient and place request with Finder to perform registration.
bool unregister_xrl_target (const string &instance_name)
 Unregister Xrl Target with FinderClient and place a request with the Finder to remove registration.
bool register_xrl (const string &instance_name, const string &xrl, const string &pf_name, const string &pf_args)
 Register an Xrl with the Finder.
bool enable_xrls (const string &instance_name)
 Request Finder advertise Xrls associated with an Xrl Target instance to other XORP Xrl targets.
void query (EventLoop &eventloop, const string &xrl, const QueryCallback &qcb)
 Request resolution of an Xrl.
uint32_t queries_pending () const
 Get number of asynchonous queries pending resolution.
const FinderDBEntryquery_cache (const string &xrl) const
 Attempt to resolve Xrl from cache.
void uncache_result (const FinderDBEntry *dbe)
 Remove an resolved entry from cache.
bool query_self (const string &incoming_xrl_command, string &local_xrl_command) const
 Resolve Xrl that an Xrl Target associated with the FinderClient registered.
bool forward_finder_xrl (const Xrl &x, const XrlPFSender::SendCallback &cb)
 Send an Xrl for the Finder to dispatch.
FinderMessengerBasemessenger ()
 Accessor for Finder Messenger used by FinderClient instance.
OperationQueue & todo_list ()
 Get list of operations pending.
OperationQueue & done_list ()
 Get List of operations done and are repeatable.
void notify_done (const FinderClientOp *completed)
 Notify successful completion of an operation on the todo list.
void notify_failed (const FinderClientOp *completed)
 Notify failed completion of an operation on the todo list.
XrlCmdMapcommands ()
 Get the Xrl Commands implemented by the FinderClient.
bool ready () const
bool connected () const
bool attach_observer (FinderClientObserver *o)
 Attach a FinderClientObserver instance to receive event notifications.
bool detach_observer (FinderClientObserver *o)
 Detach the FinderClientObserver instance.

Protected Member Functions

void messenger_birth_event (FinderMessengerBase *)
 Method called by messenger constructor.
void messenger_death_event (FinderMessengerBase *)
 Method called by messenger destructor.
void messenger_active_event (FinderMessengerBase *)
 Method called before Xrl is dispatched.
void messenger_inactive_event (FinderMessengerBase *)
 Method called immediately after Xrl is dispatched.
void messenger_stopped_event (FinderMessengerBase *)
 Method called when Messenger is unable to continue.
bool manages (const FinderMessengerBase *) const
 Method called to tell if FinderMessengerManager instance manages a particular messenger.
void uncache_xrl (const string &xrl)
void uncache_xrls_from_target (const string &target)
XrlCmdError dispatch_tunneled_xrl (const string &xrl)
void crank ()
void prepare_for_restart ()
InstanceList::iterator find_instance (const string &instance)
InstanceList::const_iterator find_instance (const string &instance) const

Protected Attributes

OperationQueue _todo_list
OperationQueue _done_list
ResolvedTable _rt
LocalResolvedTable _lrt
InstanceList _ids
XrlCmdMap _commands
FinderMessengerBase_messenger
bool _pending_result
bool _xrls_registered
FinderClientObserver_observer

Private Member Functions

void dispatch_tunneled_xrl_cb (const XrlError &e, const XrlArgs *a) const

Detailed Description

Class that represents clients of the Finder.

The FinderClient class performs communication processing with the Finder on behalf of XORP processes. It handles XRL registration and resolution requests.


Member Function Documentation

bool FinderClient::attach_observer ( FinderClientObserver o)

Attach a FinderClientObserver instance to receive event notifications.

Parameters:
opointer to observer to receive notifications.
Returns:
true on success, false if an observer is already present.
bool FinderClient::connected ( ) const [inline]
Returns:
true if a connection is established with the Finder.
bool FinderClient::detach_observer ( FinderClientObserver o)

Detach the FinderClientObserver instance.

Parameters:
opointer to the FinderClientObserver be removed.
Returns:
true on success, false if the FinderClientObserver is not the current observer.
bool FinderClient::enable_xrls ( const string &  instance_name)

Request Finder advertise Xrls associated with an Xrl Target instance to other XORP Xrl targets.

Until the Finder has satisfied this request the Xrl Target has no visibility in the Xrl universe.

Parameters:
instance_nameunique name associated with Xrl Target to be advertised.
Returns:
true on success, false if instance_name has not previously been registered with FinderClient.
bool FinderClient::forward_finder_xrl ( const Xrl x,
const XrlPFSender::SendCallback &  cb 
)

Send an Xrl for the Finder to dispatch.

This is the mechanism that allows clients of the Finder to interrogate the Finder through an Xrl interface.

Parameters:
xXrl to be dispatched.
cbcallback to be called with dispatch result.
Returns:
true on success.
void FinderClient::messenger_stopped_event ( FinderMessengerBase ) [protected, virtual]

Method called when Messenger is unable to continue.

For instance, network connection lost.

Implements FinderMessengerManager.

void FinderClient::query ( EventLoop eventloop,
const string &  xrl,
const QueryCallback &  qcb 
)

Request resolution of an Xrl.

If the Xrl to be resolved in cache exists in the FinderClients cache, the callback provided as a function argument is invoked immediately. Otherwise the request is forwarded to the finder, the cache updated, and callback dispatched when the Finder answers the request.

Parameters:
eventloopthe event loop.
xrlXrl to be resolved.
qcbcallback to be dispatched when result is availble.
const FinderDBEntry * FinderClient::query_cache ( const string &  xrl) const

Attempt to resolve Xrl from cache.

Parameters:
xrlXrl to be resolved.
Returns:
pointer to cached entry on success, 0 otherwise.
bool FinderClient::query_self ( const string &  incoming_xrl_command,
string &  local_xrl_command 
) const

Resolve Xrl that an Xrl Target associated with the FinderClient registered.

Parameters:
incoming_xrl_commandthe command component of the Xrl being resolved.
local_xrl_commandthe local name of the Xrl command being resolved.
Returns:
true and assign value to local_xrl_command on success, false on failure.
bool FinderClient::ready ( ) const [inline]
Returns:
true if FinderClient has registered Xrls and is considered operational.
bool FinderClient::register_xrl ( const string &  instance_name,
const string &  xrl,
const string &  pf_name,
const string &  pf_args 
)

Register an Xrl with the Finder.

Parameters:
instance_nameunique name associated with Xrl Target and making the registration.
xrlstring representation of the Xrl.
pf_nameprotocol family name that implements Xrl.
pf_argsprotocol family arguments to locate dispatcher for registered Xrl.
Returns:
true if registration request is successfully enqueued, false otherwise.
bool FinderClient::register_xrl_target ( const string &  instance_name,
const string &  class_name,
const XrlDispatcher dispatcher 
)

Register an Xrl Target with the FinderClient and place request with Finder to perform registration.

The request to the Finder is asynchronous and there is a delay between when the request is made when it is satisfied.

Parameters:
instance_namea unique name to be associated with the Target.
class_namethe class name that the Target is an instance of.
dispatcherpointer to Xrl dispatcher that can execute the command.
Returns:
true on success, false if instance_name or class_name are empty.
void FinderClient::uncache_result ( const FinderDBEntry dbe)

Remove an resolved entry from cache.

This method is typically called when the information provided has been useful to consumer. ie because the answer is found to be no longer valid.

bool FinderClient::unregister_xrl_target ( const string &  instance_name)

Unregister Xrl Target with FinderClient and place a request with the Finder to remove registration.

The request to the Finder is asynchronous and there is a delay between when the request is made when it is satisfied.

Parameters:
instance_nameunique name associated with Xrl Target.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations