Removes Driller from GridMate
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -3820,10 +3820,8 @@ CarrierImpl::DisconnectRequest(ConnectionID id, CarrierDisconnectReason reason)
|
||||
case Carrier::CST_CONNECTED:
|
||||
{
|
||||
conn->m_state = Carrier::CST_DISCONNECTING;
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionStateChanged, this, conn, conn->m_state);
|
||||
m_handshake->OnDisconnect(conn);
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnDisconnect, this, id, reason);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnDisconnect, this, id, reason);
|
||||
|
||||
ThreadMessage* ctm = aznew ThreadMessage(CTM_DISCONNECT);
|
||||
ctm->m_connection = conn;
|
||||
@@ -3836,10 +3834,8 @@ CarrierImpl::DisconnectRequest(ConnectionID id, CarrierDisconnectReason reason)
|
||||
case Carrier::CST_CONNECTING:
|
||||
{
|
||||
conn->m_state = Carrier::CST_DISCONNECTING;
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionStateChanged, this, id, conn->m_state);
|
||||
m_handshake->OnDisconnect(conn);
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnFailedToConnect, this, id, reason);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnFailedToConnect, this, id, reason);
|
||||
|
||||
ThreadMessage* ctm = aznew ThreadMessage(CTM_DISCONNECT);
|
||||
ctm->m_connection = conn;
|
||||
@@ -3873,13 +3869,11 @@ CarrierImpl::DeleteConnection(Connection* conn, CarrierDisconnectReason reason)
|
||||
{
|
||||
m_handshake->OnDisconnect(conn);
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnDisconnect, this, conn, reason);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnDisconnect, this, conn, reason);
|
||||
} break;
|
||||
case Carrier::CST_CONNECTING:
|
||||
{
|
||||
m_handshake->OnDisconnect(conn);
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnFailedToConnect, this, conn, reason);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnFailedToConnect, this, conn, reason);
|
||||
} break;
|
||||
case Carrier::CST_DISCONNECTED:
|
||||
case Carrier::CST_DISCONNECTING:
|
||||
@@ -4271,7 +4265,6 @@ CarrierImpl::ProcessMainThreadMessages()
|
||||
m_connections.insert(conn);
|
||||
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnIncomingConnection, this, conn);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnIncomingConnection, this, conn);
|
||||
|
||||
ThreadMessage* ctm = aznew ThreadMessage(CTM_CONNECT);
|
||||
ctm->m_connection = conn;
|
||||
@@ -4306,7 +4299,6 @@ CarrierImpl::ProcessMainThreadMessages()
|
||||
ctm->m_threadConnection = threadConn;
|
||||
ctm->m_disconnectReason = msg->m_disconnectReason;
|
||||
m_thread->PushCarrierThreadMessage(ctm);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionStateChanged, this, msg->m_connection, msg->m_connection->m_state);
|
||||
}
|
||||
} break;
|
||||
case MTM_DELETE_CONNECTION:
|
||||
@@ -4333,7 +4325,6 @@ CarrierImpl::ProcessMainThreadMessages()
|
||||
if (msg->m_errorCode == CarrierErrorCode::EC_DRIVER)
|
||||
{
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnDriverError, this, msg->m_connection, msg->m_error.m_driverError);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnDriverError, this, msg->m_connection, msg->m_error.m_driverError);
|
||||
|
||||
if (msg->m_connection)
|
||||
{
|
||||
@@ -4344,7 +4335,6 @@ CarrierImpl::ProcessMainThreadMessages()
|
||||
else
|
||||
{
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnSecurityError, this, msg->m_connection, msg->m_error.m_securityError);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnSecurityError, this, msg->m_connection, msg->m_error.m_securityError);
|
||||
}
|
||||
} break;
|
||||
case MTM_RATE_UPDATE:
|
||||
@@ -4443,13 +4433,11 @@ CarrierImpl::ProcessSystemMessages()
|
||||
if (requestError == HandshakeErrorCode::OK)
|
||||
{
|
||||
conn->m_state = Carrier::CST_CONNECTED;
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionStateChanged, this, conn, conn->m_state);
|
||||
|
||||
SendSyncTime(); // send time first if we have the clock.
|
||||
SendSystemMessage(SM_CONNECT_ACK, wb, conn, SEND_RELIABLE);
|
||||
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnConnectionEstablished, this, conn);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionEstablished, this, conn);
|
||||
|
||||
ThreadMessage* ctm = aznew ThreadMessage(CTM_HANDSHAKE_COMPLETE);
|
||||
ctm->m_connection = conn;
|
||||
@@ -4494,9 +4482,7 @@ CarrierImpl::ProcessSystemMessages()
|
||||
m_pendingHandshakes.erase(PendingHandshake(conn)); // Connected -> no need to retry handshake anymore
|
||||
|
||||
conn->m_state = Carrier::CST_CONNECTED;
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionStateChanged, this, conn, conn->m_state);
|
||||
EBUS_EVENT_ID(m_gridMate, CarrierEventBus, OnConnectionEstablished, this, conn);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionEstablished, this, conn);
|
||||
|
||||
ThreadMessage* ctm = aznew ThreadMessage(CTM_HANDSHAKE_COMPLETE);
|
||||
ctm->m_connection = conn;
|
||||
@@ -4540,7 +4526,6 @@ CarrierImpl::ProcessSystemMessages()
|
||||
ctm->m_threadConnection = threadConn;
|
||||
ctm->m_disconnectReason = reason;
|
||||
m_thread->PushCarrierThreadMessage(ctm);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionStateChanged, this, conn, conn->m_state);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
} break;
|
||||
case SM_CLOCK_SYNC:
|
||||
@@ -4850,7 +4835,6 @@ CarrierImpl::DebugDeleteConnection(ConnectionID id)
|
||||
ctm->m_threadConnection = threadConn;
|
||||
ctm->m_disconnectReason = reason;
|
||||
m_thread->PushCarrierThreadMessage(ctm);
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnConnectionStateChanged, this, conn, conn->m_state);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include <GridMate/Carrier/Driver.h>
|
||||
#include <GridMate/Carrier/TrafficControl.h>
|
||||
|
||||
#include <AzCore/Driller/DrillerBus.h>
|
||||
#include <AzCore/Driller/Driller.h>
|
||||
#include "AzCore/std/smart_ptr/weak_ptr.h"
|
||||
|
||||
namespace GridMate
|
||||
@@ -485,60 +483,6 @@ namespace GridMate
|
||||
};
|
||||
|
||||
typedef AZ::EBus<CarrierEvents> CarrierEventBus;
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
class CarrierDrillerEvents
|
||||
: public CarrierEventsBase
|
||||
, public AZ::Debug::DrillerEBusTraits
|
||||
{
|
||||
public:
|
||||
virtual void OnIncomingConnection(Carrier* carrier, ConnectionID id) = 0;
|
||||
|
||||
virtual void OnFailedToConnect(Carrier* carrier, ConnectionID id, CarrierDisconnectReason reason) = 0;
|
||||
|
||||
virtual void OnConnectionEstablished(Carrier* carrier, ConnectionID id) = 0;
|
||||
|
||||
virtual void OnDisconnect(Carrier* carrier, ConnectionID id, CarrierDisconnectReason reason) = 0;
|
||||
|
||||
/// Report all carrier and driver errors! id == InvalidConnectionID if the error is not connection related!
|
||||
virtual void OnDriverError(Carrier* carrier, ConnectionID id, const DriverError& error) = 0;
|
||||
virtual void OnSecurityError(Carrier* carrier, ConnectionID id, const SecurityError& error) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Executed from NETWORK thread
|
||||
|
||||
// Driver
|
||||
/// SendTo
|
||||
/// ReceiveFrom
|
||||
/// Errors
|
||||
|
||||
// Traffic control
|
||||
|
||||
/// Called every second when you update last second statistics
|
||||
virtual void OnUpdateStatistics(const AZStd::string& address, const TrafficControl::Statistics& lastSecond, const TrafficControl::Statistics& lifeTime, const TrafficControl::Statistics& effectiveLastSecond, const TrafficControl::Statistics& effectiveLifeTime) = 0;
|
||||
|
||||
// Simulator
|
||||
/// Enable/Disable
|
||||
/// Change Simulator parameters
|
||||
|
||||
// Carrier
|
||||
virtual void OnConnectionStateChanged(Carrier* carrier, ConnectionID id, Carrier::ConnectionStates newState) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Executed from GAME/MAIN thread
|
||||
|
||||
// Handshake low level (we drill the handshake on session level too)
|
||||
|
||||
// Carrier - in addition to carrier events
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
typedef AZ::EBus<CarrierDrillerEvents> CarrierDrillerBus;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GM_CARRIER_H
|
||||
|
||||
@@ -591,9 +591,6 @@ DefaultTrafficControl::Update()
|
||||
//AZ_TracePrintf("GridMate","Traffic control: Connection %s LifeTime(rtt %.2f packetLoss %.2f) LastSecond(rtt %.2f packetLoss %.2f)\n",
|
||||
// cd.m_address.c_str(),cd.m_sdLifetime.m_rtt,cd.m_sdLifetime.m_packetLoss,cd.m_sdLastSecond.m_rtt,cd.m_sdLastSecond.m_packetLoss);
|
||||
|
||||
// send new statistics event
|
||||
EBUS_EVENT(Debug::CarrierDrillerBus, OnUpdateStatistics, cd.m_address, cd.m_sdLastSecond, cd.m_sdLifetime, cd.m_sdEffectiveLastSecond, cd.m_sdEffectiveLifetime);
|
||||
|
||||
cd.m_sdCurrentSecond.Reset();
|
||||
cd.m_sdCurrentSecond.m_rtt = cd.m_sdLastSecond.m_rtt;
|
||||
//cd.sdCurrentSecond.flow = 1.0f; // Good
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <GridMate/Drillers/CarrierDriller.h>
|
||||
#include <AzCore/Math/Crc.h>
|
||||
|
||||
using namespace AZ::Debug;
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
//=========================================================================
|
||||
// CarrierDriller
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
CarrierDriller::CarrierDriller()
|
||||
{
|
||||
m_drillerTag = AZ_CRC("CarrierDriller", 0x72a37d06);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Start
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::Start(const Param* params, int numParams)
|
||||
{
|
||||
(void)params;
|
||||
(void)numParams;
|
||||
CarrierDrillerBus::Handler::BusConnect();
|
||||
|
||||
/* get carriers and output all the data
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId"),carrier);
|
||||
m_output->BeginTag(AZ_CRC("StartDrill"));
|
||||
for(unsigned int iConn = 0; iConn < carrier->GetNumConnections(); ++iConn )
|
||||
{
|
||||
ConnectionID connId = carrier->GetConnectionId(iConn);
|
||||
m_output->BeginTag(AZ_CRC("Connection"));
|
||||
m_output->Write(AZ_CRC("Id"),connId);
|
||||
m_output->Write(AZ_CRC("Address"),carrier->ConnectionToAddress(connId));
|
||||
m_output->Write(AZ_CRC("State"),static_cast<int>(carrier->GetConnectionState(connId)));
|
||||
m_output->EndTag(AZ_CRC("Connection"));
|
||||
}
|
||||
m_output->EndTag(AZ_CRC("StartDrill"));
|
||||
m_output->EndTag(m_drillerTag);*/
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Stop
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::Stop()
|
||||
{
|
||||
CarrierDrillerBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// OnUpdateStatistics
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnUpdateStatistics(const AZStd::string& address, const TrafficControl::Statistics& lastSecond, const TrafficControl::Statistics& lifeTime, const TrafficControl::Statistics& effectiveLastSecond, const TrafficControl::Statistics& effectiveLifeTime)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("Statistics", 0xe2d38b22));
|
||||
m_output->Write(AZ_CRC("Address", 0x0d4e6f81), address);
|
||||
m_output->BeginTag(AZ_CRC("LastSecond", 0x5e6ccbee));
|
||||
m_output->Write(AZ_CRC("DataSend", 0xae94c282), lastSecond.m_dataSend);
|
||||
m_output->Write(AZ_CRC("DataReceived", 0xd92f8e4b), lastSecond.m_dataReceived);
|
||||
m_output->Write(AZ_CRC("DataResend", 0xe44a3086), lastSecond.m_dataResend);
|
||||
m_output->Write(AZ_CRC("DataAcked", 0xbb5e5496), lastSecond.m_dataAcked);
|
||||
m_output->Write(AZ_CRC("PacketSend", 0x5b52fa79), lastSecond.m_packetSend);
|
||||
m_output->Write(AZ_CRC("PacketReceived", 0xf247dd9e), lastSecond.m_packetReceived);
|
||||
m_output->Write(AZ_CRC("PacketLost", 0xbc64441e), lastSecond.m_packetLost);
|
||||
m_output->Write(AZ_CRC("PacketAcked", 0x91c4b93a), lastSecond.m_packetAcked);
|
||||
m_output->Write(AZ_CRC("PacketLoss", 0x2200d1bd), lastSecond.m_packetLoss);
|
||||
m_output->Write(AZ_CRC("rtt", 0xb40f6cfb), lastSecond.m_rtt);
|
||||
//m_output->Write(AZ_CRC("flow"),lastSecond.m_flow);
|
||||
m_output->EndTag(AZ_CRC("LastSecond", 0x5e6ccbee));
|
||||
m_output->BeginTag(AZ_CRC("LifeTime", 0x3de73088));
|
||||
m_output->Write(AZ_CRC("DataSend", 0xae94c282), lifeTime.m_dataSend);
|
||||
m_output->Write(AZ_CRC("DataReceived", 0xd92f8e4b), lifeTime.m_dataReceived);
|
||||
m_output->Write(AZ_CRC("DataResend", 0xe44a3086), lifeTime.m_dataResend);
|
||||
m_output->Write(AZ_CRC("DataAcked", 0xbb5e5496), lifeTime.m_dataAcked);
|
||||
m_output->Write(AZ_CRC("PacketSend", 0x5b52fa79), lifeTime.m_packetSend);
|
||||
m_output->Write(AZ_CRC("PacketReceived", 0xf247dd9e), lifeTime.m_packetReceived);
|
||||
m_output->Write(AZ_CRC("PacketLost", 0xbc64441e), lifeTime.m_packetLost);
|
||||
m_output->Write(AZ_CRC("PacketAcked", 0x91c4b93a), lifeTime.m_packetAcked);
|
||||
m_output->Write(AZ_CRC("PacketLoss", 0x2200d1bd), lifeTime.m_packetLoss);
|
||||
m_output->Write(AZ_CRC("rtt", 0xb40f6cfb), lifeTime.m_rtt);
|
||||
//m_output->Write(AZ_CRC("flow"),lifeTime.m_flow);
|
||||
m_output->EndTag(AZ_CRC("LifeTime", 0x3de73088));
|
||||
m_output->BeginTag(AZ_CRC("EffectiveLastSecond", 0x8f84642f));
|
||||
m_output->Write(AZ_CRC("DataSend", 0xae94c282), effectiveLastSecond.m_dataSend);
|
||||
m_output->Write(AZ_CRC("DataReceived", 0xd92f8e4b), effectiveLastSecond.m_dataReceived);
|
||||
m_output->Write(AZ_CRC("DataResend", 0xe44a3086), effectiveLastSecond.m_dataResend);
|
||||
m_output->Write(AZ_CRC("DataAcked", 0xbb5e5496), effectiveLastSecond.m_dataAcked);
|
||||
m_output->Write(AZ_CRC("PacketSend", 0x5b52fa79), effectiveLastSecond.m_packetSend);
|
||||
m_output->Write(AZ_CRC("PacketReceived", 0xf247dd9e), effectiveLastSecond.m_packetReceived);
|
||||
m_output->Write(AZ_CRC("PacketLost", 0xbc64441e), effectiveLastSecond.m_packetLost);
|
||||
m_output->Write(AZ_CRC("PacketAcked", 0x91c4b93a), effectiveLastSecond.m_packetAcked);
|
||||
m_output->Write(AZ_CRC("PacketLoss", 0x2200d1bd), effectiveLastSecond.m_packetLoss);
|
||||
m_output->Write(AZ_CRC("rtt", 0xb40f6cfb), effectiveLastSecond.m_rtt);
|
||||
//m_output->Write(AZ_CRC("flow"),effectiveLastSecond.m_flow);
|
||||
m_output->EndTag(AZ_CRC("EffectiveLastSecond", 0x8f84642f));
|
||||
m_output->BeginTag(AZ_CRC("EffectiveLifeTime", 0x4644a47a));
|
||||
m_output->Write(AZ_CRC("DataSend", 0xae94c282), effectiveLifeTime.m_dataSend);
|
||||
m_output->Write(AZ_CRC("DataReceived", 0xd92f8e4b), effectiveLifeTime.m_dataReceived);
|
||||
m_output->Write(AZ_CRC("DataResend", 0xe44a3086), effectiveLifeTime.m_dataResend);
|
||||
m_output->Write(AZ_CRC("DataAcked", 0xbb5e5496), effectiveLifeTime.m_dataAcked);
|
||||
m_output->Write(AZ_CRC("PacketSend", 0x5b52fa79), effectiveLifeTime.m_packetSend);
|
||||
m_output->Write(AZ_CRC("PacketReceived", 0xf247dd9e), effectiveLifeTime.m_packetReceived);
|
||||
m_output->Write(AZ_CRC("PacketLost", 0xbc64441e), effectiveLifeTime.m_packetLost);
|
||||
m_output->Write(AZ_CRC("PacketAcked", 0x91c4b93a), effectiveLifeTime.m_packetAcked);
|
||||
m_output->Write(AZ_CRC("PacketLoss", 0x2200d1bd), effectiveLifeTime.m_packetLoss);
|
||||
m_output->Write(AZ_CRC("rtt", 0xb40f6cfb), effectiveLifeTime.m_rtt);
|
||||
//m_output->Write(AZ_CRC("flow"),effectiveLifeTime.m_flow);
|
||||
m_output->EndTag(AZ_CRC("EffectiveLifeTime", 0x4644a47a));
|
||||
m_output->EndTag(AZ_CRC("Statistics", 0xe2d38b22));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnConnectionStateChanged
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnConnectionStateChanged(Carrier* carrier, ConnectionID id, Carrier::ConnectionStates newState)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId", 0x93f4bfbe), carrier);
|
||||
m_output->BeginTag(AZ_CRC("ConnectionState", 0x38a6a5da));
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), id);
|
||||
m_output->Write(AZ_CRC("State", 0xa393d2fb), static_cast<int>(newState));
|
||||
m_output->EndTag(AZ_CRC("ConnectionState", 0x38a6a5da));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnIncomingConnection
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnIncomingConnection(Carrier* carrier, ConnectionID id)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId", 0x93f4bfbe), carrier);
|
||||
m_output->BeginTag(AZ_CRC("IncomingConnection", 0x8c9d071a));
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), id);
|
||||
m_output->Write(AZ_CRC("Address", 0x0d4e6f81), carrier->ConnectionToAddress(id));
|
||||
m_output->EndTag(AZ_CRC("IncomingConnection", 0x8c9d071a));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnFailedToConnect
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnFailedToConnect(Carrier* carrier, ConnectionID id, CarrierDisconnectReason reason)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId", 0x93f4bfbe), carrier);
|
||||
m_output->BeginTag(AZ_CRC("FailedToConnect", 0xb6539549));
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), id);
|
||||
m_output->Write(AZ_CRC("Reason", 0x3bb8880c), ReasonToString(reason));
|
||||
m_output->EndTag(AZ_CRC("FailedToConnect", 0xb6539549));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnConnectionEstablished
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnConnectionEstablished(Carrier* carrier, ConnectionID id)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId", 0x93f4bfbe), carrier);
|
||||
m_output->BeginTag(AZ_CRC("ConnectionEstablished", 0xcde31aa7));
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), id);
|
||||
m_output->EndTag(AZ_CRC("ConnectionEstablished", 0xcde31aa7));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnDisconnect
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnDisconnect(Carrier* carrier, ConnectionID id, CarrierDisconnectReason reason)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId", 0x93f4bfbe), carrier);
|
||||
m_output->BeginTag(AZ_CRC("Disconnect", 0x003a4b91));
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), id);
|
||||
m_output->Write(AZ_CRC("Reason", 0x3bb8880c), ReasonToString(reason));
|
||||
m_output->EndTag(AZ_CRC("Disconnect", 0x003a4b91));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnDriverError
|
||||
// [12/14/2016]
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnDriverError(Carrier* carrier, ConnectionID id, const DriverError& error)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId", 0x93f4bfbe), carrier);
|
||||
m_output->BeginTag(AZ_CRC("DriverError", 0xe7522aff));
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), id);
|
||||
m_output->Write(AZ_CRC("ErrorCode", 0x499e660e), static_cast<int>(error.m_errorCode));
|
||||
m_output->EndTag(AZ_CRC("DriverError", 0xe7522aff));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnSecurityError
|
||||
//=========================================================================
|
||||
void CarrierDriller::OnSecurityError(Carrier* carrier, ConnectionID id, const SecurityError& error)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("CarrierId", 0x93f4bfbe), carrier);
|
||||
m_output->BeginTag(AZ_CRC("SecurityError", 0xdfe940ab));
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), id);
|
||||
m_output->Write(AZ_CRC("ErrorCode", 0x499e660e), static_cast<int>(error.m_errorCode));
|
||||
m_output->EndTag(AZ_CRC("SecurityError", 0xdfe940ab));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
} // namespace Debug
|
||||
} // namespace GridMate
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef GM_CARRIER_DRILLER_H
|
||||
#define GM_CARRIER_DRILLER_H
|
||||
|
||||
#include <GridMate/Types.h>
|
||||
#include <GridMate/Carrier/Carrier.h>
|
||||
#include <AzCore/Driller/Driller.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
/**
|
||||
* Carrier driller
|
||||
* \note Be careful which buses you attach. The drillers work in Multi threaded environment and expect that
|
||||
* a driller mutex (DrillerManager::DrillerManager) will be automatically locked on every write.
|
||||
* Otherwise in output stream corruption will happen (even is the stream is thread safe).
|
||||
*/
|
||||
class CarrierDriller
|
||||
: public AZ::Debug::Driller
|
||||
, public CarrierDrillerBus::Handler
|
||||
{
|
||||
int m_drillerTag;
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CarrierDriller, AZ::OSAllocator, 0);
|
||||
CarrierDriller();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Driller
|
||||
const char* GroupName() const override { return "GridMate"; }
|
||||
const char* GetName() const override { return "CarrierDriller"; }
|
||||
const char* GetDescription() const override { return "Drills Carrier/transport layer,traffic control, driver,etc."; }
|
||||
void Start(const Param* params = nullptr, int numParams = 0) override;
|
||||
void Stop() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Carrier Driller Bus
|
||||
void OnUpdateStatistics(const AZStd::string& address, const TrafficControl::Statistics& lastSecond, const TrafficControl::Statistics& lifeTime, const TrafficControl::Statistics& effectiveLastSecond, const TrafficControl::Statistics& effectiveLifeTime) override;
|
||||
void OnConnectionStateChanged(Carrier* carrier, ConnectionID id, Carrier::ConnectionStates newState) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Carrier Event Bus
|
||||
void OnIncomingConnection(Carrier* carrier, ConnectionID id) override;
|
||||
void OnFailedToConnect(Carrier* carrier, ConnectionID id, CarrierDisconnectReason reason) override;
|
||||
void OnConnectionEstablished(Carrier* carrier, ConnectionID id) override;
|
||||
void OnDisconnect(Carrier* carrier, ConnectionID id, CarrierDisconnectReason reason) override;
|
||||
void OnDriverError(Carrier* carrier, ConnectionID id, const DriverError& error) override;
|
||||
void OnSecurityError(Carrier* carrier, ConnectionID id, const SecurityError& error) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GM_CARRIER_DRILLER_H
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <GridMate/Drillers/ReplicaDriller.h>
|
||||
#include <GridMate/Replica/ReplicaChunk.h>
|
||||
#include <GridMate/Replica/ReplicaChunkDescriptor.h>
|
||||
#include <GridMate/Replica/RemoteProcedureCall.h>
|
||||
|
||||
using namespace AZ::Debug;
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
const AZ::Crc32 ReplicaDriller::Tags::REPLICA_DRILLER = AZ_CRC("ReplicaDriller", 0xd832f49a);
|
||||
|
||||
// Event Types
|
||||
const AZ::Crc32 ReplicaDriller::Tags::CHUNK_SEND_DATASET = AZ_CRC("ChunkSendDataSet", 0x085ea99b);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::CHUNK_RECEIVE_DATASET = AZ_CRC("ChunkReceiveDataSet", 0x8d4536db);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::CHUNK_SEND_RPC = AZ_CRC("ChunkSendRPC", 0x7c40afe0);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::CHUNK_RECEIVE_RPC = AZ_CRC("ChunkReceiveRPC", 0xb49b302d);
|
||||
|
||||
// Data Fields
|
||||
const AZ::Crc32 ReplicaDriller::Tags::REPLICA_NAME = AZ_CRC("ReplicaName", 0xc69b68ee);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::REPLICA_ID = AZ_CRC("ReplicaID", 0x394dd741);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::CHUNK_TYPE = AZ_CRC("TypeName", 0x115f811d);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::CHUNK_INDEX = AZ_CRC("ChunkIndex", 0x25ba3370);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::DATA_SET_NAME = AZ_CRC("DataSetName", 0xf22dbaae);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::DATA_SET_INDEX = AZ_CRC("DataSetIndex", 0x58d2421f);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::RPC_NAME = AZ_CRC("RPCName", 0x4c4cbf3a);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::RPC_INDEX = AZ_CRC("RPCIndex", 0xaf0e7447);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::SIZE = AZ_CRC("Size", 0xf7c0246a);
|
||||
const AZ::Crc32 ReplicaDriller::Tags::TIME_PROCESSED_MILLISEC = AZ_CRC("Time", 0x6f949845);
|
||||
|
||||
ReplicaDriller::ReplicaDriller()
|
||||
{
|
||||
}
|
||||
|
||||
void ReplicaDriller::Start(const Param* params, int numParams)
|
||||
{
|
||||
(void)params;
|
||||
(void)numParams;
|
||||
ReplicaDrillerBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void ReplicaDriller::Stop()
|
||||
{
|
||||
ReplicaDrillerBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void ReplicaDriller::OnSendDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len)
|
||||
{
|
||||
(void)from;
|
||||
(void)to;
|
||||
(void)data;
|
||||
|
||||
const char* dataSetName = chunk->GetDescriptor()->GetDataSetName(chunk, dataSet);
|
||||
size_t dataSetIndex = chunk->GetDescriptor()->GetDataSetIndex(chunk, dataSet);
|
||||
|
||||
m_output->BeginTag(Tags::REPLICA_DRILLER);
|
||||
m_output->BeginTag(Tags::CHUNK_SEND_DATASET);
|
||||
OutputBaseReplicaChunkTags(chunk, chunkIndex, len);
|
||||
m_output->Write(Tags::DATA_SET_NAME, dataSetName);
|
||||
m_output->Write(Tags::DATA_SET_INDEX, dataSetIndex);
|
||||
m_output->EndTag(Tags::CHUNK_SEND_DATASET);
|
||||
m_output->EndTag(Tags::REPLICA_DRILLER);
|
||||
}
|
||||
|
||||
void ReplicaDriller::OnReceiveDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len)
|
||||
{
|
||||
(void)from;
|
||||
(void)to;
|
||||
(void)data;
|
||||
|
||||
const char* dataSetName = chunk->GetDescriptor()->GetDataSetName(chunk, dataSet);
|
||||
size_t dataSetIndex = chunk->GetDescriptor()->GetDataSetIndex(chunk, dataSet);
|
||||
|
||||
m_output->BeginTag(Tags::REPLICA_DRILLER);
|
||||
m_output->BeginTag(Tags::CHUNK_RECEIVE_DATASET);
|
||||
OutputBaseReplicaChunkTags(chunk, chunkIndex, len);
|
||||
m_output->Write(Tags::DATA_SET_NAME, dataSetName);
|
||||
m_output->Write(Tags::DATA_SET_INDEX, dataSetIndex);
|
||||
m_output->EndTag(Tags::CHUNK_RECEIVE_DATASET);
|
||||
m_output->EndTag(Tags::REPLICA_DRILLER);
|
||||
}
|
||||
|
||||
void ReplicaDriller::OnSendRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len)
|
||||
{
|
||||
(void)from;
|
||||
(void)to;
|
||||
(void)data;
|
||||
|
||||
const char* rpcName = chunk->GetDescriptor()->GetRpcName(chunk, rpc->m_rpc);
|
||||
size_t rpcIndex = chunk->GetDescriptor()->GetRpcIndex(chunk, rpc->m_rpc);
|
||||
|
||||
|
||||
m_output->BeginTag(Tags::REPLICA_DRILLER);
|
||||
m_output->BeginTag(Tags::CHUNK_SEND_RPC);
|
||||
OutputBaseReplicaChunkTags(chunk, chunkIndex, len);
|
||||
m_output->Write(Tags::RPC_NAME, rpcName);
|
||||
m_output->Write(Tags::RPC_INDEX, rpcIndex);
|
||||
m_output->EndTag(Tags::CHUNK_SEND_RPC);
|
||||
m_output->EndTag(Tags::REPLICA_DRILLER);
|
||||
}
|
||||
void ReplicaDriller::OnReceiveRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len)
|
||||
{
|
||||
(void)from;
|
||||
(void)to;
|
||||
(void)data;
|
||||
|
||||
const char* rpcName = chunk->GetDescriptor()->GetRpcName(chunk, rpc->m_rpc);
|
||||
size_t rpcIndex = chunk->GetDescriptor()->GetRpcIndex(chunk, rpc->m_rpc);
|
||||
|
||||
m_output->BeginTag(Tags::REPLICA_DRILLER);
|
||||
m_output->BeginTag(Tags::CHUNK_RECEIVE_RPC);
|
||||
OutputBaseReplicaChunkTags(chunk, chunkIndex, len);
|
||||
m_output->Write(Tags::RPC_NAME, rpcName);
|
||||
m_output->Write(Tags::RPC_INDEX, rpcIndex);
|
||||
m_output->EndTag(Tags::CHUNK_RECEIVE_RPC);
|
||||
m_output->EndTag(Tags::REPLICA_DRILLER);
|
||||
}
|
||||
|
||||
void ReplicaDriller::OutputBaseReplicaChunkTags(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, size_t len)
|
||||
{
|
||||
const char* chunkTypeName = chunk->GetDescriptor()->GetChunkName();
|
||||
const char* replicaName = chunk->GetReplica()->GetDebugName();
|
||||
|
||||
m_output->Write(Tags::REPLICA_NAME, replicaName);
|
||||
m_output->Write(Tags::REPLICA_ID, chunk->GetReplicaId());
|
||||
m_output->Write(Tags::CHUNK_TYPE, chunkTypeName);
|
||||
m_output->Write(Tags::CHUNK_INDEX, chunkIndex);
|
||||
m_output->Write(Tags::SIZE, len);
|
||||
m_output->Write(Tags::TIME_PROCESSED_MILLISEC, AZStd::chrono::milliseconds(AZStd::chrono::system_clock::now().time_since_epoch()).count());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef GM_REPLICA_DRILLER_H
|
||||
#define GM_REPLICA_DRILLER_H
|
||||
|
||||
#include <GridMate/Types.h>
|
||||
#include <AzCore/Driller/Driller.h>
|
||||
#include <GridMate/Replica/Replica.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
class ReplicaDriller
|
||||
: public AZ::Debug::Driller
|
||||
, public GridMate::Debug::ReplicaDrillerBus::Handler
|
||||
{
|
||||
public:
|
||||
struct Tags
|
||||
{
|
||||
// Driller
|
||||
static const AZ::Crc32 REPLICA_DRILLER;
|
||||
|
||||
// Event Types
|
||||
static const AZ::Crc32 CHUNK_SEND_DATASET;
|
||||
static const AZ::Crc32 CHUNK_RECEIVE_DATASET;
|
||||
static const AZ::Crc32 CHUNK_SEND_RPC;
|
||||
static const AZ::Crc32 CHUNK_RECEIVE_RPC;
|
||||
|
||||
// Data Fields
|
||||
static const AZ::Crc32 REPLICA_NAME;
|
||||
static const AZ::Crc32 REPLICA_ID;
|
||||
static const AZ::Crc32 CHUNK_TYPE;
|
||||
static const AZ::Crc32 CHUNK_INDEX;
|
||||
static const AZ::Crc32 DATA_SET_NAME;
|
||||
static const AZ::Crc32 DATA_SET_INDEX;
|
||||
static const AZ::Crc32 RPC_NAME;
|
||||
static const AZ::Crc32 RPC_INDEX;
|
||||
static const AZ::Crc32 SIZE;
|
||||
static const AZ::Crc32 TIME_PROCESSED_MILLISEC;
|
||||
};
|
||||
|
||||
AZ_CLASS_ALLOCATOR(ReplicaDriller, AZ::OSAllocator, 0);
|
||||
ReplicaDriller();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Driller
|
||||
const char* GroupName() const override { return "GridMate"; }
|
||||
const char* GetName() const override { return "ReplicaDriller"; }
|
||||
const char* GetDescription() const override { return "Drills replicas."; }
|
||||
void Start(const Param* params = NULL, int numParams = 0) override;
|
||||
void Stop() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ReplicaDrillerEvents
|
||||
void OnSendDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len) override;
|
||||
void OnReceiveDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len) override;
|
||||
|
||||
void OnSendRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len) override;
|
||||
void OnReceiveRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
|
||||
void OutputBaseReplicaChunkTags(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, size_t len);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,275 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <GridMate/Drillers/SessionDriller.h>
|
||||
|
||||
using namespace AZ::Debug;
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
//=========================================================================
|
||||
// SessionDriller
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
SessionDriller::SessionDriller()
|
||||
{
|
||||
m_drillerTag = AZ_CRC("SessionDriller", 0x30b916a9);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Start
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void SessionDriller::Start(const Param* params, int numParams)
|
||||
{
|
||||
(void)params;
|
||||
(void)numParams;
|
||||
// Collect current session information ?
|
||||
SessionDrillerBus::Handler::BusConnect();
|
||||
|
||||
//
|
||||
//m_output->BeginTag(m_drillerTag);
|
||||
//m_output->BeginTag(AZ_CRC("StartDrill"));
|
||||
//if(sessionMgr->m_activeSession)
|
||||
//{
|
||||
// GridSession* gs = sessionMgr->m_activeSession;
|
||||
// // store the current session state
|
||||
// m_output->BeginTag(AZ_CRC("Session"));
|
||||
// m_output->Write(AZ_CRC("SessionId"),gs->GetId());
|
||||
// m_output->Write(AZ_CRC("Carrier"),gs->GetCarrier());
|
||||
// m_output->Write(AZ_CRC("ReplicaMgr"),gs->GetReplicaMgr());
|
||||
// m_output->Write(AZ_CRC("Topology"),(char)gs->GetTopology());
|
||||
// m_output->Write(AZ_CRC("Time"),gs->GetTime());
|
||||
// m_output->Write(AZ_CRC("State"),(char)gs->m_sm.GetCurrentState());
|
||||
// m_output->Write(AZ_CRC("IsHost"),gs->IsHost());
|
||||
// // There are endless params add as needed
|
||||
|
||||
// for(unsigned int i = 0; i < gs->GetNumberOfMembers(); ++i )
|
||||
// {
|
||||
// GridMember* gm = gs->GetMember(i);
|
||||
// m_output->BeginTag(AZ_CRC("Member"));
|
||||
// m_output->Write(AZ_CRC("Id"),gm->GetId().ToString());
|
||||
// m_output->Write(AZ_CRC("Name"),gm->GetName());
|
||||
// m_output->Write(AZ_CRC("ConnectionId"),gm->GetConnectionId());
|
||||
// m_output->Write(AZ_CRC("NAT"),(char)gm->GetNatType());
|
||||
// m_output->Write(AZ_CRC("CommFilter"),gm->GetCommFilter());
|
||||
// m_output->Write(AZ_CRC("IsHost"),gm->IsHost());
|
||||
// m_output->Write(AZ_CRC("IsLocal"),gm->IsLocal());
|
||||
// m_output->Write(AZ_CRC("IsInvited"),gm->IsInvited());
|
||||
// m_output->EndTag(AZ_CRC("Member"));
|
||||
// }
|
||||
|
||||
// m_output->EndTag(AZ_CRC("Session"));
|
||||
//}
|
||||
//else if(sessionMgr->m_activeSearch)
|
||||
//{
|
||||
// GridSearch* gs = sessionMgr->m_activeSearch;
|
||||
// m_output->BeginTag(AZ_CRC("GridSearch"));
|
||||
// m_output->Write(AZ_CRC("SearchId"),gs);
|
||||
// m_output->Write(AZ_CRC("IsDone"),gs->IsDone());
|
||||
// m_output->Write(AZ_CRC("NumResults"),gs->GetNumResults());
|
||||
// // add platform specific drill or just generic reporting
|
||||
// m_output->EndTag(AZ_CRC("GridSearch"));
|
||||
//}
|
||||
//m_output->EndTag(AZ_CRC("StartDrill"));
|
||||
//m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Stop
|
||||
// [4/14/2011]
|
||||
//=========================================================================
|
||||
void SessionDriller::Stop()
|
||||
{
|
||||
SessionDrillerBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// OnSessionServiceReady
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnSessionServiceReady()
|
||||
{
|
||||
// m_output->BeginTag(m_drillerTag);
|
||||
// m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// OnGridSearchComplete
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnGridSearchComplete(GridSearch* gridSearch)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("GridSearchComplete", 0x974b5717));
|
||||
m_output->Write(AZ_CRC("SearchId", 0x4f7ef2d2), gridSearch);
|
||||
m_output->Write(AZ_CRC("NumResults", 0xdfb1542f), gridSearch->GetNumResults());
|
||||
// add platform specific drill or just generic reporting
|
||||
m_output->EndTag(AZ_CRC("GridSearchComplete", 0x974b5717));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// OnMemberJoined
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnMemberJoined(GridSession* session, GridMember* member)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("MemberJoined", 0xbde4706c));
|
||||
m_output->Write(AZ_CRC("SessionId", 0xacd49154), session->GetId());
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), member->GetId().ToString());
|
||||
m_output->Write(AZ_CRC("Name", 0x5e237e06), member->GetName());
|
||||
m_output->Write(AZ_CRC("ConnectionId", 0x4592a200), member->GetConnectionId());
|
||||
m_output->Write(AZ_CRC("NAT", 0x9686d0fb), (char)member->GetNatType());
|
||||
//m_output->Write(AZ_CRC("MuteList"),member->GetMuteList());
|
||||
m_output->Write(AZ_CRC("IsHost", 0xce28a9cf), member->IsHost());
|
||||
m_output->Write(AZ_CRC("IsLocal", 0x4300d6d2), member->IsLocal());
|
||||
m_output->Write(AZ_CRC("IsInvited", 0x29d785f7), member->IsInvited());
|
||||
m_output->EndTag(AZ_CRC("MemberJoined", 0xbde4706c));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// OnMemberLeaving
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnMemberLeaving(GridSession* session, GridMember* member)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("MemberLeaving", 0xd10ee176));
|
||||
m_output->Write(AZ_CRC("SessionId", 0xacd49154), session->GetId());
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), member->GetId().ToString());
|
||||
m_output->EndTag(AZ_CRC("MemberLeaving", 0xd10ee176));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// OnMemberKicked
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnMemberKicked(GridSession* session, GridMember* member)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("MemberKicked", 0x908e74e6));
|
||||
m_output->Write(AZ_CRC("SessionId", 0xacd49154), session->GetId());
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), member->GetId().ToString());
|
||||
m_output->EndTag(AZ_CRC("MemberKicked", 0x908e74e6));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// OnSessionCreated
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnSessionCreated(GridSession* session)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("SessionCreated", 0x24655a62));
|
||||
m_output->Write(AZ_CRC("SessionId", 0xacd49154), session->GetId());
|
||||
m_output->Write(AZ_CRC("Carrier", 0x4739f11c), session->GetCarrier());
|
||||
m_output->Write(AZ_CRC("ReplicaMgr", 0x41cf3853), session->GetReplicaMgr());
|
||||
m_output->Write(AZ_CRC("Topology", 0x1198610c), (char)session->GetTopology());
|
||||
m_output->Write(AZ_CRC("Time", 0x6f949845), session->GetTime());
|
||||
m_output->Write(AZ_CRC("State", 0xa393d2fb), (char)session->m_sm.GetCurrentState());
|
||||
m_output->Write(AZ_CRC("IsHost", 0xce28a9cf), session->IsHost());
|
||||
m_output->EndTag(AZ_CRC("SessionCreated", 0x24655a62));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnSessionJoined
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnSessionJoined(GridSession* session)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("SessionJoined", 0x04b85d49));
|
||||
m_output->Write(AZ_CRC("SessionId", 0xacd49154), session->GetId());
|
||||
m_output->Write(AZ_CRC("Carrier", 0x4739f11c), session->GetCarrier());
|
||||
m_output->Write(AZ_CRC("ReplicaMgr", 0x41cf3853), session->GetReplicaMgr());
|
||||
m_output->Write(AZ_CRC("Topology", 0x1198610c), (char)session->GetTopology());
|
||||
m_output->Write(AZ_CRC("Time", 0x6f949845), session->GetTime());
|
||||
m_output->Write(AZ_CRC("State", 0xa393d2fb), (char)session->m_sm.GetCurrentState());
|
||||
m_output->Write(AZ_CRC("IsHost", 0xce28a9cf), session->IsHost());
|
||||
m_output->EndTag(AZ_CRC("SessionJoined", 0x04b85d49));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnSessionDelete
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnSessionDelete(GridSession* session)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("SessionDelete", 0x6b5728cd), session->GetId());
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnSessionError
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnSessionError(GridSession* session, const AZStd::string& errorMsg)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("SessionError", 0xc689cc40));
|
||||
m_output->Write(AZ_CRC("SessionId", 0xacd49154), session ? session->GetId() : "NoId");
|
||||
m_output->Write(AZ_CRC("Error", 0x5dddbc71), errorMsg);
|
||||
m_output->EndTag(AZ_CRC("SessionError", 0xc689cc40));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnSessionStart
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnSessionStart(GridSession* session)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("SessionStart", 0x042d25be), session->GetId());
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnSessionEnd
|
||||
// [4/15/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnSessionEnd(GridSession* session)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->Write(AZ_CRC("SessionEnd", 0x07821a5e), session->GetId());
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
//=========================================================================
|
||||
// OnWriteStatistics
|
||||
// [6/8/2011]
|
||||
//=========================================================================
|
||||
void
|
||||
SessionDriller::OnWriteStatistics(GridSession* session, GridMember* member, StatisticsData& data)
|
||||
{
|
||||
m_output->BeginTag(m_drillerTag);
|
||||
m_output->BeginTag(AZ_CRC("WriteStatistics", 0xcf7f12aa));
|
||||
m_output->Write(AZ_CRC("SessionId", 0xacd49154), session->GetId());
|
||||
m_output->Write(AZ_CRC("Id", 0xbf396750), member->GetId().ToString());
|
||||
// data...
|
||||
(void)data;
|
||||
m_output->EndTag(AZ_CRC("WriteStatistics", 0xcf7f12aa));
|
||||
m_output->EndTag(m_drillerTag);
|
||||
}
|
||||
} // namespace Debug
|
||||
} // namespace GridMate
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef GM_SESSION_DRILLER_H
|
||||
#define GM_SESSION_DRILLER_H
|
||||
|
||||
#include <GridMate/Types.h>
|
||||
#include <GridMate/Session/Session.h>
|
||||
#include <AzCore/Driller/Driller.h>
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
/**
|
||||
* Session Driller
|
||||
* \note Be careful which buses you attach. The drillers work in Multi threaded environment and expect that
|
||||
* a driller mutex (DrillerManager::DrillerManager) will be automatically locked on every write.
|
||||
* Otherwise in output stream corruption will happen (even is the stream is thread safe).
|
||||
*/
|
||||
class SessionDriller
|
||||
: public AZ::Debug::Driller
|
||||
, public SessionDrillerBus::Handler
|
||||
{
|
||||
int m_drillerTag;
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SessionDriller, AZ::OSAllocator, 0);
|
||||
SessionDriller();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Driller
|
||||
const char* GroupName() const override { return "GridMate"; }
|
||||
const char* GetName() const override { return "SessionDriller"; }
|
||||
const char* GetDescription() const override { return "Drills GridSession, Search, etc."; }
|
||||
void Start(const Param* params = NULL, int numParams = 0) override;
|
||||
void Stop() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Session Event Bus
|
||||
/// Callback that is called when the Session service is ready to process sessions.
|
||||
void OnSessionServiceReady() override;
|
||||
//virtual OnCommucationChanged() = 0 Callback that notifies the title when a member's communication settings change.
|
||||
/// Callback that notifies the title when a game search query have completed.
|
||||
void OnGridSearchComplete(GridSearch* gridSearch) override;
|
||||
/// Callback that notifies the title when a new member joins the game session.
|
||||
void OnMemberJoined(GridSession* session, GridMember* member) override;
|
||||
/// Callback that notifies the title that a member is leaving the game session. member pointer is NOT valid after the callback returns.
|
||||
void OnMemberLeaving(GridSession* session, GridMember* member) override;
|
||||
// \todo a better way will be (after we solve migration) is to supply a reason to OnMemberLeaving... like the member was kicked.
|
||||
// this will require that we actually remove the replica at the same moment.
|
||||
/// Callback that host decided to kick a member. You will receive a OnMemberLeaving when the actual member leaves the session.
|
||||
void OnMemberKicked(GridSession* session, GridMember* member) override;
|
||||
/// After this callback it is safe to access session features. If host session is fully operational if client wait for OnSessionJoined.
|
||||
void OnSessionCreated(GridSession* session) override;
|
||||
/// Called on client machines to indicate that we join successfully.
|
||||
void OnSessionJoined(GridSession* session) override;
|
||||
/// Callback that notifies the title when a session will be left. session pointer is NOT valid after the callback returns.
|
||||
void OnSessionDelete(GridSession* session) override;
|
||||
/// Called when a session error occurs.
|
||||
void OnSessionError(GridSession* session, const AZStd::string& errorMsg) override;
|
||||
/// Called when the actual game(match) starts
|
||||
void OnSessionStart(GridSession* session) override;
|
||||
/// Called when the actual game(match) ends
|
||||
void OnSessionEnd(GridSession* session) override;
|
||||
/// Called when we have our last chance to write statistics data for member in the session.
|
||||
void OnWriteStatistics(GridSession* session, GridMember* member, StatisticsData& data) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GM_SESSION_DRILLER_H
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <GridMate/Replica/RemoteProcedureCall.h>
|
||||
#include <GridMate/Replica/Replica.h>
|
||||
#include <GridMate/Replica/ReplicaChunkDescriptor.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
#include <GridMate/Replica/ReplicaUtils.h>
|
||||
|
||||
@@ -32,14 +31,12 @@ namespace GridMate
|
||||
m_replicaChunk->QueueRPCRequest(rpc);
|
||||
}
|
||||
|
||||
void RpcBase::OnRpcRequest(GridMate::Internal::RpcRequest* rpc) const
|
||||
void RpcBase::OnRpcRequest(GridMate::Internal::RpcRequest*) const
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnRequestRpc, m_replicaChunk, rpc);
|
||||
}
|
||||
|
||||
void RpcBase::OnRpcInvoke(GridMate::Internal::RpcRequest* rpc) const
|
||||
void RpcBase::OnRpcInvoke(GridMate::Internal::RpcRequest*) const
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnInvokeRpc, m_replicaChunk, rpc);
|
||||
}
|
||||
|
||||
PeerId RpcBase::GetSourcePeerId()
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <GridMate/Replica/Replica.h>
|
||||
#include <GridMate/Replica/ReplicaChunk.h>
|
||||
#include <GridMate/Replica/ReplicaChunkDescriptor.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
#include <GridMate/Replica/ReplicaFunctions.h>
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
#include <GridMate/Replica/ReplicaStatus.h>
|
||||
@@ -49,8 +48,6 @@ namespace GridMate
|
||||
replicaName = nullptr;
|
||||
#endif
|
||||
InternalCreateInitialChunks(replicaName);
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnCreateReplica, this);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
Replica::~Replica()
|
||||
@@ -96,8 +93,6 @@ namespace GridMate
|
||||
}
|
||||
}
|
||||
m_chunks.clear();
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnDestroyReplica, this);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Replica::Destroy()
|
||||
@@ -257,17 +252,12 @@ namespace GridMate
|
||||
//-----------------------------------------------------------------------------
|
||||
void Replica::OnActivate(const ReplicaContext& rc)
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnActivateReplica, this);
|
||||
|
||||
for (auto chunk : m_chunks)
|
||||
{
|
||||
if (chunk)
|
||||
{
|
||||
{
|
||||
GM_PROFILE_USER_CALLBACK("OnReplicaActivate");
|
||||
chunk->OnReplicaActivate(rc);
|
||||
}
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnActivateReplicaChunk, chunk.get());
|
||||
GM_PROFILE_USER_CALLBACK("OnReplicaActivate");
|
||||
chunk->OnReplicaActivate(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,17 +267,13 @@ namespace GridMate
|
||||
AZ_PROFILE_FUNCTION(GridMate);
|
||||
|
||||
EBUS_EVENT_ID(rc.m_rm->GetGridMate(), ReplicaMgrCallbackBus, OnDeactivateReplica, GetRepId(), rc.m_rm);
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnDeactivateReplica, this);
|
||||
|
||||
for (auto chunk : m_chunks)
|
||||
{
|
||||
if (chunk)
|
||||
{
|
||||
{
|
||||
GM_PROFILE_USER_CALLBACK("OnReplicaDeactivate");
|
||||
chunk->OnReplicaDeactivate(rc);
|
||||
}
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnDeactivateReplicaChunk, chunk.get());
|
||||
GM_PROFILE_USER_CALLBACK("OnReplicaDeactivate");
|
||||
chunk->OnReplicaDeactivate(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,8 +311,6 @@ namespace GridMate
|
||||
{
|
||||
if (IsPrimary())
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnRequestReplicaChangeOwnership, this, requestor);
|
||||
|
||||
if (IsMigratable() && requestor != m_manager->GetLocalPeerId())
|
||||
{
|
||||
bool accepted;
|
||||
@@ -595,7 +579,6 @@ namespace GridMate
|
||||
chunkInfo.m_payload.Init(128);
|
||||
mc.m_outBuffer = &chunkInfo.m_payload;
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSendReplicaChunkBegin, chunk.get(), static_cast<AZ::u32>(iChunk), mc.m_rm->GetLocalPeerId(), mc.m_peer->GetId());
|
||||
PackedSize writeOffset = mc.m_outBuffer->GetExactSize();
|
||||
// Write the ctor data if we need to
|
||||
if (mc.m_marshalFlags & ReplicaMarshalFlags::IncludeCtorData)
|
||||
@@ -606,7 +589,6 @@ namespace GridMate
|
||||
|
||||
// Marshal the chunk data
|
||||
chunk->Marshal(mc, static_cast<AZ::u32>(iChunk));
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSendReplicaChunkEnd, chunk.get(), static_cast<AZ::u32>(iChunk), mc.m_outBuffer->Get() + writeOffset.GetBytes(), mc.m_outBuffer->Size() - writeOffset.GetBytes());
|
||||
|
||||
// Precompute the chunk payload length and add to overall replica payload length
|
||||
PackedSize chunkLen = chunkInfo.m_payload.GetExactSize();
|
||||
@@ -696,9 +678,7 @@ namespace GridMate
|
||||
|
||||
if (chunk)
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaChunkBegin, chunk.get(), static_cast<AZ::u32>(iChunk), chunkContext.m_peer->GetId(), chunkContext.m_rm->GetLocalPeerId(), innerBuffer.Get(), chunkSize.GetSizeInBytesRoundUp());
|
||||
chunk->Unmarshal(chunkContext, static_cast<AZ::u32>(iChunk));
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaChunkEnd, chunk.get(), static_cast<AZ::u32>(iChunk));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <GridMate/Replica/Replica.h>
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
#include <GridMate/Replica/ReplicaUtils.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
#include <GridMate/Serialize/CompressionMarshal.h>
|
||||
|
||||
namespace GridMate
|
||||
@@ -41,13 +40,11 @@ namespace GridMate
|
||||
ReplicaChunkInitContext* initContext = ReplicaChunkDescriptorTable::Get().GetCurrentReplicaChunkInitContext();
|
||||
AZ_Assert(initContext, "Replica's descriptor is NOT pushed on the stack! Call Replica::Desriptor::Push() before construction!");
|
||||
initContext->m_chunk = this;
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnCreateReplicaChunk, this);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
ReplicaChunkBase::~ReplicaChunkBase()
|
||||
{
|
||||
AZ_Assert(m_refCount == 0, "Attempting to free replica with non-zero refCount(%d)!", m_refCount);
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnDestroyReplicaChunk, this);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReplicaChunkBase::Init(ReplicaChunkClassId chunkTypeId)
|
||||
@@ -332,7 +329,7 @@ namespace GridMate
|
||||
return dataSetMask;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReplicaChunkBase::MarshalDataSets(MarshalContext& mc, AZ::u32 chunkIndex)
|
||||
void ReplicaChunkBase::MarshalDataSets(MarshalContext& mc, [[maybe_unused]] AZ::u32 chunkIndex)
|
||||
{
|
||||
//AZ_PROFILE_SCOPE("GridMate");
|
||||
AZ::u32 dirtyDataSetMask = CalculateDirtyDataSetMask(mc);
|
||||
@@ -358,15 +355,6 @@ namespace GridMate
|
||||
ReadBuffer data = dataset->GetMarshalData();
|
||||
mc.m_outBuffer->WriteRaw(data.Get(), data.Size());
|
||||
wroteDataSet = true;
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSendDataSet,
|
||||
this,
|
||||
chunkIndex,
|
||||
dataset,
|
||||
mc.m_rm->GetLocalPeerId(),
|
||||
mc.m_peer->GetId(),
|
||||
data.Get(),
|
||||
data.Size().GetSizeInBytesRoundUp());
|
||||
}
|
||||
}
|
||||
if(wroteDataSet)
|
||||
@@ -380,7 +368,7 @@ namespace GridMate
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReplicaChunkBase::UnmarshalDataSets(UnmarshalContext& mc, AZ::u32 chunkIndex)
|
||||
void ReplicaChunkBase::UnmarshalDataSets(UnmarshalContext& mc, [[maybe_unused]] AZ::u32 chunkIndex)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(GridMate);
|
||||
|
||||
@@ -421,22 +409,12 @@ namespace GridMate
|
||||
dataset->MarkAsNonDefaultValue();
|
||||
m_nonDefaultValueBits.set(i);
|
||||
|
||||
const char* readPtr = mc.m_iBuf->GetCurrent();
|
||||
dataset->Unmarshal(mc);
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveDataSet,
|
||||
this,
|
||||
chunkIndex,
|
||||
dataset,
|
||||
mc.m_peer->GetId(),
|
||||
mc.m_rm->GetLocalPeerId(),
|
||||
readPtr,
|
||||
mc.m_iBuf->GetCurrent() - readPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReplicaChunkBase::MarshalRpcs(MarshalContext& mc, AZ::u32 chunkIndex)
|
||||
void ReplicaChunkBase::MarshalRpcs(MarshalContext& mc, [[maybe_unused]] AZ::u32 chunkIndex)
|
||||
{
|
||||
//AZ_PROFILE_SCOPE("GridMate");
|
||||
|
||||
@@ -467,22 +445,12 @@ namespace GridMate
|
||||
|
||||
AZ::u8 rpcIndex = static_cast<AZ::u8>(GetDescriptor()->GetRpcIndex(this, rpc->m_rpc));
|
||||
|
||||
auto bufferSize = mc.m_outBuffer->Size();
|
||||
|
||||
SafeGuardWrite(mc.m_outBuffer, [rpc, rpcIndex, &mc]()
|
||||
{
|
||||
mc.m_outBuffer->Write(rpcIndex);
|
||||
rpc->m_rpc->Marshal(*mc.m_outBuffer, rpc);
|
||||
});
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSendRpc,
|
||||
this,
|
||||
chunkIndex,
|
||||
rpc,
|
||||
mc.m_rm->GetLocalPeerId(),
|
||||
mc.m_peer->GetId(),
|
||||
mc.m_outBuffer->Get() + bufferSize,
|
||||
mc.m_outBuffer->Size() - bufferSize);
|
||||
rpc->m_relayed = !(mc.m_marshalFlags & ReplicaMarshalFlags::Authoritative); // marking upstream rpcs relayed, for downstream rpcs - replicamgr marks them relayed after marshaling is finished
|
||||
rpcsSent++;
|
||||
}
|
||||
@@ -494,7 +462,7 @@ namespace GridMate
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReplicaChunkBase::UnmarshalRpcs(UnmarshalContext& mc, AZ::u32 chunkIndex)
|
||||
void ReplicaChunkBase::UnmarshalRpcs(UnmarshalContext& mc, [[maybe_unused]] AZ::u32 chunkIndex)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(GridMate);
|
||||
|
||||
@@ -504,7 +472,7 @@ namespace GridMate
|
||||
{
|
||||
for (AZ::u32 rpcsRead = 0; rpcsRead < rpcCount; ++rpcsRead)
|
||||
{
|
||||
SafeGuardRead(mc.m_iBuf, [this, &mc, &chunkIndex]()
|
||||
SafeGuardRead(mc.m_iBuf, [this, &mc]()
|
||||
{
|
||||
unsigned char rpcIndex;
|
||||
if (!mc.m_iBuf->Read(rpcIndex))
|
||||
@@ -519,7 +487,6 @@ namespace GridMate
|
||||
return;
|
||||
}
|
||||
|
||||
const char* dataPtr = mc.m_iBuf->GetCurrent();
|
||||
Internal::RpcRequest* request = rpc->Unmarshal(*mc.m_iBuf);
|
||||
if (!request)
|
||||
{
|
||||
@@ -565,15 +532,6 @@ namespace GridMate
|
||||
request->m_sourcePeer = mc.m_peer->GetId();
|
||||
}
|
||||
|
||||
size_t dataSize = mc.m_iBuf->GetCurrent() - dataPtr;
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveRpc,
|
||||
this,
|
||||
chunkIndex,
|
||||
request,
|
||||
mc.m_peer->GetId(),
|
||||
mc.m_rm->GetLocalPeerId(),
|
||||
dataPtr,
|
||||
dataSize);
|
||||
m_rpcQueue.push_back(request);
|
||||
}
|
||||
else
|
||||
@@ -739,7 +697,6 @@ namespace GridMate
|
||||
|
||||
m_replica = replica;
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnAttachReplicaChunk, this);
|
||||
{
|
||||
GM_PROFILE_USER_CALLBACK("OnAttachedToReplica");
|
||||
OnAttachedToReplica(replica);
|
||||
@@ -751,7 +708,6 @@ namespace GridMate
|
||||
AZ_PROFILE_FUNCTION(GridMate);
|
||||
|
||||
AZ_Assert(m_replica, "Should be attached to a replica");
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnDetachReplicaChunk, this);
|
||||
{
|
||||
GM_PROFILE_USER_CALLBACK("OnDetachedFromReplica");
|
||||
OnDetachedFromReplica(m_replica);
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef GM_REPLICA_DRILLER_EVENTS_H
|
||||
#define GM_REPLICA_DRILLER_EVENTS_H
|
||||
|
||||
#include <AzCore/Driller/DrillerBus.h>
|
||||
|
||||
/*!
|
||||
* The replica system emits debugging EBus events via the ReplicaDrillerEvents interface.
|
||||
* To listen for these events, derive from ReplicaDrillerBus::Handler and implement all
|
||||
* the functions declared in the ReplicaDrillerEvents interface.
|
||||
*/
|
||||
|
||||
namespace GridMate
|
||||
{
|
||||
class Replica;
|
||||
class ReplicaChunk;
|
||||
class ReplicaChunkBase;
|
||||
class DataSetBase;
|
||||
typedef AZ::u32 PeerId;
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
struct RpcRequest;
|
||||
}
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
/*!
|
||||
* These are the driller events that the replica system will emit.
|
||||
* All functions in this interface should be implemented by the user.
|
||||
*/
|
||||
class ReplicaDrillerEvents
|
||||
: public AZ::Debug::DrillerEBusTraits
|
||||
{
|
||||
public:
|
||||
//! Called when a replica is instantiated. It doesn't mean it will be added to the system.
|
||||
virtual void OnCreateReplica(Replica* replica) { (void)replica; }
|
||||
//! Called when a replica is actually destroyed.
|
||||
virtual void OnDestroyReplica(Replica* replica) { (void)replica; }
|
||||
//! Called when a replica is added to the system.
|
||||
virtual void OnActivateReplica(Replica* replica) { (void)replica; }
|
||||
//! Called when a replica is removed from the system.
|
||||
virtual void OnDeactivateReplica(Replica* replica) { (void)replica; }
|
||||
//! Called every time the replica data is sent to a peer.
|
||||
virtual void OnSendReplicaBegin(Replica* replica) { (void)replica; }
|
||||
//! Called every time the replica data is sent to a peer.
|
||||
virtual void OnSendReplicaEnd(Replica* replica, const void* data, size_t len) { (void)replica; (void)data; (void)len; }
|
||||
//! Called when data is received for a replica. Called with nullptr replica pointer when data for unknown replica received.
|
||||
virtual void OnReceiveReplicaBegin(Replica* replica, const void* data, size_t len) { (void)replica; (void)data; (void)len; }
|
||||
//! Called when data is received for a replica. Called with nullptr replica pointer when data for unknown replica received.
|
||||
virtual void OnReceiveReplicaEnd(Replica* replica) { (void)replica; }
|
||||
//! Called when an ownership transfer request is received.
|
||||
virtual void OnRequestReplicaChangeOwnership(Replica* replica, PeerId requestor) { (void)replica; (void)requestor; }
|
||||
//! Called when a replica changes ownership, not necessarily to or from the local node.
|
||||
virtual void OnReplicaChangeOwnership(Replica* replica, bool wasPrimary) { (void)replica; (void)wasPrimary; }
|
||||
|
||||
//! Called when a chunk has been created. It doesn't mean it will be added to the system.
|
||||
//! Object will be partially constructed at this point if you inherit from ReplicaChunk
|
||||
virtual void OnCreateReplicaChunk(ReplicaChunkBase* chunk) { (void)chunk; }
|
||||
//! Called when a chuck is actually destroyed.
|
||||
virtual void OnDestroyReplicaChunk(ReplicaChunkBase* chunk) { (void)chunk; }
|
||||
//! Called when a chunk is added to the system.
|
||||
virtual void OnActivateReplicaChunk(ReplicaChunkBase* chunk) { (void)chunk; }
|
||||
//! Called when a chunk is removed from the system.
|
||||
virtual void OnDeactivateReplicaChunk(ReplicaChunkBase* chunk) { (void)chunk; }
|
||||
//! Called when a chunk is attached to a replica.
|
||||
virtual void OnAttachReplicaChunk(ReplicaChunkBase* chunk) { (void)chunk; }
|
||||
//! Called when a chunk is detached from a replica.
|
||||
virtual void OnDetachReplicaChunk(ReplicaChunkBase* chunk) { (void)chunk; }
|
||||
//! Called every time the chunk data is sent to a peer.
|
||||
virtual void OnSendReplicaChunkBegin(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, PeerId from, PeerId to) { (void)chunk; (void)chunkIndex; (void)from; (void)to; }
|
||||
//! Called every time the chunk data is sent to a peer.
|
||||
virtual void OnSendReplicaChunkEnd(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, const void* data, size_t len) { (void)chunk; (void)chunkIndex; (void)data; (void)len; }
|
||||
//! Called when data is received for a chunk.
|
||||
virtual void OnReceiveReplicaChunkBegin(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, PeerId from, PeerId to, const void* data, size_t len) { (void)chunk; (void)chunkIndex; (void)from; (void)to; (void)data; (void)len; }
|
||||
//! Called when data is received for a chunk.
|
||||
virtual void OnReceiveReplicaChunkEnd(ReplicaChunkBase* chunk, AZ::u32 chunkIndex) { (void)chunk; (void)chunkIndex; }
|
||||
|
||||
//! Called every time a dataset is sent to a peer.
|
||||
virtual void OnSendDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len) { (void)chunk; (void)chunkIndex; (void)dataSet; (void)from; (void)to; (void)data; (void)len; }
|
||||
//! Called when data is received for a dataset.
|
||||
virtual void OnReceiveDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len) { (void)chunk; (void)chunkIndex; (void)dataSet; (void)from; (void)to; (void)data; (void)len; }
|
||||
|
||||
//! Called when an rpc request is received. RpcRequest pointer will be null if rpc is called on primary replica.
|
||||
virtual void OnRequestRpc(ReplicaChunkBase* chunk, Internal::RpcRequest* rpc) { (void)chunk; (void)rpc; }
|
||||
//! Called when an rpc is invoked. RpcRequest pointer will be null if rpc is called on primary replica.
|
||||
virtual void OnInvokeRpc(ReplicaChunkBase* chunk, Internal::RpcRequest* rpc) { (void)chunk; (void)rpc; }
|
||||
//! Called every time an rpc is sent to a peer.
|
||||
virtual void OnSendRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len) { (void)chunk; (void)chunkIndex; (void)rpc; (void)from; (void)to; (void)data; (void)len; }
|
||||
//! Called when an rpc is received.
|
||||
virtual void OnReceiveRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len) { (void)chunk; (void)chunkIndex; (void)rpc; (void)from; (void)to; (void)data; (void)len; }
|
||||
|
||||
//! Called when a replica packet is sent.
|
||||
virtual void OnSend(PeerId to, const void* data, size_t len, bool isReliable) { (void)to; (void)data; (void)len; (void)isReliable; }
|
||||
//! Called when a replica packet is received.
|
||||
virtual void OnReceive(PeerId from, const void* data, size_t len) { (void)from; (void)data; (void)len; }
|
||||
};
|
||||
|
||||
/*!
|
||||
* Replica driller events are sent are sent via this the ReplicaDrillerBus.
|
||||
* To receive events, derive a handler from ReplicaDrillerBus::Handler and
|
||||
* attach it to the bus.
|
||||
*/
|
||||
typedef AZ::EBus<ReplicaDrillerEvents> ReplicaDrillerBus;
|
||||
} // namespace Debug
|
||||
} // namespace GridMate
|
||||
|
||||
#endif // GM_REPLICA_DRILLER_EVENTS_H
|
||||
|
||||
#pragma once
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <GridMate/Replica/MigrationSequence.h>
|
||||
#include <GridMate/Replica/Tasks/ReplicaMarshalTasks.h>
|
||||
#include <GridMate/Replica/Tasks/ReplicaUpdateTasks.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
#include <GridMate/Replica/ReplicaChunkDescriptor.h>
|
||||
#include <GridMate/Serialize/CompressionMarshal.h>
|
||||
|
||||
@@ -147,8 +146,6 @@ namespace GridMate
|
||||
|
||||
auto callback = AZStd::make_unique<PeerAckCallbacks>((m_reliableCallbacks));
|
||||
carrier->SendWithCallback(m_reliableOutBuffer.Get(), static_cast<unsigned int>(m_reliableOutBuffer.Size()), AZStd::move(callback), GetConnectionId(), Carrier::SEND_RELIABLE, Carrier::PRIORITY_NORMAL, commChannel);
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSend, GetId(), m_reliableOutBuffer.Get(), m_reliableOutBuffer.Size(), true);
|
||||
}
|
||||
|
||||
if (hasUnreliableData)
|
||||
@@ -164,8 +161,6 @@ namespace GridMate
|
||||
|
||||
auto callback = AZStd::make_unique<PeerAckCallbacks>((m_unreliableCallbacks));
|
||||
carrier->SendWithCallback(m_unreliableOutBuffer.Get(), static_cast<unsigned int>(m_unreliableOutBuffer.Size()), AZStd::move(callback), GetConnectionId(), Carrier::SEND_UNRELIABLE, Carrier::PRIORITY_NORMAL, commChannel);
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSend, GetId(), m_unreliableOutBuffer.Get(), m_unreliableOutBuffer.Size(), false);
|
||||
}
|
||||
// prepare for next cycle
|
||||
ResetBuffer();
|
||||
@@ -1024,9 +1019,6 @@ namespace GridMate
|
||||
*/
|
||||
while (!rb.IsEmptyIgnoreTrailingBits())
|
||||
{
|
||||
// This is used later to report the buffer information to driller.
|
||||
const char* cmdBufferBegin = rb.GetCurrent();
|
||||
|
||||
CmdId cmdhdr;
|
||||
if (!rb.Read(cmdhdr))
|
||||
{
|
||||
@@ -1179,10 +1171,8 @@ namespace GridMate
|
||||
return;
|
||||
}
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaBegin, pReplica.get(), cmdBufferBegin, rb.GetCurrent() - cmdBufferBegin);
|
||||
pReplica->Unmarshal(mc);
|
||||
OnReplicaUnmarshaled(pReplica);
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaEnd, pReplica.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1195,12 +1185,10 @@ namespace GridMate
|
||||
pReplica->SetSyncStage(isSyncStage);
|
||||
pReplica->SetMigratable(isMigratable);
|
||||
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaBegin, pReplica.get(), cmdBufferBegin, rb.GetCurrent() - cmdBufferBegin);
|
||||
pReplica->Unmarshal(mc);
|
||||
ReplicaContext rc(this, GetTime(), pFrom);
|
||||
RegisterReplica(pReplica, false, rc);
|
||||
OnReplicaUnmarshaled(pReplica);
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaEnd, pReplica.get());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1268,11 +1256,9 @@ namespace GridMate
|
||||
}
|
||||
if (pObj->m_upstreamHop)
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaBegin, pObj.get(), cmdBufferBegin, rb.GetCurrent() - cmdBufferBegin);
|
||||
mc.m_peer = pFrom;
|
||||
pObj->Unmarshal(mc);
|
||||
OnReplicaUnmarshaled(pObj);
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceiveReplicaEnd, pObj.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1332,7 +1318,6 @@ namespace GridMate
|
||||
}
|
||||
|
||||
ReadBuffer rb(GetGridMate()->GetDefaultEndianType(), m_receiveBuffer.data(), result.m_numBytes);
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReceive, peer->GetId(), rb.Get(), rb.Size().GetSizeInBytesRoundUp());
|
||||
_Unmarshal(rb, peer);
|
||||
AZ_Assert(rb.IsEmptyIgnoreTrailingBits(), "We did not process the whole message!");
|
||||
}
|
||||
@@ -1655,7 +1640,6 @@ namespace GridMate
|
||||
{
|
||||
replica->SetPrimary(isPrimary);
|
||||
replica->OnChangeOwnership(rc);
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnReplicaChangeOwnership, replica.get(), wasPrimary);
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <GridMate/Replica/SystemReplicas.h>
|
||||
#include <GridMate/Replica/Tasks/ReplicaMarshalTasks.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
#include <GridMate/Replica/ReplicaStatus.h>
|
||||
#include <GridMate/Replica/ReplicaUtils.h>
|
||||
@@ -72,12 +71,10 @@ namespace GridMate
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReplicaMarshalTaskBase::OnSendReplicaBegin()
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSendReplicaBegin, m_replica.get());
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void ReplicaMarshalTaskBase::OnSendReplicaEnd(ReplicaPeer* to, const void* data, size_t len)
|
||||
void ReplicaMarshalTaskBase::OnSendReplicaEnd(ReplicaPeer* to, const void*, size_t len)
|
||||
{
|
||||
EBUS_EVENT(Debug::ReplicaDrillerBus, OnSendReplicaEnd, m_replica.get(), data, len);
|
||||
to->m_sentBytes += static_cast<int>(len);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -882,7 +882,6 @@ LANSession::OnStateHostMigrateSession(AZ::HSM& sm, const AZ::HSM::Event& e)
|
||||
{
|
||||
// check the output for more info
|
||||
AZStd::string errorMsg = AZStd::string::format("Failed to initialize socket at port %d!", hostPort);
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionError, this, errorMsg);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionError, this, errorMsg);
|
||||
// We can't be a real host if we failed to provide matching services.
|
||||
Leave(false);
|
||||
@@ -1146,7 +1145,6 @@ void LANSessionService::OnServiceRegistered(IGridMate* gridMate)
|
||||
|
||||
LANSessionServiceBus::Handler::BusConnect(gridMate);
|
||||
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionServiceReady);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionServiceReady);
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +316,6 @@ GridSession::Shutdown()
|
||||
m_carrier->Shutdown();
|
||||
}
|
||||
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionDelete, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionDelete, this);
|
||||
|
||||
m_state = nullptr;
|
||||
@@ -438,7 +437,6 @@ GridSession::Update()
|
||||
memberStateIter = m_unboundMemberStates.erase(memberStateIter);
|
||||
|
||||
// Both member and client state are valid! send member joined message
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMemberJoined, this, member);
|
||||
EBUS_EVENT_ID(GetGridMate(), SessionEventBus, OnMemberJoined, this, member);
|
||||
}
|
||||
else
|
||||
@@ -1221,7 +1219,6 @@ GridSession::OnDriverError(Carrier* carrier, ConnectionID id, const DriverError&
|
||||
}
|
||||
uintptr_t idInt = reinterpret_cast<uintptr_t>(static_cast<void*>(id));
|
||||
AZStd::string errorMsg = AZStd::string::format("Carrier driver error ConnectionID: %" PRIuPTR "ErrorCode: 0x%08x", idInt, error.m_errorCode);
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionError, this, errorMsg);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionError, this, errorMsg);
|
||||
|
||||
if (id != InvalidConnectionID)
|
||||
@@ -1249,7 +1246,6 @@ GridSession::OnSecurityError(Carrier* carrier, ConnectionID id, const SecurityEr
|
||||
}
|
||||
uintptr_t idInt = reinterpret_cast<uintptr_t>(static_cast<void*>(id));
|
||||
AZStd::string errorMsg = AZStd::string::format("Carrier security error ConnectionID: %" PRIuPTR " ErrorCode: 0x%08x", idInt, error.m_errorCode);
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionError, this, errorMsg);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -1276,7 +1272,6 @@ GridSession::ElectNewHost()
|
||||
// AZ_Assert(m_sm.IsInState(SS_HOST_MIGRATE_ELECTION),"We should be in host migrate election state to call this function!");
|
||||
GridMember* newHost = nullptr; // Allow the user to choose
|
||||
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMigrationElectHost, this, newHost);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnMigrationElectHost, this, newHost);
|
||||
|
||||
if (newHost == nullptr || newHost->GetConnectionId() == InvalidConnectionID || newHost->IsHost())
|
||||
@@ -1497,7 +1492,6 @@ GridSession::OnStateJoin(HSM& sm, const HSM::Event& e)
|
||||
{
|
||||
case SE_JOINED:
|
||||
{
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionJoined, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionJoined, this);
|
||||
sm.Transition(SS_IDLE);
|
||||
} return true;
|
||||
@@ -1591,7 +1585,6 @@ GridSession::OnStateCreate(HSM& sm, const HSM::Event& e)
|
||||
}
|
||||
|
||||
sm.Transition(SS_IDLE);
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionCreated, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionCreated, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionHosted, this);
|
||||
}
|
||||
@@ -1616,7 +1609,6 @@ GridSession::OnStateCreate(HSM& sm, const HSM::Event& e)
|
||||
|
||||
m_carrier->Connect(m_hostAddress);
|
||||
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionCreated, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionCreated, this);
|
||||
}
|
||||
|
||||
@@ -1639,7 +1631,6 @@ GridSession::OnStateStart(HSM& sm, const HSM::Event& e)
|
||||
{
|
||||
case HSM::EnterEventId:
|
||||
{
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionStart, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionStart, this);
|
||||
} return true;
|
||||
}
|
||||
@@ -1660,7 +1651,6 @@ GridSession::OnStateEnd(HSM& sm, const HSM::Event& e)
|
||||
{
|
||||
case HSM::EnterEventId:
|
||||
{
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnSessionEnd, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnSessionEnd, this);
|
||||
} return true;
|
||||
}
|
||||
@@ -1710,7 +1700,6 @@ GridSession::OnStateHostMigrateElection(AZ::HSM& sm, const AZ::HSM::Event& e)
|
||||
m_hostMigrationInProcess = true;
|
||||
m_handshake->SetHostMigration(true);
|
||||
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMigrationStart, this);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnMigrationStart, this);
|
||||
|
||||
m_hostMigrationTimeOut = m_state ? m_state->m_hostMigrationTimeout.Get() : 0;
|
||||
@@ -1890,7 +1879,6 @@ GridSession::OnStateHostMigrateSession(AZ::HSM& sm, const AZ::HSM::Event& e)
|
||||
|
||||
GridMember* host = GetHost();
|
||||
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMigrationEnd, this, host);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnMigrationEnd, this, host);
|
||||
|
||||
m_myMember->m_clientState->m_newHostVote.Set(0);
|
||||
@@ -2004,7 +1992,6 @@ GridMember::OnReplicaActivate(const ReplicaContext& rc)
|
||||
rc.m_rm->AddPrimary(m_clientState->GetReplica());
|
||||
|
||||
// Both member and client state are valid! send member joined message
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMemberJoined, m_session, this);
|
||||
EBUS_EVENT_ID(m_session->GetGridMate(), SessionEventBus, OnMemberJoined, m_session, this);
|
||||
}
|
||||
}
|
||||
@@ -2021,7 +2008,6 @@ GridMember::OnReplicaDeactivate(const ReplicaContext& rc)
|
||||
if (m_clientState)
|
||||
{
|
||||
// We are deleting the member so send leave message (we are always keeping member <-> state together).
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMemberLeaving, m_session, this);
|
||||
EBUS_EVENT_ID(m_session->GetGridMate(), SessionEventBus, OnMemberLeaving, m_session, this);
|
||||
|
||||
m_clientState->m_member = nullptr;
|
||||
@@ -2072,7 +2058,6 @@ GridMember::OnKick(AZ::u8 reason, const RpcContext& rc)
|
||||
// 2 Kick messages in quick succession can cause this to crash otherwise.
|
||||
if (m_session && m_session->GetHost() && rc.m_sourcePeer == m_session->GetHost()->GetIdCompact()) //Only the host can kick
|
||||
{
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMemberKicked, m_session, this);
|
||||
EBUS_EVENT_ID(m_session->GetGridMate(), SessionEventBus, OnMemberKicked, m_session, this, reason);
|
||||
|
||||
if (IsLocal())
|
||||
@@ -2325,7 +2310,6 @@ GridMemberStateReplica::OnReplicaDeactivate(const ReplicaContext& rc)
|
||||
if (m_member)
|
||||
{
|
||||
// client state is gone send leave message
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnMemberLeaving, m_member->m_session, m_member);
|
||||
EBUS_EVENT_ID(m_member->GetSession()->GetGridMate(), SessionEventBus, OnMemberLeaving, m_member->m_session, m_member);
|
||||
|
||||
m_member->m_clientState = nullptr;
|
||||
@@ -2519,7 +2503,6 @@ SessionService::Update()
|
||||
it = m_activeSearches.erase(it);
|
||||
m_completedSearches.push_back(search);
|
||||
|
||||
EBUS_DBG_EVENT(Debug::SessionDrillerBus, OnGridSearchComplete, search);
|
||||
EBUS_EVENT_ID(m_gridMate, SessionEventBus, OnGridSearchComplete, search);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -28,10 +28,6 @@ namespace GridMate
|
||||
|
||||
extern const EndianType kSessionEndian;
|
||||
|
||||
namespace Debug {
|
||||
class SessionDriller;
|
||||
}
|
||||
|
||||
typedef AZ::u32 MemberIDCompact;
|
||||
/**
|
||||
* MemberID interface class.
|
||||
@@ -403,7 +399,6 @@ namespace GridMate
|
||||
friend class Internal::GridSessionReplica;
|
||||
friend class Internal::GridMemberStateReplica;
|
||||
friend class SessionService;
|
||||
friend class Debug::SessionDriller;
|
||||
public:
|
||||
enum CarrierChannels
|
||||
{
|
||||
@@ -742,7 +737,6 @@ namespace GridMate
|
||||
: public GridMateService
|
||||
{
|
||||
friend class GridSession;
|
||||
friend class Debug::SessionDriller;
|
||||
friend class GridSearch;
|
||||
public:
|
||||
typedef vector<GridSession*> SessionArrayType;
|
||||
@@ -936,62 +930,6 @@ namespace GridMate
|
||||
};
|
||||
}
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
/**
|
||||
* Session driller events,
|
||||
* this events are in addition to the session event bus
|
||||
*/
|
||||
class SessionDrillerEvents
|
||||
: public AZ::Debug::DrillerEBusTraits
|
||||
{
|
||||
public:
|
||||
virtual ~SessionDrillerEvents() {}
|
||||
|
||||
/// Callback that is called when the Session service is ready to process sessions.
|
||||
virtual void OnSessionServiceReady() {}
|
||||
|
||||
//virtual OnCommucationChanged() = 0 Callback that notifies the title when a member's communication settings change.
|
||||
|
||||
/// Callback when we start a grid search.
|
||||
virtual void OnGridSearchStart(GridSearch* gridSearch) { (void)gridSearch; }
|
||||
/// Callback that notifies the title when a game search query have completed.
|
||||
virtual void OnGridSearchComplete(GridSearch* gridSearch) { (void)gridSearch; }
|
||||
/// Callback when we release (delete) a grid search. It's not safe to hold the grid pointer after this.
|
||||
virtual void OnGridSearchRelease(GridSearch* gridSearch) { (void)gridSearch; }
|
||||
|
||||
/// Callback that notifies the title when a new member joins the game session.
|
||||
virtual void OnMemberJoined(GridSession* session, GridMember* member) { (void)session; (void)member; }
|
||||
/// Callback that notifies the title that a member is leaving the game session. member pointer is NOT valid after the callback returns.
|
||||
virtual void OnMemberLeaving(GridSession* session, GridMember* member) { (void)session; (void)member; }
|
||||
// \todo a better way will be (after we solve migration) is to supply a reason to OnMemberLeaving... like the member was kicked.
|
||||
// this will require that we actually remove the replica at the same moment.
|
||||
/// Callback that host decided to kick a member. You will receive a OnMemberLeaving when the actual member leaves the session.
|
||||
virtual void OnMemberKicked(GridSession* session, GridMember* member) { (void)session; (void)member; }
|
||||
/// After this callback it is safe to access session features. If host session is fully operational if client wait for OnSessionJoined.
|
||||
virtual void OnSessionCreated(GridSession* session) { (void)session; }
|
||||
/// Called on client machines to indicate that we join successfully.
|
||||
virtual void OnSessionJoined(GridSession* session) { (void)session; }
|
||||
/// Callback that notifies the title when a session will be left. session pointer is NOT valid after the callback returns.
|
||||
virtual void OnSessionDelete(GridSession* session) { (void)session; }
|
||||
/// Called when a session error occurs.
|
||||
virtual void OnSessionError(GridSession* session, const AZStd::string& errorMsg) { (void)session; (void)errorMsg; }
|
||||
/// Called when the actual game(match) starts
|
||||
virtual void OnSessionStart(GridSession* session) { (void)session; }
|
||||
/// Called when the actual game(match) ends
|
||||
virtual void OnSessionEnd(GridSession* session) { (void)session; }
|
||||
/// Called when we start a host migration.
|
||||
virtual void OnMigrationStart(GridSession* session) { (void)session; }
|
||||
/// Called so the user can select a member that should be the new Host. Value will be ignored if NULL, current host or the member has invalid connection id.
|
||||
virtual void OnMigrationElectHost(GridSession* session, GridMember*& newHost) { (void)session; (void)newHost; }
|
||||
/// Called when the host migration has completed.
|
||||
virtual void OnMigrationEnd(GridSession* session, GridMember* newHost) { (void)session; (void)newHost; }
|
||||
/// Called when we have our last chance to write statistics data for member in the session.
|
||||
virtual void OnWriteStatistics(GridSession* session, GridMember* member, StatisticsData& data) { (void)session; (void)member; (void)data; }
|
||||
};
|
||||
|
||||
typedef AZ::EBus<SessionDrillerEvents> SessionDrillerBus;
|
||||
}
|
||||
} // namespace GridMate
|
||||
|
||||
#endif // GM_SESSION_H
|
||||
|
||||
@@ -45,12 +45,6 @@ set(FILES
|
||||
Containers/unordered_map.h
|
||||
Containers/unordered_set.h
|
||||
Containers/vector.h
|
||||
Drillers/CarrierDriller.cpp
|
||||
Drillers/CarrierDriller.h
|
||||
Drillers/ReplicaDriller.cpp
|
||||
Drillers/ReplicaDriller.h
|
||||
Drillers/SessionDriller.cpp
|
||||
Drillers/SessionDriller.h
|
||||
Online/OnlineUtilityThread.h
|
||||
Online/UserServiceTypes.h
|
||||
Replica/BasicHostChunkDescriptor.h
|
||||
@@ -71,7 +65,6 @@ set(FILES
|
||||
Replica/ReplicaChunkInterface.h
|
||||
Replica/ReplicaCommon.h
|
||||
Replica/ReplicaDefs.h
|
||||
Replica/ReplicaDrillerEvents.h
|
||||
Replica/ReplicaFunctions.h
|
||||
Replica/ReplicaFunctions.inl
|
||||
Replica/ReplicaInline.inl
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,6 @@
|
||||
#include <GridMate/Replica/Replica.h>
|
||||
#include <GridMate/Replica/ReplicaFunctions.h>
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
#include <GridMate/Serialize/CompressionMarshal.h>
|
||||
|
||||
using namespace GridMate;
|
||||
@@ -584,837 +583,5 @@ namespace ReplicaBehavior {
|
||||
AZStd::array<MPSession, 10> m_sessions;
|
||||
};
|
||||
|
||||
/*
|
||||
* A hook to intercept the payload size of a replica and it's contents.
|
||||
*/
|
||||
class ReplicaDrillerHook
|
||||
: public Debug::ReplicaDrillerBus::Handler
|
||||
{
|
||||
public:
|
||||
ReplicaDrillerHook()
|
||||
{
|
||||
}
|
||||
|
||||
void OnSendReplicaEnd(Replica* /*replica*/, const void* /*data*/, size_t len) override
|
||||
{
|
||||
m_replicaLengths.push_back(len);
|
||||
}
|
||||
|
||||
void ResetCounts([[maybe_unused]] bool trace = false)
|
||||
{
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
if (trace && m_replicaLengths.size() > 0)
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "Driller saw replicas with the following byte sizes:\n");
|
||||
for (auto length : m_replicaLengths)
|
||||
{
|
||||
AZ_TracePrintf("GridMate", "\t\t\t %d \n", length);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
m_replicaLengths.clear();
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::u64> m_replicaLengths;
|
||||
};
|
||||
|
||||
template <typename ReplicaChunkType>
|
||||
class FilteredHook : public ReplicaDrillerHook
|
||||
{
|
||||
public:
|
||||
void OnSendReplicaEnd(Replica* replica, const void* /*data*/, size_t len) override
|
||||
{
|
||||
if (ContainsChunkTypeWeWant(replica))
|
||||
{
|
||||
m_replicaLengths.push_back(len);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool ContainsChunkTypeWeWant(Replica* replica) const
|
||||
{
|
||||
auto numChunks = replica->GetNumChunks();
|
||||
for (size_t i = 0; i < numChunks; i++)
|
||||
{
|
||||
auto chunk = replica->GetChunkByIndex(i);
|
||||
if (chunk->GetDescriptor()->GetChunkName() == ReplicaChunkType::GetChunkName())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* The most basic functionality test for sending datasets that have a default value and have not yet been modified
|
||||
* from their constructor values.
|
||||
*
|
||||
* This is a simple sanity check to ensure the logic sends the update when it's necessary.
|
||||
*/
|
||||
class Replica_DontSendDataSets_WithNoDiffFromCtorData
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Replica_DontSendDataSets_WithNoDiffFromCtorData()
|
||||
: m_replicaIdDefault(InvalidReplicaId), m_replicaIdModified(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
{
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
|
||||
auto chunk = CreateAndAttachReplicaChunk<LargeChunkWithDefaults>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(chunk->Data1.IsDefaultValue());
|
||||
AZ_TEST_ASSERT(chunk->Data2.IsDefaultValue());
|
||||
|
||||
m_replicaIdDefault = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
}
|
||||
|
||||
const int ExpectedReplicaSizeWithDefaults = 37;
|
||||
const int ExpectedReplicaSizeWithNonDefaults = 46;
|
||||
|
||||
TestStatus Tick(int tick) override
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 20:
|
||||
{
|
||||
{
|
||||
ReplicaPtr rep = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaIdDefault);
|
||||
AZ_TEST_ASSERT(rep);
|
||||
|
||||
auto chunk = rep->FindReplicaChunk<LargeChunkWithDefaults>();
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
auto replicaSize = m_driller.m_replicaLengths[0];
|
||||
AZ_TEST_ASSERT(replicaSize == ExpectedReplicaSizeWithDefaults);
|
||||
m_driller.ResetCounts();
|
||||
}
|
||||
// create another replica with non-default values
|
||||
{
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
|
||||
auto chunk = CreateAndAttachReplicaChunk<LargeChunkWithDefaults>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
AZ_TEST_ASSERT(chunk->Data1.IsDefaultValue());
|
||||
AZ_TEST_ASSERT(chunk->Data2.IsDefaultValue());
|
||||
chunk->Data1.Set(4242);
|
||||
chunk->Data2.Set(4242);
|
||||
AZ_TEST_ASSERT(!chunk->Data1.IsDefaultValue());
|
||||
AZ_TEST_ASSERT(!chunk->Data2.IsDefaultValue());
|
||||
|
||||
m_replicaIdModified = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 40:
|
||||
{
|
||||
{
|
||||
ReplicaPtr rep = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaIdModified);
|
||||
AZ_TEST_ASSERT(rep);
|
||||
|
||||
auto chunk = rep->FindReplicaChunk<LargeChunkWithDefaults>();
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
auto replicaSize = m_driller.m_replicaLengths[0];
|
||||
AZ_TEST_ASSERT(replicaSize == ExpectedReplicaSizeWithNonDefaults);
|
||||
m_driller.ResetCounts();
|
||||
|
||||
// check that non-default values are set for the dataset
|
||||
{
|
||||
AZ_TEST_ASSERT(!chunk->Data1.IsDefaultValue());
|
||||
auto value = chunk->Data1.Get();
|
||||
AZ_TEST_ASSERT(value == 4242);
|
||||
}
|
||||
{
|
||||
AZ_TEST_ASSERT(!chunk->Data2.IsDefaultValue());
|
||||
auto value = chunk->Data2.Get();
|
||||
AZ_TEST_ASSERT(value == 4242);
|
||||
}
|
||||
}
|
||||
m_driller.ResetCounts(true);
|
||||
break;
|
||||
}
|
||||
case 45:
|
||||
{
|
||||
{
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaIdDefault)->Destroy();
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaIdModified)->Destroy();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 50:
|
||||
return TestStatus::Completed;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
}
|
||||
|
||||
ReplicaId m_replicaIdDefault;
|
||||
ReplicaId m_replicaIdModified;
|
||||
FilteredHook<LargeChunkWithDefaults> m_driller;
|
||||
};
|
||||
|
||||
TEST(Replica_DontSendDataSets_WithNoDiffFromCtorData, DISABLED_Replica_DontSendDataSets_WithNoDiffFromCtorData)
|
||||
{
|
||||
Replica_DontSendDataSets_WithNoDiffFromCtorData tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
/*
|
||||
* This test checks the actual size of the replica as marshalled in the binary payload.
|
||||
* The assessment of the payload size is done using driller EBus.
|
||||
*/
|
||||
class ReplicaDefaultDataSetDriller
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
ReplicaDefaultDataSetDriller()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
static const int NonDefaultValue = 4242;
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
LargeChunkWithDefaults* chunk = CreateAndAttachReplicaChunk<LargeChunkWithDefaults>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~ReplicaDefaultDataSetDriller() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
TestStatus Tick(int tick) override
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
auto rep = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
AZ_TEST_ASSERT(rep);
|
||||
|
||||
m_driller.ResetCounts();
|
||||
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
ReplicaPtr replica = m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
auto chunk = replica->FindReplicaChunk<LargeChunkWithDefaults>();
|
||||
int nonDefaultValue = NonDefaultValue;
|
||||
auto touch = [nonDefaultValue](DataSet<int>& dataSet) { dataSet.Set(nonDefaultValue); };
|
||||
touch(chunk->Data1);
|
||||
touch(chunk->Data2);
|
||||
touch(chunk->Data3);
|
||||
|
||||
m_driller.ResetCounts();
|
||||
|
||||
break;
|
||||
}
|
||||
case 20:
|
||||
{
|
||||
auto repLengths = m_driller.m_replicaLengths;
|
||||
m_driller.ResetCounts();
|
||||
|
||||
// check exact expected sizes
|
||||
const auto countUnreliable = 4;
|
||||
const auto countReliable = 1;
|
||||
const auto expectedReplicaSize = 22;
|
||||
|
||||
AZ_TEST_ASSERT(repLengths.size() == countUnreliable + countReliable);
|
||||
for (auto length : repLengths)
|
||||
{
|
||||
AZ_TEST_ASSERT(length == expectedReplicaSize);
|
||||
}
|
||||
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId)->Destroy();
|
||||
break;
|
||||
}
|
||||
case 25:
|
||||
{
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
}
|
||||
|
||||
ReplicaDrillerHook m_driller;
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
const int ReplicaDefaultDataSetDriller::NonDefaultValue;
|
||||
|
||||
TEST(ReplicaDefaultDataSetDriller, DISABLED_ReplicaDefaultDataSetDriller)
|
||||
{
|
||||
ReplicaDefaultDataSetDriller tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
/*
|
||||
* This test checks the actual size of the replica as marshalled in the binary payload.
|
||||
* The assessment of the payload size is done using driller EBus.
|
||||
*/
|
||||
class Replica_ComparePackingBoolsVsU8
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
Replica_ComparePackingBoolsVsU8()
|
||||
: m_replicaBoolsId(InvalidReplicaId)
|
||||
, m_replicaU8Id(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica1 = Replica::CreateReplica(nullptr);
|
||||
ChunkWithBools* chunk1 = CreateAndAttachReplicaChunk<ChunkWithBools>(replica1);
|
||||
AZ_TEST_ASSERT(chunk1);
|
||||
|
||||
m_replicaBoolsId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica1);
|
||||
|
||||
ReplicaPtr replica2 = Replica::CreateReplica(nullptr);
|
||||
ChunkWithShortInts* chunk2 = CreateAndAttachReplicaChunk<ChunkWithShortInts>(replica2);
|
||||
AZ_TEST_ASSERT(chunk2);
|
||||
|
||||
m_replicaU8Id = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica2);
|
||||
}
|
||||
|
||||
~Replica_ComparePackingBoolsVsU8() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
TestStatus Tick(int tick) override
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
auto rep1 = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaBoolsId);
|
||||
AZ_TEST_ASSERT(rep1);
|
||||
auto rep2 = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaU8Id);
|
||||
AZ_TEST_ASSERT(rep2);
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
// we have to poke the values so that they become non-default
|
||||
{
|
||||
ReplicaPtr replica = m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaBoolsId);
|
||||
auto chunk = replica->FindReplicaChunk<ChunkWithBools>();
|
||||
|
||||
auto touch = [](DataSet<bool>& dataSet) { dataSet.Set(true); };
|
||||
touch(chunk->Data1);
|
||||
touch(chunk->Data2);
|
||||
touch(chunk->Data3);
|
||||
touch(chunk->Data4);
|
||||
touch(chunk->Data5);
|
||||
touch(chunk->Data6);
|
||||
touch(chunk->Data7);
|
||||
touch(chunk->Data8);
|
||||
touch(chunk->Data9);
|
||||
touch(chunk->Data10);
|
||||
}
|
||||
{
|
||||
ReplicaPtr replica = m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaU8Id);
|
||||
auto chunk = replica->FindReplicaChunk<ChunkWithShortInts>();
|
||||
|
||||
auto touch = [](DataSet<AZ::u8>& dataSet) { dataSet.Set(42); };
|
||||
touch(chunk->Data1);
|
||||
touch(chunk->Data2);
|
||||
touch(chunk->Data3);
|
||||
touch(chunk->Data4);
|
||||
touch(chunk->Data5);
|
||||
touch(chunk->Data6);
|
||||
touch(chunk->Data7);
|
||||
touch(chunk->Data8);
|
||||
touch(chunk->Data9);
|
||||
touch(chunk->Data10);
|
||||
}
|
||||
m_driller.ResetCounts();
|
||||
|
||||
break;
|
||||
}
|
||||
case 30:
|
||||
{
|
||||
auto repLengths = m_driller.m_replicaLengths;
|
||||
m_driller.ResetCounts();
|
||||
|
||||
// check exact expected sizes
|
||||
const auto expectedReplicaSizeWithBools = 12;
|
||||
const auto expectedReplicaSizeWithShortInts = 20;
|
||||
|
||||
AZ_TEST_ASSERT(repLengths.size() >= 2);
|
||||
AZ_TEST_ASSERT(AZStd::find(repLengths.begin(), repLengths.end(), expectedReplicaSizeWithBools));
|
||||
AZ_TEST_ASSERT(AZStd::find(repLengths.begin(), repLengths.end(), expectedReplicaSizeWithShortInts));
|
||||
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaBoolsId)->Destroy();
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaU8Id)->Destroy();
|
||||
break;
|
||||
}
|
||||
case 35:
|
||||
{
|
||||
//auto boolDatasetSize = m_driller.m_boolChunkLengths[1];
|
||||
//auto u8DatasetSize = m_driller.m_u8ChunkLengths[1];
|
||||
//AZ_TEST_ASSERT(boolDatasetSize < u8DatasetSize); // Observed example: 5bytes < 13bytes
|
||||
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
}
|
||||
|
||||
ReplicaDrillerHook m_driller;
|
||||
ReplicaId m_replicaBoolsId;
|
||||
ReplicaId m_replicaU8Id;
|
||||
};
|
||||
|
||||
TEST(Replica_ComparePackingBoolsVsU8, DISABLED_Replica_ComparePackingBoolsVsU8)
|
||||
{
|
||||
Replica_ComparePackingBoolsVsU8 tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class CheckDataSetStreamIsntWrittenMoreThanNecessary
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessary()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
static const int NonDefaultValue = 4242;
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
auto chunk = CreateAndAttachReplicaChunk<CustomMarshalerTestChunk>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~CheckDataSetStreamIsntWrittenMoreThanNecessary() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
CustomMarshalerTestChunk::Ptr GetHostChunk()
|
||||
{
|
||||
ReplicaPtr replica = m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
auto chunk = replica->FindReplicaChunk<CustomMarshalerTestChunk>();
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
TestStatus Tick(int tick) override
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
auto rep = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
AZ_TEST_ASSERT(rep);
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
auto chunk = GetHostChunk();
|
||||
//chunk->Data1.Set(CustomInt(41));
|
||||
|
||||
const auto& m = chunk->Data1.GetMarshaler();
|
||||
// Only the initial setup call should have occurred
|
||||
AZ_TEST_ASSERT(m.m_marshalCalls == 1);
|
||||
m.m_marshalCalls = 0;
|
||||
m_driller.ResetCounts();
|
||||
|
||||
break;
|
||||
}
|
||||
case 42:
|
||||
{
|
||||
auto chunk = GetHostChunk();
|
||||
const auto& m = chunk->Data1.GetMarshaler();
|
||||
// No reason for any new calls to occur
|
||||
AZ_TEST_ASSERT(m.m_marshalCalls == 0);
|
||||
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId)->Destroy();
|
||||
break;
|
||||
}
|
||||
case 45:
|
||||
{
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
}
|
||||
|
||||
ReplicaDrillerHook m_driller;
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(CheckDataSetStreamIsntWrittenMoreThanNecessary, DISABLED_CheckDataSetStreamIsntWrittenMoreThanNecessary)
|
||||
{
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessary tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
static const int NonDefaultValue = 4242;
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
auto chunk = CreateAndAttachReplicaChunk<CustomMarshalerTestChunk>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
CustomMarshalerTestChunk::Ptr GetHostChunk()
|
||||
{
|
||||
ReplicaPtr replica = m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
auto chunk = replica->FindReplicaChunk<CustomMarshalerTestChunk>();
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
TestStatus Tick(int tick) override
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
auto rep = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
AZ_TEST_ASSERT(rep);
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
auto chunk = GetHostChunk();
|
||||
chunk->Data1.Set(CustomInt(41));
|
||||
|
||||
const auto& m = chunk->Data1.GetMarshaler();
|
||||
// Only the initial setup call
|
||||
AZ_TEST_ASSERT(m.m_marshalCalls == 1);
|
||||
m.m_marshalCalls = 0;
|
||||
m_driller.ResetCounts();
|
||||
|
||||
break;
|
||||
}
|
||||
case 42:
|
||||
{
|
||||
auto chunk = GetHostChunk();
|
||||
const auto& m = chunk->Data1.GetMarshaler();
|
||||
AZ_TEST_ASSERT(m.m_marshalCalls == 6 /* 5 unreliables + 1 reliable */);
|
||||
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId)->Destroy();
|
||||
break;
|
||||
}
|
||||
case 45:
|
||||
{
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
}
|
||||
|
||||
ReplicaDrillerHook m_driller;
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty, DISABLED_CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty)
|
||||
{
|
||||
CheckDataSetStreamIsntWrittenMoreThanNecessaryOnceDirty tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class CheckReplicaIsntSentWithNoChanges
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
CheckReplicaIsntSentWithNoChanges()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
ForcingDirtyTestChunk* chunk = CreateAndAttachReplicaChunk<ForcingDirtyTestChunk>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~CheckReplicaIsntSentWithNoChanges() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
const int NewValue = 999;
|
||||
const int MomentaryValue = 1;
|
||||
const int ExpectedNumberReplicasSent = 6;
|
||||
|
||||
ReplicaPtr GetHostReplica()
|
||||
{
|
||||
return m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
}
|
||||
|
||||
TestStatus Tick(int tick) override
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 9:
|
||||
{
|
||||
auto rep = GetHostReplica();
|
||||
AZ_TEST_ASSERT(rep);
|
||||
m_driller.ResetCounts();
|
||||
|
||||
auto chunk = rep->FindReplicaChunk<ForcingDirtyTestChunk>();
|
||||
chunk->Data1.Set(NewValue);
|
||||
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
auto rep = GetHostReplica();
|
||||
AZ_TEST_ASSERT(rep);
|
||||
|
||||
auto counts = m_driller.m_replicaLengths.size();
|
||||
AZ_TEST_ASSERT(counts == ExpectedNumberReplicasSent);
|
||||
m_driller.ResetCounts();
|
||||
|
||||
auto chunk = rep->FindReplicaChunk<ForcingDirtyTestChunk>();
|
||||
chunk->Data1.Set(MomentaryValue);
|
||||
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
auto rep = GetHostReplica();
|
||||
AZ_TEST_ASSERT(rep);
|
||||
auto chunk = rep->FindReplicaChunk<ForcingDirtyTestChunk>();
|
||||
chunk->Data1.Set(NewValue);
|
||||
|
||||
auto counts = m_driller.m_replicaLengths.size();
|
||||
AZ_TEST_ASSERT(counts == 1);
|
||||
m_driller.ResetCounts();
|
||||
|
||||
break;
|
||||
}
|
||||
case 100:
|
||||
{
|
||||
auto counts = m_driller.m_replicaLengths.size();
|
||||
AZ_TEST_ASSERT(counts == ExpectedNumberReplicasSent);
|
||||
m_driller.ResetCounts();
|
||||
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId)->Destroy();
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
}
|
||||
|
||||
FilteredHook<ForcingDirtyTestChunk> m_driller;
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(CheckReplicaIsntSentWithNoChanges, DISABLED_CheckReplicaIsntSentWithNoChanges)
|
||||
{
|
||||
CheckReplicaIsntSentWithNoChanges tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
class CheckEntityScriptReplicaIsntSentWithNoChanges
|
||||
: public SimpleBehaviorTest
|
||||
{
|
||||
public:
|
||||
CheckEntityScriptReplicaIsntSentWithNoChanges()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
auto chunk = CreateAndAttachReplicaChunk<EntityLikeScriptReplicaChunk>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~CheckEntityScriptReplicaIsntSentWithNoChanges() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
const int NewValue = 999;
|
||||
const int MomentaryValue = 1;
|
||||
const int ExpectedNumberReplicasSent = 6;
|
||||
|
||||
ReplicaPtr GetHostReplica()
|
||||
{
|
||||
return m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
}
|
||||
|
||||
TestStatus Tick(int tick) override
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
auto rep = GetHostReplica();
|
||||
AZ_TEST_ASSERT(rep);
|
||||
m_driller.ResetCounts();
|
||||
|
||||
auto chunk = rep->FindReplicaChunk<EntityLikeScriptReplicaChunk>();
|
||||
|
||||
// mimicing behavior of entity script chunk
|
||||
chunk->m_scriptDataSets[0].SetIsEnabled(true);
|
||||
chunk->m_scriptDataSets[0].Set(NewValue);
|
||||
|
||||
break;
|
||||
}
|
||||
case 60:
|
||||
{
|
||||
auto counts = m_driller.m_replicaLengths.size();
|
||||
AZ_TEST_ASSERT(counts == ExpectedNumberReplicasSent);
|
||||
m_driller.ResetCounts();
|
||||
|
||||
m_sessions[sHost].GetReplicaMgr().FindReplica(m_replicaId)->Destroy();
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
}
|
||||
|
||||
ReplicaDrillerHook m_driller;
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST(CheckEntityScriptReplicaIsntSentWithNoChanges, DISABLED_CheckEntityScriptReplicaIsntSentWithNoChanges)
|
||||
{
|
||||
CheckEntityScriptReplicaIsntSentWithNoChanges tester;
|
||||
tester.run();
|
||||
}
|
||||
|
||||
} // namespace ReplicaBehavior
|
||||
} // namespace UnitTest
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <GridMate/Replica/Replica.h>
|
||||
#include <GridMate/Replica/ReplicaFunctions.h>
|
||||
#include <GridMate/Replica/ReplicaMgr.h>
|
||||
#include <GridMate/Replica/ReplicaDrillerEvents.h>
|
||||
#include <GridMate/Replica/BasicHostChunkDescriptor.h>
|
||||
|
||||
#include <GridMate/Serialize/DataMarshal.h>
|
||||
@@ -525,22 +524,6 @@ public:
|
||||
int m_deactivates;
|
||||
};
|
||||
|
||||
class DrillerTestChunk
|
||||
: public ReplicaChunk
|
||||
{
|
||||
public:
|
||||
GM_CLASS_ALLOCATOR(DrillerTestChunk);
|
||||
typedef AZStd::intrusive_ptr<DrillerTestChunk> Ptr;
|
||||
static const char* GetChunkName() { return "DrillerTestChunk"; }
|
||||
|
||||
DrillerTestChunk() { }
|
||||
|
||||
bool IsReplicaMigratable() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class NonConstMarshaler
|
||||
{
|
||||
public:
|
||||
@@ -744,10 +727,6 @@ public:
|
||||
{
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<AllEventChunk>();
|
||||
}
|
||||
if (!ReplicaChunkDescriptorTable::Get().FindReplicaChunkDescriptor(ReplicaChunkClassId(DrillerTestChunk::GetChunkName())))
|
||||
{
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<DrillerTestChunk>();
|
||||
}
|
||||
if (!ReplicaChunkDescriptorTable::Get().FindReplicaChunkDescriptor(ReplicaChunkClassId(NonConstMarshalerChunk::GetChunkName())))
|
||||
{
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<NonConstMarshalerChunk>();
|
||||
@@ -1648,440 +1627,6 @@ TEST_F(ReplicaChunkEventsDeactivate, DISABLED_ReplicaChunkEventsDeactivate)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class ReplicaDriller
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
ReplicaDriller()
|
||||
: m_replicaId(InvalidReplicaId)
|
||||
{
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
class ReplicaDrillerHook
|
||||
: public Debug::ReplicaDrillerBus::Handler
|
||||
{
|
||||
public:
|
||||
ReplicaDrillerHook()
|
||||
: m_createdReplicas(0)
|
||||
, m_destroyedReplicas(0)
|
||||
, m_activatedReplicas(0)
|
||||
, m_deactivatedReplicas(0)
|
||||
, m_attachedChunks(0)
|
||||
, m_detachedChunks(0)
|
||||
, m_numReplicaBytesSent(0)
|
||||
, m_numReplicaBytesReceived(0)
|
||||
, m_numRequestChangeOwnership(0)
|
||||
, m_numChangedOwnership(0)
|
||||
, m_createdChunks(0)
|
||||
, m_destroyedChunks(0)
|
||||
, m_activatedChunks(0)
|
||||
, m_deactivatedChunks(0)
|
||||
, m_numChunkBytesSent(0)
|
||||
, m_numChunkBytesReceived(0)
|
||||
, m_numOutgoingDatasets(0)
|
||||
, m_numIncomingDatasets(0)
|
||||
, m_numRpcRequests(0)
|
||||
, m_numRpcInvokes(0)
|
||||
, m_outgoingRpcDataSize(0)
|
||||
, m_incomingRpcDataSize(0)
|
||||
, m_totalOutgoingBytes(0)
|
||||
, m_totalIncomingBytes(0)
|
||||
, m_curReplicaSend(nullptr)
|
||||
, m_curReplicaChunkSend(nullptr)
|
||||
, m_curReplicaChunkIndexSend(GM_MAX_CHUNKS_PER_REPLICA)
|
||||
, m_curReplicaReceive(nullptr)
|
||||
, m_curReplicaChunkReceive(nullptr)
|
||||
, m_curReplicaChunkIndexReceive(GM_MAX_CHUNKS_PER_REPLICA)
|
||||
{
|
||||
}
|
||||
|
||||
AZStd::size_t m_createdReplicas;
|
||||
AZStd::size_t m_destroyedReplicas;
|
||||
AZStd::size_t m_activatedReplicas;
|
||||
AZStd::size_t m_deactivatedReplicas;
|
||||
AZStd::size_t m_attachedChunks;
|
||||
AZStd::size_t m_detachedChunks;
|
||||
AZStd::size_t m_numReplicaBytesSent;
|
||||
AZStd::size_t m_numReplicaBytesReceived;
|
||||
AZStd::size_t m_numRequestChangeOwnership;
|
||||
AZStd::size_t m_numChangedOwnership;
|
||||
|
||||
AZStd::size_t m_createdChunks;
|
||||
AZStd::size_t m_destroyedChunks;
|
||||
AZStd::size_t m_activatedChunks;
|
||||
AZStd::size_t m_deactivatedChunks;
|
||||
AZStd::size_t m_numChunkBytesSent;
|
||||
AZStd::size_t m_numChunkBytesReceived;
|
||||
|
||||
AZStd::size_t m_numOutgoingDatasets;
|
||||
AZStd::size_t m_numIncomingDatasets;
|
||||
|
||||
AZStd::size_t m_numRpcRequests;
|
||||
AZStd::size_t m_numRpcInvokes;
|
||||
AZStd::size_t m_outgoingRpcDataSize;
|
||||
AZStd::size_t m_incomingRpcDataSize;
|
||||
|
||||
AZStd::size_t m_totalOutgoingBytes;
|
||||
AZStd::size_t m_totalIncomingBytes;
|
||||
|
||||
Replica* m_curReplicaSend;
|
||||
ReplicaChunkBase* m_curReplicaChunkSend;
|
||||
size_t m_curReplicaChunkIndexSend;
|
||||
Replica* m_curReplicaReceive;
|
||||
ReplicaChunkBase* m_curReplicaChunkReceive;
|
||||
AZ::u32 m_curReplicaChunkIndexReceive;
|
||||
|
||||
void OnCreateReplica(Replica* replica) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
++m_createdReplicas;
|
||||
}
|
||||
|
||||
void OnDestroyReplica(Replica* replica) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
++m_destroyedReplicas;
|
||||
}
|
||||
|
||||
void OnActivateReplica(Replica* replica) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
++m_activatedReplicas;
|
||||
}
|
||||
|
||||
void OnDeactivateReplica(Replica* replica) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
++m_deactivatedReplicas;
|
||||
}
|
||||
|
||||
void OnAttachReplicaChunk(ReplicaChunkBase* chunk) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
++m_attachedChunks;
|
||||
}
|
||||
|
||||
void OnDetachReplicaChunk(ReplicaChunkBase* chunk) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
++m_detachedChunks;
|
||||
}
|
||||
|
||||
void OnSendReplicaBegin(Replica* replica) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
AZ_TEST_ASSERT(m_curReplicaSend == nullptr);
|
||||
m_curReplicaSend = replica;
|
||||
}
|
||||
|
||||
void OnSendReplicaEnd(Replica* replica, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
AZ_TEST_ASSERT(replica == m_curReplicaSend);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_numReplicaBytesSent += len;
|
||||
m_curReplicaSend = nullptr;
|
||||
}
|
||||
|
||||
void OnReceiveReplicaBegin(Replica* replica, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
AZ_TEST_ASSERT(m_curReplicaReceive == nullptr);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_curReplicaReceive = replica;
|
||||
m_numReplicaBytesReceived += len;
|
||||
}
|
||||
|
||||
void OnReceiveReplicaEnd(Replica* replica) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
AZ_TEST_ASSERT(replica == m_curReplicaReceive);
|
||||
m_curReplicaReceive = nullptr;
|
||||
}
|
||||
|
||||
void OnRequestReplicaChangeOwnership(Replica* replica, PeerId requestor) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
AZ_TEST_ASSERT(requestor == (s2 + 1));
|
||||
++m_numRequestChangeOwnership;
|
||||
}
|
||||
|
||||
void OnReplicaChangeOwnership(Replica* replica, bool wasPrimary) override
|
||||
{
|
||||
AZ_TEST_ASSERT(replica);
|
||||
switch (m_numChangedOwnership)
|
||||
{
|
||||
case 0: // host loses ownership
|
||||
AZ_TEST_ASSERT(replica->IsProxy() && wasPrimary == true);
|
||||
break;
|
||||
case 1: // peer acquires ownership
|
||||
AZ_TEST_ASSERT(replica->IsPrimary() && wasPrimary == false);
|
||||
break;
|
||||
default:
|
||||
AZ_TEST_ASSERT(0);
|
||||
}
|
||||
|
||||
++m_numChangedOwnership;
|
||||
}
|
||||
|
||||
void OnCreateReplicaChunk(ReplicaChunkBase* chunk) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
++m_createdChunks;
|
||||
}
|
||||
|
||||
void OnDestroyReplicaChunk(ReplicaChunkBase* chunk) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
++m_destroyedChunks;
|
||||
}
|
||||
|
||||
void OnActivateReplicaChunk(ReplicaChunkBase* chunk) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
++m_activatedChunks;
|
||||
}
|
||||
|
||||
void OnDeactivateReplicaChunk(ReplicaChunkBase* chunk) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
++m_deactivatedChunks;
|
||||
}
|
||||
|
||||
void OnSendReplicaChunkBegin(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, PeerId from, PeerId to) override
|
||||
{
|
||||
(void)from;
|
||||
(void)to;
|
||||
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaSend == chunk->GetReplica());
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkSend == nullptr);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexSend == GM_MAX_CHUNKS_PER_REPLICA);
|
||||
m_curReplicaChunkSend = chunk;
|
||||
m_curReplicaChunkIndexSend = chunkIndex;
|
||||
}
|
||||
|
||||
void OnSendReplicaChunkEnd(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaSend == chunk->GetReplica());
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkSend == chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexSend == chunkIndex);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_numChunkBytesSent += len;
|
||||
m_curReplicaChunkSend = nullptr;
|
||||
m_curReplicaChunkIndexSend = GM_MAX_CHUNKS_PER_REPLICA;
|
||||
|
||||
}
|
||||
|
||||
void OnReceiveReplicaChunkBegin(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, PeerId from, PeerId to, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaReceive == chunk->GetReplica());
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkReceive == nullptr);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexReceive == GM_MAX_CHUNKS_PER_REPLICA);
|
||||
AZ_TEST_ASSERT(from);
|
||||
AZ_TEST_ASSERT(to);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_curReplicaChunkReceive = chunk;
|
||||
m_curReplicaChunkIndexReceive = chunkIndex;
|
||||
m_numChunkBytesReceived += len;
|
||||
}
|
||||
|
||||
void OnReceiveReplicaChunkEnd(ReplicaChunkBase* chunk, AZ::u32 chunkIndex) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaReceive == chunk->GetReplica());
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkReceive == chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexReceive == chunkIndex);
|
||||
m_curReplicaChunkReceive = nullptr;
|
||||
m_curReplicaChunkIndexReceive = GM_MAX_CHUNKS_PER_REPLICA;
|
||||
}
|
||||
|
||||
void OnSendDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkSend == chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexSend == chunkIndex);
|
||||
AZ_TEST_ASSERT(dataSet);
|
||||
AZ_TEST_ASSERT(from);
|
||||
AZ_TEST_ASSERT(to);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
|
||||
++m_numOutgoingDatasets;
|
||||
}
|
||||
|
||||
void OnReceiveDataSet(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, DataSetBase* dataSet, PeerId from, PeerId to, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkReceive == chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexReceive == chunkIndex);
|
||||
AZ_TEST_ASSERT(dataSet);
|
||||
AZ_TEST_ASSERT(from);
|
||||
AZ_TEST_ASSERT(to);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
|
||||
++m_numIncomingDatasets;
|
||||
}
|
||||
|
||||
void OnRequestRpc(ReplicaChunkBase* chunk, Internal::RpcRequest* rpc) override
|
||||
{
|
||||
(void)chunk;
|
||||
(void)rpc;
|
||||
++m_numRpcRequests;
|
||||
}
|
||||
|
||||
void OnInvokeRpc(ReplicaChunkBase* chunk, Internal::RpcRequest* rpc) override
|
||||
{
|
||||
(void)chunk;
|
||||
(void)rpc;
|
||||
++m_numRpcInvokes;
|
||||
}
|
||||
|
||||
void OnSendRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkSend == chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexSend == chunkIndex);
|
||||
AZ_TEST_ASSERT(rpc);
|
||||
AZ_TEST_ASSERT(from);
|
||||
AZ_TEST_ASSERT(to);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_outgoingRpcDataSize += len;
|
||||
}
|
||||
|
||||
void OnReceiveRpc(ReplicaChunkBase* chunk, AZ::u32 chunkIndex, Internal::RpcRequest* rpc, PeerId from, PeerId to, const void* data, size_t len) override
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkReceive == chunk);
|
||||
AZ_TEST_ASSERT(m_curReplicaChunkIndexReceive == chunkIndex);
|
||||
AZ_TEST_ASSERT(rpc);
|
||||
AZ_TEST_ASSERT(from);
|
||||
AZ_TEST_ASSERT(to);
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_incomingRpcDataSize += len;
|
||||
}
|
||||
|
||||
void OnSend(PeerId to, const void* data, size_t len, bool isReliable) override
|
||||
{
|
||||
(void)to; // peerId might not be valid at this point, e.g. handshake (Cmd_Greetings) did not accomplish yet
|
||||
(void)isReliable;
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_totalOutgoingBytes += len;
|
||||
}
|
||||
|
||||
void OnReceive(PeerId from, const void* data, size_t len) override
|
||||
{
|
||||
(void)from; // peerId might not be valid at this point, e.g. handshake (Cmd_Greetings) did not accomplish yet
|
||||
AZ_TEST_ASSERT(data);
|
||||
AZ_TEST_ASSERT(len > 0);
|
||||
m_totalIncomingBytes += len;
|
||||
}
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
CreateAndAttachReplicaChunk<DrillerTestChunk>(replica);
|
||||
m_replicaId = m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
|
||||
~ReplicaDriller() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
ReplicaDrillerHook m_driller;
|
||||
ReplicaId m_replicaId;
|
||||
};
|
||||
|
||||
TEST_F(ReplicaDriller, DISABLED_ReplicaDriller)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
auto rep = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
AZ_TEST_ASSERT(rep);
|
||||
AZ_TEST_ASSERT(rep->IsProxy());
|
||||
rep->RequestChangeOwnership();
|
||||
break;
|
||||
}
|
||||
case 30:
|
||||
{
|
||||
auto rep = m_sessions[s2].GetReplicaMgr().FindReplica(m_replicaId);
|
||||
AZ_TEST_ASSERT(rep);
|
||||
AZ_TEST_ASSERT(rep->IsPrimary());
|
||||
rep->Destroy();
|
||||
break;
|
||||
}
|
||||
case 40:
|
||||
// replicas
|
||||
AZ_TEST_ASSERT(m_driller.m_createdReplicas > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_destroyedReplicas > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_activatedReplicas > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_deactivatedReplicas > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_numReplicaBytesSent > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_numReplicaBytesReceived > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_numRequestChangeOwnership == 1);
|
||||
AZ_TEST_ASSERT(m_driller.m_numChangedOwnership == 2); // two because one call for host & one for peer
|
||||
|
||||
// chunks
|
||||
AZ_TEST_ASSERT(m_driller.m_createdChunks >= m_driller.m_createdReplicas);
|
||||
AZ_TEST_ASSERT(m_driller.m_destroyedChunks >= m_driller.m_destroyedReplicas);
|
||||
AZ_TEST_ASSERT(m_driller.m_activatedChunks >= m_driller.m_activatedReplicas);
|
||||
AZ_TEST_ASSERT(m_driller.m_deactivatedChunks >= m_driller.m_deactivatedReplicas);
|
||||
AZ_TEST_ASSERT(m_driller.m_attachedChunks > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_detachedChunks > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_numChunkBytesReceived > 0);
|
||||
|
||||
AZ_TEST_ASSERT(m_driller.m_numChunkBytesSent > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_numChunkBytesReceived > 0);
|
||||
|
||||
// datasets
|
||||
AZ_TEST_ASSERT(m_driller.m_numOutgoingDatasets > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_numIncomingDatasets > 0);
|
||||
|
||||
// rpcs
|
||||
AZ_TEST_ASSERT(m_driller.m_numRpcRequests > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_numRpcInvokes > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_outgoingRpcDataSize > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_incomingRpcDataSize > 0);
|
||||
|
||||
// data
|
||||
AZ_TEST_ASSERT(m_driller.m_totalOutgoingBytes > 0);
|
||||
AZ_TEST_ASSERT(m_driller.m_totalIncomingBytes > 0);
|
||||
return TestStatus::Completed;
|
||||
default: break;
|
||||
}
|
||||
return TestStatus::Running;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class DataSetChangedTest
|
||||
: public SimpleTest
|
||||
{
|
||||
@@ -2403,114 +1948,6 @@ TEST_F(SourcePeerTest, DISABLED_SourcePeerTest)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class SendWithPriority
|
||||
: public SimpleTest
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
class PriorityChunk
|
||||
: public ReplicaChunk
|
||||
{
|
||||
public:
|
||||
GM_CLASS_ALLOCATOR(PriorityChunk);
|
||||
typedef AZStd::intrusive_ptr<PriorityChunk> Ptr;
|
||||
static const char* GetChunkName() { return "PriorityChunk"; }
|
||||
|
||||
PriorityChunk()
|
||||
: m_value("Value")
|
||||
{
|
||||
}
|
||||
|
||||
bool IsReplicaMigratable() override { return false; }
|
||||
|
||||
DataSet<int> m_value;
|
||||
};
|
||||
|
||||
class ReplicaDrillerHook
|
||||
: public Debug::ReplicaDrillerBus::Handler
|
||||
{
|
||||
public:
|
||||
ReplicaDrillerHook()
|
||||
: m_expectedSendValue(SendWithPriority::kNumReplicas)
|
||||
, m_expectedRecvValue(SendWithPriority::kNumReplicas)
|
||||
{
|
||||
}
|
||||
|
||||
void OnReceiveReplicaEnd(Replica* replica) override
|
||||
{
|
||||
auto chunk = replica->FindReplicaChunk<PriorityChunk>();
|
||||
if (chunk && m_expectedRecvValue > 0)
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk->m_value.Get() == m_expectedRecvValue); // checking reverse order
|
||||
--m_expectedRecvValue;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSendReplicaEnd(Replica* replica, const void* data, size_t len) override
|
||||
{
|
||||
(void)data;
|
||||
(void)len;
|
||||
|
||||
auto chunk = replica->FindReplicaChunk<PriorityChunk>();
|
||||
if (chunk && m_expectedSendValue > 0)
|
||||
{
|
||||
AZ_TEST_ASSERT(chunk->m_value.Get() == m_expectedSendValue); // checking reverse order
|
||||
--m_expectedSendValue;
|
||||
}
|
||||
}
|
||||
|
||||
int m_expectedSendValue;
|
||||
int m_expectedRecvValue;
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
ReplicaChunkDescriptorTable::Get().RegisterChunkType<PriorityChunk>();
|
||||
|
||||
m_driller.BusConnect();
|
||||
|
||||
for (unsigned i = 0; i < kNumReplicas; ++i)
|
||||
{
|
||||
ReplicaPtr replica = Replica::CreateReplica(nullptr);
|
||||
m_chunks[i] = CreateAndAttachReplicaChunk<PriorityChunk>(replica);
|
||||
m_chunks[i]->m_value.Set(i + 1); // setting dataset values to 1..kNumReplicas
|
||||
m_chunks[i]->SetPriority(k_replicaPriorityNormal + static_cast<ReplicaPriority>(i)); // the later created - the higher priorities, so should be sent in reverse order
|
||||
m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const size_t kNumReplicas = 5;
|
||||
|
||||
ReplicaDrillerHook m_driller;
|
||||
PriorityChunk::Ptr m_chunks[kNumReplicas];
|
||||
};
|
||||
|
||||
TEST_F(SendWithPriority, DISABLED_SendWithPriority)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
if (tick == 20)
|
||||
{
|
||||
AZ_TEST_ASSERT(m_driller.m_expectedSendValue == 0); // sent all the replicas in the right order
|
||||
AZ_TEST_ASSERT(m_driller.m_expectedRecvValue == 0); // received all the replicas in the right order
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
|
||||
return TestStatus::Running;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class SuspendUpdatesTest
|
||||
: public SimpleTest
|
||||
{
|
||||
@@ -2787,75 +2224,6 @@ TEST_F(BasicHostChunkDescriptorTest, DISABLED_BasicHostChunkDescriptorTest)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create and immedietly destroy primary replica
|
||||
* Test that it does not result in any network sync
|
||||
*/
|
||||
class CreateDestroyPrimary
|
||||
: public SimpleTest
|
||||
, public Debug::ReplicaDrillerBus::Handler
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
sHost,
|
||||
s2,
|
||||
nSessions
|
||||
};
|
||||
|
||||
int GetNumSessions() override { return nSessions; }
|
||||
|
||||
|
||||
// ReplicaDrillerBus
|
||||
void OnReceive(PeerId from, const void* data, size_t len) override
|
||||
{
|
||||
(void)from;
|
||||
(void)data;
|
||||
(void)len;
|
||||
|
||||
AZ_TEST_ASSERT(false); // should not receive any replica data
|
||||
}
|
||||
|
||||
void ConnectDriller()
|
||||
{
|
||||
Debug::ReplicaDrillerBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void DisconnectDriller()
|
||||
{
|
||||
Debug::ReplicaDrillerBus::Handler::BusDisconnect();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(CreateDestroyPrimary, DISABLED_CreateDestroyPrimary)
|
||||
{
|
||||
RunTickLoop([this](int tick)-> TestStatus
|
||||
{
|
||||
switch (tick)
|
||||
{
|
||||
|
||||
case 10:
|
||||
{
|
||||
ConnectDriller();
|
||||
auto replica = Replica::CreateReplica(nullptr);
|
||||
CreateAndAttachReplicaChunk<DataSetChunk>(replica);
|
||||
m_sessions[sHost].GetReplicaMgr().AddPrimary(replica);
|
||||
|
||||
// Destroying replica right away
|
||||
replica->Destroy();
|
||||
break;
|
||||
}
|
||||
|
||||
case 20:
|
||||
DisconnectDriller();
|
||||
return TestStatus::Completed;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return TestStatus::Running;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* This test checks that when the carrier ACKs a message it feeds back to the ReplicaTarget.
|
||||
* The ReplicaTarget will prevent sending more updates.
|
||||
@@ -2884,8 +2252,6 @@ public:
|
||||
|
||||
void PreConnect() override
|
||||
{
|
||||
m_driller.BusConnect();
|
||||
|
||||
ReplicaPtr replica = Replica::CreateReplica("ReplicaACKfeedbackTest");
|
||||
LargeChunkWithDefaultsMedium* chunk = CreateAndAttachReplicaChunk<LargeChunkWithDefaultsMedium>(replica);
|
||||
AZ_TEST_ASSERT(chunk);
|
||||
@@ -2895,12 +2261,9 @@ public:
|
||||
|
||||
~ReplicaACKfeedbackTestFixture() override
|
||||
{
|
||||
m_driller.BusDisconnect();
|
||||
}
|
||||
|
||||
size_t m_replicaBytesSentPrev = 0;
|
||||
ReplicaId m_replicaId;
|
||||
ReplicaDriller::ReplicaDrillerHook m_driller;
|
||||
};
|
||||
|
||||
TEST_F(ReplicaACKfeedbackTestFixture, ReplicaACKfeedbackTest)
|
||||
@@ -2912,7 +2275,6 @@ TEST_F(ReplicaACKfeedbackTestFixture, ReplicaACKfeedbackTest)
|
||||
return TestStatus::Completed;
|
||||
}
|
||||
|
||||
//AZ_Printf("GridMateTests", "%d %d\n", tick, m_driller.m_numReplicaBytesSent);
|
||||
// Tests the Revision stamp with Carrier ACK feedback
|
||||
// result is true on the immediate tick after changing, but false on the next and stays false until next change
|
||||
auto CheckHostReplicaChanged = [this](bool result)
|
||||
@@ -2963,12 +2325,10 @@ TEST_F(ReplicaACKfeedbackTestFixture, ReplicaACKfeedbackTest)
|
||||
|
||||
updateDataSets(chunk, NonDefaultValue);
|
||||
|
||||
m_replicaBytesSentPrev = m_driller.m_numReplicaBytesSent;
|
||||
CheckHostReplicaChanged(false); //Changed now, but wont know until next prepareData()
|
||||
}break;
|
||||
case 16:
|
||||
{
|
||||
AZ_TEST_ASSERT(m_driller.m_numReplicaBytesSent - m_replicaBytesSentPrev == k_updateBytes);
|
||||
CheckHostReplicaChanged(true); //Detected change. ACK feedback on next tick returns to false.
|
||||
}break;
|
||||
case 20:
|
||||
@@ -2978,12 +2338,10 @@ TEST_F(ReplicaACKfeedbackTestFixture, ReplicaACKfeedbackTest)
|
||||
|
||||
updateDataSets(chunk, NonDefaultValue + 1);
|
||||
|
||||
m_replicaBytesSentPrev = m_driller.m_numReplicaBytesSent;
|
||||
CheckHostReplicaChanged(false); //Changed now, but wont know until next prepareData()
|
||||
}break;
|
||||
case 21:
|
||||
{
|
||||
AZ_TEST_ASSERT(m_driller.m_numReplicaBytesSent - m_replicaBytesSentPrev == k_updateBytes);
|
||||
CheckHostReplicaChanged(true); //Detected change. ACK feedback on next tick returns to false.
|
||||
}break;
|
||||
case 25:
|
||||
|
||||
@@ -453,7 +453,6 @@ public:
|
||||
// replicaHeader += 16;
|
||||
//#endif
|
||||
// const int marshalDataSize = 48; //Data plus length
|
||||
//Only for Driller
|
||||
ReplicaManager rm;
|
||||
ReplicaPeer peer(&rm);
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
#include <AzCore/Memory/OSAllocator.h>
|
||||
#include <AzCore/Memory/AllocationRecords.h>
|
||||
|
||||
#include <AzCore/Driller/Driller.h>
|
||||
|
||||
#include <GridMate/Carrier/Carrier.h>
|
||||
|
||||
#include <AzCore/AzCore_Traits_Platform.h>
|
||||
@@ -42,9 +40,6 @@ namespace UnitTest
|
||||
{
|
||||
protected:
|
||||
GridMate::IGridMate* m_gridMate;
|
||||
AZ::Debug::DrillerSession* m_drillerSession;
|
||||
AZ::Debug::DrillerOutputFileStream* m_drillerStream;
|
||||
AZ::Debug::DrillerManager* m_drillerManager;
|
||||
|
||||
private:
|
||||
using Platform = GridMateTestFixture_Platform;
|
||||
@@ -52,9 +47,6 @@ namespace UnitTest
|
||||
public:
|
||||
GridMateTestFixture([[maybe_unused]] unsigned int memorySize = 100 * 1024 * 1024)
|
||||
: m_gridMate(nullptr)
|
||||
, m_drillerSession(nullptr)
|
||||
, m_drillerStream(nullptr)
|
||||
, m_drillerManager(nullptr)
|
||||
{
|
||||
GridMate::GridMateDesc desc;
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
|
||||
@@ -63,8 +55,7 @@ namespace UnitTest
|
||||
m_gridMate = GridMateCreate(desc);
|
||||
AZ_TEST_ASSERT(m_gridMate != NULL);
|
||||
|
||||
m_drillerSession = NULL;
|
||||
|
||||
AZ::AllocatorManager::Instance().EnterProfilingMode();
|
||||
AZ::Debug::AllocationRecords* records = AZ::AllocatorInstance<GridMate::GridMateAllocator>::GetAllocator().GetRecords();
|
||||
if (records)
|
||||
{
|
||||
@@ -85,13 +76,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
|
||||
|
||||
if (m_drillerManager)
|
||||
{
|
||||
AZ::Debug::DrillerManager::Destroy(m_drillerManager);
|
||||
AZ::AllocatorManager::Instance().ExitProfilingMode();
|
||||
m_drillerManager = nullptr;
|
||||
}
|
||||
AZ::AllocatorManager::Instance().ExitProfilingMode();
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
Reference in New Issue
Block a user