sign: Clear Port+Stream Stats on Clear(All) click

Although the RPC API provides separate APIs for clearing Port and Stream
Stats, typical use case would be to clear both together
This commit is contained in:
Srivats P 2016-11-28 20:19:17 +05:30
parent b622cc8e72
commit eed4f8eb1d
3 changed files with 42 additions and 3 deletions

View File

@ -1578,13 +1578,14 @@ void PortGroup::clearPortStats(QList<uint> *portList)
}
serviceStub->clearStats(controller, portIdList, ack,
NewCallback(this, &PortGroup::processClearStatsAck, controller));
NewCallback(this, &PortGroup::processClearPortStatsAck,
controller));
}
_exit:
return;
}
void PortGroup::processClearStatsAck(PbRpcController *controller)
void PortGroup::processClearPortStatsAck(PbRpcController *controller)
{
qDebug("In %s", __FUNCTION__);
@ -1594,6 +1595,38 @@ void PortGroup::processClearStatsAck(PbRpcController *controller)
delete controller;
}
bool PortGroup::clearStreamStats(QList<uint> *portList)
{
qDebug("In %s", __FUNCTION__);
if (state() != QAbstractSocket::ConnectedState)
return false;
OstProto::StreamGuidList *guidList = new OstProto::StreamGuidList;
OstProto::Ack *ack = new OstProto::Ack;
PbRpcController *controller = new PbRpcController(guidList, ack);
if (portList == NULL)
guidList->mutable_port_id_list()->CopyFrom(*portIdList_);
else
for (int i = 0; i < portList->size(); i++)
guidList->mutable_port_id_list()->add_port_id()
->set_id(portList->at(i));
serviceStub->clearStreamStats(controller, guidList, ack,
NewCallback(this, &PortGroup::processClearStreamStatsAck,
controller));
return true;
}
void PortGroup::processClearStreamStatsAck(PbRpcController *controller)
{
qDebug("In %s", __FUNCTION__);
delete controller;
}
bool PortGroup::getStreamStats(QList<uint> *portList)
{
qDebug("In %s", __FUNCTION__);

View File

@ -164,7 +164,9 @@ public:
void getPortStats();
void processPortStatsList();
void clearPortStats(QList<uint> *portList = NULL);
void processClearStatsAck(PbRpcController *controller);
void processClearPortStatsAck(PbRpcController *controller);
bool clearStreamStats(QList<uint> *portList = NULL);
void processClearStreamStatsAck(PbRpcController *controller);
bool getStreamStats(QList<uint> *portList = NULL);
void processStreamStatsList(PbRpcController *controller);

View File

@ -196,6 +196,8 @@ void PortStatsWindow::on_tbClear_clicked()
{
pgl->portGroupByIndex(portList.at(i).portGroupId).
clearPortStats(&portList[i].portList);
pgl->portGroupByIndex(portList.at(i).portGroupId).
clearStreamStats(&portList[i].portList);
}
}
@ -222,6 +224,8 @@ void PortStatsWindow::on_tbClearAll_clicked()
{
pgl->portGroupByIndex(portList.at(i).portGroupId)
.clearPortStats(&portList[i].portList);
pgl->portGroupByIndex(portList.at(i).portGroupId)
.clearStreamStats(&portList[i].portList);
}
}