aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP
diff options
context:
space:
mode:
authordiva2009-05-15 05:00:25 +0000
committerdiva2009-05-15 05:00:25 +0000
commit5e4fc6e91e5edffd1dc23af4f583d6294f394a3d (patch)
tree497076db68193be2d14fc3788c1d80c74d8c977d /OpenSim/Region/ClientStack/LindenUDP
parentsome sculpted prim geometry accuracy and meshing speed improvements (diff)
downloadopensim-SC_OLD-5e4fc6e91e5edffd1dc23af4f583d6294f394a3d.zip
opensim-SC_OLD-5e4fc6e91e5edffd1dc23af4f583d6294f394a3d.tar.gz
opensim-SC_OLD-5e4fc6e91e5edffd1dc23af4f583d6294f394a3d.tar.bz2
opensim-SC_OLD-5e4fc6e91e5edffd1dc23af4f583d6294f394a3d.tar.xz
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
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs11
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs107
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs7
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs2
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs2
6 files changed, 119 insertions, 15 deletions
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;
31using OpenMetaverse.Imaging; 31using OpenMetaverse.Imaging;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Services.Interfaces;
34using log4net; 35using log4net;
35using System.Reflection; 36using System.Reflection;
36 37
@@ -50,7 +51,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
50 public sbyte m_requestedDiscardLevel; 51 public sbyte m_requestedDiscardLevel;
51 public UUID m_requestedUUID; 52 public UUID m_requestedUUID;
52 public IJ2KDecoder m_j2kDecodeModule; 53 public IJ2KDecoder m_j2kDecodeModule;
53 public IAssetCache m_assetCache; 54 public IAssetService m_assetCache;
54 public OpenJPEG.J2KLayerInfo[] Layers = new OpenJPEG.J2KLayerInfo[0]; 55 public OpenJPEG.J2KLayerInfo[] Layers = new OpenJPEG.J2KLayerInfo[0];
55 public AssetBase m_MissingSubstitute = null; 56 public AssetBase m_MissingSubstitute = null;
56 public bool m_decoded = false; 57 public bool m_decoded = false;
@@ -131,6 +132,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
131 RunUpdate(); 132 RunUpdate();
132 } 133 }
133 134
135 protected void AssetReceived(string id, Object sender, AssetBase asset)
136 {
137 if (asset != null)
138 AssetDataCallback(asset.FullID, asset);
139 }
140
134 private int GetPacketForBytePosition(int bytePosition) 141 private int GetPacketForBytePosition(int bytePosition)
135 { 142 {
136 return ((bytePosition - cFirstPacketSize + cImagePacketSize - 1) / cImagePacketSize) + 1; 143 return ((bytePosition - cFirstPacketSize + cImagePacketSize - 1) / cImagePacketSize) + 1;
@@ -301,7 +308,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
301 if (!m_asset_requested) 308 if (!m_asset_requested)
302 { 309 {
303 m_asset_requested = true; 310 m_asset_requested = true;
304 m_assetCache.GetAsset(m_requestedUUID, AssetDataCallback, true); 311 m_assetCache.Get(m_requestedUUID.ToString(), this, AssetReceived);
305 312
306 } 313 }
307 314
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;
43using OpenSim.Framework.Statistics; 43using OpenSim.Framework.Statistics;
44using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
46using OpenSim.Services.Interfaces;
46using Timer=System.Timers.Timer; 47using Timer=System.Timers.Timer;
47using Nini.Config; 48using Nini.Config;
48 49
@@ -66,7 +67,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
66 67
67 private int m_debugPacketLevel; 68 private int m_debugPacketLevel;
68 69
69 private readonly IAssetCache m_assetCache; 70 //private readonly IAssetCache m_assetCache;
70 private int m_cachedTextureSerial; 71 private int m_cachedTextureSerial;
71 private Timer m_clientPingTimer; 72 private Timer m_clientPingTimer;
72 73
@@ -141,6 +142,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
141 142
142 protected int m_packetMTU = 1400; 143 protected int m_packetMTU = 1400;
143 144
145 protected IAssetService m_assetService;
146
144 // LLClientView Only 147 // LLClientView Only
145 public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args); 148 public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
146 149
@@ -490,7 +493,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
490 InitDefaultAnimations(); 493 InitDefaultAnimations();
491 494
492 m_scene = scene; 495 m_scene = scene;
493 m_assetCache = assetCache; 496 //m_assetCache = assetCache;
497
498 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
499 m_log.Debug("[XXX] m_assetService is null? " + ((m_assetService == null) ? "yes" : "no"));
494 500
495 m_networkServer = packServer; 501 m_networkServer = packServer;
496 502
@@ -543,7 +549,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
543 } 549 }
544 550
545 RegisterLocalPacketHandlers(); 551 RegisterLocalPacketHandlers();
546 m_imageManager = new LLImageManager(this, m_assetCache,Scene.RequestModuleInterface<IJ2KDecoder>()); 552 m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
547 } 553 }
548 554
549 public void SetDebugPacketLevel(int newDebugPacketLevel) 555 public void SetDebugPacketLevel(int newDebugPacketLevel)
@@ -6451,7 +6457,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6451 } 6457 }
6452 } 6458 }
6453 6459
6454 m_assetCache.AddAssetRequest(this, transfer); 6460 //m_assetCache.AddAssetRequest(this, transfer);
6461
6462 MakeAssetRequest(transfer);
6463
6455 /* RequestAsset = OnRequestAsset; 6464 /* RequestAsset = OnRequestAsset;
6456 if (RequestAsset != null) 6465 if (RequestAsset != null)
6457 { 6466 {
@@ -7115,7 +7124,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7115 AssetLandmark lm; 7124 AssetLandmark lm;
7116 if (lmid != UUID.Zero) 7125 if (lmid != UUID.Zero)
7117 { 7126 {
7118 AssetBase lma = m_assetCache.GetAsset(lmid, false); 7127 //AssetBase lma = m_assetCache.GetAsset(lmid, false);
7128 AssetBase lma = m_assetService.Get(lmid.ToString());
7119 7129
7120 if (lma == null) 7130 if (lma == null)
7121 { 7131 {
@@ -10604,6 +10614,93 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10604 return ""; 10614 return "";
10605 } 10615 }
10606 10616
10617 public void MakeAssetRequest(TransferRequestPacket transferRequest)
10618 {
10619 UUID requestID = UUID.Zero;
10620 if (transferRequest.TransferInfo.SourceType == 2)
10621 {
10622 //direct asset request
10623 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
10624 }
10625 else if (transferRequest.TransferInfo.SourceType == 3)
10626 {
10627 //inventory asset request
10628 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
10629 //m_log.Debug("asset request " + requestID);
10630 }
10631
10632 //check to see if asset is in local cache, if not we need to request it from asset server.
10633 //m_log.Debug("asset request " + requestID);
10634
10635 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
10636
10637 }
10638
10639 protected void AssetReceived(string id, Object sender, AssetBase asset)
10640 {
10641 TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
10642
10643 UUID requestID = UUID.Zero;
10644 byte source = 2;
10645 if (transferRequest.TransferInfo.SourceType == 2)
10646 {
10647 //direct asset request
10648 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
10649 }
10650 else if (transferRequest.TransferInfo.SourceType == 3)
10651 {
10652 //inventory asset request
10653 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
10654 source = 3;
10655 //m_log.Debug("asset request " + requestID);
10656 }
10657
10658 // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right.
10659 if (null == asset)
10660 {
10661 //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID);
10662 return;
10663 }
10664
10665 // Scripts cannot be retrieved by direct request
10666 if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10)
10667 return;
10668
10669 // The asset is known to exist and is in our cache, so add it to the AssetRequests list
10670 AssetRequestToClient req = new AssetRequestToClient();
10671 req.AssetInf = asset;
10672 req.AssetRequestSource = source;
10673 req.IsTextureRequest = false;
10674 req.NumPackets = CalculateNumPackets(asset.Data);
10675 req.Params = transferRequest.TransferInfo.Params;
10676 req.RequestAssetID = requestID;
10677 req.TransferRequestID = transferRequest.TransferInfo.TransferID;
10678
10679 SendAsset(req);
10680 }
10681
10682 /// <summary>
10683 /// Calculate the number of packets required to send the asset to the client.
10684 /// </summary>
10685 /// <param name="data"></param>
10686 /// <returns></returns>
10687 private static int CalculateNumPackets(byte[] data)
10688 {
10689 const uint m_maxPacketSize = 600;
10690 int numPackets = 1;
10691
10692 if (data.LongLength > m_maxPacketSize)
10693 {
10694 // over max number of bytes so split up file
10695 long restData = data.LongLength - m_maxPacketSize;
10696 int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
10697 numPackets += restPackets;
10698 }
10699
10700 return numPackets;
10701 }
10702
10703
10607 #region IClientIPEndpoint Members 10704 #region IClientIPEndpoint Members
10608 10705
10609 public IPAddress EndPoint 10706 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;
31using OpenMetaverse.Imaging; 31using OpenMetaverse.Imaging;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Services.Interfaces;
34using log4net; 35using log4net;
35using System.Reflection; 36using System.Reflection;
36 37
@@ -50,7 +51,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
50 private long m_lastloopprocessed = 0; 51 private long m_lastloopprocessed = 0;
51 52
52 private LLClientView m_client; //Client we're assigned to 53 private LLClientView m_client; //Client we're assigned to
53 private IAssetCache m_assetCache; //Asset Cache 54 private IAssetService m_assetCache; //Asset Cache
54 private IJ2KDecoder m_j2kDecodeModule; //Our J2K module 55 private IJ2KDecoder m_j2kDecodeModule; //Our J2K module
55 56
56 private readonly AssetBase m_missingsubstitute; //Sustitute for bad decodes 57 private readonly AssetBase m_missingsubstitute; //Sustitute for bad decodes
@@ -62,7 +63,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
62 63
63 public int m_outstandingtextures = 0; 64 public int m_outstandingtextures = 0;
64 //Constructor 65 //Constructor
65 public LLImageManager(LLClientView client, IAssetCache pAssetCache, IJ2KDecoder pJ2kDecodeModule) 66 public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
66 { 67 {
67 68
68 m_imagestore = new Dictionary<UUID,J2KImage>(); 69 m_imagestore = new Dictionary<UUID,J2KImage>();
@@ -71,7 +72,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
71 m_client = client; 72 m_client = client;
72 m_assetCache = pAssetCache; 73 m_assetCache = pAssetCache;
73 if (pAssetCache != null) 74 if (pAssetCache != null)
74 m_missingsubstitute = pAssetCache.GetAsset(UUID.Parse("5748decc-f629-461c-9a36-a35a221fe21f"), true); 75 m_missingsubstitute = pAssetCache.Get("5748decc-f629-461c-9a36-a35a221fe21f");
75 else 76 else
76 m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break"); 77 m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break");
77 m_j2kDecodeModule = pJ2kDecodeModule; 78 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
132 IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource, 132 IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource,
133 IAssetCache assetCache, AgentCircuitManager authenticateClass) 133 IAssetCache assetCache, AgentCircuitManager authenticateClass)
134 { 134 {
135 Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, configSource, assetCache, authenticateClass); 135 Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, configSource, authenticateClass);
136 } 136 }
137 137
138 /// <summary> 138 /// <summary>
@@ -147,7 +147,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
147 /// <param name="circuitManager"></param> 147 /// <param name="circuitManager"></param>
148 public void Initialise( 148 public void Initialise(
149 IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, 149 IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource,
150 IAssetCache assetCache, AgentCircuitManager circuitManager) 150 AgentCircuitManager circuitManager)
151 { 151 {
152 ClientStackUserSettings userSettings = new ClientStackUserSettings(); 152 ClientStackUserSettings userSettings = new ClientStackUserSettings();
153 153
@@ -165,7 +165,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
165 listenPort = (uint) (port + proxyPortOffsetParm); 165 listenPort = (uint) (port + proxyPortOffsetParm);
166 listenIP = _listenIP; 166 listenIP = _listenIP;
167 Allow_Alternate_Port = allow_alternate_port; 167 Allow_Alternate_Port = allow_alternate_port;
168 m_assetCache = assetCache;
169 m_circuitManager = circuitManager; 168 m_circuitManager = circuitManager;
170 CreatePacketServer(userSettings); 169 CreatePacketServer(userSettings);
171 170
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
73 acm = new AgentCircuitManager(); 73 acm = new AgentCircuitManager();
74 74
75 uint port = 666; 75 uint port = 666;
76 testLLUDPServer.Initialise(null, ref port, 0, false, configSource, null, acm); 76 testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm);
77 testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); 77 testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings);
78 testLLUDPServer.LocalScene = scene; 78 testLLUDPServer.LocalScene = scene;
79 } 79 }
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
98 acm = new AgentCircuitManager(); 98 acm = new AgentCircuitManager();
99 99
100 uint port = 666; 100 uint port = 666;
101 testLLUDPServer.Initialise(null, ref port, 0, false, configSource, null, acm); 101 testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm);
102 testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); 102 testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings);
103 testLLUDPServer.LocalScene = scene; 103 testLLUDPServer.LocalScene = scene;
104 } 104 }