* Refinement of new Cache Interface:

- Defined expected parameters for GxsGroups (see comments in rsidentity.h)
	- Added Various #defines for Groups / Msgs (again in rsidentity.h)
	- Converted new Group / new Msg into async "token" calls, returing MetaData.
	- Refined Grp/Msg Status Flags... similarly to how Forums used them...
		Expect UNREAD & UNPROCESSED flags to be set for a new msg, 
		and UPDATED flag to be set for the corresponding group. 
		There is flexibility for services to add their own flags too.
	- removed groupsChanged(). This can alternatively be implemented using.
		getGroupList(opts.Status == UPDATED)...
	- refined SubscribeFlags in a similar manner.
	- Added "ServiceString" to Group/Msg MetaData. This is freeform cache
	  storage for service to use... currently p3Posted uses it to count Votes.
	- Added MsgStatus & SubscribeFlag filtering to Cache Requests.
	- Implemented these filters in GxsDataProxy (no efficient yet!)

 * Cleaned up all 6 new Cache Services to conform to new interface.
 * Removed old interface code that was #ifdef'd out.

 * Implemented Basic Ranking algorithms for p3posted:
	- Background process to process new votes/comments.
	- getRanking(token) interface call.
	- Intercept StatusRequests, etc to hide internal data requests.
	- While the basic code is complete, it needs much testing / tweaking.
		- Should shift work to a seperate thread.
		- Comment Ranking has still to be done.
		- Interfacing with GUI not yet attempted.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5276 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-07-06 23:14:18 +00:00
parent 081b59ee1a
commit 8387c538f1
20 changed files with 1793 additions and 514 deletions

View file

@ -102,28 +102,54 @@ virtual uint32_t requestStatus(const uint32_t token);
virtual bool cancelRequest(const uint32_t &token);
//////////////////////////////////////////////////////////////////////////////
/* Functions from Forums -> need to be implemented generically */
virtual bool groupsChanged(std::list<std::string> &groupIds);
// Get Message Status - is retrived via MessageSummary.
virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
//
virtual bool groupSubscribe(const std::string &groupId, bool subscribe);
virtual bool setGroupStatus(const std::string &groupId, const uint32_t status, const uint32_t statusMask);
virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
virtual bool setMessageServiceString(const std::string &msgId, const std::string &str);
virtual bool setGroupServiceString(const std::string &grpId, const std::string &str);
virtual bool groupRestoreKeys(const std::string &groupId);
virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
/* details are updated in album - to choose Album ID, and storage path */
virtual bool submitGroup(RsPostedGroup &group, bool isNew);
virtual bool submitPost(RsPostedPost &post, bool isNew);
virtual bool submitVote(RsPostedVote &vote, bool isNew);
virtual bool submitComment(RsPostedComment &comment, bool isNew);
virtual bool submitGroup(uint32_t &token, RsPostedGroup &group, bool isNew);
virtual bool submitPost(uint32_t &token, RsPostedPost &post, bool isNew);
virtual bool submitVote(uint32_t &token, RsPostedVote &vote, bool isNew);
virtual bool submitComment(uint32_t &token, RsPostedComment &comment, bool isNew);
// Extended Interface for Collated Data View.
virtual bool setViewMode(uint32_t mode);
virtual bool setViewPeriod(uint32_t period);
virtual bool setViewRange(uint32_t first, uint32_t count);
virtual bool requestRanking(uint32_t &token, std::string groupId);
virtual bool getRankedPost(const uint32_t &token, RsPostedPost &post);
// These are exposed for GUI usage.
virtual bool encodePostedCache(std::string &str, uint32_t votes, uint32_t comments);
virtual bool extractPostedCache(const std::string &str, uint32_t &votes, uint32_t &comments);
private:
//
bool checkRankingRequest();
float calcPostScore(const RsMsgMetaData &meta);
bool processPosts();
// background processing of Votes.
// NB: These should probably be handled by a background thread.
// At the moment they are run from the tick() thread.
bool background_checkTokenRequest();
bool background_requestGroups();
bool background_requestNewMessages();
bool background_processNewMessages();
bool background_updateVoteCounts();
bool background_cleanup();
std::string genRandomId();
bool generateDummyData();
@ -132,6 +158,27 @@ bool generateDummyData();
RsMutex mPostedMtx;
bool mUpdated;
// Ranking view mode, stored here.
uint32_t mViewMode;
uint32_t mViewPeriod;
uint32_t mViewStart;
uint32_t mViewCount;
// Processing Ranking stuff.
bool mProcessingRanking;
uint32_t mRankingState;
uint32_t mRankingExternalToken;
uint32_t mRankingInternalToken;
// background processing - Mutex protected.
time_t mLastBgCheck;
bool mBgProcessing;
uint32_t mBgPhase;
uint32_t mBgToken;
std::map<std::string, uint32_t> mBgVoteMap; // ParentId -> Vote Count.
std::map<std::string, uint32_t> mBgCommentMap; // ThreadId -> Comment Count.
};