mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-18 15:56:51 +02:00
work on client stats and max total packets per second
This commit is contained in:
parent
39ba98f3b1
commit
1603c1f38c
5 changed files with 48 additions and 6 deletions
assignment-client/src/octree
|
@ -41,6 +41,7 @@ void OctreeQueryNode::initializeOctreeSendThread(OctreeServer* octreeServer, con
|
|||
// Create octree sending thread...
|
||||
_octreeSendThread = new OctreeSendThread(nodeUUID, octreeServer);
|
||||
_octreeSendThread->initialize(true);
|
||||
//connect(_octreeSendThread, SIGNAL(finished()), _octreeSendThread, SLOT(deleteLater()));
|
||||
}
|
||||
|
||||
bool OctreeQueryNode::packetIsDuplicate() const {
|
||||
|
@ -159,8 +160,11 @@ void OctreeQueryNode::writeToPacket(const unsigned char* buffer, int bytes) {
|
|||
}
|
||||
|
||||
OctreeQueryNode::~OctreeQueryNode() {
|
||||
//qDebug() << "OctreeQueryNode::~OctreeQueryNode() this=" << this;
|
||||
if (_octreeSendThread) {
|
||||
//qDebug() << "OctreeQueryNode::~OctreeQueryNode() calling _octreeSendThread->terminate() _octreeSendThread=" << _octreeSendThread;
|
||||
_octreeSendThread->terminate();
|
||||
//qDebug() << "OctreeQueryNode::~OctreeQueryNode() calling _octreeSendThread->deleteLater() _octreeSendThread=" << _octreeSendThread;
|
||||
_octreeSendThread->deleteLater();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,20 @@ OctreeSendThread::OctreeSendThread(const QUuid& nodeUUID, OctreeServer* myServer
|
|||
_myServer(myServer),
|
||||
_packetData()
|
||||
{
|
||||
qDebug() << "client connected this=" << this;
|
||||
_myServer->clientConnected();
|
||||
}
|
||||
|
||||
OctreeSendThread::~OctreeSendThread() {
|
||||
qDebug() << "OctreeSendThread::~OctreeSendThread()... this=" << this;
|
||||
qDebug() << "client disconnected this=" << this;
|
||||
_myServer->clientDisconnected();
|
||||
}
|
||||
|
||||
|
||||
bool OctreeSendThread::process() {
|
||||
qDebug() << "OctreeSendThread::process() this=" << this;
|
||||
|
||||
quint64 start = usecTimestampNow();
|
||||
bool gotLock = false;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
class OctreeSendThread : public GenericThread {
|
||||
public:
|
||||
OctreeSendThread(const QUuid& nodeUUID, OctreeServer* myServer);
|
||||
virtual ~OctreeSendThread();
|
||||
|
||||
static quint64 _totalBytes;
|
||||
static quint64 _totalWastedBytes;
|
||||
|
|
|
@ -35,6 +35,7 @@ OctreeServer::OctreeServer(const QByteArray& packet) :
|
|||
_parsedArgV(NULL),
|
||||
_httpManager(NULL),
|
||||
_packetsPerClientPerInterval(10),
|
||||
_packetsTotalPerInterval(DEFAULT_PACKETS_PER_INTERVAL),
|
||||
_tree(NULL),
|
||||
_wantPersist(true),
|
||||
_debugSending(false),
|
||||
|
@ -45,7 +46,8 @@ OctreeServer::OctreeServer(const QByteArray& packet) :
|
|||
_octreeInboundPacketProcessor(NULL),
|
||||
_persistThread(NULL),
|
||||
_started(time(0)),
|
||||
_startedUSecs(usecTimestampNow())
|
||||
_startedUSecs(usecTimestampNow()),
|
||||
_clientCount(0)
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
@ -234,6 +236,9 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
|||
quint64 totalBytesOfColor = OctreePacketData::getTotalBytesOfColor();
|
||||
|
||||
const int COLUMN_WIDTH = 10;
|
||||
statsString += QString(" Total Clients Connected: %1 clients\r\n\r\n")
|
||||
.arg(locale.toString((uint)getCurrentClientCount()).rightJustified(COLUMN_WIDTH, ' '));
|
||||
|
||||
statsString += QString(" Total Outbound Packets: %1 packets\r\n")
|
||||
.arg(locale.toString((uint)totalOutboundPackets).rightJustified(COLUMN_WIDTH, ' '));
|
||||
statsString += QString(" Total Outbound Bytes: %1 bytes\r\n")
|
||||
|
@ -612,15 +617,28 @@ void OctreeServer::run() {
|
|||
}
|
||||
|
||||
// Check to see if the user passed in a command line option for setting packet send rate
|
||||
const char* PACKETS_PER_SECOND = "--packetsPerSecond";
|
||||
const char* packetsPerSecond = getCmdOption(_argc, _argv, PACKETS_PER_SECOND);
|
||||
if (packetsPerSecond) {
|
||||
_packetsPerClientPerInterval = atoi(packetsPerSecond) / INTERVALS_PER_SECOND;
|
||||
const char* PACKETS_PER_SECOND_PER_CLIENT_MAX = "--packetsPerSecondPerClientMax";
|
||||
const char* packetsPerSecondPerClientMax = getCmdOption(_argc, _argv, PACKETS_PER_SECOND_PER_CLIENT_MAX);
|
||||
if (packetsPerSecondPerClientMax) {
|
||||
_packetsPerClientPerInterval = atoi(packetsPerSecondPerClientMax) / INTERVALS_PER_SECOND;
|
||||
if (_packetsPerClientPerInterval < 1) {
|
||||
_packetsPerClientPerInterval = 1;
|
||||
}
|
||||
qDebug("packetsPerSecond=%s PACKETS_PER_CLIENT_PER_INTERVAL=%d", packetsPerSecond, _packetsPerClientPerInterval);
|
||||
}
|
||||
qDebug("packetsPerSecondPerClientMax=%s _packetsPerClientPerInterval=%d",
|
||||
packetsPerSecondPerClientMax, _packetsPerClientPerInterval);
|
||||
|
||||
// Check to see if the user passed in a command line option for setting packet send rate
|
||||
const char* PACKETS_PER_SECOND_TOTAL_MAX = "--packetsPerSecondTotalMax";
|
||||
const char* packetsPerSecondTotalMax = getCmdOption(_argc, _argv, PACKETS_PER_SECOND_TOTAL_MAX);
|
||||
if (packetsPerSecondTotalMax) {
|
||||
_packetsTotalPerInterval = atoi(packetsPerSecondTotalMax) / INTERVALS_PER_SECOND;
|
||||
if (_packetsTotalPerInterval < 1) {
|
||||
_packetsTotalPerInterval = 1;
|
||||
}
|
||||
}
|
||||
qDebug("packetsPerSecondTotalMax=%s _packetsTotalPerInterval=%d",
|
||||
packetsPerSecondTotalMax, _packetsTotalPerInterval);
|
||||
|
||||
HifiSockAddr senderSockAddr;
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "OctreeServerConsts.h"
|
||||
#include "OctreeInboundPacketProcessor.h"
|
||||
|
||||
const int DEFAULT_PACKETS_PER_INTERVAL = 2000; // some 120,000 packets per second total
|
||||
|
||||
/// Handles assignments of type OctreeServer - sending octrees to various clients.
|
||||
class OctreeServer : public ThreadedAssignment, public HTTPRequestHandler {
|
||||
Q_OBJECT
|
||||
|
@ -42,6 +44,9 @@ public:
|
|||
JurisdictionMap* getJurisdiction() { return _jurisdiction; }
|
||||
|
||||
int getPacketsPerClientPerInterval() const { return _packetsPerClientPerInterval; }
|
||||
int getCurrentClientCount() const { return _clientCount; }
|
||||
void clientConnected() { _clientCount++; }
|
||||
void clientDisconnected() { _clientCount--; }
|
||||
|
||||
bool isInitialLoadComplete() const { return (_persistThread) ? _persistThread->isInitialLoadComplete() : true; }
|
||||
bool isPersistEnabled() const { return (_persistThread) ? true : false; }
|
||||
|
@ -81,6 +86,7 @@ protected:
|
|||
|
||||
char _persistFilename[MAX_FILENAME_LENGTH];
|
||||
int _packetsPerClientPerInterval;
|
||||
int _packetsTotalPerInterval;
|
||||
Octree* _tree; // this IS a reaveraging tree
|
||||
bool _wantPersist;
|
||||
bool _debugSending;
|
||||
|
@ -95,6 +101,8 @@ protected:
|
|||
|
||||
time_t _started;
|
||||
quint64 _startedUSecs;
|
||||
|
||||
int _clientCount;
|
||||
};
|
||||
|
||||
#endif // __octree_server__OctreeServer__
|
||||
|
|
Loading…
Reference in a new issue