Merge PR #69: bounded cross-region object messaging
0.9.3.5: Add bounded cross-region object messaging
This commit is contained in:
14 files changed
+658
-13
No files matched your search
@@ -197,6 +197,10 @@ jobs:
|
||||
shell: bash
|
||||
run: dotnet run --configuration Release --project tools/ci/NexBusRegression/NexBusRegression.csproj
|
||||
|
||||
- name: Verify cross-region object messaging
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_object_messaging.py
|
||||
|
||||
- name: Verify NodeAgent registry projection
|
||||
shell: bash
|
||||
run: dotnet run --configuration Release --project tools/ci/NexNodeRegistryRegression/NexNodeRegistryRegression.csproj
|
||||
@@ -468,6 +472,10 @@ jobs:
|
||||
assert "node_id" in schemas["GridRegionPlacement"]["properties"]
|
||||
assert "node_state" in schemas["GridRegionPlacement"]["properties"]
|
||||
assert schemas["Node"]["properties"]["managed_region_commands"]["type"] == "boolean"
|
||||
assert schemas["Node"]["properties"]["cross_region_object_messaging"]["type"] == "boolean"
|
||||
assert schemas["Node"]["properties"]["cross_owner_object_messaging"]["type"] == "boolean"
|
||||
assert schemas["Node"]["properties"]["object_messages_per_second"]["maximum"] == 200
|
||||
assert schemas["Node"]["properties"]["object_message_max_age_seconds"]["maximum"] == 300
|
||||
|
||||
nodes_get = doc["paths"]["/api/v1/nodes"]["get"]
|
||||
assert nodes_get["x-nexverse-scope"] == "simulators:read"
|
||||
@@ -556,7 +564,7 @@ jobs:
|
||||
assert milestones["0.9.3.3"]["status"] == "completed"
|
||||
assert milestones["0.9.3.4"]["status"] == "released"
|
||||
assert milestones["0.9.3.5"]["status"] == "active"
|
||||
assert milestones["0.9.3.5"]["checklist"] == {"completed": 74, "total": 74, "open": 0}
|
||||
assert milestones["0.9.3.5"]["checklist"] == {"completed": 83, "total": 83, "open": 0}
|
||||
assert milestones["0.9.3.6"]["status"] == "planned"
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
@@ -54,6 +54,10 @@ namespace NexVerse.Core.ControlPlane
|
||||
int regionCount,
|
||||
int agentCount,
|
||||
bool managedRegionCommands,
|
||||
bool crossRegionObjectMessaging,
|
||||
bool crossOwnerObjectMessaging,
|
||||
int objectMessagesPerSecond,
|
||||
int objectMessageMaxAgeSeconds,
|
||||
string migrationStorageId,
|
||||
bool maintenanceMode,
|
||||
bool draining,
|
||||
@@ -79,6 +83,10 @@ namespace NexVerse.Core.ControlPlane
|
||||
RegionCount = regionCount;
|
||||
AgentCount = agentCount;
|
||||
ManagedRegionCommands = managedRegionCommands;
|
||||
CrossRegionObjectMessaging = crossRegionObjectMessaging;
|
||||
CrossOwnerObjectMessaging = crossOwnerObjectMessaging;
|
||||
ObjectMessagesPerSecond = Math.Max(0, objectMessagesPerSecond);
|
||||
ObjectMessageMaxAgeSeconds = Math.Max(0, objectMessageMaxAgeSeconds);
|
||||
MigrationStorageId = migrationStorageId ?? string.Empty;
|
||||
MaintenanceMode = maintenanceMode;
|
||||
Draining = draining;
|
||||
@@ -108,6 +116,10 @@ namespace NexVerse.Core.ControlPlane
|
||||
public int RegionCount { get; }
|
||||
public int AgentCount { get; }
|
||||
public bool ManagedRegionCommands { get; }
|
||||
public bool CrossRegionObjectMessaging { get; }
|
||||
public bool CrossOwnerObjectMessaging { get; }
|
||||
public int ObjectMessagesPerSecond { get; }
|
||||
public int ObjectMessageMaxAgeSeconds { get; }
|
||||
public string MigrationStorageId { get; }
|
||||
public bool MaintenanceMode { get; }
|
||||
public bool Draining { get; }
|
||||
@@ -319,6 +331,22 @@ namespace NexVerse.Core.ControlPlane
|
||||
nexEvent,
|
||||
"managed_region_commands",
|
||||
value => record.ManagedRegionCommands = value);
|
||||
AssignBool(
|
||||
nexEvent,
|
||||
"cross_region_object_messaging",
|
||||
value => record.CrossRegionObjectMessaging = value);
|
||||
AssignBool(
|
||||
nexEvent,
|
||||
"cross_owner_object_messaging",
|
||||
value => record.CrossOwnerObjectMessaging = value);
|
||||
AssignInt(
|
||||
nexEvent,
|
||||
"object_messages_per_second",
|
||||
value => record.ObjectMessagesPerSecond = Math.Max(0, value));
|
||||
AssignInt(
|
||||
nexEvent,
|
||||
"object_message_max_age_seconds",
|
||||
value => record.ObjectMessageMaxAgeSeconds = Math.Max(0, value));
|
||||
AssignString(
|
||||
nexEvent,
|
||||
"migration_storage_id",
|
||||
@@ -605,6 +633,10 @@ namespace NexVerse.Core.ControlPlane
|
||||
record.RegionCount,
|
||||
record.AgentCount,
|
||||
record.ManagedRegionCommands,
|
||||
record.CrossRegionObjectMessaging,
|
||||
record.CrossOwnerObjectMessaging,
|
||||
record.ObjectMessagesPerSecond,
|
||||
record.ObjectMessageMaxAgeSeconds,
|
||||
record.MigrationStorageId,
|
||||
record.MaintenanceMode,
|
||||
record.Draining,
|
||||
@@ -906,6 +938,10 @@ namespace NexVerse.Core.ControlPlane
|
||||
public int RegionCount;
|
||||
public int AgentCount;
|
||||
public bool ManagedRegionCommands;
|
||||
public bool CrossRegionObjectMessaging;
|
||||
public bool CrossOwnerObjectMessaging;
|
||||
public int ObjectMessagesPerSecond;
|
||||
public int ObjectMessageMaxAgeSeconds;
|
||||
public string MigrationStorageId = string.Empty;
|
||||
public bool MaintenanceMode;
|
||||
public bool Draining;
|
||||
|
||||
@@ -33,19 +33,30 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
Id = "NexVerseNodeAgentModule")]
|
||||
public sealed class NexVerseNodeAgentModule :
|
||||
ISharedRegionModule,
|
||||
INexVerseEventBusModule
|
||||
INexVerseEventBusModule,
|
||||
ICrossRegionObjectMessageRouter
|
||||
{
|
||||
private const int DebugChannel = 0x7fffffff;
|
||||
private const int ObjectMessageRateEntryLimit = 8192;
|
||||
private static readonly ILog m_Log =
|
||||
LogManager.GetLogger(typeof(NexVerseNodeAgentModule));
|
||||
|
||||
private readonly ConcurrentDictionary<UUID, Scene> m_Scenes =
|
||||
new ConcurrentDictionary<UUID, Scene>();
|
||||
private readonly ConcurrentDictionary<UUID, ObjectMessageRateState> m_ObjectMessageOutboundRates =
|
||||
new ConcurrentDictionary<UUID, ObjectMessageRateState>();
|
||||
private readonly ConcurrentDictionary<UUID, ObjectMessageRateState> m_ObjectMessageInboundRates =
|
||||
new ConcurrentDictionary<UUID, ObjectMessageRateState>();
|
||||
|
||||
private bool m_Enabled;
|
||||
private string m_NodeId = string.Empty;
|
||||
private string m_SharedKey = string.Empty;
|
||||
private string m_InboundPath = "/internal/nexbus/v1/events";
|
||||
private int m_HeartbeatSeconds = 30;
|
||||
private bool m_ObjectMessagingEnabled;
|
||||
private bool m_AllowCrossOwnerObjectMessages;
|
||||
private int m_ObjectMessagesPerSecond = 20;
|
||||
private int m_ObjectMessageMaxAgeSeconds = 30;
|
||||
private string m_MigrationStorageId = string.Empty;
|
||||
private SimulatorNexEventTransport m_Transport;
|
||||
private DistributedNexEventBus m_Bus;
|
||||
@@ -56,11 +67,13 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
private IDisposable m_NodeControlSubscription;
|
||||
private IDisposable m_OarControlSubscription;
|
||||
private IDisposable m_IarControlSubscription;
|
||||
private IDisposable m_ObjectMessageSubscription;
|
||||
private volatile bool m_MaintenanceMode;
|
||||
private volatile bool m_Draining;
|
||||
private DateTimeOffset m_StartedAt;
|
||||
|
||||
public string NodeId => m_NodeId;
|
||||
public bool Enabled => m_Enabled && m_ObjectMessagingEnabled;
|
||||
public string Name => "NexVerseNodeAgentModule";
|
||||
public Type ReplaceableInterface => null;
|
||||
|
||||
@@ -98,6 +111,28 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
"InboundPath",
|
||||
"/internal/nexbus/v1/events").Trim();
|
||||
m_HeartbeatSeconds = Math.Max(5, config.GetInt("HeartbeatSeconds", 30));
|
||||
m_ObjectMessagingEnabled =
|
||||
config.GetBoolean(
|
||||
"CrossRegionObjectMessaging",
|
||||
false);
|
||||
m_AllowCrossOwnerObjectMessages =
|
||||
config.GetBoolean(
|
||||
"AllowCrossOwnerObjectMessages",
|
||||
false);
|
||||
m_ObjectMessagesPerSecond =
|
||||
Math.Clamp(
|
||||
config.GetInt(
|
||||
"ObjectMessagesPerSecond",
|
||||
20),
|
||||
1,
|
||||
200);
|
||||
m_ObjectMessageMaxAgeSeconds =
|
||||
Math.Clamp(
|
||||
config.GetInt(
|
||||
"ObjectMessageMaxAgeSeconds",
|
||||
30),
|
||||
5,
|
||||
300);
|
||||
|
||||
IConfig oarConfig = source.Configs["OpenGenesisLINKOAR"];
|
||||
m_MigrationStorageId =
|
||||
@@ -131,6 +166,7 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
|
||||
m_Scenes[scene.RegionInfo.RegionID] = scene;
|
||||
scene.RegisterModuleInterface<INexVerseEventBusModule>(this);
|
||||
scene.RegisterModuleInterface<ICrossRegionObjectMessageRouter>(this);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
@@ -147,6 +183,7 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
return;
|
||||
|
||||
PublishRegionEvent("region.offline", scene);
|
||||
scene.UnregisterModuleInterface<ICrossRegionObjectMessageRouter>(this);
|
||||
scene.UnregisterModuleInterface<INexVerseEventBusModule>(this);
|
||||
m_Scenes.TryRemove(scene.RegionInfo.RegionID, out _);
|
||||
}
|
||||
@@ -183,6 +220,13 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
m_NodeControlSubscription = m_Bus.Subscribe("node.control.requested", HandleNodeControlCommand);
|
||||
m_OarControlSubscription = m_Bus.Subscribe("archive.oar.requested", HandleOarCommand);
|
||||
m_IarControlSubscription = m_Bus.Subscribe("archive.iar.requested", HandleIarCommand);
|
||||
if (m_ObjectMessagingEnabled)
|
||||
{
|
||||
m_ObjectMessageSubscription =
|
||||
m_Bus.Subscribe(
|
||||
"object.message.requested",
|
||||
HandleObjectMessage);
|
||||
}
|
||||
|
||||
m_HeartbeatTimer = new Timer(
|
||||
_ => PublishHeartbeatSafe(),
|
||||
@@ -224,6 +268,10 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
m_OarControlSubscription = null;
|
||||
m_IarControlSubscription?.Dispose();
|
||||
m_IarControlSubscription = null;
|
||||
m_ObjectMessageSubscription?.Dispose();
|
||||
m_ObjectMessageSubscription = null;
|
||||
m_ObjectMessageOutboundRates.Clear();
|
||||
m_ObjectMessageInboundRates.Clear();
|
||||
m_HeartbeatTimer?.Dispose();
|
||||
m_Bus?.Dispose();
|
||||
m_Transport = null;
|
||||
@@ -249,6 +297,317 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
m_Bus.Publish(nexEvent);
|
||||
}
|
||||
|
||||
public bool TryRoute(
|
||||
UUID sourceRegionId,
|
||||
UUID sourceObjectId,
|
||||
UUID sourceOwnerId,
|
||||
string sourceName,
|
||||
Vector3 sourcePosition,
|
||||
UUID targetObjectId,
|
||||
int channel,
|
||||
string message)
|
||||
{
|
||||
if (!Enabled ||
|
||||
m_Bus == null ||
|
||||
sourceRegionId.IsZero() ||
|
||||
sourceObjectId.IsZero() ||
|
||||
sourceOwnerId.IsZero() ||
|
||||
targetObjectId.IsZero() ||
|
||||
channel == DebugChannel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_Scenes.TryGetValue(
|
||||
sourceRegionId,
|
||||
out Scene sourceScene))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SceneObjectPart sourcePart =
|
||||
sourceScene.GetSceneObjectPart(
|
||||
sourceObjectId);
|
||||
if (sourcePart == null ||
|
||||
sourcePart.IsDeleted ||
|
||||
sourcePart.OwnerID != sourceOwnerId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string payload =
|
||||
message ?? string.Empty;
|
||||
if (payload.Length > 1023)
|
||||
payload = payload[..1023];
|
||||
|
||||
if (!TryTakeObjectMessageRateSlot(
|
||||
m_ObjectMessageOutboundRates,
|
||||
sourceObjectId))
|
||||
{
|
||||
m_Log.WarnFormat(
|
||||
"[NEX-OBJECT]: Rate limit reached for source object {0} in region {1}.",
|
||||
sourceObjectId,
|
||||
sourceScene.RegionInfo.RegionName);
|
||||
return false;
|
||||
}
|
||||
|
||||
Dictionary<string, string> data =
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
["source_node_id"] =
|
||||
m_NodeId,
|
||||
["source_region_id"] =
|
||||
sourceRegionId.ToString(),
|
||||
["source_object_id"] =
|
||||
sourceObjectId.ToString(),
|
||||
["source_owner_id"] =
|
||||
sourceOwnerId.ToString(),
|
||||
["source_name"] =
|
||||
string.IsNullOrWhiteSpace(sourceName)
|
||||
? sourcePart.Name ?? string.Empty
|
||||
: sourceName.Trim(),
|
||||
["source_position"] =
|
||||
string.Format(
|
||||
System.Globalization.CultureInfo.InvariantCulture,
|
||||
"{0:R},{1:R},{2:R}",
|
||||
sourcePosition.X,
|
||||
sourcePosition.Y,
|
||||
sourcePosition.Z),
|
||||
["target_object_id"] =
|
||||
targetObjectId.ToString(),
|
||||
["channel"] =
|
||||
channel.ToString(
|
||||
System.Globalization.CultureInfo.InvariantCulture),
|
||||
["message"] =
|
||||
payload
|
||||
};
|
||||
|
||||
Publish(new NexEvent(
|
||||
"object.message.requested",
|
||||
"nexverse.simulator",
|
||||
data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void HandleObjectMessage(
|
||||
NexEvent nexEvent)
|
||||
{
|
||||
if (!Enabled ||
|
||||
nexEvent == null ||
|
||||
nexEvent.Data == null ||
|
||||
!string.Equals(
|
||||
nexEvent.Source,
|
||||
"nexverse.simulator",
|
||||
StringComparison.Ordinal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TimeSpan age =
|
||||
DateTimeOffset.UtcNow -
|
||||
nexEvent.Timestamp;
|
||||
if (age >
|
||||
TimeSpan.FromSeconds(
|
||||
m_ObjectMessageMaxAgeSeconds) ||
|
||||
age <
|
||||
TimeSpan.FromSeconds(-5))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryCommandData(
|
||||
nexEvent,
|
||||
"source_object_id",
|
||||
out string rawSourceObject) ||
|
||||
!UUID.TryParse(
|
||||
rawSourceObject,
|
||||
out UUID sourceObjectId) ||
|
||||
sourceObjectId.IsZero() ||
|
||||
!TryCommandData(
|
||||
nexEvent,
|
||||
"source_owner_id",
|
||||
out string rawSourceOwner) ||
|
||||
!UUID.TryParse(
|
||||
rawSourceOwner,
|
||||
out UUID sourceOwnerId) ||
|
||||
sourceOwnerId.IsZero() ||
|
||||
!TryCommandData(
|
||||
nexEvent,
|
||||
"target_object_id",
|
||||
out string rawTarget) ||
|
||||
!UUID.TryParse(
|
||||
rawTarget,
|
||||
out UUID targetObjectId) ||
|
||||
targetObjectId.IsZero() ||
|
||||
!TryCommandInt(
|
||||
nexEvent,
|
||||
"channel",
|
||||
out int channel) ||
|
||||
channel ==
|
||||
DebugChannel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string sourceName =
|
||||
nexEvent.Data.TryGetValue(
|
||||
"source_name",
|
||||
out string rawName)
|
||||
? rawName ?? string.Empty
|
||||
: string.Empty;
|
||||
string message =
|
||||
nexEvent.Data.TryGetValue(
|
||||
"message",
|
||||
out string rawMessage)
|
||||
? rawMessage ?? string.Empty
|
||||
: string.Empty;
|
||||
if (message.Length > 1023)
|
||||
message = message[..1023];
|
||||
|
||||
foreach (Scene scene in
|
||||
m_Scenes.Values)
|
||||
{
|
||||
SceneObjectPart targetPart =
|
||||
scene.GetSceneObjectPart(
|
||||
targetObjectId);
|
||||
if (targetPart == null ||
|
||||
targetPart.IsDeleted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!m_AllowCrossOwnerObjectMessages &&
|
||||
targetPart.OwnerID !=
|
||||
sourceOwnerId)
|
||||
{
|
||||
m_Log.DebugFormat(
|
||||
"[NEX-OBJECT]: Cross-owner object message rejected from {0} to {1}.",
|
||||
sourceObjectId,
|
||||
targetObjectId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryTakeObjectMessageRateSlot(
|
||||
m_ObjectMessageInboundRates,
|
||||
sourceObjectId))
|
||||
{
|
||||
m_Log.WarnFormat(
|
||||
"[NEX-OBJECT]: Inbound rate limit reached for source object {0}.",
|
||||
sourceObjectId);
|
||||
return;
|
||||
}
|
||||
|
||||
IWorldComm worldComm =
|
||||
scene.RequestModuleInterface<IWorldComm>();
|
||||
if (worldComm == null)
|
||||
return;
|
||||
|
||||
worldComm.DeliverMessageTo(
|
||||
targetObjectId,
|
||||
channel,
|
||||
Vector3.Zero,
|
||||
sourceName,
|
||||
sourceObjectId,
|
||||
message);
|
||||
|
||||
Publish(new NexEvent(
|
||||
"object.message.received",
|
||||
"nexverse.simulator",
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
["source_object_id"] =
|
||||
sourceObjectId.ToString(),
|
||||
["source_owner_id"] =
|
||||
sourceOwnerId.ToString(),
|
||||
["target_object_id"] =
|
||||
targetObjectId.ToString(),
|
||||
["target_region_id"] =
|
||||
scene.RegionInfo.RegionID.ToString(),
|
||||
["target_node_id"] =
|
||||
m_NodeId,
|
||||
["channel"] =
|
||||
channel.ToString(
|
||||
System.Globalization.CultureInfo.InvariantCulture),
|
||||
["request_event_id"] =
|
||||
nexEvent.EventId.ToString()
|
||||
},
|
||||
nexEvent.CorrelationId));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryTakeObjectMessageRateSlot(
|
||||
ConcurrentDictionary<UUID, ObjectMessageRateState> rates,
|
||||
UUID sourceObjectId)
|
||||
{
|
||||
long currentSecond =
|
||||
DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
|
||||
if (!rates.ContainsKey(sourceObjectId) &&
|
||||
rates.Count >= ObjectMessageRateEntryLimit)
|
||||
{
|
||||
PruneObjectMessageRateStates(
|
||||
rates,
|
||||
currentSecond);
|
||||
|
||||
if (rates.Count >= ObjectMessageRateEntryLimit)
|
||||
return false;
|
||||
}
|
||||
|
||||
ObjectMessageRateState state =
|
||||
rates.GetOrAdd(
|
||||
sourceObjectId,
|
||||
_ => new ObjectMessageRateState());
|
||||
|
||||
lock (state.SyncRoot)
|
||||
{
|
||||
if (state.WindowSecond !=
|
||||
currentSecond)
|
||||
{
|
||||
state.WindowSecond =
|
||||
currentSecond;
|
||||
state.Count = 0;
|
||||
}
|
||||
|
||||
state.LastSeenSecond =
|
||||
currentSecond;
|
||||
|
||||
if (state.Count >=
|
||||
m_ObjectMessagesPerSecond)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
state.Count++;
|
||||
}
|
||||
|
||||
if (rates.Count > ObjectMessageRateEntryLimit / 2)
|
||||
PruneObjectMessageRateStates(
|
||||
rates,
|
||||
currentSecond);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void PruneObjectMessageRateStates(
|
||||
ConcurrentDictionary<UUID, ObjectMessageRateState> rates,
|
||||
long currentSecond)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, ObjectMessageRateState> item in rates)
|
||||
{
|
||||
if (currentSecond -
|
||||
item.Value.LastSeenSecond >
|
||||
60)
|
||||
{
|
||||
rates.TryRemove(
|
||||
item.Key,
|
||||
out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PublishHeartbeatSafe()
|
||||
{
|
||||
try
|
||||
@@ -294,6 +653,16 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
["managed_region_commands"] =
|
||||
(NexVerseManagedRegionHostPlugin.Current?.Enabled == true)
|
||||
.ToString(),
|
||||
["cross_region_object_messaging"] =
|
||||
m_ObjectMessagingEnabled.ToString(),
|
||||
["cross_owner_object_messaging"] =
|
||||
m_AllowCrossOwnerObjectMessages.ToString(),
|
||||
["object_messages_per_second"] =
|
||||
m_ObjectMessagesPerSecond.ToString(
|
||||
System.Globalization.CultureInfo.InvariantCulture),
|
||||
["object_message_max_age_seconds"] =
|
||||
m_ObjectMessageMaxAgeSeconds.ToString(
|
||||
System.Globalization.CultureInfo.InvariantCulture),
|
||||
["migration_storage_id"] =
|
||||
m_MigrationStorageId,
|
||||
["luna_texture_diagnostic_count"] =
|
||||
@@ -1248,6 +1617,16 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
response.RawBuffer = JsonSerializer.SerializeToUtf8Bytes(payload);
|
||||
}
|
||||
|
||||
private sealed class ObjectMessageRateState
|
||||
{
|
||||
public object SyncRoot { get; } =
|
||||
new object();
|
||||
|
||||
public long WindowSecond;
|
||||
public long LastSeenSecond;
|
||||
public int Count;
|
||||
}
|
||||
|
||||
private sealed class SimulatorNexEventTransport : INexEventTransport
|
||||
{
|
||||
private readonly string m_NodeId;
|
||||
|
||||
@@ -220,7 +220,10 @@ namespace NexVerse.Server.Api
|
||||
{
|
||||
heartbeat = node.State,
|
||||
disk_free_percent = node.DiskTotalBytes > 0 ? Math.Round(100.0 * node.DiskFreeBytes / node.DiskTotalBytes, 2) : (double?)null,
|
||||
accepting_managed_commands = node.State == "online" && node.ManagedRegionCommands
|
||||
accepting_managed_commands = node.State == "online" && node.ManagedRegionCommands,
|
||||
accepting_remote_object_messages =
|
||||
node.State == "online" &&
|
||||
node.CrossRegionObjectMessaging
|
||||
},
|
||||
region_count =
|
||||
node.RegionCount,
|
||||
@@ -228,6 +231,14 @@ namespace NexVerse.Server.Api
|
||||
node.AgentCount,
|
||||
managed_region_commands =
|
||||
node.ManagedRegionCommands,
|
||||
cross_region_object_messaging =
|
||||
node.CrossRegionObjectMessaging,
|
||||
cross_owner_object_messaging =
|
||||
node.CrossOwnerObjectMessaging,
|
||||
object_messages_per_second =
|
||||
node.ObjectMessagesPerSecond,
|
||||
object_message_max_age_seconds =
|
||||
node.ObjectMessageMaxAgeSeconds,
|
||||
maintenance_mode = node.MaintenanceMode,
|
||||
draining = node.Draining,
|
||||
luna_texture =
|
||||
|
||||
@@ -1331,15 +1331,16 @@ namespace NexVerse.Server.Api
|
||||
codename = "",
|
||||
title = "Inventar, OAR/IAR, Auftragssteuerung und NexBus",
|
||||
status = "active",
|
||||
checklist = new { completed = 74, total = 74, open = 0 },
|
||||
summary = "Alle 74 expliziten 0.9.3.5-Checklist-Punkte sind umgesetzt. Inventar-API-Grundlage, OAR/IAR, persistente Auftragssteuerung, native Betriebs-Worker sowie LunaTexture-Persistenz und deren aggregierte NodeAgent/World-API-Projektion sind integriert; nicht checkbox-basierte Erweiterungen werden weiterhin separat verfolgt.",
|
||||
checklist = new { completed = 83, total = 83, open = 0 },
|
||||
summary = "Alle 83 expliziten 0.9.3.5-Checklist-Punkte sind umgesetzt. Inventar-API-Grundlage, OAR/IAR, persistente Auftragssteuerung, native Betriebs-Worker, LunaTexture-Persistenz sowie die abgesicherte Cross-Region-Objektkommunikation ueber NexBus sind integriert.",
|
||||
evidence = new[]
|
||||
{
|
||||
"Persistente Job Engine mit queued/running/completed/failed/cancelled, Fortschritt, Logs und Result-Metadaten",
|
||||
"OAR/IAR sind über NexBus/NodeAgent an die autoritativen Archivmodule angebunden",
|
||||
"Native Backup/Restore-, Asset-Reindex-, Regionsmigrations-, Datenbankwartungs- und Inventarreparatur-Worker sind integriert",
|
||||
"Inventar-API unterstützt Baum-, Ordner-, Item-Metadaten-, Trash-, Restore-, Copy- und Lost-&-Found-Abläufe",
|
||||
"LunaTexture-Diagnosen werden pro Region persistent gespeichert und als datensparsame Aggregate über NodeAgent und World API projiziert"
|
||||
"LunaTexture-Diagnosen werden pro Region persistent gespeichert und als datensparsame Aggregate über NodeAgent und World API projiziert",
|
||||
"llRegionSayTo kann fuer nichtlokale Objekt-UUIDs optional ueber den authentifizierten NexBus geroutet werden; Same-Owner-, Rate- und Altersgrenzen sind standardmaessig aktiv"
|
||||
}
|
||||
},
|
||||
new { version = "0.9.3.6", codename = "", title = "NV$-Wirtschaft, Bankwesen, Handel und Land", status = "planned", checklist = (object)null, summary = "Natives Kontobuch, Bankwesen, Viewer-Wirtschaftskompatibilität und Landhandel.", evidence = Array.Empty<string>() },
|
||||
@@ -2268,6 +2269,10 @@ namespace NexVerse.Server.Api
|
||||
"region_count",
|
||||
"agent_count",
|
||||
"managed_region_commands",
|
||||
"cross_region_object_messaging",
|
||||
"cross_owner_object_messaging",
|
||||
"object_messages_per_second",
|
||||
"object_message_max_age_seconds",
|
||||
"luna_texture",
|
||||
"last_seen",
|
||||
"last_event_at",
|
||||
@@ -2290,6 +2295,10 @@ namespace NexVerse.Server.Api
|
||||
["region_count"] = new { type = "integer", minimum = 0 },
|
||||
["agent_count"] = new { type = "integer", minimum = 0 },
|
||||
["managed_region_commands"] = new { type = "boolean" },
|
||||
["cross_region_object_messaging"] = new { type = "boolean" },
|
||||
["cross_owner_object_messaging"] = new { type = "boolean" },
|
||||
["object_messages_per_second"] = new { type = "integer", minimum = 0, maximum = 200 },
|
||||
["object_message_max_age_seconds"] = new { type = "integer", minimum = 0, maximum = 300 },
|
||||
["luna_texture"] = SchemaRef("LunaTextureDiagnosticsSummary"),
|
||||
["last_seen"] = new { type = "string", format = "date-time" },
|
||||
["last_event_at"] = new { type = "string", format = "date-time" },
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Optional simulator-level router used by script APIs when a direct
|
||||
/// object target is not present in the local region.
|
||||
/// </summary>
|
||||
public interface ICrossRegionObjectMessageRouter
|
||||
{
|
||||
bool Enabled { get; }
|
||||
|
||||
bool TryRoute(
|
||||
UUID sourceRegionId,
|
||||
UUID sourceObjectId,
|
||||
UUID sourceOwnerId,
|
||||
string sourceName,
|
||||
Vector3 sourcePosition,
|
||||
UUID targetObjectId,
|
||||
int channel,
|
||||
string message);
|
||||
}
|
||||
}
|
||||
@@ -1234,14 +1234,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if(UUID.TryParse(target, out UUID TargetID) && TargetID.IsNotZero())
|
||||
{
|
||||
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
|
||||
if (wComm != null)
|
||||
{
|
||||
if (msg.Length > 1023)
|
||||
msg = msg[..1023];
|
||||
if (msg.Length > 1023)
|
||||
msg = msg[..1023];
|
||||
|
||||
wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
|
||||
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
|
||||
bool localTarget =
|
||||
World.GetScenePresence(TargetID) is not null ||
|
||||
World.GetSceneObjectPart(TargetID) is not null;
|
||||
|
||||
if (localTarget)
|
||||
{
|
||||
wComm?.DeliverMessageTo(
|
||||
TargetID,
|
||||
channel,
|
||||
m_host.AbsolutePosition,
|
||||
m_host.Name,
|
||||
m_host.UUID,
|
||||
msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ICrossRegionObjectMessageRouter router =
|
||||
m_ScriptEngine.World.RequestModuleInterface<ICrossRegionObjectMessageRouter>();
|
||||
router?.TryRoute(
|
||||
World.RegionInfo.RegionID,
|
||||
m_host.UUID,
|
||||
m_host.OwnerID,
|
||||
m_host.Name,
|
||||
m_host.AbsolutePosition,
|
||||
TargetID,
|
||||
channel,
|
||||
msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
RequestTimeoutMilliseconds = 2000
|
||||
DeduplicationWindow = 10000
|
||||
|
||||
; Optional transparent remote fallback for llRegionSayTo when the target
|
||||
; object is not present in the local region. Requires NexBus transport.
|
||||
; Same-owner delivery is the safe default.
|
||||
CrossRegionObjectMessaging = false
|
||||
AllowCrossOwnerObjectMessages = false
|
||||
ObjectMessagesPerSecond = 20
|
||||
ObjectMessageMaxAgeSeconds = 30
|
||||
|
||||
; Managed region mutation executor. Keep false until the bidirectional
|
||||
; NexBus path is authenticated and protected by TLS/private networking.
|
||||
ManagedRegionCommands = false
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
RequestTimeoutMilliseconds = 2000
|
||||
DeduplicationWindow = 10000
|
||||
|
||||
; Optional transparent remote fallback for llRegionSayTo when the target
|
||||
; object is not present in the local region. Requires NexBus transport.
|
||||
; Same-owner delivery is the safe default.
|
||||
CrossRegionObjectMessaging = false
|
||||
AllowCrossOwnerObjectMessages = false
|
||||
ObjectMessagesPerSecond = 20
|
||||
ObjectMessageMaxAgeSeconds = 30
|
||||
|
||||
; Managed region mutation executor. Keep false until the bidirectional
|
||||
; NexBus path is authenticated and protected by TLS/private networking.
|
||||
ManagedRegionCommands = false
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
RequestTimeoutMilliseconds = 2000
|
||||
DeduplicationWindow = 10000
|
||||
|
||||
; Optional transparent remote fallback for llRegionSayTo when the target
|
||||
; object is not present in the local region. Requires NexBus transport.
|
||||
; Same-owner delivery is the safe default.
|
||||
CrossRegionObjectMessaging = false
|
||||
AllowCrossOwnerObjectMessages = false
|
||||
ObjectMessagesPerSecond = 20
|
||||
ObjectMessageMaxAgeSeconds = 30
|
||||
|
||||
; Managed region mutation executor. Keep false until the bidirectional
|
||||
; NexBus path is authenticated and protected by TLS/private networking.
|
||||
ManagedRegionCommands = false
|
||||
|
||||
@@ -900,7 +900,15 @@ Implemented transport foundation:
|
||||
|
||||
### 9.6 Cross-region object-to-object communication
|
||||
|
||||
Provide a supported mechanism for objects in different regions and different simulators to communicate through NexBus while retaining permission, rate-limit and abuse controls.
|
||||
- [x] Existing `llRegionSayTo` keeps native local behavior and gains an optional NexBus fallback only for non-local UUID targets.
|
||||
- [x] Simulator NodeAgent validates the source scene/object/owner before publishing `object.message.requested`.
|
||||
- [x] Receiving nodes resolve the exact target object UUID and inject through the native `IWorldComm` listener path.
|
||||
- [x] Same-owner policy is the secure default; cross-owner routing requires explicit `AllowCrossOwnerObjectMessages=true`.
|
||||
- [x] Per-source outbound and inbound rate limits are configurable and bounded.
|
||||
- [x] Delayed events are rejected by maximum age in addition to NexBus EventId deduplication.
|
||||
- [x] Existing 1023-character and debug-channel restrictions remain enforced.
|
||||
- [x] Delivery receipts are projected as `object.message.received`.
|
||||
- [x] Feature is configuration-driven and disabled by default; it requires the authenticated NexBus transport and is not automatically extended to untrusted Hypergrid peers.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -235,6 +235,27 @@ The separate `simulators:manage` scope is defined for the later command plane. N
|
||||
|
||||
Grid-layout region records include `node_id` and `node_state` when ownership can be resolved from the live registry. Operational host/process details remain available only through the simulator API and are not copied into the `regions:read` response.
|
||||
|
||||
## Cross-region object messaging
|
||||
|
||||
OpenGenesisLINK 0.9.3.5 adds an opt-in remote fallback for the existing LSL `llRegionSayTo` behavior. Local targets remain completely local. Only when the requested UUID is not present as an avatar or scene object in the current region does the script API ask the NodeAgent's cross-region router to publish an `object.message.requested` NexBus event.
|
||||
|
||||
The receiving simulator scans only its currently loaded scenes for the exact target object UUID and injects the message through the normal `IWorldComm.DeliverMessageTo` path. A receiving script therefore continues to observe an ordinary `listen` event with the original source object UUID, source object name, channel and message. No second scripting API is required.
|
||||
|
||||
The feature is disabled by default with `CrossRegionObjectMessaging=false` in `[NexVerseNodeAgent]`. It is intended only for a trusted OpenGenesisLINK NexBus topology protected by HMAC plus TLS/private networking. It is not a permission bypass for arbitrary Hypergrid peers.
|
||||
|
||||
Safety defaults are deliberately restrictive:
|
||||
|
||||
- `AllowCrossOwnerObjectMessages=false` requires source and target objects to have the same owner UUID;
|
||||
- `ObjectMessagesPerSecond=20` applies a fixed per-source-object rate limit on both outbound and inbound delivery;
|
||||
- `ObjectMessageMaxAgeSeconds=30` drops delayed/replayed events outside the accepted time window in addition to NexBus EventId deduplication;
|
||||
- message payloads retain the existing `llRegionSayTo` 1023-character limit;
|
||||
- the LSL debug channel is never routed remotely;
|
||||
- the source object and owner are revalidated against the local source scene before publication.
|
||||
|
||||
Successful remote delivery emits `object.message.received` with object, region, node and request-event identifiers. The initial implementation intentionally uses UUID fan-out across configured NexBus peers; a later object-directory optimization may reduce fan-out without changing the LSL contract.
|
||||
|
||||
The protected Node API projects the effective simulator capability as `cross_region_object_messaging`, `cross_owner_object_messaging`, `object_messages_per_second` and `object_message_max_age_seconds`. Its health object also reports `accepting_remote_object_messages`, so administrators can distinguish configured policy from a node that is currently offline or stale.
|
||||
|
||||
## Region-grid administration API
|
||||
|
||||
The first read-only Region Control Plane foundation is implemented and is used as the data contract for the later administrator raster planner.
|
||||
|
||||
@@ -43,6 +43,11 @@ internal static class Program
|
||||
["cpu_seconds"] = "3.500",
|
||||
["region_count"] = "2",
|
||||
["agent_count"] = "7",
|
||||
["managed_region_commands"] = "true",
|
||||
["cross_region_object_messaging"] = "true",
|
||||
["cross_owner_object_messaging"] = "false",
|
||||
["object_messages_per_second"] = "20",
|
||||
["object_message_max_age_seconds"] = "30",
|
||||
["luna_texture_diagnostic_count"] = "3",
|
||||
["luna_texture_occurrence_count"] = "8",
|
||||
["luna_texture_regions_affected"] = "2",
|
||||
@@ -61,6 +66,16 @@ internal static class Program
|
||||
Require(first.Hostname == "sim-a.internal", "hostname mismatch");
|
||||
Require(first.RegionCount == 2, "heartbeat region count mismatch");
|
||||
Require(first.AgentCount == 7, "heartbeat agent count mismatch");
|
||||
Require(first.ManagedRegionCommands,
|
||||
"managed-region capability mismatch");
|
||||
Require(first.CrossRegionObjectMessaging,
|
||||
"cross-region object messaging capability mismatch");
|
||||
Require(!first.CrossOwnerObjectMessaging,
|
||||
"cross-owner object messaging capability mismatch");
|
||||
Require(first.ObjectMessagesPerSecond == 20,
|
||||
"object message rate projection mismatch");
|
||||
Require(first.ObjectMessageMaxAgeSeconds == 30,
|
||||
"object message max-age projection mismatch");
|
||||
Require(first.LunaTextureDiagnosticCount == 3,
|
||||
"LunaTexture diagnostic count mismatch");
|
||||
Require(first.LunaTextureOccurrenceCount == 8,
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env python3
|
||||
from pathlib import Path
|
||||
|
||||
router = Path("OpenSim/Region/Framework/Interfaces/ICrossRegionObjectMessageRouter.cs").read_text(encoding="utf-8")
|
||||
lsl = Path("OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs").read_text(encoding="utf-8")
|
||||
node = Path("NexVerse/RegionModules/NodeAgent/NexVerseNodeAgentModule.cs").read_text(encoding="utf-8")
|
||||
registry = Path("NexVerse/Core/ControlPlane/NexNodeRegistry.cs").read_text(encoding="utf-8")
|
||||
node_api = Path("NexVerse/Server/Api/NexNodeApi.cs").read_text(encoding="utf-8")
|
||||
world_api = Path("NexVerse/Server/Api/NexVerseWorldApiHandlers.cs").read_text(encoding="utf-8")
|
||||
roadmap = Path("doc/NexVerse/ROADMAP.md").read_text(encoding="utf-8")
|
||||
|
||||
for marker in (
|
||||
"interface ICrossRegionObjectMessageRouter",
|
||||
"bool TryRoute(",
|
||||
):
|
||||
assert marker in router, f"missing cross-region router marker: {marker}"
|
||||
|
||||
for marker in (
|
||||
"llRegionSayTo",
|
||||
"ICrossRegionObjectMessageRouter",
|
||||
"World.GetScenePresence(TargetID)",
|
||||
"World.GetSceneObjectPart(TargetID)",
|
||||
"router?.TryRoute(",
|
||||
):
|
||||
assert marker in lsl, f"missing LSL remote fallback marker: {marker}"
|
||||
|
||||
for marker in (
|
||||
"ICrossRegionObjectMessageRouter",
|
||||
'CrossRegionObjectMessaging',
|
||||
'AllowCrossOwnerObjectMessages',
|
||||
'ObjectMessagesPerSecond',
|
||||
'ObjectMessageMaxAgeSeconds',
|
||||
'"object.message.requested"',
|
||||
'"object.message.received"',
|
||||
"TryTakeObjectMessageRateSlot",
|
||||
"ObjectMessageRateEntryLimit = 8192",
|
||||
'"nexverse.simulator"',
|
||||
"m_AllowCrossOwnerObjectMessages",
|
||||
"targetPart.OwnerID",
|
||||
"sourcePart.OwnerID != sourceOwnerId",
|
||||
"message.Length > 1023",
|
||||
):
|
||||
assert marker in node, f"missing NodeAgent object messaging marker: {marker}"
|
||||
|
||||
for marker in (
|
||||
"CrossRegionObjectMessaging",
|
||||
"CrossOwnerObjectMessaging",
|
||||
"ObjectMessagesPerSecond",
|
||||
"ObjectMessageMaxAgeSeconds",
|
||||
'"cross_region_object_messaging"',
|
||||
'"cross_owner_object_messaging"',
|
||||
'"object_messages_per_second"',
|
||||
'"object_message_max_age_seconds"',
|
||||
):
|
||||
assert marker in registry, f"missing Node registry object messaging projection: {marker}"
|
||||
|
||||
for marker in (
|
||||
"node.CrossRegionObjectMessaging",
|
||||
"node.CrossOwnerObjectMessaging",
|
||||
"node.ObjectMessagesPerSecond",
|
||||
"node.ObjectMessageMaxAgeSeconds",
|
||||
"cross_region_object_messaging =",
|
||||
"cross_owner_object_messaging =",
|
||||
"object_messages_per_second =",
|
||||
"object_message_max_age_seconds =",
|
||||
"accepting_remote_object_messages =",
|
||||
):
|
||||
assert marker in node_api, f"missing Node API object messaging projection: {marker}"
|
||||
|
||||
for marker in (
|
||||
'["cross_region_object_messaging"]',
|
||||
'["cross_owner_object_messaging"]',
|
||||
'["object_messages_per_second"]',
|
||||
'["object_message_max_age_seconds"]',
|
||||
):
|
||||
assert marker in world_api, f"missing Node OpenAPI object messaging marker: {marker}"
|
||||
|
||||
for path in ("bin/OpenSim.ini", "bin/OpenSim.ini.example", "bin/OpenSimDefaults.ini"):
|
||||
config = Path(path).read_text(encoding="utf-8")
|
||||
assert "CrossRegionObjectMessaging = false" in config
|
||||
assert "AllowCrossOwnerObjectMessages = false" in config
|
||||
assert "ObjectMessagesPerSecond = 20" in config
|
||||
assert "ObjectMessageMaxAgeSeconds = 30" in config
|
||||
|
||||
assert "### 9.6 Cross-region object-to-object communication" in roadmap
|
||||
print("Cross-region object messaging contract: OK")
|
||||
Reference in new issue
Block a user