removed TokenQueue from GxsTransportStatistics

This commit is contained in:
csoler 2020-04-04 22:00:52 +02:00
parent 72a22bcc88
commit 4653f18dd1
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
6 changed files with 171 additions and 166 deletions

View file

@ -43,7 +43,7 @@ p3GxsTrans::~p3GxsTrans()
}
}
bool p3GxsTrans::getStatistics(GxsTransStatistics& stats)
bool p3GxsTrans::getDataStatistics(GxsTransStatistics& stats)
{
{
RS_STACK_MUTEX(mDataMutex);
@ -1335,4 +1335,53 @@ bool p3GxsTrans::acceptNewMessage(const RsGxsMsgMetaData *msgMeta,uint32_t msg_s
}
bool p3GxsTrans::getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats)
{
uint32_t token1;
RsTokReqOptions opts1;
opts1.mReqType = GXS_REQUEST_TYPE_GROUP_META;
if( !requestGroupInfo(token1, opts1) || waitToken(token1) != RsTokenService::COMPLETE )
return false;
std::list<RsGroupMetaData> group_metas;
getGroupSummary(token1,group_metas);
for(auto& group_meta:group_metas)
{
RsGxsTransGroupStatistics& stat(stats[group_meta.mGroupId]);
uint32_t token2;
if(!RsGxsIfaceHelper::requestGroupStatistic(token2,group_meta.mGroupId) || waitToken(token2) != RsTokenService::COMPLETE)
continue;
RsGenExchange::getGroupStatistic(token2,stat);
stat.popularity = group_meta.mPop ;
stat.subscribed = IS_GROUP_SUBSCRIBED(group_meta.mSubscribeFlags) ;
stat.mGrpId = group_meta.mGroupId ;
std::vector<RsMsgMetaData> metas;
uint32_t token3;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(group_meta.mGroupId);
if( !requestMsgInfo(token3, opts, groupIds) || waitToken(token3, std::chrono::seconds(5)) != RsTokenService::COMPLETE )
continue;
GxsMsgMetaMap metaMap;
if(!RsGenExchange::getMsgMeta(token3, metaMap) || metaMap.size() != 1)
continue;
for(auto& meta: metaMap.begin()->second)
stat.addMessageMeta(group_meta.mGroupId,meta) ;
}
return true;
}

View file

@ -113,13 +113,21 @@ public:
/*!
* \brief getStatistics
* Gathers all sorts of statistics about the internals of p3GxsTrans, in order to display info about the running status,
* message transport, etc.
* Gathers all sorts of statistics about the data transported by p3GxsTrans, in order to display info about the running status,
* message transport, etc. This is a blocking call. Use it in a thread.
* \param stats This structure contains all statistics information.
* \return true is the call succeeds.
*/
virtual bool getStatistics(GxsTransStatistics& stats);
virtual bool getDataStatistics(GxsTransStatistics& stats) override;
/*!
* \brief getGroupStatistics
* Gathers statistics about GXS groups and messages used by GxsTrans to transport data. This is a blocking call. Use it in a thread.
* \param stats
* \return true if the data collection succeeds.
*/
virtual bool getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats) override;
/**
* Send an email to recipient, in the process author of the email is

View file

@ -85,8 +85,7 @@ public:
* @param groupIds the ids return for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getGroupList(const uint32_t &token,
std::list<RsGxsGroupId> &groupIds)
bool getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds)
{
return mGxs.getGroupList(token, groupIds);
}
@ -119,8 +118,7 @@ public:
* @param groupInfo the ids returned for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getGroupSummary(const uint32_t &token,
std::list<RsGroupMetaData> &groupInfo)
bool getGroupSummary(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
{
return mGxs.getGroupMeta(token, groupInfo);
}
@ -130,8 +128,7 @@ public:
* @param msgInfo the message metadata returned for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getMsgSummary(const uint32_t &token,
GxsMsgMetaMap &msgInfo)
bool getMsgSummary(const uint32_t &token, GxsMsgMetaMap &msgInfo)
{
return mGxs.getMsgMeta(token, msgInfo);
}

View file

@ -70,10 +70,8 @@ enum class GxsTransSendStatus : uint8_t
typedef uint64_t RsGxsTransId;
class RsGxsTransGroup
class RsGxsTransGroup: public RsGxsGenericGroupData
{
public:
RsGroupMetaData mMeta;
};
class RsGxsTransMsg
@ -103,7 +101,34 @@ struct RsGxsTransOutgoingRecord
RsGxsGroupId group_id ;
};
class RsGxsTransGroupStatistics: public GxsGroupStatistic
{
public:
RsGxsTransGroupStatistics()
{
last_publish_TS = 0;
popularity = 0;
subscribed = false;
}
void addMessageMeta(const RsGxsGroupId& grp,const RsMsgMetaData& meta)
{
messages_metas[meta.mMsgId] = meta ;
last_publish_TS = std::max(last_publish_TS,meta.mPublishTs) ;
mGrpId = grp ;
}
bool subscribed ;
int popularity ;
rstime_t last_publish_TS;
std::map<RsGxsMessageId,RsMsgMetaData> messages_metas ;
};
/// RetroShare GxsTrans asyncronous redundant small mail trasport on top of GXS
///
class RsGxsTrans: public RsGxsIfaceHelper
{
public:
@ -120,10 +145,8 @@ public:
virtual ~RsGxsTrans() {}
virtual bool getStatistics(GxsTransStatistics& stats)=0;
// virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsTransGroup> &groups) = 0;
// virtual bool getPostData(const uint32_t &token, std::vector<RsGxsTransMsg> &posts) = 0;
virtual bool getDataStatistics(GxsTransStatistics& stats)=0;
virtual bool getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats) =0;
};
extern RsGxsTrans *rsGxsTrans ;