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
This commit is contained in:
diva
2009-05-15 05:00:25 +00:00
parent 14c1e991c6
commit 5e4fc6e91e
56 changed files with 716 additions and 511 deletions

View File

@@ -86,10 +86,10 @@ namespace OpenSim.Region.ClientStack
/// <returns></returns>
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);
}
/// <summary>
@@ -107,7 +107,7 @@ namespace OpenSim.Region.ClientStack
/// <returns></returns>
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;
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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<IAssetService>();
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<IJ2KDecoder>());
m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
}
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);
}
/// <summary>
/// Calculate the number of packets required to send the asset to the client.
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
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

View File

@@ -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<UUID,J2KImage>();
@@ -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;

View File

@@ -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);
}
/// <summary>
@@ -147,7 +147,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="circuitManager"></param>
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);

View File

@@ -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;
}

View File

@@ -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;
}