diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Tests/Clients/Assets/AssetsClient.cs | 116 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestClient.cs | 2 |
2 files changed, 117 insertions, 1 deletions
diff --git a/OpenSim/Tests/Clients/Assets/AssetsClient.cs b/OpenSim/Tests/Clients/Assets/AssetsClient.cs new file mode 100644 index 0000000..26d740b --- /dev/null +++ b/OpenSim/Tests/Clients/Assets/AssetsClient.cs | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Text; | ||
32 | using System.Reflection; | ||
33 | using System.Threading; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using log4net; | ||
37 | using log4net.Appender; | ||
38 | using log4net.Layout; | ||
39 | |||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Services.Connectors; | ||
43 | |||
44 | namespace OpenSim.Tests.Clients.AssetsClient | ||
45 | { | ||
46 | public class AssetsClient | ||
47 | { | ||
48 | private static readonly ILog m_log = | ||
49 | LogManager.GetLogger( | ||
50 | MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private static int m_MaxThreadID = 0; | ||
53 | private static readonly int NREQS = 150; | ||
54 | private static int m_NReceived = 0; | ||
55 | |||
56 | public static void Main(string[] args) | ||
57 | { | ||
58 | ConsoleAppender consoleAppender = new ConsoleAppender(); | ||
59 | consoleAppender.Layout = | ||
60 | new PatternLayout("[%thread] - %message%newline"); | ||
61 | log4net.Config.BasicConfigurator.Configure(consoleAppender); | ||
62 | |||
63 | string serverURI = "http://127.0.0.1:8003"; | ||
64 | if (args.Length > 1) | ||
65 | serverURI = args[1]; | ||
66 | int max1, max2; | ||
67 | ThreadPool.GetMaxThreads(out max1, out max2); | ||
68 | m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} max threads = {1} - {2}", serverURI, max1, max2); | ||
69 | ThreadPool.GetMinThreads(out max1, out max2); | ||
70 | m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} min threads = {1} - {2}", serverURI, max1, max2); | ||
71 | ThreadPool.SetMinThreads(1, 1); | ||
72 | ThreadPool.SetMaxThreads(10, 3); | ||
73 | ServicePointManager.DefaultConnectionLimit = 12; | ||
74 | |||
75 | AssetServicesConnector m_Connector = new AssetServicesConnector(serverURI); | ||
76 | m_Connector.MaxAssetRequestConcurrency = 30; | ||
77 | |||
78 | for (int i = 0; i < NREQS; i++) | ||
79 | { | ||
80 | UUID uuid = UUID.Random(); | ||
81 | m_Connector.Get(uuid.ToString(), null, ResponseReceived); | ||
82 | m_log.InfoFormat("[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid); | ||
83 | } | ||
84 | |||
85 | for (int i = 0; i < 500; i++) | ||
86 | { | ||
87 | var x = i; | ||
88 | ThreadPool.QueueUserWorkItem(delegate | ||
89 | { | ||
90 | Dummy(x); | ||
91 | }); | ||
92 | } | ||
93 | |||
94 | Thread.Sleep(30 * 1000); | ||
95 | m_log.InfoFormat("[ASSET CLIENT]: Received responses {0}", m_NReceived); | ||
96 | } | ||
97 | |||
98 | private static void ResponseReceived(string id, Object sender, AssetBase asset) | ||
99 | { | ||
100 | if (Thread.CurrentThread.ManagedThreadId > m_MaxThreadID) | ||
101 | m_MaxThreadID = Thread.CurrentThread.ManagedThreadId; | ||
102 | int max1, max2; | ||
103 | ThreadPool.GetAvailableThreads(out max1, out max2); | ||
104 | m_log.InfoFormat("[ASSET CLIENT]: Received asset {0} ({1}) ({2}-{3}) {4}", id, m_MaxThreadID, max1, max2, DateTime.Now.ToString("hh:mm:ss")); | ||
105 | m_NReceived++; | ||
106 | } | ||
107 | |||
108 | private static void Dummy(int i) | ||
109 | { | ||
110 | int max1, max2; | ||
111 | ThreadPool.GetAvailableThreads(out max1, out max2); | ||
112 | m_log.InfoFormat("[ASSET CLIENT]: ({0}) Hello! {1} - {2} {3}", i, max1, max2, DateTime.Now.ToString("hh:mm:ss")); | ||
113 | Thread.Sleep(2000); | ||
114 | } | ||
115 | } | ||
116 | } | ||
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 179a91f..6528d9a 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -591,7 +591,7 @@ namespace OpenSim.Tests.Common.Mock | |||
591 | { | 591 | { |
592 | AgentCircuitData agentData = new AgentCircuitData(); | 592 | AgentCircuitData agentData = new AgentCircuitData(); |
593 | agentData.AgentID = AgentId; | 593 | agentData.AgentID = AgentId; |
594 | agentData.SessionID = UUID.Zero; | 594 | agentData.SessionID = SessionId; |
595 | agentData.SecureSessionID = UUID.Zero; | 595 | agentData.SecureSessionID = UUID.Zero; |
596 | agentData.circuitcode = m_circuitCode; | 596 | agentData.circuitcode = m_circuitCode; |
597 | agentData.child = false; | 597 | agentData.child = false; |