mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
fixed up display of GroupStatisticsReq and moved priorities to RsTokReqOptions
This commit is contained in:
parent
7c77e82b1e
commit
ebee69df96
@ -34,7 +34,7 @@
|
||||
|
||||
bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2)
|
||||
{
|
||||
return p1.second->priority <= p2.second->priority ; // <= so that new elements with same priority are inserted before
|
||||
return p1.second->Options.mPriority <= p2.second->Options.mPriority ; // <= so that new elements with same priority are inserted before
|
||||
}
|
||||
|
||||
|
||||
@ -47,9 +47,7 @@ RsGxsDataAccess::~RsGxsDataAccess()
|
||||
for(auto& it:mRequestQueue)
|
||||
delete it.second;
|
||||
}
|
||||
bool RsGxsDataAccess::requestGroupInfo(
|
||||
uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts,
|
||||
const std::list<RsGxsGroupId> &groupIds )
|
||||
bool RsGxsDataAccess::requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds )
|
||||
{
|
||||
if(groupIds.empty())
|
||||
{
|
||||
@ -145,8 +143,7 @@ void RsGxsDataAccess::generateToken(uint32_t &token)
|
||||
}
|
||||
|
||||
|
||||
bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
const RsTokReqOptions &opts, const GxsMsgReq &msgIds)
|
||||
bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq &msgIds)
|
||||
{
|
||||
|
||||
GxsRequest* req = NULL;
|
||||
@ -207,8 +204,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds)
|
||||
bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds)
|
||||
{
|
||||
GxsRequest* req = NULL;
|
||||
uint32_t reqType = opts.mReqType;
|
||||
@ -262,33 +258,40 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
}
|
||||
|
||||
|
||||
void RsGxsDataAccess::requestServiceStatistic(uint32_t& token)
|
||||
void RsGxsDataAccess::requestServiceStatistic(uint32_t& token,const RsTokReqOptions& opts)
|
||||
{
|
||||
ServiceStatisticRequest* req = new ServiceStatisticRequest();
|
||||
|
||||
generateToken(token);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
|
||||
if(opts.mReqType != GXS_REQUEST_TYPE_SERVICE_STATS)
|
||||
{
|
||||
RsErr() << "Expected opts.mReqType to be GXS_REQUEST_TYPE_SERVICE_STATS requestServiceStatistic()" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
setReq(req, token, 0, opts);
|
||||
storeRequest(req);
|
||||
}
|
||||
|
||||
void RsGxsDataAccess::requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
|
||||
void RsGxsDataAccess::requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId,const RsTokReqOptions& opts)
|
||||
{
|
||||
GroupStatisticRequest* req = new GroupStatisticRequest();
|
||||
req->mGrpId = grpId;
|
||||
|
||||
if(opts.mReqType != GXS_REQUEST_TYPE_GROUP_STATS)
|
||||
{
|
||||
RsErr() << "Expected opts.mReqType to be GXS_REQUEST_TYPE_SERVICE_STATS requestServiceStatistic()" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
generateToken(token);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
|
||||
setReq(req, token, 0, opts);
|
||||
setReq(req, token,0, opts);
|
||||
storeRequest(req);
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts,
|
||||
const std::vector<RsGxsGrpMsgIdPair> &msgIds)
|
||||
bool RsGxsDataAccess::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds)
|
||||
{
|
||||
|
||||
MsgRelatedInfoReq* req = new MsgRelatedInfoReq();
|
||||
@ -320,9 +323,9 @@ void RsGxsDataAccess::storeRequest(GxsRequest* req)
|
||||
mPublicToken[req->token] = PENDING;
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "Stored request token=" << req->token << " priority = " << static_cast<int>(req->priority) << " Current request Queue is:" ;
|
||||
std::cerr << "Stored request token=" << req->token << " priority = " << static_cast<int>(req->Options.mPriority) << " Current request Queue is:" ;
|
||||
for(auto it(mRequestQueue.begin());it!=mRequestQueue.end();++it)
|
||||
std::cerr << it->first << " (p=" << static_cast<int>(req->priority) << ") ";
|
||||
std::cerr << it->first << " (p=" << static_cast<int>(req->Options.mPriority) << ") ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Completed requests waiting for client: " << mCompletedRequests.size() << std::endl;
|
||||
#endif
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
* @param groupIds group id to request info for
|
||||
* @return
|
||||
*/
|
||||
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds);
|
||||
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds) override;
|
||||
|
||||
/*!
|
||||
* Use this to request all group related info
|
||||
@ -68,7 +68,7 @@ public:
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
* @return
|
||||
*/
|
||||
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts);
|
||||
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts) override;
|
||||
|
||||
/*!
|
||||
* Use this to get msg information (id, meta, or data), store token value to poll for request completion
|
||||
@ -78,7 +78,7 @@ public:
|
||||
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
|
||||
* @return true if request successful false otherwise
|
||||
*/
|
||||
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds);
|
||||
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds) override;
|
||||
|
||||
/*!
|
||||
* Use this to get message information (id, meta, or data), store token value to poll for request completion
|
||||
@ -89,7 +89,7 @@ public:
|
||||
* all messages for all groups are retrieved
|
||||
* @return true if request successful false otherwise
|
||||
*/
|
||||
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds);
|
||||
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds) override;
|
||||
|
||||
/*!
|
||||
* For requesting msgs related to a given msg id within a group
|
||||
@ -99,7 +99,7 @@ public:
|
||||
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
|
||||
* @return true if request successful false otherwise
|
||||
*/
|
||||
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds);
|
||||
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds) override;
|
||||
|
||||
/*!
|
||||
* This request statistics on amount of data held
|
||||
@ -110,16 +110,17 @@ public:
|
||||
* total size of messages
|
||||
* total size of groups
|
||||
* @param token
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
*/
|
||||
void requestServiceStatistic(uint32_t& token);
|
||||
void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) override;
|
||||
|
||||
/*!
|
||||
* To request statistic on a group
|
||||
* @param token set to value to be redeemed to get statistic
|
||||
* @param grpId the id of the group
|
||||
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
|
||||
*/
|
||||
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId);
|
||||
|
||||
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) override;
|
||||
|
||||
/* Poll */
|
||||
GxsRequestStatus requestStatus(const uint32_t token);
|
||||
|
@ -31,10 +31,15 @@ std::ostream& operator<<(std::ostream& o,const GxsRequest& g)
|
||||
|
||||
std::ostream& GroupMetaReq::print(std::ostream& o) const
|
||||
{
|
||||
o << "[Request type=GroupMeta groupIds (size=" << mGroupIds.size() << "): " << *mGroupIds.begin() ;
|
||||
o << "[Request type=GroupMeta groupIds (size=" << mGroupIds.size() << "): " ;
|
||||
|
||||
if(mGroupIds.size() > 1)
|
||||
o << " ..." ;
|
||||
if(!mGroupIds.empty())
|
||||
{
|
||||
o << *mGroupIds.begin() ;
|
||||
|
||||
if(mGroupIds.size() > 1)
|
||||
o << " ..." ;
|
||||
}
|
||||
|
||||
o << "]" ;
|
||||
|
||||
@ -52,10 +57,15 @@ std::ostream& GroupSerializedDataReq::print(std::ostream& o) const
|
||||
|
||||
std::ostream& GroupDataReq::print(std::ostream& o) const
|
||||
{
|
||||
o << "[Request type=GroupDataReq groupIds (size=" << mGroupIds.size() << "): " << *mGroupIds.begin() ;
|
||||
o << "[Request type=GroupDataReq groupIds (size=" << mGroupIds.size() << "): " ;
|
||||
|
||||
if(mGroupIds.size() > 1)
|
||||
o << " ..." ;
|
||||
if(!mGroupIds.empty())
|
||||
{
|
||||
o << *mGroupIds.begin() ;
|
||||
|
||||
if(mGroupIds.size() > 1)
|
||||
o << " ..." ;
|
||||
}
|
||||
|
||||
o << "]" ;
|
||||
|
||||
@ -69,10 +79,15 @@ std::ostream& MsgIdReq::print(std::ostream& o) const
|
||||
|
||||
std::ostream& MsgMetaReq::print(std::ostream& o) const
|
||||
{
|
||||
o << "[Request type=MsgMetaReq groups (size=" << mMsgIds.size() << "): " << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
|
||||
o << "[Request type=MsgMetaReq groups (size=" << mMsgIds.size() << "): " ;
|
||||
|
||||
if(mMsgIds.size() > 1)
|
||||
o << " ..." ;
|
||||
if(!mMsgIds.empty())
|
||||
{
|
||||
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
|
||||
|
||||
if(mMsgIds.size() > 1)
|
||||
o << " ..." ;
|
||||
}
|
||||
|
||||
o << "]" ;
|
||||
|
||||
@ -81,10 +96,15 @@ std::ostream& MsgMetaReq::print(std::ostream& o) const
|
||||
|
||||
std::ostream& MsgDataReq::print(std::ostream& o) const
|
||||
{
|
||||
o << "[Request type=MsgDataReq groups (size=" << mMsgIds.size() << "): " << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
|
||||
o << "[Request type=MsgDataReq groups (size=" << mMsgIds.size() << "): " ;
|
||||
|
||||
if(mMsgIds.size() > 1)
|
||||
o << " ..." ;
|
||||
if(!mMsgIds.empty())
|
||||
{
|
||||
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
|
||||
|
||||
if(mMsgIds.size() > 1)
|
||||
o << " ..." ;
|
||||
}
|
||||
|
||||
o << "]" ;
|
||||
|
||||
@ -93,10 +113,15 @@ std::ostream& MsgDataReq::print(std::ostream& o) const
|
||||
|
||||
std::ostream& MsgRelatedInfoReq::print(std::ostream& o) const
|
||||
{
|
||||
o << "[Request type=MsgRelatedInfo msgIds (size=" << mMsgIds.size() << "): " << mMsgIds.begin()->first ;
|
||||
o << "[Request type=MsgRelatedInfo msgIds (size=" << mMsgIds.size() << "): " ;
|
||||
|
||||
if(mMsgIds.size() > 1)
|
||||
o << " ..." ;
|
||||
if(!mMsgIds.empty())
|
||||
{
|
||||
o << mMsgIds.begin()->first ;
|
||||
|
||||
if(mMsgIds.size() > 1)
|
||||
o << " ..." ;
|
||||
}
|
||||
|
||||
o << "]" ;
|
||||
|
||||
@ -105,7 +130,7 @@ std::ostream& MsgRelatedInfoReq::print(std::ostream& o) const
|
||||
|
||||
std::ostream& GroupSetFlagReq::print(std::ostream& o) const
|
||||
{
|
||||
return o << "[Request type=GroupFlagSet" << "]" ;
|
||||
return o << "[Request type=GroupFlagSet grpId=" << grpId << "]" ;
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +142,7 @@ std::ostream& ServiceStatisticRequest::print(std::ostream& o) const
|
||||
|
||||
std::ostream& GroupStatisticRequest::print(std::ostream& o) const
|
||||
{
|
||||
return o << "[Request type=GroupStatistics" << "]" ;
|
||||
return o << "[Request type=GroupStatistics grpId=" << mGrpId << "]" ;
|
||||
}
|
||||
|
||||
GroupMetaReq::~GroupMetaReq()
|
||||
|
@ -26,18 +26,10 @@
|
||||
#include "gxs/rsgds.h"
|
||||
#include "util/rsdeprecate.h"
|
||||
|
||||
enum class GxsRequestPriority {
|
||||
VERY_HIGH = 0x00,
|
||||
HIGH = 0x01,
|
||||
NORMAL = 0x02,
|
||||
LOW = 0x03,
|
||||
VERY_LOW = 0x04,
|
||||
};
|
||||
|
||||
struct GxsRequest
|
||||
{
|
||||
GxsRequest() :
|
||||
token(0), reqTime(0), ansType(0), reqType(0),priority(GxsRequestPriority::NORMAL),
|
||||
token(0), reqTime(0), ansType(0), reqType(0),
|
||||
status(RsTokenService::FAILED) {}
|
||||
virtual ~GxsRequest() {}
|
||||
|
||||
@ -46,7 +38,6 @@ struct GxsRequest
|
||||
|
||||
RS_DEPRECATED uint32_t ansType; /// G10h4ck: This is of no use. csoler: it's made available to the clients.
|
||||
uint32_t reqType;
|
||||
GxsRequestPriority priority;
|
||||
RsTokReqOptions Options;
|
||||
|
||||
RsTokenService::GxsRequestStatus status;
|
||||
|
@ -360,7 +360,10 @@ public:
|
||||
/// @see RsTokenService::requestServiceStatistic
|
||||
void requestServiceStatistic(uint32_t& token)
|
||||
{
|
||||
mTokenService.requestServiceStatistic(token);
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
|
||||
|
||||
mTokenService.requestServiceStatistic(token,opts);
|
||||
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
|
||||
@ -371,7 +374,10 @@ public:
|
||||
/// @see RsTokenService::requestGroupStatistic
|
||||
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
|
||||
{
|
||||
mTokenService.requestGroupStatistic(token, grpId);
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
|
||||
|
||||
mTokenService.requestGroupStatistic(token, grpId,opts);
|
||||
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
|
||||
|
@ -45,6 +45,13 @@ struct RsMsgMetaData;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
|
||||
|
||||
enum class GxsRequestPriority {
|
||||
VERY_HIGH = 0x00,
|
||||
HIGH = 0x01,
|
||||
NORMAL = 0x02,
|
||||
LOW = 0x03,
|
||||
VERY_LOW = 0x04,
|
||||
};
|
||||
|
||||
class RsGxsGrpMetaData;
|
||||
class RsGxsMsgMetaData;
|
||||
|
@ -80,7 +80,7 @@ struct RsTokReqOptions
|
||||
{
|
||||
RsTokReqOptions() : mOptions(0), mStatusFilter(0), mStatusMask(0),
|
||||
mMsgFlagMask(0), mMsgFlagFilter(0), mReqType(0), mSubscribeFilter(0),
|
||||
mSubscribeMask(0), mBefore(0), mAfter(0) {}
|
||||
mSubscribeMask(0), mBefore(0), mAfter(0),mPriority(GxsRequestPriority::NORMAL) {}
|
||||
|
||||
/**
|
||||
* Can be one or multiple RS_TOKREQOPT_*
|
||||
@ -107,6 +107,8 @@ struct RsTokReqOptions
|
||||
// Time range... again applied after Options.
|
||||
rstime_t mBefore;
|
||||
rstime_t mAfter;
|
||||
|
||||
GxsRequestPriority mPriority;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -181,6 +183,25 @@ public:
|
||||
*/
|
||||
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgIds) = 0;
|
||||
|
||||
/*!
|
||||
* This request statistics on amount of data held
|
||||
* number of groups
|
||||
* number of groups subscribed
|
||||
* number of messages
|
||||
* size of db store
|
||||
* total size of messages
|
||||
* total size of groups
|
||||
* @param token
|
||||
*/
|
||||
virtual void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) = 0;
|
||||
|
||||
/*!
|
||||
* To request statistic on a group
|
||||
* @param token set to value to be redeemed to get statistic
|
||||
* @param grpId the id of the group
|
||||
*/
|
||||
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) = 0;
|
||||
|
||||
|
||||
/* Poll */
|
||||
|
||||
@ -194,25 +215,6 @@ public:
|
||||
*/
|
||||
virtual GxsRequestStatus requestStatus(const uint32_t token) = 0;
|
||||
|
||||
/*!
|
||||
* This request statistics on amount of data held
|
||||
* number of groups
|
||||
* number of groups subscribed
|
||||
* number of messages
|
||||
* size of db store
|
||||
* total size of messages
|
||||
* total size of groups
|
||||
* @param token
|
||||
*/
|
||||
virtual void requestServiceStatistic(uint32_t& token) = 0;
|
||||
|
||||
/*!
|
||||
* To request statistic on a group
|
||||
* @param token set to value to be redeemed to get statistic
|
||||
* @param grpId the id of the group
|
||||
*/
|
||||
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) = 0;
|
||||
|
||||
/*!
|
||||
* @brief Cancel Request
|
||||
* If this function returns false, it may be that the request has completed
|
||||
|
@ -56,7 +56,10 @@ void GxsUserNotify::startUpdate()
|
||||
mNewChildMessageCount = 0;
|
||||
|
||||
uint32_t token;
|
||||
mTokenService->requestServiceStatistic(token);
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
|
||||
|
||||
mTokenService->requestServiceStatistic(token,opts);
|
||||
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,10 @@ void GxsTransportStatistics::requestGroupMeta()
|
||||
void GxsTransportStatistics::requestGroupStat(const RsGxsGroupId &groupId)
|
||||
{
|
||||
uint32_t token;
|
||||
rsGxsTrans->getTokenService()->requestGroupStatistic(token, groupId);
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
|
||||
|
||||
rsGxsTrans->getTokenService()->requestGroupStatistic(token, groupId,opts);
|
||||
mTransQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, GXSTRANS_GROUP_STAT);
|
||||
}
|
||||
void GxsTransportStatistics::requestMsgMeta(const RsGxsGroupId& grpId)
|
||||
|
Loading…
Reference in New Issue
Block a user