Another versioning checkpoint + cleanup

This commit is contained in:
Leonardo Murillo 2015-08-13 16:35:55 -06:00
parent cda5b29fd3
commit 7c4813f1cf
7 changed files with 37 additions and 18 deletions

View file

@ -740,6 +740,7 @@ void DomainServer::processConnectRequestPacket(QSharedPointer<NLPacket> packet)
if (isAssignment) { if (isAssignment) {
nodeData->setAssignmentUUID(matchingQueuedAssignment->getUUID()); nodeData->setAssignmentUUID(matchingQueuedAssignment->getUUID());
nodeData->setWalletUUID(pendingAssigneeData->getWalletUUID()); nodeData->setWalletUUID(pendingAssigneeData->getWalletUUID());
nodeData->setNodeVersion(pendingAssigneeData->getNodeVersion());
// always allow assignment clients to create and destroy entities // always allow assignment clients to create and destroy entities
newNode->setCanAdjustLocks(true); newNode->setCanAdjustLocks(true);
@ -1170,7 +1171,8 @@ void DomainServer::processRequestAssignmentPacket(QSharedPointer<NLPacket> packe
// add the information for that deployed assignment to the hash of pending assigned nodes // add the information for that deployed assignment to the hash of pending assigned nodes
PendingAssignedNodeData* pendingNodeData = new PendingAssignedNodeData(assignmentToDeploy->getUUID(), PendingAssignedNodeData* pendingNodeData = new PendingAssignedNodeData(assignmentToDeploy->getUUID(),
requestAssignment.getWalletUUID()); requestAssignment.getWalletUUID(),
requestAssignment.getNodeVersion());
_pendingAssignedNodes.insert(uniqueAssignment.getUUID(), pendingNodeData); _pendingAssignedNodes.insert(uniqueAssignment.getUUID(), pendingNodeData);
} else { } else {
if (requestAssignment.getType() != Assignment::AgentType if (requestAssignment.getType() != Assignment::AgentType
@ -1480,6 +1482,7 @@ const char JSON_KEY_POOL[] = "pool";
const char JSON_KEY_PENDING_CREDITS[] = "pending_credits"; const char JSON_KEY_PENDING_CREDITS[] = "pending_credits";
const char JSON_KEY_WAKE_TIMESTAMP[] = "wake_timestamp"; const char JSON_KEY_WAKE_TIMESTAMP[] = "wake_timestamp";
const char JSON_KEY_USERNAME[] = "username"; const char JSON_KEY_USERNAME[] = "username";
const char JSON_KEY_VERSION[] = "version";
QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
QJsonObject nodeJson; QJsonObject nodeJson;
@ -1506,6 +1509,7 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
// add the node username, if it exists // add the node username, if it exists
nodeJson[JSON_KEY_USERNAME] = nodeData->getUsername(); nodeJson[JSON_KEY_USERNAME] = nodeData->getUsername();
nodeJson[JSON_KEY_VERSION] = nodeData->getNodeVersion();
SharedAssignmentPointer matchingAssignment = _allAssignments.value(nodeData->getAssignmentUUID()); SharedAssignmentPointer matchingAssignment = _allAssignments.value(nodeData->getAssignmentUUID());
if (matchingAssignment) { if (matchingAssignment) {

View file

@ -50,6 +50,10 @@ public:
const NodeSet& getNodeInterestSet() const { return _nodeInterestSet; } const NodeSet& getNodeInterestSet() const { return _nodeInterestSet; }
void setNodeInterestSet(const NodeSet& nodeInterestSet) { _nodeInterestSet = nodeInterestSet; } void setNodeInterestSet(const NodeSet& nodeInterestSet) { _nodeInterestSet = nodeInterestSet; }
void setNodeVersion(const QString& nodeVersion) { _nodeVersion = nodeVersion; }
const QString& getNodeVersion() { return _nodeVersion; }
private: private:
QJsonObject mergeJSONStatsFromNewObject(const QJsonObject& newObject, QJsonObject destinationObject); QJsonObject mergeJSONStatsFromNewObject(const QJsonObject& newObject, QJsonObject destinationObject);
@ -62,6 +66,7 @@ private:
HifiSockAddr _sendingSockAddr; HifiSockAddr _sendingSockAddr;
bool _isAuthenticated; bool _isAuthenticated;
NodeSet _nodeInterestSet; NodeSet _nodeInterestSet;
QString _nodeVersion;
}; };
#endif // hifi_DomainServerNodeData_h #endif // hifi_DomainServerNodeData_h

View file

@ -11,9 +11,10 @@
#include "PendingAssignedNodeData.h" #include "PendingAssignedNodeData.h"
PendingAssignedNodeData::PendingAssignedNodeData(const QUuid& assignmentUUID, const QUuid& walletUUID) : PendingAssignedNodeData::PendingAssignedNodeData(const QUuid& assignmentUUID, const QUuid& walletUUID, const QString& nodeVersion) :
_assignmentUUID(assignmentUUID), _assignmentUUID(assignmentUUID),
_walletUUID(walletUUID) _walletUUID(walletUUID),
_nodeVersion(nodeVersion)
{ {
} }

View file

@ -18,16 +18,20 @@
class PendingAssignedNodeData : public QObject { class PendingAssignedNodeData : public QObject {
Q_OBJECT Q_OBJECT
public: public:
PendingAssignedNodeData(const QUuid& assignmentUUID, const QUuid& walletUUID); PendingAssignedNodeData(const QUuid& assignmentUUID, const QUuid& walletUUID, const QString& nodeVersion);
void setAssignmentUUID(const QUuid& assignmentUUID) { _assignmentUUID = assignmentUUID; } void setAssignmentUUID(const QUuid& assignmentUUID) { _assignmentUUID = assignmentUUID; }
const QUuid& getAssignmentUUID() const { return _assignmentUUID; } const QUuid& getAssignmentUUID() const { return _assignmentUUID; }
void setWalletUUID(const QUuid& walletUUID) { _walletUUID = walletUUID; } void setWalletUUID(const QUuid& walletUUID) { _walletUUID = walletUUID; }
const QUuid& getWalletUUID() const { return _walletUUID; } const QUuid& getWalletUUID() const { return _walletUUID; }
const QString& getNodeVersion() const { return _nodeVersion; }
private: private:
QUuid _assignmentUUID; QUuid _assignmentUUID;
QUuid _walletUUID; QUuid _walletUUID;
QString _nodeVersion;
}; };
#endif // hifi_PendingAssignedNodeData_h #endif // hifi_PendingAssignedNodeData_h

View file

@ -13,8 +13,10 @@
#include "SharedUtil.h" #include "SharedUtil.h"
#include "UUID.h" #include "UUID.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDataStream> #include <QtCore/QDataStream>
#include <ApplicationVersion.h>
#include "Assignment.h" #include "Assignment.h"
Assignment::Type Assignment::typeForNodeType(NodeType_t nodeType) { Assignment::Type Assignment::typeForNodeType(NodeType_t nodeType) {
@ -52,11 +54,14 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, const
_location(location), _location(location),
_payload(), _payload(),
_isStatic(false), _isStatic(false),
_walletUUID() _walletUUID(),
_nodeVersion()
{ {
if (_command == Assignment::CreateCommand) { if (_command == Assignment::CreateCommand) {
// this is a newly created assignment, generate a random UUID // this is a newly created assignment, generate a random UUID
_uuid = QUuid::createUuid(); _uuid = QUuid::createUuid();
} else if (_command == Assignment::RequestCommand) {
_nodeVersion = BUILD_VERSION;
} }
} }
@ -64,11 +69,10 @@ Assignment::Assignment(NLPacket& packet) :
_pool(), _pool(),
_location(GlobalLocation), _location(GlobalLocation),
_payload(), _payload(),
_walletUUID() _walletUUID(),
_nodeVersion()
{ {
qDebug() << "LEOTEST: We are building an Assignment from a packet";
if (packet.getType() == PacketType::RequestAssignment) { if (packet.getType() == PacketType::RequestAssignment) {
qDebug() << "LEOTEST: This is a request assignment packet";
_command = Assignment::RequestCommand; _command = Assignment::RequestCommand;
} else if (packet.getType() == PacketType::CreateAssignment) { } else if (packet.getType() == PacketType::CreateAssignment) {
_command = Assignment::CreateCommand; _command = Assignment::CreateCommand;
@ -85,15 +89,14 @@ Assignment::Assignment(NLPacket& packet) :
Assignment::Assignment(const Assignment& otherAssignment) { Assignment::Assignment(const Assignment& otherAssignment) {
_uuid = otherAssignment._uuid; _uuid = otherAssignment._uuid;
_command = otherAssignment._command; _command = otherAssignment._command;
_type = otherAssignment._type; _type = otherAssignment._type;
_location = otherAssignment._location; _location = otherAssignment._location;
_pool = otherAssignment._pool; _pool = otherAssignment._pool;
_payload = otherAssignment._payload; _payload = otherAssignment._payload;
_walletUUID = otherAssignment._walletUUID; _walletUUID = otherAssignment._walletUUID;
_nodeVersion = otherAssignment._nodeVersion;
} }
Assignment& Assignment::operator=(const Assignment& rhsAssignment) { Assignment& Assignment::operator=(const Assignment& rhsAssignment) {
@ -112,6 +115,7 @@ void Assignment::swap(Assignment& otherAssignment) {
swap(_pool, otherAssignment._pool); swap(_pool, otherAssignment._pool);
swap(_payload, otherAssignment._payload); swap(_payload, otherAssignment._payload);
swap(_walletUUID, otherAssignment._walletUUID); swap(_walletUUID, otherAssignment._walletUUID);
swap(_nodeVersion, otherAssignment._nodeVersion);
} }
const char* Assignment::getTypeName() const { const char* Assignment::getTypeName() const {
@ -141,7 +145,13 @@ QDebug operator<<(QDebug debug, const Assignment &assignment) {
} }
QDataStream& operator<<(QDataStream &out, const Assignment& assignment) { QDataStream& operator<<(QDataStream &out, const Assignment& assignment) {
out << (quint8) assignment._type << assignment._uuid << assignment._pool << assignment._payload; out << (quint8) assignment._type;
if (assignment._command == Assignment::RequestCommand) {
out << assignment._nodeVersion;
}
out << assignment._uuid << assignment._pool << assignment._payload;
if (assignment._command == Assignment::RequestCommand) { if (assignment._command == Assignment::RequestCommand) {
out << assignment._walletUUID; out << assignment._walletUUID;
@ -154,7 +164,6 @@ QDataStream& operator>>(QDataStream &in, Assignment& assignment) {
quint8 packedType; quint8 packedType;
in >> packedType; in >> packedType;
if (assignment._command == Assignment::RequestCommand) { if (assignment._command == Assignment::RequestCommand) {
qDebug() << "We are extracting the version";
in >> assignment._nodeVersion; in >> assignment._nodeVersion;
} }
assignment._type = (Assignment::Type) packedType; assignment._type = (Assignment::Type) packedType;
@ -162,7 +171,6 @@ QDataStream& operator>>(QDataStream &in, Assignment& assignment) {
in >> assignment._uuid >> assignment._pool >> assignment._payload; in >> assignment._uuid >> assignment._pool >> assignment._payload;
if (assignment._command == Assignment::RequestCommand) { if (assignment._command == Assignment::RequestCommand) {
qDebug() << "LEOTEST: Operator for >> in case of RequestCommand";
in >> assignment._walletUUID; in >> assignment._walletUUID;
} }

View file

@ -83,6 +83,8 @@ public:
void setWalletUUID(const QUuid& walletUUID) { _walletUUID = walletUUID; } void setWalletUUID(const QUuid& walletUUID) { _walletUUID = walletUUID; }
const QUuid& getWalletUUID() const { return _walletUUID; } const QUuid& getWalletUUID() const { return _walletUUID; }
const QString& getNodeVersion() const { return _nodeVersion; }
const char* getTypeName() const; const char* getTypeName() const;
friend QDebug operator<<(QDebug debug, const Assignment& assignment); friend QDebug operator<<(QDebug debug, const Assignment& assignment);

View file

@ -546,14 +546,9 @@ void NodeList::sendAssignment(Assignment& assignment) {
? PacketType::CreateAssignment ? PacketType::CreateAssignment
: PacketType::RequestAssignment; : PacketType::RequestAssignment;
qDebug() << "LEOTEST: Packet type name " << nameForPacketType(assignmentPacketType);
auto assignmentPacket = NLPacket::create(assignmentPacketType); auto assignmentPacket = NLPacket::create(assignmentPacketType);
QDataStream packetStream(assignmentPacket.get()); QDataStream packetStream(assignmentPacket.get());
if (assignmentPacketType == PacketType::RequestAssignment) {
qDebug() << "LEOTEST: This is an assignment request, lets send the node version here " << BUILD_VERSION;
packetStream << BUILD_VERSION;
}
packetStream << assignment; packetStream << assignment;
// TODO: should this be a non sourced packet? // TODO: should this be a non sourced packet?