From ab4e6a02a52bfd473ea3c2050774103ec8eb3934 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 11 May 2012 00:37:20 +0100
Subject: If a bot is not connected, show region name "(none)" instead of
throwing an exception in the "show bots" command of pCampbot
---
OpenSim/Tools/pCampBot/BotManager.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 0f501b7..fd32a6a 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -302,9 +302,11 @@ namespace pCampBot
{
foreach (Bot pb in m_lBot)
{
+ Simulator currentSim = pb.Client.Network.CurrentSim;
+
MainConsole.Instance.OutputFormat(
outputFormat,
- pb.Name, pb.Client.Network.CurrentSim.Name, pb.IsConnected ? "Connected" : "Disconnected");
+ pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.IsConnected ? "Connected" : "Disconnected");
}
}
}
--
cgit v1.1
From dc39ec82fa8343657ad9b45a7d9cfeb27bf26e79 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 11 May 2012 00:53:21 +0100
Subject: Change bot.IsConnected to be ConnectionState with Disconnected,
Connecting, Connnected and Disconnecting states
---
OpenSim/Tools/pCampBot/Bot.cs | 23 ++++++++++++++++++++---
OpenSim/Tools/pCampBot/BotManager.cs | 4 ++--
2 files changed, 22 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index da090dd..2b4a171 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -43,6 +43,14 @@ using Timer = System.Timers.Timer;
namespace pCampBot
{
+ public enum ConnectionState
+ {
+ Disconnected,
+ Connecting,
+ Connected,
+ Disconnecting
+ }
+
public class Bot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -86,7 +94,7 @@ namespace pCampBot
///
/// Is this bot connected to the grid?
///
- public bool IsConnected { get; private set; }
+ public ConnectionState ConnectionState { get; private set; }
public string FirstName { get; private set; }
public string LastName { get; private set; }
@@ -130,6 +138,8 @@ namespace pCampBot
BotManager bm, List behaviours,
string firstName, string lastName, string password, string loginUri)
{
+ ConnectionState = ConnectionState.Disconnected;
+
behaviours.ForEach(b => b.Initialize(this));
Client = new GridClient();
@@ -178,6 +188,8 @@ namespace pCampBot
///
public void shutdown()
{
+ ConnectionState = ConnectionState.Disconnecting;
+
if (m_actionThread != null)
m_actionThread.Abort();
@@ -209,9 +221,11 @@ namespace pCampBot
Client.Network.Disconnected += this.Network_OnDisconnected;
Client.Objects.ObjectUpdate += Objects_NewPrim;
+ ConnectionState = ConnectionState.Connecting;
+
if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
{
- IsConnected = true;
+ ConnectionState = ConnectionState.Connected;
Thread.Sleep(Random.Next(1000, 10000));
m_actionThread = new Thread(Action);
@@ -241,6 +255,8 @@ namespace pCampBot
}
else
{
+ ConnectionState = ConnectionState.Disconnected;
+
m_log.ErrorFormat(
"{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage);
@@ -439,6 +455,8 @@ namespace pCampBot
public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
{
+ ConnectionState = ConnectionState.Disconnected;
+
m_log.DebugFormat(
"[BOT]: Bot {0} disconnected reason {1}, message {2}", Name, args.Reason, args.Message);
@@ -456,7 +474,6 @@ namespace pCampBot
&& OnDisconnected != null)
// if (OnDisconnected != null)
{
- IsConnected = false;
OnDisconnected(this, EventType.DISCONNECTED);
}
}
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index fd32a6a..d4bbc2a 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -242,7 +242,7 @@ namespace pCampBot
lock (m_lBot)
{
- if (m_lBot.TrueForAll(b => !b.IsConnected))
+ if (m_lBot.TrueForAll(b => b.ConnectionState == ConnectionState.Disconnected))
Environment.Exit(0);
break;
@@ -306,7 +306,7 @@ namespace pCampBot
MainConsole.Instance.OutputFormat(
outputFormat,
- pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.IsConnected ? "Connected" : "Disconnected");
+ pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState);
}
}
}
--
cgit v1.1
From 93b615c51df3dec8276aead52141534a7ed32ff9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 11 May 2012 01:37:03 +0100
Subject: Do each bot shutdown on its own threads to prevent one slow shutdown
holding up all the rest.
This does increase the aggressiveness of shutdown
Also prevents the bot list being locked for a long period, which was preventing commands such as "show bots" from working during shutdown
---
OpenSim/Tools/pCampBot/BotManager.cs | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index d4bbc2a..d06c55b 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -251,13 +251,21 @@ namespace pCampBot
}
///
- /// Shutting down all bots
+ /// Shut down all bots
///
+ ///
+ /// We launch each shutdown on its own thread so that a slow shutting down bot doesn't hold up all the others.
+ ///
public void doBotShutdown()
{
lock (m_lBot)
- foreach (Bot pb in m_lBot)
- pb.shutdown();
+ {
+ foreach (Bot bot in m_lBot)
+ {
+ Bot thisBot = bot;
+ Util.FireAndForget(o => thisBot.shutdown());
+ }
+ }
}
///
@@ -271,11 +279,8 @@ namespace pCampBot
private void HandleShutdown(string module, string[] cmd)
{
- Util.FireAndForget(o =>
- {
- m_log.Warn("[BOTMANAGER]: Shutting down bots");
- doBotShutdown();
- });
+ m_log.Info("[BOTMANAGER]: Shutting down bots");
+ doBotShutdown();
}
private void HandleShowRegions(string module, string[] cmd)
--
cgit v1.1
From 0ddf3c5289f32fc5ed3283d493f305286058e48c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 11 May 2012 01:56:00 +0100
Subject: Do bot startup on another thread so console is responsive during this
process
---
OpenSim/Tools/pCampBot/BotManager.cs | 1 +
OpenSim/Tools/pCampBot/pCampBot.cs | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index d06c55b..6d4bdb1 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -222,6 +222,7 @@ namespace pCampBot
Thread pbThread = new Thread(pb.startup);
pbThread.Name = pb.Name;
pbThread.IsBackground = true;
+
pbThread.Start();
}
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs
index ec5ad04..52e7501 100644
--- a/OpenSim/Tools/pCampBot/pCampBot.cs
+++ b/OpenSim/Tools/pCampBot/pCampBot.cs
@@ -27,6 +27,7 @@
using System;
using System.Reflection;
+using System.Threading;
using log4net;
using Nini.Config;
using OpenSim.Framework;
@@ -67,7 +68,9 @@ namespace pCampBot
BotManager bm = new BotManager();
//startup specified number of bots. 1 is the default
- bm.dobotStartup(botcount, config);
+ Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, config));
+ startBotThread.Name = "Initial start bots thread";
+ startBotThread.Start();
while (true)
{
--
cgit v1.1
From 9c392f6a6894d532917a3b4b44720fa1e6e30be7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 11 May 2012 02:05:32 +0100
Subject: Stagger multiple bot logins by 5 seconds to make this part of the
test more 'realistic'
TODO: Need to make this value configurable by a command line parameter to pCampbot
---
OpenSim/Tools/pCampBot/BotManager.cs | 13 +++++++++++++
1 file changed, 13 insertions(+)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 6d4bdb1..b9eabbf 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -49,6 +49,14 @@ namespace pCampBot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ public const int DefaultLoginDelay = 5000;
+
+ ///
+ /// Delay between logins of multiple bots.
+ ///
+ /// TODO: This value needs to be configurable by a command line argument.
+ public int LoginDelay { get; set; }
+
///
/// Command console
///
@@ -84,6 +92,8 @@ namespace pCampBot
///
public BotManager()
{
+ LoginDelay = DefaultLoginDelay;
+
Rng = new Random(Environment.TickCount);
AssetsReceived = new Dictionary();
RegionsKnown = new Dictionary();
@@ -224,6 +234,9 @@ namespace pCampBot
pbThread.IsBackground = true;
pbThread.Start();
+
+ // Stagger logins
+ Thread.Sleep(LoginDelay);
}
///
--
cgit v1.1
From f231ac39de7348965b5c4c04d8b29a885501c90d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 11 May 2012 02:23:18 +0100
Subject: Increase minimum period between bot actions to 3 seconds, so that
teleport doesn't fall under the minimum 2 second limits that clients take to
process it
---
OpenSim/Tools/pCampBot/Bot.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index 2b4a171..95dba9f 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -167,10 +167,10 @@ namespace pCampBot
Behaviours.ForEach(
b =>
{
+ Thread.Sleep(Random.Next(3000, 10000));
+
// m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType());
b.Action();
-
- Thread.Sleep(Random.Next(1000, 10000));
}
);
}
--
cgit v1.1
From 480216f50f40bdb9709f9c6eec189a2ca027f395 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 11 May 2012 02:38:29 +0100
Subject: Print out more information on connecting bots
---
OpenSim/Tools/pCampBot/Bot.cs | 2 +-
OpenSim/Tools/pCampBot/BotManager.cs | 26 ++++++++++++++++++--------
2 files changed, 19 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index 95dba9f..b6cd287 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -168,7 +168,7 @@ namespace pCampBot
b =>
{
Thread.Sleep(Random.Next(3000, 10000));
-
+
// m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType());
b.Action();
}
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index b9eabbf..d615b3f 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -161,28 +161,34 @@ namespace pCampBot
Array.ForEach(
cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
+ MainConsole.Instance.OutputFormat(
+ "[BOT MANAGER]: Starting {0} bots connecting to {1}, named {2} {3}_",
+ botcount,
+ loginUri,
+ firstName,
+ lastNameStem);
+
+ MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay);
+
for (int i = 0; i < botcount; i++)
{
string lastName = string.Format("{0}_{1}", lastNameStem, i);
+ // We must give each bot its own list of instantiated behaviours since they store state.
List behaviours = new List();
-
+
// Hard-coded for now
if (behaviourSwitches.Contains("p"))
behaviours.Add(new PhysicsBehaviour());
-
+
if (behaviourSwitches.Contains("g"))
behaviours.Add(new GrabbingBehaviour());
-
+
if (behaviourSwitches.Contains("t"))
behaviours.Add(new TeleportBehaviour());
-
+
if (behaviourSwitches.Contains("c"))
behaviours.Add(new CrossBehaviour());
-
- MainConsole.Instance.OutputFormat(
- "[BOT MANAGER]: Bot {0} {1} configured for behaviours {2}",
- firstName, lastName, string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray()));
StartBot(this, behaviours, firstName, lastName, password, loginUri);
}
@@ -221,6 +227,10 @@ namespace pCampBot
BotManager bm, List behaviours,
string firstName, string lastName, string password, string loginUri)
{
+ MainConsole.Instance.OutputFormat(
+ "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
+ firstName, lastName, string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray()));
+
Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
pb.OnConnected += handlebotEvent;
--
cgit v1.1
From 565c73751cd1ac9b09393a0801591ced04d7e635 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 18 May 2012 00:49:39 +0100
Subject: Invoke log4net configurator in pCampBot.exe in order to get OpenSim
sylte logging
---
OpenSim/Tools/pCampBot/pCampBot.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs
index 52e7501..9e82577 100644
--- a/OpenSim/Tools/pCampBot/pCampBot.cs
+++ b/OpenSim/Tools/pCampBot/pCampBot.cs
@@ -29,6 +29,7 @@ using System;
using System.Reflection;
using System.Threading;
using log4net;
+using log4net.Config;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
@@ -52,6 +53,8 @@ namespace pCampBot
[STAThread]
public static void Main(string[] args)
{
+ XmlConfigurator.Configure();
+
IConfig config = ParseConfig(args);
if (config.Get("help") != null || config.Get("loginuri") == null)
{
--
cgit v1.1
From c215b1ad169cb8c3add70622f610e980ee9cfa31 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 8 Jun 2012 03:53:03 +0100
Subject: If logging a client out due to ack timeout, do this asynchronously
rather than synchronously on the outgoing packet loop.
This is the same async behaviour as normal logouts.
This is necessary because the event queue will sleep the thread for 5 seconds on an ack timeout logout as the client isn't around to pick up the final event queue messages.
---
OpenSim/Tools/pCampBot/Bot.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index b6cd287..daaa3c0 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -480,6 +480,9 @@ namespace pCampBot
public void Objects_NewPrim(object sender, PrimEventArgs args)
{
+// if (Name.EndsWith("4"))
+// throw new Exception("Aaargh");
+
Primitive prim = args.Prim;
if (prim != null)
--
cgit v1.1
From 916e3bf886ee622e2f18d6eb74f90fee8c630471 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 11 Jul 2012 22:54:22 +0100
Subject: Where possible, use the system Encoding.ASCII and Encoding.UTF8
rather than constructing fresh copies.
The encodings are thread-safe and already used in such a manner in other places.
This isn't done where Byte Order Mark output is suppressed, since Encoding.UTF8 is constructed to output the BOM.
---
OpenSim/Tools/Compiler/Program.cs | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Tools')
diff --git a/OpenSim/Tools/Compiler/Program.cs b/OpenSim/Tools/Compiler/Program.cs
index 249e18b..6c59c31 100644
--- a/OpenSim/Tools/Compiler/Program.cs
+++ b/OpenSim/Tools/Compiler/Program.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Text;
using Microsoft.CSharp;
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
using System.CodeDom.Compiler;
@@ -201,12 +202,8 @@ namespace OpenSim.Tools.LSL.Compiler
// Convert to base64
//
string filetext = System.Convert.ToBase64String(data);
-
- System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
-
- Byte[] buf = enc.GetBytes(filetext);
-
- FileStream sfs = File.Create(OutFile+".text");
+ Byte[] buf = Encoding.ASCII.GetBytes(filetext);
+ FileStream sfs = File.Create(OutFile + ".text");
sfs.Write(buf, 0, buf.Length);
sfs.Close();
@@ -222,9 +219,9 @@ namespace OpenSim.Tools.LSL.Compiler
// }
// }
- buf = enc.GetBytes(posmap);
+ buf = Encoding.ASCII.GetBytes(posmap);
- FileStream mfs = File.Create(OutFile+".map");
+ FileStream mfs = File.Create(OutFile + ".map");
mfs.Write(buf, 0, buf.Length);
mfs.Close();
--
cgit v1.1