AndroMeta  2.0.0
Public Member Functions
Meta::MPeerBroker Class Reference

Interface for distributing or obtaining objects across an AndroMeta peer-to-peer network. More...

#include <MPeerBroker.h>

Inheritance diagram for Meta::MPeerBroker:
Meta::MBrokerBase

List of all members.

Public Member Functions

 MPeerBroker (MProcTask *task)
virtual ~MPeerBroker ()
mnode process (MObject *object, mnode n, bool block)
bool connect ()
bool connect (int localPort, long groupId, const mstr &user, const mstr &key)
bool isConnected () const
MProcTasktask ()
int localPort () const
long groupId () const
long peerId () const
long submitterId () const
mvec peers () const
void close ()
virtual void onClose ()
mstr distribute (MObject *object, const mstr &className, const mstr &objectName="")
bool revoke (MObject *object)
MObjectobtain (long peerId, const mstr &objectName)
virtual bool onObtain (MObject *object)
bool release (MObject *object, bool disconnect=false)
mvarsession (MObject *object)

Detailed Description

Interface for distributing or obtaining objects across an AndroMeta peer-to-peer network.

Similar to MBroker, but instead of using TCP/IP networking, MPeerBroker uses the AndroMeta peer-to-peer system to distribute and obtain objects. This provides a flexible mechanism whereby the interface and implementation of a distributed object can be submitted as peer process.


Constructor & Destructor Documentation

Constructor. Does not require authentication, as authentication is already handled by the peer-to-peer system.

Parameters:
taskThe task to use for internal concurrent network processing. For best performance the task must be configured with an adequate number of threads.
virtual Meta::MPeerBroker::~MPeerBroker ( ) [virtual]

Destructor.


Member Function Documentation

Close the connection.

Uses the MProgram arguments to attempt to connect to a peer process.

Returns:
true on success.
bool Meta::MPeerBroker::connect ( int  localPort,
long  groupId,
const mstr user,
const mstr key 
)

Explicitly connect to a peer connect to a peer process.

Returns:
true on success.
mstr Meta::MPeerBroker::distribute ( MObject object,
const mstr className,
const mstr objectName = "" 
)

Distribute the specified object.

Parameters:
classNameThe class name of the object.
objectNameThe broker's name of this object that client's use to obtain the object. If empty, a name will be assigned.
Returns:
The name of the object as distributed, or empty string in the case of failure.
Returns:
The group id this peer broker is running as.
Returns:
true if connected.
Returns:
The local peer port this peer broker is connected to.
MObject* Meta::MPeerBroker::obtain ( long  peerId,
const mstr objectName 
)

Obtain an object from a remote MPeerBroker.

Parameters:
peerIdThe peer id that is hosting the remote object.
objectNameThe name of the remote object as distributed.
Returns:
On success, a pointer to the object obtained which must now be cast to the appropriate type. null is returned in the event of failure.
virtual void Meta::MPeerBroker::onClose ( ) [virtual]

Called upon close.

virtual bool Meta::MPeerBroker::onObtain ( MObject object) [virtual]

Called on the server-side when a remote client attempts to obtain the specified object. The default behavior is to return true.

Parameters:
objectThe object to be obtained.
Returns:
true in order to grant access to the object.
long Meta::MPeerBroker::peerId ( ) const
Returns:
The peer id this peer broker is running as.
Returns:
A vector of peer id's in the current group.
mnode Meta::MPeerBroker::process ( MObject object,
mnode  n,
bool  block 
) [virtual]

Do not call directly.

Implements Meta::MBrokerBase.

bool Meta::MPeerBroker::release ( MObject object,
bool  disconnect = false 
) [virtual]

Called on the client-side to release the specified object. May be called internally when a disconnect occurs in which case disconnect is set to true.

Returns:
true on success.

Implements Meta::MBrokerBase.

bool Meta::MPeerBroker::revoke ( MObject object)

Revoke/stop serving the specified object.

mvar& Meta::MPeerBroker::session ( MObject object) [virtual]

Called to get the session data. Should not be called directly, instead use MObject::session()

Implements Meta::MBrokerBase.

Returns:
The peer id that submitted this process.
Returns:
The MProcTask that the broker was constructed with.

Implements Meta::MBrokerBase.


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