fluffy changes

git-svn-id: https://svn.resiprocate.org/rep/resiprocate/main@8098 ddefafc4-47db-0310-ae44-fa13212b10f2
This commit is contained in:
Cullen Jennings
2008-06-24 22:44:04 +00:00
parent 8f9825c4dd
commit 09f0ce48c9
4 changed files with 64 additions and 40 deletions

View File

@@ -19,8 +19,10 @@ using namespace p2p;
#define RESIPROCATE_SUBSYSTEM P2PSubsystem::P2P
ChordTopology::ChordTopology(Profile& config, Dispatcher& dispatcher, Transporter& transporter) :
TopologyAPI(config, dispatcher, transporter), mJoined(false)
ChordTopology::ChordTopology(Profile& config,
Dispatcher& dispatcher,
Transporter& transporter) :
TopologyAPI(config, dispatcher, transporter), mJoined(false)
{
}
@@ -189,6 +191,13 @@ ChordTopology::consume(LeaveReq& msg)
}
void
ChordTopology::consume(ConnectReq& msg)
{
DebugLog(<< "received CONNECT Req from: " << msg.getResponseNodeId());
}
void
ChordTopology::consume(ConnectAns& msg)
{
@@ -244,6 +253,9 @@ ChordTopology::findNextHop( const NodeId& node )
// return the next pointer and increment around slowly
assert( mNextTable.size() > 0 );
DebugLog(<< "findNextHop returning: " << mNextTable[0]);
// TODO - deal with case wehre there is no next
return mNextTable[0];
}
@@ -302,18 +314,22 @@ ChordTopology::getReplicationSet( const ResourceId& resource )
bool
ChordTopology::isResponsible( const NodeId& node ) const
{
// If it is us, then we are responsible
if(node == mProfile.nodeId())
{
return true;
}
// for now we are going to assume that if the prev table is empty, then we have a
// a new ring being formed and we are responsible for this request. We need to consider
// the case where we are a node trying to join a stable ring, and the "join" process
// has not completed yet - but we receive a message for another node.
if (mPrevTable.size() == 0) return true;
if (mPrevTable.size() == 0)
{
if ( mProfile.isBootstrap() )
{
return true; // only thing in the ring so responsible for everything
}
else
{
return false; // have not joined ring yet so responsible for nothing
}
}
if ( (mPrevTable[0] < node) && (node <= mProfile.nodeId()) )
{
return true;

View File

@@ -20,7 +20,9 @@ class Dispatcher;
class ChordTopology : public TopologyAPI
{
public:
ChordTopology(Profile& config, Dispatcher& dispatcher, Transporter& transporter);
ChordTopology(Profile& config,
Dispatcher& dispatcher,
Transporter& transporter);
virtual ~ChordTopology();
virtual void joinOverlay();
@@ -41,6 +43,7 @@ class ChordTopology : public TopologyAPI
// deal with responses
virtual void consume(ConnectAns& msg);
virtual void consume(ConnectReq& msg);
virtual void consume(JoinAns& msg);
virtual void consume(UpdateAns& msg);
virtual void consume(LeaveAns& msg);

View File

@@ -23,36 +23,40 @@ class Profile
{
public:
Profile() : mNodeId(), mNumInitialFingers(8) {}
virtual ~Profile() {;}
virtual const X509 *getCertificate() { return 0; }
virtual const EVP_PKEY *getPrivateKey() { return 0; }
virtual resip::Data& signatureDigest() { return mSignatureDigest; }
virtual const resip::Data& signatureDigest() const { return mSignatureDigest; }
virtual resip::Data& overlayName() { return mOverlayName; }
virtual const resip::Data& overlayName() const { return mOverlayName; }
virtual NodeId& nodeId() { return mNodeId; }
virtual const NodeId nodeId() const { return mNodeId; }
virtual UserName& userName() { return mUserName; }
virtual const UserName& userName() const { return mUserName; }
virtual unsigned int& numInitialFingers() { return mNumInitialFingers; }
virtual const unsigned int numInitialFingers() const { return mNumInitialFingers; }
virtual std::vector<resip::GenericIPAddress>& bootstrapNodes() { return mBootstrapNodes; }
virtual const std::vector<resip::GenericIPAddress>& bootstrapNodes() const { return mBootstrapNodes; }
virtual ~Profile() {;}
private:
resip::Data mOverlayName;
resip::Data mSignatureDigest;
NodeId mNodeId;
UserName mUserName;
unsigned int mNumInitialFingers;
std::vector<resip::GenericIPAddress> mBootstrapNodes;
virtual const X509 *getCertificate() { return 0; }
virtual const EVP_PKEY *getPrivateKey() { return 0; }
virtual resip::Data& signatureDigest() { return mSignatureDigest; }
virtual const resip::Data& signatureDigest() const { return mSignatureDigest; }
virtual resip::Data& overlayName() { return mOverlayName; }
virtual const resip::Data& overlayName() const { return mOverlayName; }
virtual bool& isBootstrap() { return mBootstrap; }
virtual const bool isBootstrap() const { return mBootstrap; }
virtual NodeId& nodeId() { return mNodeId; }
virtual const NodeId nodeId() const { return mNodeId; }
virtual UserName& userName() { return mUserName; }
virtual const UserName& userName() const { return mUserName; }
virtual unsigned int& numInitialFingers() { return mNumInitialFingers; }
virtual const unsigned int numInitialFingers() const { return mNumInitialFingers; }
virtual std::vector<resip::GenericIPAddress>& bootstrapNodes() { return mBootstrapNodes; }
virtual const std::vector<resip::GenericIPAddress>& bootstrapNodes() const { return mBootstrapNodes; }
private:
resip::Data mOverlayName;
resip::Data mSignatureDigest;
NodeId mNodeId;
UserName mUserName;
unsigned int mNumInitialFingers;
std::vector<resip::GenericIPAddress> mBootstrapNodes;
bool mBootstrap;
};
}

View File

@@ -46,6 +46,7 @@ class TopologyAPI : public EventConsumer
// deal with responses
virtual void consume(ConnectAns& msg)=0;
virtual void consume(ConnectReq& msg)=0;
virtual void consume(JoinAns& msg)=0;
virtual void consume(UpdateAns& msg)=0;
virtual void consume(LeaveAns& msg)=0;