Sirikata
|
Distributed BSP-tree based implementation of CoordinateSegmentation. More...
#include <CoordinateSegmentationClient.hpp>
Classes | |
struct | LookupCacheEntry |
Public Member Functions | |
CoordinateSegmentationClient (SpaceContext *ctx, const BoundingBox3f ®ion, const Vector3ui32 &perdim, ServerIDMap *sidmap) | |
virtual | ~CoordinateSegmentationClient () |
virtual ServerID | lookup (const Vector3f &pos) |
virtual BoundingBoxList | serverRegion (const ServerID &server) |
virtual BoundingBox3f | region () |
virtual uint32 | numServers () |
virtual std::vector< ServerID > | lookupBoundingBox (const BoundingBox3f &bbox) |
virtual void | receiveMessage (Message *msg) |
virtual void | reportLoad (ServerID, const BoundingBox3f &bbox, uint32 loadValue) |
virtual void | migrationHint (std::vector< ServerLoadInfo > &svrLoadInfo) |
Private Types | |
typedef struct Sirikata::CoordinateSegmentationClient::LookupCacheEntry | LookupCacheEntry |
Private Member Functions | |
virtual void | service () |
void | csegChangeMessage (Sirikata::Protocol::CSeg::ChangeMessage *ccMsg) |
void | downloadUpdatedBSPTree () |
void | handleSelfLookup (ServerID my_sid, Address4 my_addr) |
void | startAccepting () |
void | accept_handler () |
void | sendSegmentationListenMessage (const Address4 &my_addr) |
boost::shared_ptr < Network::TCPSocket > | getLeasedSocket () |
void | writeCSEGMessage (boost::shared_ptr< tcp::socket > socket, Sirikata::Protocol::CSeg::CSegMessage &csegMessage) |
void | readCSEGMessage (boost::shared_ptr< tcp::socket > socket, Sirikata::Protocol::CSeg::CSegMessage &csegMessage) |
Private Attributes | |
bool | mBSPTreeValid |
Trace::Trace * | mTrace |
boost::mutex | mCacheMutex |
std::vector< LookupCacheEntry > | mLookupCache |
uint16 | mAvailableServersCount |
std::map< ServerID, BoundingBoxList > | mServerRegionCache |
SegmentedRegion | mTopLevelRegion |
Network::IOService * | mIOService |
boost::shared_ptr < Network::TCPListener > | mAcceptor |
boost::shared_ptr < Network::TCPSocket > | mSocket |
ServerIDMap * | mSidMap |
boost::mutex | mMutex |
boost::shared_ptr < Network::TCPSocket > | mLeasedSocket |
Time | mLeaseExpiryTime |
String | mCSEGHost |
String | mCSEGPort |
Distributed BSP-tree based implementation of CoordinateSegmentation.
typedef struct Sirikata::CoordinateSegmentationClient::LookupCacheEntry Sirikata::CoordinateSegmentationClient::LookupCacheEntry [private] |
Sirikata::CoordinateSegmentationClient::CoordinateSegmentationClient | ( | SpaceContext * | ctx, |
const BoundingBox3f & | region, | ||
const Vector3ui32 & | perdim, | ||
ServerIDMap * | sidmap | ||
) |
References Sirikata::GetOptionValue< String >(), handleSelfLookup(), Sirikata::SpaceContext::id(), Sirikata::ServerIDMap::lookupExternal(), Sirikata::Context::mainStrand, Sirikata::SegmentedRegion::mBoundingBox, Sirikata::CoordinateSegmentation::mContext, mCSEGHost, mCSEGPort, mSidMap, mTopLevelRegion, and Sirikata::Network::IOStrand::wrap().
Sirikata::CoordinateSegmentationClient::~CoordinateSegmentationClient | ( | ) | [virtual] |
void Sirikata::CoordinateSegmentationClient::accept_handler | ( | ) | [private] |
void Sirikata::CoordinateSegmentationClient::csegChangeMessage | ( | Sirikata::Protocol::CSeg::ChangeMessage * | ccMsg | ) | [private] |
void Sirikata::CoordinateSegmentationClient::downloadUpdatedBSPTree | ( | ) | [private] |
boost::shared_ptr< TCPSocket > Sirikata::CoordinateSegmentationClient::getLeasedSocket | ( | ) | [private] |
References CSEG_LOG, Sirikata::Logging::error, mCSEGHost, mCSEGPort, mIOService, mLeasedSocket, mLeaseExpiryTime, and Sirikata::Timer::now().
Referenced by lookup(), lookupBoundingBox(), numServers(), region(), reportLoad(), sendSegmentationListenMessage(), and serverRegion().
void Sirikata::CoordinateSegmentationClient::handleSelfLookup | ( | ServerID | my_sid, |
Address4 | my_addr | ||
) | [private] |
ServerID Sirikata::CoordinateSegmentationClient::lookup | ( | const Vector3f & | pos | ) | [virtual] |
Implements Sirikata::CoordinateSegmentation.
References CSEG_LOG, getLeasedSocket(), Sirikata::Logging::info, mCacheMutex, mLookupCache, mMutex, readCSEGMessage(), and writeCSEGMessage().
std::vector< ServerID > Sirikata::CoordinateSegmentationClient::lookupBoundingBox | ( | const BoundingBox3f & | bbox | ) | [virtual] |
Implements Sirikata::CoordinateSegmentation.
References getLeasedSocket(), mMutex, readCSEGMessage(), and writeCSEGMessage().
void Sirikata::CoordinateSegmentationClient::migrationHint | ( | std::vector< ServerLoadInfo > & | svrLoadInfo | ) | [virtual] |
Reimplemented from Sirikata::CoordinateSegmentation.
uint32 Sirikata::CoordinateSegmentationClient::numServers | ( | ) | [virtual] |
Implements Sirikata::CoordinateSegmentation.
References getLeasedSocket(), mAvailableServersCount, mCacheMutex, mMutex, readCSEGMessage(), and writeCSEGMessage().
void Sirikata::CoordinateSegmentationClient::readCSEGMessage | ( | boost::shared_ptr< tcp::socket > | socket, |
Sirikata::Protocol::CSeg::CSegMessage & | csegMessage | ||
) | [private] |
References Sirikata::parsePBJMessage().
Referenced by accept_handler(), lookup(), lookupBoundingBox(), numServers(), region(), reportLoad(), and serverRegion().
void Sirikata::CoordinateSegmentationClient::receiveMessage | ( | Message * | msg | ) | [virtual] |
Implements Sirikata::CoordinateSegmentation.
BoundingBox3f Sirikata::CoordinateSegmentationClient::region | ( | ) | [virtual] |
Implements Sirikata::CoordinateSegmentation.
References getLeasedSocket(), Sirikata::SegmentedRegion::mBoundingBox, mCacheMutex, mMutex, mTopLevelRegion, readCSEGMessage(), and writeCSEGMessage().
void Sirikata::CoordinateSegmentationClient::reportLoad | ( | ServerID | sid, |
const BoundingBox3f & | bbox, | ||
uint32 | loadValue | ||
) | [virtual] |
Reimplemented from Sirikata::CoordinateSegmentation.
References CSEG_LOG, Sirikata::Logging::error, getLeasedSocket(), mMutex, readCSEGMessage(), and writeCSEGMessage().
void Sirikata::CoordinateSegmentationClient::sendSegmentationListenMessage | ( | const Address4 & | my_addr | ) | [private] |
References CSEG_LOG, getLeasedSocket(), Sirikata::Logging::info, Sirikata::Address4::ip, mMutex, Sirikata::Address4::port, and writeCSEGMessage().
Referenced by handleSelfLookup().
BoundingBoxList Sirikata::CoordinateSegmentationClient::serverRegion | ( | const ServerID & | server | ) | [virtual] |
Implements Sirikata::CoordinateSegmentation.
References getLeasedSocket(), mCacheMutex, mMutex, mServerRegionCache, readCSEGMessage(), and writeCSEGMessage().
void Sirikata::CoordinateSegmentationClient::service | ( | ) | [private, virtual] |
Implements Sirikata::CoordinateSegmentation.
References CSEG_LOG, Sirikata::Logging::info, mIOService, mLeasedSocket, mLeaseExpiryTime, mMutex, Sirikata::Timer::now(), and Sirikata::Network::IOService::poll().
void Sirikata::CoordinateSegmentationClient::startAccepting | ( | ) | [private] |
References accept_handler(), mAcceptor, mIOService, and mSocket.
Referenced by accept_handler(), and handleSelfLookup().
void Sirikata::CoordinateSegmentationClient::writeCSEGMessage | ( | boost::shared_ptr< tcp::socket > | socket, |
Sirikata::Protocol::CSeg::CSegMessage & | csegMessage | ||
) | [private] |
References Sirikata::serializePBJMessage().
Referenced by lookup(), lookupBoundingBox(), numServers(), region(), reportLoad(), sendSegmentationListenMessage(), and serverRegion().
boost::shared_ptr<Network::TCPListener> Sirikata::CoordinateSegmentationClient::mAcceptor [private] |
Referenced by handleSelfLookup(), and startAccepting().
uint16 Sirikata::CoordinateSegmentationClient::mAvailableServersCount [private] |
Referenced by numServers().
bool Sirikata::CoordinateSegmentationClient::mBSPTreeValid [private] |
boost::mutex Sirikata::CoordinateSegmentationClient::mCacheMutex [private] |
Referenced by accept_handler(), lookup(), numServers(), region(), and serverRegion().
String Sirikata::CoordinateSegmentationClient::mCSEGHost [private] |
Referenced by CoordinateSegmentationClient(), and getLeasedSocket().
String Sirikata::CoordinateSegmentationClient::mCSEGPort [private] |
Referenced by CoordinateSegmentationClient(), and getLeasedSocket().
Referenced by getLeasedSocket(), handleSelfLookup(), service(), and startAccepting().
boost::shared_ptr<Network::TCPSocket> Sirikata::CoordinateSegmentationClient::mLeasedSocket [private] |
Referenced by getLeasedSocket(), and service().
Referenced by getLeasedSocket(), and service().
std::vector<LookupCacheEntry> Sirikata::CoordinateSegmentationClient::mLookupCache [private] |
Referenced by accept_handler(), and lookup().
boost::mutex Sirikata::CoordinateSegmentationClient::mMutex [private] |
Referenced by lookup(), lookupBoundingBox(), numServers(), region(), reportLoad(), sendSegmentationListenMessage(), serverRegion(), and service().
std::map<ServerID, BoundingBoxList> Sirikata::CoordinateSegmentationClient::mServerRegionCache [private] |
Referenced by accept_handler(), and serverRegion().
Referenced by CoordinateSegmentationClient().
boost::shared_ptr<Network::TCPSocket> Sirikata::CoordinateSegmentationClient::mSocket [private] |
Referenced by accept_handler(), and startAccepting().
Referenced by accept_handler(), CoordinateSegmentationClient(), and region().