29 using System.Collections.Generic;
32 using System.Reflection;
33 using System.Threading;
37 using log4net.Appender;
40 using OpenSim.Framework;
41 using OpenSim.Services.Interfaces;
42 using OpenSim.Services.Connectors;
48 private static readonly ILog m_log =
50 MethodBase.GetCurrentMethod().DeclaringType);
52 private static int m_MaxThreadID = 0;
53 private static readonly
int NREQS = 150;
54 private static int m_NReceived = 0;
56 public static void Main(
string[] args)
58 ConsoleAppender consoleAppender =
new ConsoleAppender();
59 consoleAppender.Layout =
60 new PatternLayout(
"[%thread] - %message%newline");
61 log4net.Config.BasicConfigurator.Configure(consoleAppender);
63 string serverURI =
"http://127.0.0.1:8003";
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);
72 if (!ThreadPool.SetMinThreads(1, 1))
73 m_log.WarnFormat(
"[ASSET CLIENT]: Failed to set min threads");
75 if (!ThreadPool.SetMaxThreads(10, 3))
76 m_log.WarnFormat(
"[ASSET CLIENT]: Failed to set max threads");
78 ThreadPool.GetMaxThreads(out max1, out max2);
79 m_log.InfoFormat(
"[ASSET CLIENT]: Post set max threads = {1} - {2}", serverURI, max1, max2);
80 ThreadPool.GetMinThreads(out max1, out max2);
81 m_log.InfoFormat(
"[ASSET CLIENT]: Post set min threads = {1} - {2}", serverURI, max1, max2);
83 ServicePointManager.DefaultConnectionLimit = 12;
86 m_Connector.MaxAssetRequestConcurrency = 30;
88 for (
int i = 0; i < NREQS; i++)
90 UUID uuid = UUID.Random();
91 m_Connector.Get(uuid.ToString(), null, ResponseReceived);
92 m_log.InfoFormat(
"[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid);
95 for (
int i = 0; i < 500; i++)
98 ThreadPool.QueueUserWorkItem(delegate
104 Thread.Sleep(30 * 1000);
105 m_log.InfoFormat(
"[ASSET CLIENT]: Received responses {0}", m_NReceived);
108 private static void ResponseReceived(
string id, Object sender,
AssetBase asset)
110 if (
Thread.CurrentThread.ManagedThreadId > m_MaxThreadID)
111 m_MaxThreadID = Thread.CurrentThread.ManagedThreadId;
113 ThreadPool.GetAvailableThreads(out max1, out max2);
114 m_log.InfoFormat(
"[ASSET CLIENT]: Received asset {0} ({1}) ({2}-{3}) {4}", id, m_MaxThreadID, max1, max2, DateTime.Now.ToString(
"hh:mm:ss"));
118 private static void Dummy(
int i)
121 ThreadPool.GetAvailableThreads(out max1, out max2);
122 m_log.InfoFormat(
"[ASSET CLIENT]: ({0}) Hello! {1} - {2} {3}", i, max1, max2, DateTime.Now.ToString(
"hh:mm:ss"));
static void Main(string[] args)
Asset class. All Assets are reference by this class or a class derived from this class ...
Interactive OpenSim region server