From 5e4fc6e91e5edffd1dc23af4f583d6294f394a3d Mon Sep 17 00:00:00 2001
From: diva
Date: Fri, 15 May 2009 05:00:25 +0000
Subject: Heart surgery on asset service code bits. Affects OpenSim.ini
configuration -- please see the example. Affects region servers only. This
may break a lot of things, but it needs to go in. It was tested in standalone
and the UCI grid, but it needs a lot more testing. Known problems: * HG asset
transfers are borked for now * missing texture is missing * 3 unit tests
commented out for now
---
OpenSim/Region/ClientStack/ClientStackManager.cs | 8 +-
OpenSim/Region/ClientStack/IClientNetworkServer.cs | 2 +-
OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 11 ++-
.../Region/ClientStack/LindenUDP/LLClientView.cs | 107 ++++++++++++++++++++-
.../Region/ClientStack/LindenUDP/LLImageManager.cs | 7 +-
.../Region/ClientStack/LindenUDP/LLUDPServer.cs | 5 +-
.../LindenUDP/Tests/BasicCircuitTests.cs | 2 +-
.../LindenUDP/Tests/PacketHandlerTests.cs | 2 +-
8 files changed, 124 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/ClientStack')
diff --git a/OpenSim/Region/ClientStack/ClientStackManager.cs b/OpenSim/Region/ClientStack/ClientStackManager.cs
index a7b65cb..4f36df8 100644
--- a/OpenSim/Region/ClientStack/ClientStackManager.cs
+++ b/OpenSim/Region/ClientStack/ClientStackManager.cs
@@ -86,10 +86,10 @@ namespace OpenSim.Region.ClientStack
///
public IClientNetworkServer CreateServer(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port,
- IAssetCache assetCache, AgentCircuitManager authenticateClass)
+ AgentCircuitManager authenticateClass)
{
return CreateServer(
- _listenIP, ref port, proxyPortOffset, allow_alternate_port, null, assetCache, authenticateClass);
+ _listenIP, ref port, proxyPortOffset, allow_alternate_port, null, authenticateClass);
}
///
@@ -107,7 +107,7 @@ namespace OpenSim.Region.ClientStack
///
public IClientNetworkServer CreateServer(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource,
- IAssetCache assetCache, AgentCircuitManager authenticateClass)
+ AgentCircuitManager authenticateClass)
{
if (plugin != null)
{
@@ -116,7 +116,7 @@ namespace OpenSim.Region.ClientStack
server.Initialise(
_listenIP, ref port, proxyPortOffset, allow_alternate_port,
- configSource, assetCache, authenticateClass);
+ configSource, authenticateClass);
return server;
}
diff --git a/OpenSim/Region/ClientStack/IClientNetworkServer.cs b/OpenSim/Region/ClientStack/IClientNetworkServer.cs
index f2f1614..23f639f 100644
--- a/OpenSim/Region/ClientStack/IClientNetworkServer.cs
+++ b/OpenSim/Region/ClientStack/IClientNetworkServer.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ClientStack
{
void Initialise(
IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource,
- IAssetCache assetCache, AgentCircuitManager authenticateClass);
+ AgentCircuitManager authenticateClass);
Socket Server { get; }
bool HandlesRegion(Location x);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index aef0ada..a88fd26 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -31,6 +31,7 @@ using OpenMetaverse;
using OpenMetaverse.Imaging;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Services.Interfaces;
using log4net;
using System.Reflection;
@@ -50,7 +51,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public sbyte m_requestedDiscardLevel;
public UUID m_requestedUUID;
public IJ2KDecoder m_j2kDecodeModule;
- public IAssetCache m_assetCache;
+ public IAssetService m_assetCache;
public OpenJPEG.J2KLayerInfo[] Layers = new OpenJPEG.J2KLayerInfo[0];
public AssetBase m_MissingSubstitute = null;
public bool m_decoded = false;
@@ -131,6 +132,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
RunUpdate();
}
+ protected void AssetReceived(string id, Object sender, AssetBase asset)
+ {
+ if (asset != null)
+ AssetDataCallback(asset.FullID, asset);
+ }
+
private int GetPacketForBytePosition(int bytePosition)
{
return ((bytePosition - cFirstPacketSize + cImagePacketSize - 1) / cImagePacketSize) + 1;
@@ -301,7 +308,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!m_asset_requested)
{
m_asset_requested = true;
- m_assetCache.GetAsset(m_requestedUUID, AssetDataCallback, true);
+ m_assetCache.Get(m_requestedUUID.ToString(), this, AssetReceived);
}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 0eb08b2..7c524d9 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -43,6 +43,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Statistics;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
using Timer=System.Timers.Timer;
using Nini.Config;
@@ -66,7 +67,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_debugPacketLevel;
- private readonly IAssetCache m_assetCache;
+ //private readonly IAssetCache m_assetCache;
private int m_cachedTextureSerial;
private Timer m_clientPingTimer;
@@ -141,6 +142,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected int m_packetMTU = 1400;
+ protected IAssetService m_assetService;
+
// LLClientView Only
public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
@@ -490,7 +493,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
InitDefaultAnimations();
m_scene = scene;
- m_assetCache = assetCache;
+ //m_assetCache = assetCache;
+
+ m_assetService = m_scene.RequestModuleInterface();
+ m_log.Debug("[XXX] m_assetService is null? " + ((m_assetService == null) ? "yes" : "no"));
m_networkServer = packServer;
@@ -543,7 +549,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
RegisterLocalPacketHandlers();
- m_imageManager = new LLImageManager(this, m_assetCache,Scene.RequestModuleInterface());
+ m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface());
}
public void SetDebugPacketLevel(int newDebugPacketLevel)
@@ -6451,7 +6457,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
- m_assetCache.AddAssetRequest(this, transfer);
+ //m_assetCache.AddAssetRequest(this, transfer);
+
+ MakeAssetRequest(transfer);
+
/* RequestAsset = OnRequestAsset;
if (RequestAsset != null)
{
@@ -7115,7 +7124,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
AssetLandmark lm;
if (lmid != UUID.Zero)
{
- AssetBase lma = m_assetCache.GetAsset(lmid, false);
+ //AssetBase lma = m_assetCache.GetAsset(lmid, false);
+ AssetBase lma = m_assetService.Get(lmid.ToString());
if (lma == null)
{
@@ -10604,6 +10614,93 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return "";
}
+ public void MakeAssetRequest(TransferRequestPacket transferRequest)
+ {
+ UUID requestID = UUID.Zero;
+ if (transferRequest.TransferInfo.SourceType == 2)
+ {
+ //direct asset request
+ requestID = new UUID(transferRequest.TransferInfo.Params, 0);
+ }
+ else if (transferRequest.TransferInfo.SourceType == 3)
+ {
+ //inventory asset request
+ requestID = new UUID(transferRequest.TransferInfo.Params, 80);
+ //m_log.Debug("asset request " + requestID);
+ }
+
+ //check to see if asset is in local cache, if not we need to request it from asset server.
+ //m_log.Debug("asset request " + requestID);
+
+ m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
+
+ }
+
+ protected void AssetReceived(string id, Object sender, AssetBase asset)
+ {
+ TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
+
+ UUID requestID = UUID.Zero;
+ byte source = 2;
+ if (transferRequest.TransferInfo.SourceType == 2)
+ {
+ //direct asset request
+ requestID = new UUID(transferRequest.TransferInfo.Params, 0);
+ }
+ else if (transferRequest.TransferInfo.SourceType == 3)
+ {
+ //inventory asset request
+ requestID = new UUID(transferRequest.TransferInfo.Params, 80);
+ source = 3;
+ //m_log.Debug("asset request " + requestID);
+ }
+
+ // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right.
+ if (null == asset)
+ {
+ //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID);
+ return;
+ }
+
+ // Scripts cannot be retrieved by direct request
+ if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10)
+ return;
+
+ // The asset is known to exist and is in our cache, so add it to the AssetRequests list
+ AssetRequestToClient req = new AssetRequestToClient();
+ req.AssetInf = asset;
+ req.AssetRequestSource = source;
+ req.IsTextureRequest = false;
+ req.NumPackets = CalculateNumPackets(asset.Data);
+ req.Params = transferRequest.TransferInfo.Params;
+ req.RequestAssetID = requestID;
+ req.TransferRequestID = transferRequest.TransferInfo.TransferID;
+
+ SendAsset(req);
+ }
+
+ ///
+ /// Calculate the number of packets required to send the asset to the client.
+ ///
+ ///
+ ///
+ private static int CalculateNumPackets(byte[] data)
+ {
+ const uint m_maxPacketSize = 600;
+ int numPackets = 1;
+
+ if (data.LongLength > m_maxPacketSize)
+ {
+ // over max number of bytes so split up file
+ long restData = data.LongLength - m_maxPacketSize;
+ int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
+ numPackets += restPackets;
+ }
+
+ return numPackets;
+ }
+
+
#region IClientIPEndpoint Members
public IPAddress EndPoint
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
index 1aa0c75..a2160c6 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
@@ -31,6 +31,7 @@ using OpenMetaverse;
using OpenMetaverse.Imaging;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Services.Interfaces;
using log4net;
using System.Reflection;
@@ -50,7 +51,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private long m_lastloopprocessed = 0;
private LLClientView m_client; //Client we're assigned to
- private IAssetCache m_assetCache; //Asset Cache
+ private IAssetService m_assetCache; //Asset Cache
private IJ2KDecoder m_j2kDecodeModule; //Our J2K module
private readonly AssetBase m_missingsubstitute; //Sustitute for bad decodes
@@ -62,7 +63,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public int m_outstandingtextures = 0;
//Constructor
- public LLImageManager(LLClientView client, IAssetCache pAssetCache, IJ2KDecoder pJ2kDecodeModule)
+ public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
{
m_imagestore = new Dictionary();
@@ -71,7 +72,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_client = client;
m_assetCache = pAssetCache;
if (pAssetCache != null)
- m_missingsubstitute = pAssetCache.GetAsset(UUID.Parse("5748decc-f629-461c-9a36-a35a221fe21f"), true);
+ m_missingsubstitute = pAssetCache.Get("5748decc-f629-461c-9a36-a35a221fe21f");
else
m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break");
m_j2kDecodeModule = pJ2kDecodeModule;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index e796cff..4eaaea1 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -132,7 +132,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource,
IAssetCache assetCache, AgentCircuitManager authenticateClass)
{
- Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, configSource, assetCache, authenticateClass);
+ Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, configSource, authenticateClass);
}
///
@@ -147,7 +147,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
///
public void Initialise(
IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource,
- IAssetCache assetCache, AgentCircuitManager circuitManager)
+ AgentCircuitManager circuitManager)
{
ClientStackUserSettings userSettings = new ClientStackUserSettings();
@@ -165,7 +165,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
listenPort = (uint) (port + proxyPortOffsetParm);
listenIP = _listenIP;
Allow_Alternate_Port = allow_alternate_port;
- m_assetCache = assetCache;
m_circuitManager = circuitManager;
CreatePacketServer(userSettings);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
index 02f78c7..46d39c7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
acm = new AgentCircuitManager();
uint port = 666;
- testLLUDPServer.Initialise(null, ref port, 0, false, configSource, null, acm);
+ testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm);
testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings);
testLLUDPServer.LocalScene = scene;
}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs
index 4ebc624..e014634 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs
@@ -98,7 +98,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
acm = new AgentCircuitManager();
uint port = 666;
- testLLUDPServer.Initialise(null, ref port, 0, false, configSource, null, acm);
+ testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm);
testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings);
testLLUDPServer.LocalScene = scene;
}
--
cgit v1.1