mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:38:27 +02:00
handle mutli-VS config in DS when creating static file
This commit is contained in:
parent
fb27e37607
commit
94f7b98a5c
4 changed files with 37 additions and 65 deletions
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
|
@ -160,36 +162,53 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::prepopulateStaticAssignmentFile() {
|
void DomainServer::prepopulateStaticAssignmentFile() {
|
||||||
const uint NUM_FRESH_STATIC_ASSIGNMENTS = 3;
|
int numFreshStaticAssignments = 0;
|
||||||
|
|
||||||
// write a fresh static assignment array to file
|
// write a fresh static assignment array to file
|
||||||
|
|
||||||
Assignment freshStaticAssignments[NUM_FRESH_STATIC_ASSIGNMENTS];
|
Assignment freshStaticAssignments[MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS];
|
||||||
|
|
||||||
// pre-populate the first static assignment list with assignments for root AuM, AvM, VS
|
// pre-populate the first static assignment list with assignments for root AuM, AvM, VS
|
||||||
freshStaticAssignments[0] = Assignment(Assignment::CreateCommand,
|
freshStaticAssignments[numFreshStaticAssignments++] = Assignment(Assignment::CreateCommand,
|
||||||
Assignment::AudioMixerType,
|
Assignment::AudioMixerType,
|
||||||
Assignment::LocalLocation);
|
Assignment::LocalLocation);
|
||||||
freshStaticAssignments[1] = Assignment(Assignment::CreateCommand,
|
freshStaticAssignments[numFreshStaticAssignments++] = Assignment(Assignment::CreateCommand,
|
||||||
Assignment::AvatarMixerType,
|
Assignment::AvatarMixerType,
|
||||||
Assignment::LocalLocation);
|
Assignment::LocalLocation);
|
||||||
|
|
||||||
Assignment voxelServerAssignment(Assignment::CreateCommand, Assignment::VoxelServerType, Assignment::LocalLocation);
|
|
||||||
|
|
||||||
// Handle Domain/Voxel Server configuration command line arguments
|
// Handle Domain/Voxel Server configuration command line arguments
|
||||||
if (_voxelServerConfig) {
|
if (_voxelServerConfig) {
|
||||||
qDebug("Reading Voxel Server Configuration.\n");
|
qDebug("Reading Voxel Server Configuration.\n");
|
||||||
qDebug() << " config: " << _voxelServerConfig << "\n";
|
qDebug() << "config: " << _voxelServerConfig << "\n";
|
||||||
int payloadLength = strlen(_voxelServerConfig) + sizeof(char);
|
|
||||||
voxelServerAssignment.setPayload((const uchar*)_voxelServerConfig, payloadLength);
|
QString multiConfig((const char*) _voxelServerConfig);
|
||||||
|
QStringList multiConfigList = multiConfig.split(";");
|
||||||
|
|
||||||
|
// read each config to a payload for a VS assignment
|
||||||
|
for (int i = 0; i < multiConfigList.size(); i++) {
|
||||||
|
QString config = multiConfigList.at(i);
|
||||||
|
|
||||||
|
qDebug("config[%d]=%s\n", i, config.toLocal8Bit().constData());
|
||||||
|
|
||||||
|
Assignment voxelServerAssignment(Assignment::CreateCommand,
|
||||||
|
Assignment::VoxelServerType,
|
||||||
|
Assignment::LocalLocation); // use same location as we were created in.
|
||||||
|
|
||||||
|
int payloadLength = config.length() + sizeof(char);
|
||||||
|
voxelServerAssignment.setPayload((uchar*)config.toLocal8Bit().constData(), payloadLength);
|
||||||
|
|
||||||
|
freshStaticAssignments[numFreshStaticAssignments++] = voxelServerAssignment;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Assignment rootVoxelServerAssignment(Assignment::CreateCommand,
|
||||||
|
Assignment::VoxelServerType,
|
||||||
|
Assignment::LocalLocation);
|
||||||
|
freshStaticAssignments[numFreshStaticAssignments++] = rootVoxelServerAssignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
freshStaticAssignments[2] = voxelServerAssignment;
|
qDebug() << "Adding" << numFreshStaticAssignments << "static assignments to fresh file.\n";
|
||||||
|
|
||||||
_staticAssignmentFile.open(QIODevice::WriteOnly);
|
_staticAssignmentFile.open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
_staticAssignmentFile.write((char*) &NUM_FRESH_STATIC_ASSIGNMENTS,
|
|
||||||
sizeof(uint16_t));
|
|
||||||
_staticAssignmentFile.write((char*) &freshStaticAssignments, sizeof(freshStaticAssignments));
|
_staticAssignmentFile.write((char*) &freshStaticAssignments, sizeof(freshStaticAssignments));
|
||||||
_staticAssignmentFile.resize(MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS * sizeof(Assignment));
|
_staticAssignmentFile.resize(MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS * sizeof(Assignment));
|
||||||
_staticAssignmentFile.close();
|
_staticAssignmentFile.close();
|
||||||
|
@ -360,9 +379,7 @@ int DomainServer::run() {
|
||||||
|
|
||||||
_staticAssignmentFileData = _staticAssignmentFile.map(0, _staticAssignmentFile.size());
|
_staticAssignmentFileData = _staticAssignmentFile.map(0, _staticAssignmentFile.size());
|
||||||
|
|
||||||
_numAssignmentsInStaticFile = (uint16_t*) _staticAssignmentFileData;
|
_staticAssignments = (Assignment*) _staticAssignmentFileData;
|
||||||
_staticAssignments = (Assignment*)
|
|
||||||
(_staticAssignmentFileData + sizeof(*_numAssignmentsInStaticFile));
|
|
||||||
|
|
||||||
timeval startTime;
|
timeval startTime;
|
||||||
gettimeofday(&startTime, NULL);
|
gettimeofday(&startTime, NULL);
|
||||||
|
|
|
@ -57,7 +57,6 @@ private:
|
||||||
QFile _staticAssignmentFile;
|
QFile _staticAssignmentFile;
|
||||||
uchar* _staticAssignmentFileData;
|
uchar* _staticAssignmentFileData;
|
||||||
|
|
||||||
uint16_t* _numAssignmentsInStaticFile;
|
|
||||||
Assignment* _staticAssignments;
|
Assignment* _staticAssignments;
|
||||||
|
|
||||||
const char* _voxelServerConfig;
|
const char* _voxelServerConfig;
|
||||||
|
|
|
@ -49,8 +49,7 @@ void attachVoxelNodeDataToNode(Node* newNode) {
|
||||||
|
|
||||||
VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location location) :
|
VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location location) :
|
||||||
Assignment(command, Assignment::VoxelServerType, location),
|
Assignment(command, Assignment::VoxelServerType, location),
|
||||||
_serverTree(true),
|
_serverTree(true) {
|
||||||
_multiConfigList() {
|
|
||||||
_argc = 0;
|
_argc = 0;
|
||||||
_argv = NULL;
|
_argv = NULL;
|
||||||
|
|
||||||
|
@ -72,8 +71,7 @@ VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location locat
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes),
|
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes),
|
||||||
_serverTree(true),
|
_serverTree(true) {
|
||||||
_multiConfigList() {
|
|
||||||
_argc = 0;
|
_argc = 0;
|
||||||
_argv = NULL;
|
_argv = NULL;
|
||||||
|
|
||||||
|
@ -117,11 +115,9 @@ void VoxelServer::setArguments(int argc, char** argv) {
|
||||||
void VoxelServer::parsePayload() {
|
void VoxelServer::parsePayload() {
|
||||||
|
|
||||||
if (getNumPayloadBytes() > 0) {
|
if (getNumPayloadBytes() > 0) {
|
||||||
QString multiConfig((const char*) _payload);
|
QString config((const char*) _payload);
|
||||||
_multiConfigList = multiConfig.split(";");
|
|
||||||
|
|
||||||
// Now, parse the first config
|
// Now, parse the config
|
||||||
QString config = _multiConfigList.at(0);
|
|
||||||
QStringList configList = config.split(" ");
|
QStringList configList = config.split(" ");
|
||||||
|
|
||||||
int argCount = configList.size() + 1;
|
int argCount = configList.size() + 1;
|
||||||
|
@ -144,34 +140,6 @@ void VoxelServer::parsePayload() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelServer::parseOtherServerConfigs() {
|
|
||||||
// There there are multiple configs, then this instance will run the first
|
|
||||||
// config, and launch Assignment requests for the additional configs.
|
|
||||||
if (_multiConfigList.size() > 1) {
|
|
||||||
qDebug("Voxel Server received assignment for multiple Configs... config count=%d\n", _multiConfigList.size());
|
|
||||||
|
|
||||||
// skip 0 - that's the one we'll run
|
|
||||||
for (int i = 1; i < _multiConfigList.size(); i++) {
|
|
||||||
QString config = _multiConfigList.at(i);
|
|
||||||
|
|
||||||
qDebug(" config[%d]=%s\n", i, config.toLocal8Bit().constData());
|
|
||||||
|
|
||||||
Assignment voxelServerAssignment(Assignment::CreateCommand,
|
|
||||||
Assignment::VoxelServerType,
|
|
||||||
getLocation()); // use same location as we were created in.
|
|
||||||
|
|
||||||
// match this create request with our UUID so the DS knows who the create request is from
|
|
||||||
voxelServerAssignment.setUUID(_uuid);
|
|
||||||
|
|
||||||
int payloadLength = config.length() + sizeof(char);
|
|
||||||
voxelServerAssignment.setPayload((uchar*)config.toLocal8Bit().constData(), payloadLength);
|
|
||||||
|
|
||||||
qDebug("Requesting additional Voxel Server assignment to handle config %d\n", i);
|
|
||||||
NodeList::getInstance()->sendAssignment(voxelServerAssignment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//int main(int argc, const char * argv[]) {
|
//int main(int argc, const char * argv[]) {
|
||||||
void VoxelServer::run() {
|
void VoxelServer::run() {
|
||||||
|
|
||||||
|
@ -360,8 +328,6 @@ void VoxelServer::run() {
|
||||||
_voxelServerPacketProcessor->initialize(true);
|
_voxelServerPacketProcessor->initialize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFirstDomainPacket = true;
|
|
||||||
|
|
||||||
// loop to send to nodes requesting data
|
// loop to send to nodes requesting data
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
@ -401,14 +367,6 @@ void VoxelServer::run() {
|
||||||
// If the packet is a ping, let processNodeData handle it.
|
// If the packet is a ping, let processNodeData handle it.
|
||||||
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
||||||
} else if (packetData[0] == PACKET_TYPE_DOMAIN) {
|
} else if (packetData[0] == PACKET_TYPE_DOMAIN) {
|
||||||
|
|
||||||
if (isFirstDomainPacket) {
|
|
||||||
// this is the first packet we've received from the DS, parse the other server configs
|
|
||||||
// so we can make the appropriate create assignment requests
|
|
||||||
parseOtherServerConfigs();
|
|
||||||
isFirstDomainPacket = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
||||||
} else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
} else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
||||||
if (_jurisdictionSender) {
|
if (_jurisdictionSender) {
|
||||||
|
|
|
@ -80,10 +80,8 @@ private:
|
||||||
EnvironmentData _environmentData[3];
|
EnvironmentData _environmentData[3];
|
||||||
|
|
||||||
NodeWatcher _nodeWatcher; // used to cleanup AGENT data when agents are killed
|
NodeWatcher _nodeWatcher; // used to cleanup AGENT data when agents are killed
|
||||||
QStringList _multiConfigList;
|
|
||||||
|
|
||||||
void parsePayload();
|
void parsePayload();
|
||||||
void parseOtherServerConfigs();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __voxel_server__VoxelServer__
|
#endif // __voxel_server__VoxelServer__
|
||||||
|
|
Loading…
Reference in a new issue