Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim

remotes/origin/0.6.7-post-fixes
Justin Clark-Casey (justincc) 2009-09-25 19:19:01 +01:00
commit 0bdf75637f
25 changed files with 910 additions and 443 deletions

View File

@ -58,7 +58,7 @@ namespace OpenSim.Client.Linden
{ {
if (m_firstScene != null) if (m_firstScene != null)
{ {
return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; return m_firstScene.SceneGridService.RegionLoginsEnabled;
} }
else else
{ {

View File

@ -62,7 +62,7 @@ namespace OpenSim.Client.Linden
{ {
if (m_firstScene != null) if (m_firstScene != null)
{ {
return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; return m_firstScene.SceneGridService.RegionLoginsEnabled;
} }
else else
{ {

View File

@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
List<RegionData> ret = RunCommand(cmd); List<RegionData> ret = RunCommand(cmd);
if (ret == null) if (ret.Count == 0)
return null; return null;
return ret[0]; return ret[0];
@ -95,7 +95,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
List<RegionData> ret = RunCommand(cmd); List<RegionData> ret = RunCommand(cmd);
if (ret == null) if (ret.Count == 0)
return null; return null;
return ret[0]; return ret[0];
@ -170,10 +170,7 @@ namespace OpenSim.Data.MySQL
result.Close(); result.Close();
CloseReaderCommand(cmd); CloseReaderCommand(cmd);
if (retList.Count > 0) return retList;
return retList;
return null;
} }
public bool Store(RegionData data) public bool Store(RegionData data)
@ -182,12 +179,6 @@ namespace OpenSim.Data.MySQL
data.Data.Remove("uuid"); data.Data.Remove("uuid");
if (data.Data.ContainsKey("ScopeID")) if (data.Data.ContainsKey("ScopeID"))
data.Data.Remove("ScopeID"); data.Data.Remove("ScopeID");
if (data.Data.ContainsKey("regionName"))
data.Data.Remove("regionName");
if (data.Data.ContainsKey("posX"))
data.Data.Remove("posX");
if (data.Data.ContainsKey("posY"))
data.Data.Remove("posY");
string[] fields = new List<string>(data.Data.Keys).ToArray(); string[] fields = new List<string>(data.Data.Keys).ToArray();

View File

@ -101,10 +101,7 @@ namespace OpenSim.Data.Null
ret.Add(r); ret.Add(r);
} }
if (ret.Count > 0) return ret;
return ret;
return null;
} }
public bool Store(RegionData data) public bool Store(RegionData data)

View File

@ -56,14 +56,14 @@ namespace OpenSim.Framework.Servers.HttpServer
request.ContentType = "text/www-form-urlencoded"; request.ContentType = "text/www-form-urlencoded";
MemoryStream buffer = new MemoryStream(); MemoryStream buffer = new MemoryStream();
int length = 0;
using (StreamWriter writer = new StreamWriter(buffer)) using (StreamWriter writer = new StreamWriter(buffer))
{ {
writer.WriteLine(obj); writer.WriteLine(obj);
writer.Flush(); writer.Flush();
length = (int)buffer.Length;
} }
int length = (int) buffer.Length;
request.ContentLength = length; request.ContentLength = length;
Stream requestStream = request.GetRequestStream(); Stream requestStream = request.GetRequestStream();

View File

@ -557,7 +557,7 @@ namespace OpenSim
/// <param name="cmd"></param> /// <param name="cmd"></param>
private void HandleLoginStatus(string module, string[] cmd) private void HandleLoginStatus(string module, string[] cmd)
{ {
if (m_commsManager.GridService.RegionLoginsEnabled == false) if (m_sceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled == false)
m_log.Info("[ Login ] Login are disabled "); m_log.Info("[ Login ] Login are disabled ");
else else

View File

@ -209,9 +209,9 @@ namespace OpenSim
} }
// Only enable logins to the regions once we have completely finished starting up (apart from scripts) // Only enable logins to the regions once we have completely finished starting up (apart from scripts)
if ((m_commsManager != null) && (m_commsManager.GridService != null)) if ((SceneManager.CurrentOrFirstScene != null) && (SceneManager.CurrentOrFirstScene.SceneGridService != null))
{ {
m_commsManager.GridService.RegionLoginsEnabled = true; SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
} }
AddPluginCommands(); AddPluginCommands();
@ -299,12 +299,12 @@ namespace OpenSim
if (LoginEnabled) if (LoginEnabled)
{ {
m_log.Info("[LOGIN]: Login is now enabled."); m_log.Info("[LOGIN]: Login is now enabled.");
m_commsManager.GridService.RegionLoginsEnabled = true; SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
} }
else else
{ {
m_log.Info("[LOGIN]: Login is now disabled."); m_log.Info("[LOGIN]: Login is now disabled.");
m_commsManager.GridService.RegionLoginsEnabled = false; SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = false;
} }
} }

View File

@ -142,7 +142,7 @@ namespace Flotsam.RegionModules.AssetCache
m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory);
m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", true); m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false);
m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
#if WAIT_ON_INPROGRESS_REQUESTS #if WAIT_ON_INPROGRESS_REQUESTS
@ -150,7 +150,7 @@ namespace Flotsam.RegionModules.AssetCache
#endif #endif
m_LogLevel = assetConfig.GetInt("LogLevel", 1); m_LogLevel = assetConfig.GetInt("LogLevel", 1);
m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1); m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000);
m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration));

View File

@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
{ {
if (m_firstScene != null) if (m_firstScene != null)
{ {
return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; return m_firstScene.SceneGridService.RegionLoginsEnabled;
} }
else else
{ {

View File

@ -63,6 +63,13 @@ namespace OpenSim.Region.Framework.Scenes
protected List<UUID> m_agentsInTransit; protected List<UUID> m_agentsInTransit;
public bool RegionLoginsEnabled
{
get { return m_regionLoginsEnabled; }
set { m_regionLoginsEnabled = value; }
}
private bool m_regionLoginsEnabled = false;
/// <summary> /// <summary>
/// An agent is crossing into this region /// An agent is crossing into this region
/// </summary> /// </summary>

View File

@ -204,7 +204,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
tempAngularVelocity2 = new btVector3(0, 0, 0); tempAngularVelocity2 = new btVector3(0, 0, 0);
tempInertia1 = new btVector3(0, 0, 0); tempInertia1 = new btVector3(0, 0, 0);
tempInertia2 = new btVector3(0, 0, 0); tempInertia2 = new btVector3(0, 0, 0);
tempOrientation1 = new btQuaternion(0,0,0,1); tempOrientation1 = new btQuaternion(0, 0, 0, 1);
tempOrientation2 = new btQuaternion(0, 0, 0, 1); tempOrientation2 = new btQuaternion(0, 0, 0, 1);
_parent_scene = parent_scene; _parent_scene = parent_scene;
tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero); tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero);
@ -218,7 +218,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize); AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize);
int regionsize = (int) Constants.RegionSize; int regionsize = (int)Constants.RegionSize;
if (regionsize == 256) if (regionsize == 256)
regionsize = 512; regionsize = 512;
@ -802,7 +802,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
changesize(timestep); changesize(timestep);
} }
// //
if (m_taintshape) if (m_taintshape)
{ {
@ -1012,7 +1012,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
if (_parent_scene.needsMeshing(_pbs)) if (_parent_scene.needsMeshing(_pbs))
{ {
ProcessGeomCreationAsTriMesh(PhysicsVector.Zero,Quaternion.Identity); ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity);
// createmesh returns null when it doesn't mesh. // createmesh returns null when it doesn't mesh.
CreateGeom(IntPtr.Zero, _mesh); CreateGeom(IntPtr.Zero, _mesh);
} }
@ -1038,30 +1038,30 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
meshlod = _parent_scene.MeshSculptphysicalLOD; meshlod = _parent_scene.MeshSculptphysicalLOD;
IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
if (!positionOffset.IsIdentical(PhysicsVector.Zero,0.001f) || orientation != Quaternion.Identity) if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity)
{ {
float[] xyz = new float[3]; float[] xyz = new float[3];
xyz[0] = positionOffset.X; xyz[0] = positionOffset.X;
xyz[1] = positionOffset.Y; xyz[1] = positionOffset.Y;
xyz[2] = positionOffset.Z; xyz[2] = positionOffset.Z;
Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation); Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation);
float[,] matrix = new float[3,3]; float[,] matrix = new float[3, 3];
matrix[0, 0] = m4.M11; matrix[0, 0] = m4.M11;
matrix[0, 1] = m4.M12; matrix[0, 1] = m4.M12;
matrix[0, 2] = m4.M13; matrix[0, 2] = m4.M13;
matrix[1, 0] = m4.M21; matrix[1, 0] = m4.M21;
matrix[1, 1] = m4.M22; matrix[1, 1] = m4.M22;
matrix[1, 2] = m4.M23; matrix[1, 2] = m4.M23;
matrix[2, 0] = m4.M31; matrix[2, 0] = m4.M31;
matrix[2, 1] = m4.M32; matrix[2, 1] = m4.M32;
matrix[2, 2] = m4.M33; matrix[2, 2] = m4.M33;
mesh.TransformLinear(matrix, xyz); mesh.TransformLinear(matrix, xyz);
@ -1627,7 +1627,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
{ {
if (m_zeroPosition == null) if (m_zeroPosition == null)
m_zeroPosition = new PhysicsVector(0, 0, 0); m_zeroPosition = new PhysicsVector(0, 0, 0);
m_zeroPosition.setValues(_position.X,_position.Y,_position.Z); m_zeroPosition.setValues(_position.X, _position.Y, _position.Z);
return; return;
} }
} }
@ -1994,15 +1994,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//SetGeom to a Regular Sphere //SetGeom to a Regular Sphere
if (tempSize1 == null) if (tempSize1 == null)
tempSize1 = new btVector3(0, 0, 0); tempSize1 = new btVector3(0, 0, 0);
tempSize1.setValue(_size.X * 0.5f,_size.Y * 0.5f, _size.Z * 0.5f); tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f);
SetCollisionShape(new btSphereShape(_size.X*0.5f)); SetCollisionShape(new btSphereShape(_size.X * 0.5f));
} }
else else
{ {
// uses halfextents // uses halfextents
if (tempSize1 == null) if (tempSize1 == null)
tempSize1 = new btVector3(0, 0, 0); tempSize1 = new btVector3(0, 0, 0);
tempSize1.setValue(_size.X*0.5f, _size.Y*0.5f, _size.Z*0.5f); tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f);
SetCollisionShape(new btBoxShape(tempSize1)); SetCollisionShape(new btBoxShape(tempSize1));
} }
} }
@ -2052,14 +2052,24 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
} }
} }
//IMesh oldMesh = primMesh;
//primMesh = mesh;
//float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
//int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
////Array.Reverse(indexList);
//primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory
IMesh oldMesh = primMesh; IMesh oldMesh = primMesh;
primMesh = mesh; primMesh = mesh;
float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
//Array.Reverse(indexList); //Array.Reverse(indexList);
primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
int VertexCount = vertexList.GetLength(0) / 3; int VertexCount = vertexList.GetLength(0) / 3;
int IndexCount = indexList.GetLength(0); int IndexCount = indexList.GetLength(0);
@ -2068,17 +2078,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
btshapeArray.Dispose(); btshapeArray.Dispose();
//Array.Reverse(indexList); //Array.Reverse(indexList);
btshapeArray = new btTriangleIndexVertexArray(IndexCount / 3, indexList, (3 * sizeof(int)), btshapeArray = new btTriangleIndexVertexArray(IndexCount / 3, indexList, (3 * sizeof(int)),
VertexCount, vertexList, 3*sizeof (float)); VertexCount, vertexList, 3 * sizeof(float));
SetCollisionShape(new btGImpactMeshShape(btshapeArray)); SetCollisionShape(new btGImpactMeshShape(btshapeArray));
//((btGImpactMeshShape) prim_geom).updateBound(); //((btGImpactMeshShape) prim_geom).updateBound();
((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1,1, 1)); ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1));
((btGImpactMeshShape)prim_geom).updateBound(); ((btGImpactMeshShape)prim_geom).updateBound();
_parent_scene.SetUsingGImpact(); _parent_scene.SetUsingGImpact();
if (oldMesh != null) //if (oldMesh != null)
{ //{
oldMesh.releasePinned(); // oldMesh.releasePinned();
oldMesh = null; // oldMesh = null;
} //}
} }
@ -2143,8 +2153,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
if (prim_geom is btGImpactMeshShape) if (prim_geom is btGImpactMeshShape)
{ {
((btGImpactMeshShape) prim_geom).setLocalScaling(new btVector3(1, 1, 1)); ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1));
((btGImpactMeshShape) prim_geom).updateBound(); ((btGImpactMeshShape)prim_geom).updateBound();
} }
//Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK); //Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK);
//Body.setUserPointer((IntPtr) (int)m_localID); //Body.setUserPointer((IntPtr) (int)m_localID);
@ -2167,40 +2177,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
//if (hasTrimesh) //if (hasTrimesh)
//{ //{
ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity);
// createmesh returns null when it doesn't mesh. // createmesh returns null when it doesn't mesh.
/* /*
if (_mesh is Mesh) if (_mesh is Mesh)
{ {
} }
else else
{ {
m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object"); m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object");
return; return;
} }
*/ */
foreach (BulletDotNETPrim chld in childrenPrim) foreach (BulletDotNETPrim chld in childrenPrim)
{ {
if (chld == null) if (chld == null)
continue; continue;
PhysicsVector offset = chld.Position - Position; PhysicsVector offset = chld.Position - Position;
Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
pos *= Quaternion.Inverse(Orientation); pos *= Quaternion.Inverse(Orientation);
//pos *= Orientation; //pos *= Orientation;
offset.setValues(pos.X, pos.Y, pos.Z); offset.setValues(pos.X, pos.Y, pos.Z);
chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
_mesh.Append(chld._mesh); _mesh.Append(chld._mesh);
} }
setMesh(_parent_scene, _mesh); setMesh(_parent_scene, _mesh);
//} //}
if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero) if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero)
tempMotionState1.Dispose(); tempMotionState1.Dispose();
@ -2252,7 +2262,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
if (Body.Handle != IntPtr.Zero) if (Body.Handle != IntPtr.Zero)
{ {
DisableAxisMotor(); DisableAxisMotor();
_parent_scene.removeFromWorld(this,Body); _parent_scene.removeFromWorld(this, Body);
Body.Dispose(); Body.Dispose();
} }
Body = null; Body = null;
@ -2587,10 +2597,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
_velocity.Y = tempLinearVelocity1.getY(); _velocity.Y = tempLinearVelocity1.getY();
_velocity.Z = tempLinearVelocity1.getZ(); _velocity.Z = tempLinearVelocity1.getZ();
_acceleration = ((_velocity - m_lastVelocity)/0.1f); _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
_acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X/0.1f, _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f,
_velocity.Y - m_lastVelocity.Y/0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f,
_velocity.Z - m_lastVelocity.Z/0.1f); _velocity.Z - m_lastVelocity.Z / 0.1f);
//m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
if (_velocity.IsIdentical(pv, 0.5f)) if (_velocity.IsIdentical(pv, 0.5f))

View File

@ -40,7 +40,6 @@ namespace OpenSim.Region.Physics.Meshing
private List<Triangle> triangles; private List<Triangle> triangles;
GCHandle pinnedVirtexes; GCHandle pinnedVirtexes;
GCHandle pinnedIndex; GCHandle pinnedIndex;
public PrimMesh primMesh = null;
public float[] normals; public float[] normals;
public Mesh() public Mesh()
@ -63,6 +62,8 @@ namespace OpenSim.Region.Physics.Meshing
public void Add(Triangle triangle) public void Add(Triangle triangle)
{ {
if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
throw new NotSupportedException("Attempt to Add to a pinned Mesh");
// If a vertex of the triangle is not yet in the vertices list, // If a vertex of the triangle is not yet in the vertices list,
// add it and set its index to the current index count // add it and set its index to the current index count
if (!vertices.ContainsKey(triangle.v1)) if (!vertices.ContainsKey(triangle.v1))
@ -148,40 +149,22 @@ namespace OpenSim.Region.Physics.Meshing
public float[] getVertexListAsFloatLocked() public float[] getVertexListAsFloatLocked()
{ {
if( pinnedVirtexes.IsAllocated )
return (float[])(pinnedVirtexes.Target);
float[] result; float[] result;
if (primMesh == null) //m_log.WarnFormat("vertices.Count = {0}", vertices.Count);
result = new float[vertices.Count * 3];
foreach (KeyValuePair<Vertex, int> kvp in vertices)
{ {
//m_log.WarnFormat("vertices.Count = {0}", vertices.Count); Vertex v = kvp.Key;
result = new float[vertices.Count * 3]; int i = kvp.Value;
foreach (KeyValuePair<Vertex, int> kvp in vertices) //m_log.WarnFormat("kvp.Value = {0}", i);
{ result[3 * i + 0] = v.X;
Vertex v = kvp.Key; result[3 * i + 1] = v.Y;
int i = kvp.Value; result[3 * i + 2] = v.Z;
//m_log.WarnFormat("kvp.Value = {0}", i);
result[3 * i + 0] = v.X;
result[3 * i + 1] = v.Y;
result[3 * i + 2] = v.Z;
}
pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
}
else
{
int count = primMesh.coords.Count;
result = new float[count * 3];
for (int i = 0; i < count; i++)
{
Coord c = primMesh.coords[i];
{
int resultIndex = 3 * i;
result[resultIndex] = c.X;
result[resultIndex + 1] = c.Y;
result[resultIndex + 2] = c.Z;
}
}
pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
} }
pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
return result; return result;
} }
@ -189,33 +172,13 @@ namespace OpenSim.Region.Physics.Meshing
{ {
int[] result; int[] result;
if (primMesh == null) result = new int[triangles.Count * 3];
for (int i = 0; i < triangles.Count; i++)
{ {
result = new int[triangles.Count * 3]; Triangle t = triangles[i];
for (int i = 0; i < triangles.Count; i++) result[3 * i + 0] = vertices[t.v1];
{ result[3 * i + 1] = vertices[t.v2];
Triangle t = triangles[i]; result[3 * i + 2] = vertices[t.v3];
result[3 * i + 0] = vertices[t.v1];
result[3 * i + 1] = vertices[t.v2];
result[3 * i + 2] = vertices[t.v3];
}
}
else
{
int numFaces = primMesh.faces.Count;
result = new int[numFaces * 3];
for (int i = 0; i < numFaces; i++)
{
Face f = primMesh.faces[i];
// Coord c1 = primMesh.coords[f.v1];
// Coord c2 = primMesh.coords[f.v2];
// Coord c3 = primMesh.coords[f.v3];
int resultIndex = i * 3;
result[resultIndex] = f.v1;
result[resultIndex + 1] = f.v2;
result[resultIndex + 2] = f.v3;
}
} }
return result; return result;
} }
@ -226,6 +189,9 @@ namespace OpenSim.Region.Physics.Meshing
/// <returns></returns> /// <returns></returns>
public int[] getIndexListAsIntLocked() public int[] getIndexListAsIntLocked()
{ {
if (pinnedIndex.IsAllocated)
return (int[])(pinnedIndex.Target);
int[] result = getIndexListAsInt(); int[] result = getIndexListAsInt();
pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned);
@ -245,11 +211,13 @@ namespace OpenSim.Region.Physics.Meshing
{ {
triangles = null; triangles = null;
vertices = null; vertices = null;
primMesh = null;
} }
public void Append(IMesh newMesh) public void Append(IMesh newMesh)
{ {
if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
throw new NotSupportedException("Attempt to Append to a pinned Mesh");
if (!(newMesh is Mesh)) if (!(newMesh is Mesh))
return; return;
@ -260,6 +228,9 @@ namespace OpenSim.Region.Physics.Meshing
// Do a linear transformation of mesh. // Do a linear transformation of mesh.
public void TransformLinear(float[,] matrix, float[] offset) public void TransformLinear(float[,] matrix, float[] offset)
{ {
if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
throw new NotSupportedException("Attempt to TransformLinear a pinned Mesh");
foreach (Vertex v in vertices.Keys) foreach (Vertex v in vertices.Keys)
{ {
if (v == null) if (v == null)

View File

@ -76,6 +76,7 @@ namespace OpenSim.Region.Physics.Meshing
private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
private Dictionary<ulong, Mesh> m_uniqueMeshes = new Dictionary<ulong, Mesh>();
/// <summary> /// <summary>
/// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
@ -170,9 +171,62 @@ namespace OpenSim.Region.Physics.Meshing
} }
public Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) private ulong GetMeshKey( PrimitiveBaseShape pbs, PhysicsVector size, float lod )
{
ulong hash = 5381;
hash = djb2(hash, pbs.PathCurve);
hash = djb2(hash, (byte)((byte)pbs.HollowShape | (byte)pbs.ProfileShape));
hash = djb2(hash, pbs.PathBegin);
hash = djb2(hash, pbs.PathEnd);
hash = djb2(hash, pbs.PathScaleX);
hash = djb2(hash, pbs.PathScaleY);
hash = djb2(hash, pbs.PathShearX);
hash = djb2(hash, pbs.PathShearY);
hash = djb2(hash, (byte)pbs.PathTwist);
hash = djb2(hash, (byte)pbs.PathTwistBegin);
hash = djb2(hash, (byte)pbs.PathRadiusOffset);
hash = djb2(hash, (byte)pbs.PathTaperX);
hash = djb2(hash, (byte)pbs.PathTaperY);
hash = djb2(hash, pbs.PathRevolutions);
hash = djb2(hash, (byte)pbs.PathSkew);
hash = djb2(hash, pbs.ProfileBegin);
hash = djb2(hash, pbs.ProfileEnd);
hash = djb2(hash, pbs.ProfileHollow);
// TODO: Separate scale out from the primitive shape data (after
// scaling is supported at the physics engine level)
byte[] scaleBytes = size.GetBytes();
for (int i = 0; i < scaleBytes.Length; i++)
hash = djb2(hash, scaleBytes[i]);
// Include LOD in hash, accounting for endianness
byte[] lodBytes = new byte[4];
Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4);
if (!BitConverter.IsLittleEndian)
{
Array.Reverse(lodBytes, 0, 4);
}
for (int i = 0; i < lodBytes.Length; i++)
hash = djb2(hash, lodBytes[i]);
return hash;
}
private ulong djb2(ulong hash, byte c)
{
return ((hash << 5) + hash) + (ulong)c;
}
private ulong djb2(ulong hash, ushort c)
{
hash = ((hash << 5) + hash) + (ulong)((byte)c);
return ((hash << 5) + hash) + (ulong)(c >> 8);
}
private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod)
{ {
Mesh mesh = new Mesh();
PrimMesh primMesh; PrimMesh primMesh;
PrimMesher.SculptMesh sculptMesh; PrimMesher.SculptMesh sculptMesh;
@ -385,8 +439,6 @@ namespace OpenSim.Region.Physics.Meshing
coords = primMesh.coords; coords = primMesh.coords;
faces = primMesh.faces; faces = primMesh.faces;
} }
@ -401,13 +453,13 @@ namespace OpenSim.Region.Physics.Meshing
vertices.Add(new Vertex(c.X, c.Y, c.Z)); vertices.Add(new Vertex(c.X, c.Y, c.Z));
} }
Mesh mesh = new Mesh();
// Add the corresponding triangles to the mesh // Add the corresponding triangles to the mesh
for (int i = 0; i < numFaces; i++) for (int i = 0; i < numFaces; i++)
{ {
Face f = faces[i]; Face f = faces[i];
mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3])); mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3]));
} }
return mesh; return mesh;
} }
@ -418,7 +470,12 @@ namespace OpenSim.Region.Physics.Meshing
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical)
{ {
// If this mesh has been created already, return it instead of creating another copy
// For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory
ulong key = GetMeshKey(primShape, size, lod);
Mesh mesh = null; Mesh mesh = null;
if (m_uniqueMeshes.TryGetValue(key, out mesh))
return mesh;
if (size.X < 0.01f) size.X = 0.01f; if (size.X < 0.01f) size.X = 0.01f;
if (size.Y < 0.01f) size.Y = 0.01f; if (size.Y < 0.01f) size.Y = 0.01f;
@ -441,7 +498,7 @@ namespace OpenSim.Region.Physics.Meshing
// trim the vertex and triangle lists to free up memory // trim the vertex and triangle lists to free up memory
mesh.TrimExcess(); mesh.TrimExcess();
} }
m_uniqueMeshes.Add(key, mesh);
return mesh; return mesh;
} }
} }

View File

@ -82,7 +82,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// private float m_tensor = 5f; // private float m_tensor = 5f;
private int body_autodisable_frames = 20; private int body_autodisable_frames = 20;
private IMesh primMesh = null;
private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
@ -814,14 +813,10 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
IMesh oldMesh = primMesh; float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
primMesh = mesh; mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory
int VertexCount = vertexList.GetLength(0)/3; int VertexCount = vertexList.GetLength(0)/3;
int IndexCount = indexList.GetLength(0); int IndexCount = indexList.GetLength(0);
@ -847,12 +842,6 @@ namespace OpenSim.Region.Physics.OdePlugin
return; return;
} }
if (oldMesh != null)
{
oldMesh.releasePinned();
oldMesh = null;
}
// if (IsPhysical && Body == (IntPtr) 0) // if (IsPhysical && Body == (IntPtr) 0)
// { // {
// Recreate the body // Recreate the body

View File

@ -258,6 +258,8 @@ namespace OpenSim.Server.Base
public static Dictionary<string, object> ParseXmlResponse(string data) public static Dictionary<string, object> ParseXmlResponse(string data)
{ {
//m_log.DebugFormat("[XXX]: received xml string: {0}", data);
Dictionary<string, object> ret = new Dictionary<string, object>(); Dictionary<string, object> ret = new Dictionary<string, object>();
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
@ -284,7 +286,7 @@ namespace OpenSim.Server.Base
foreach (XmlNode part in partL) foreach (XmlNode part in partL)
{ {
XmlNode type = part.Attributes.GetNamedItem("Type"); XmlNode type = part.Attributes.GetNamedItem("type");
if (type == null || type.Value != "List") if (type == null || type.Value != "List")
{ {
ret[part.Name] = part.InnerText; ret[part.Name] = part.InnerText;

View File

@ -45,7 +45,7 @@ namespace OpenSim.Server.Handlers.Grid
if (serverConfig == null) if (serverConfig == null)
throw new Exception("No section 'Server' in config file"); throw new Exception("No section 'Server' in config file");
string gridService = serverConfig.GetString("GridServiceModule", string gridService = serverConfig.GetString("LocalServiceModule",
String.Empty); String.Empty);
if (gridService == String.Empty) if (gridService == String.Empty)

View File

@ -63,6 +63,9 @@ namespace OpenSim.Server.Handlers.Grid
StreamReader sr = new StreamReader(requestData); StreamReader sr = new StreamReader(requestData);
string body = sr.ReadToEnd(); string body = sr.ReadToEnd();
sr.Close(); sr.Close();
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
Dictionary<string, string> request = Dictionary<string, string> request =
ServerUtils.ParseQueryString(body); ServerUtils.ParseQueryString(body);
@ -98,11 +101,11 @@ namespace OpenSim.Server.Handlers.Grid
case "get_region_range": case "get_region_range":
return GetRegionRange(request); return GetRegionRange(request);
default:
m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method);
return FailureResult();
} }
m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
return FailureResult();
} }
#region Method-specific handlers #region Method-specific handlers
@ -155,22 +158,29 @@ namespace OpenSim.Server.Handlers.Grid
UUID regionID = UUID.Zero; UUID regionID = UUID.Zero;
if (request["REGIONID"] != null) if (request["REGIONID"] != null)
UUID.TryParse(request["REGIONID"], out scopeID); UUID.TryParse(request["REGIONID"], out regionID);
else else
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID); List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
Dictionary<string, object> result = new Dictionary<string, object>(); Dictionary<string, object> result = new Dictionary<string, object>();
int i = 0; if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
foreach (GridRegion rinfo in rinfos) result["result"] = "null";
else
{ {
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); int i = 0;
result["region" + i] = rinfoDict; foreach (GridRegion rinfo in rinfos)
i++; {
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
result["region" + i] = rinfoDict;
i++;
}
} }
string xmlString = ServerUtils.BuildXmlResponse(result); string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding(); UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString); return encoding.GetBytes(xmlString);
@ -178,32 +188,185 @@ namespace OpenSim.Server.Handlers.Grid
byte[] GetRegionByUUID(Dictionary<string, string> request) byte[] GetRegionByUUID(Dictionary<string, string> request)
{ {
// TODO UUID scopeID = UUID.Zero;
return new byte[0]; if (request["SCOPEID"] != null)
UUID.TryParse(request["SCOPEID"], out scopeID);
else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
UUID regionID = UUID.Zero;
if (request["REGIONID"] != null)
UUID.TryParse(request["REGIONID"], out regionID);
else
m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
Dictionary<string, object> result = new Dictionary<string, object>();
if (rinfo == null)
result["result"] = "null";
else
result["result"] = rinfo.ToKeyValuePairs();
string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
} }
byte[] GetRegionByPosition(Dictionary<string, string> request) byte[] GetRegionByPosition(Dictionary<string, string> request)
{ {
// TODO UUID scopeID = UUID.Zero;
return new byte[0]; if (request["SCOPEID"] != null)
UUID.TryParse(request["SCOPEID"], out scopeID);
else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
int x = 0, y = 0;
if (request["X"] != null)
Int32.TryParse(request["X"], out x);
else
m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
if (request["Y"] != null)
Int32.TryParse(request["Y"], out y);
else
m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
Dictionary<string, object> result = new Dictionary<string, object>();
if (rinfo == null)
result["result"] = "null";
else
result["result"] = rinfo.ToKeyValuePairs();
string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
} }
byte[] GetRegionByName(Dictionary<string, string> request) byte[] GetRegionByName(Dictionary<string, string> request)
{ {
// TODO UUID scopeID = UUID.Zero;
return new byte[0]; if (request["SCOPEID"] != null)
UUID.TryParse(request["SCOPEID"], out scopeID);
else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
string regionName = string.Empty;
if (request["NAME"] != null)
regionName = request["NAME"];
else
m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
Dictionary<string, object> result = new Dictionary<string, object>();
if (rinfo == null)
result["result"] = "null";
else
result["result"] = rinfo.ToKeyValuePairs();
string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
} }
byte[] GetRegionsByName(Dictionary<string, string> request) byte[] GetRegionsByName(Dictionary<string, string> request)
{ {
// TODO UUID scopeID = UUID.Zero;
return new byte[0]; if (request["SCOPEID"] != null)
UUID.TryParse(request["SCOPEID"], out scopeID);
else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
string regionName = string.Empty;
if (request["NAME"] != null)
regionName = request["NAME"];
else
m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
int max = 0;
if (request["MAX"] != null)
Int32.TryParse(request["MAX"], out max);
else
m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
//m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
Dictionary<string, object> result = new Dictionary<string, object>();
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
result["result"] = "null";
else
{
int i = 0;
foreach (GridRegion rinfo in rinfos)
{
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
result["region" + i] = rinfoDict;
i++;
}
}
string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
} }
byte[] GetRegionRange(Dictionary<string, string> request) byte[] GetRegionRange(Dictionary<string, string> request)
{ {
// TODO //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
return new byte[0]; UUID scopeID = UUID.Zero;
if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID);
else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
if (request.ContainsKey("XMIN"))
Int32.TryParse(request["XMIN"], out xmin);
else
m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
if (request.ContainsKey("XMAX"))
Int32.TryParse(request["XMAX"], out xmax);
else
m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
if (request.ContainsKey("YMIN"))
Int32.TryParse(request["YMIN"], out ymin);
else
m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
if (request.ContainsKey("YMAX"))
Int32.TryParse(request["YMAX"], out ymax);
else
m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");
List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
Dictionary<string, object> result = new Dictionary<string, object>();
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
result["result"] = "null";
else
{
int i = 0;
foreach (GridRegion rinfo in rinfos)
{
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
result["region" + i] = rinfoDict;
i++;
}
}
string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
} }
#endregion #endregion

View File

@ -97,14 +97,27 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "register"; sendData["METHOD"] = "register";
string reply = SynchronousRestFormsRequester.MakeRequest("POST", string reqString = ServerUtils.BuildQueryString(sendData);
m_ServerURI + "/grid", //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
ServerUtils.BuildQueryString(sendData)); try
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
reqString);
if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
return true;
if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) }
return true; else
m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
}
return false; return false;
} }
@ -117,14 +130,26 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "deregister"; sendData["METHOD"] = "deregister";
string reply = SynchronousRestFormsRequester.MakeRequest("POST", try
m_ServerURI + "/grid", {
ServerUtils.BuildQueryString(sendData)); string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
return true; return true;
}
else
m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
}
return false; return false;
} }
@ -138,16 +163,28 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "get_neighbours"; sendData["METHOD"] = "get_neighbours";
string reply = SynchronousRestFormsRequester.MakeRequest("POST", List<GridRegion> rinfos = new List<GridRegion>();
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData)); string reqString = ServerUtils.BuildQueryString(sendData);
string reply = string.Empty;
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
reqString);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return rinfos;
}
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
List<GridRegion> rinfos = new List<GridRegion>();
if (replyData != null) if (replyData != null)
{ {
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
//m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
foreach (object r in rinfosList) foreach (object r in rinfosList)
{ {
if (r is Dictionary<string, object>) if (r is Dictionary<string, object>)
@ -156,8 +193,8 @@ namespace OpenSim.Services.Connectors
rinfos.Add(rinfo); rinfos.Add(rinfo);
} }
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}",
scopeID, regionID); scopeID, regionID, r.GetType());
} }
} }
else else
@ -176,24 +213,39 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "get_region_by_uuid"; sendData["METHOD"] = "get_region_by_uuid";
string reply = SynchronousRestFormsRequester.MakeRequest("POST", string reply = string.Empty;
m_ServerURI + "/grid", try
ServerUtils.BuildQueryString(sendData)); {
reply = SynchronousRestFormsRequester.MakeRequest("POST",
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return null;
}
GridRegion rinfo = null; GridRegion rinfo = null;
if ((replyData != null) && (replyData["result"] != null))
if (reply != string.Empty)
{ {
if (replyData["result"] is Dictionary<string, object>) Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
if ((replyData != null) && (replyData["result"] != null))
{
if (replyData["result"] is Dictionary<string, object>)
rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
//else
// m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
// scopeID, regionID);
}
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
scopeID, regionID); scopeID, regionID);
} }
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
scopeID, regionID);
return rinfo; return rinfo;
} }
@ -207,25 +259,38 @@ namespace OpenSim.Services.Connectors
sendData["Y"] = y.ToString(); sendData["Y"] = y.ToString();
sendData["METHOD"] = "get_region_by_position"; sendData["METHOD"] = "get_region_by_position";
string reply = string.Empty;
string reply = SynchronousRestFormsRequester.MakeRequest("POST", try
m_ServerURI + "/grid", {
ServerUtils.BuildQueryString(sendData)); reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return null;
}
GridRegion rinfo = null; GridRegion rinfo = null;
if ((replyData != null) && (replyData["result"] != null)) if (reply != string.Empty)
{ {
if (replyData["result"] is Dictionary<string, object>) Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
if ((replyData != null) && (replyData["result"] != null))
{
if (replyData["result"] is Dictionary<string, object>)
rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
scopeID, x, y);
}
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
scopeID, x, y); scopeID, x, y);
} }
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
scopeID, x, y);
return rinfo; return rinfo;
} }
@ -238,25 +303,35 @@ namespace OpenSim.Services.Connectors
sendData["NAME"] = regionName; sendData["NAME"] = regionName;
sendData["METHOD"] = "get_region_by_name"; sendData["METHOD"] = "get_region_by_name";
string reply = string.Empty;
string reply = SynchronousRestFormsRequester.MakeRequest("POST", try
m_ServerURI + "/grid", {
ServerUtils.BuildQueryString(sendData)); reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return null;
}
GridRegion rinfo = null; GridRegion rinfo = null;
if ((replyData != null) && (replyData["result"] != null)) if (reply != string.Empty)
{ {
if (replyData["result"] is Dictionary<string, object>) Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
if ((replyData != null) && (replyData["result"] != null))
{
if (replyData["result"] is Dictionary<string, object>)
rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
}
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
scopeID, regionName); scopeID, regionName);
} }
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
scopeID, regionName);
return rinfo; return rinfo;
} }
@ -270,32 +345,45 @@ namespace OpenSim.Services.Connectors
sendData["MAX"] = maxNumber.ToString(); sendData["MAX"] = maxNumber.ToString();
sendData["METHOD"] = "get_regions_by_name"; sendData["METHOD"] = "get_regions_by_name";
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
List<GridRegion> rinfos = new List<GridRegion>(); List<GridRegion> rinfos = new List<GridRegion>();
if (replyData != null) string reply = string.Empty;
try
{ {
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; reply = SynchronousRestFormsRequester.MakeRequest("POST",
foreach (object r in rinfosList) m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return rinfos;
}
if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData != null)
{ {
if (r is Dictionary<string, object>) Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
foreach (object r in rinfosList)
{ {
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); if (r is Dictionary<string, object>)
rinfos.Add(rinfo); {
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
rinfos.Add(rinfo);
}
else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
scopeID, name, maxNumber);
} }
else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
scopeID, name, maxNumber);
} }
else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
scopeID, name, maxNumber);
} }
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
scopeID, name, maxNumber);
return rinfos; return rinfos;
} }
@ -312,31 +400,44 @@ namespace OpenSim.Services.Connectors
sendData["METHOD"] = "get_region_range"; sendData["METHOD"] = "get_region_range";
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
List<GridRegion> rinfos = new List<GridRegion>(); List<GridRegion> rinfos = new List<GridRegion>();
if (replyData != null) string reply = string.Empty;
try
{ {
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; reply = SynchronousRestFormsRequester.MakeRequest("POST",
foreach (object r in rinfosList) m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return rinfos;
}
if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData != null)
{ {
if (r is Dictionary<string, object>) Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
foreach (object r in rinfosList)
{ {
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); if (r is Dictionary<string, object>)
rinfos.Add(rinfo); {
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
rinfos.Add(rinfo);
}
} }
else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response",
scopeID, xmin, xmax, ymin, ymax);
} }
else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
scopeID, xmin, xmax, ymin, ymax);
} }
else else
m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
scopeID, xmin, xmax, ymin, ymax);
return rinfos; return rinfos;
} }

View File

@ -50,35 +50,27 @@ namespace OpenSim.Services.GridService
: base(config) : base(config)
{ {
m_log.DebugFormat("[GRID SERVICE]: Starting..."); m_log.DebugFormat("[GRID SERVICE]: Starting...");
MainConsole.Instance.Commands.AddCommand("kfs", false,
"show digest",
"show digest <ID>",
"Show asset digest", HandleShowDigest);
MainConsole.Instance.Commands.AddCommand("kfs", false,
"delete asset",
"delete asset <ID>",
"Delete asset from database", HandleDeleteAsset);
} }
#region IGridService #region IGridService
public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
{ {
if (m_Database.Get(regionInfos.RegionID, scopeID) != null)
{
m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID);
return false;
}
// This needs better sanity testing. What if regionInfo is registering in // This needs better sanity testing. What if regionInfo is registering in
// overlapping coords? // overlapping coords?
if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
if ((region != null) && (region.RegionID != regionInfos.RegionID))
{ {
m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
return false; return false;
} }
if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
{
// Region reregistering in other coordinates. Delete the old entry
m_Database.Delete(regionInfos.RegionID);
}
// Everything is ok, let's register // Everything is ok, let's register
RegionData rdata = RegionInfo2RegionData(regionInfos); RegionData rdata = RegionInfo2RegionData(regionInfos);
@ -183,9 +175,9 @@ namespace OpenSim.Services.GridService
rdata.posX = (int)rinfo.RegionLocX; rdata.posX = (int)rinfo.RegionLocX;
rdata.posY = (int)rinfo.RegionLocY; rdata.posY = (int)rinfo.RegionLocY;
rdata.RegionID = rinfo.RegionID; rdata.RegionID = rinfo.RegionID;
rdata.Data = rinfo.ToKeyValuePairs();
rdata.RegionName = rinfo.RegionName; rdata.RegionName = rinfo.RegionName;
rdata.Data = rinfo.ToKeyValuePairs();
rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY);
return rdata; return rdata;
} }
@ -196,73 +188,12 @@ namespace OpenSim.Services.GridService
rinfo.RegionLocY = rdata.posY; rinfo.RegionLocY = rdata.posY;
rinfo.RegionID = rdata.RegionID; rinfo.RegionID = rdata.RegionID;
rinfo.RegionName = rdata.RegionName; rinfo.RegionName = rdata.RegionName;
rinfo.ScopeID = rdata.ScopeID;
return rinfo; return rinfo;
} }
#endregion #endregion
void HandleShowDigest(string module, string[] args)
{
//if (args.Length < 3)
//{
// MainConsole.Instance.Output("Syntax: show digest <ID>");
// return;
//}
//AssetBase asset = Get(args[2]);
//if (asset == null || asset.Data.Length == 0)
//{
// MainConsole.Instance.Output("Asset not found");
// return;
//}
//int i;
//MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name));
//MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description));
//MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type));
//MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType));
//for (i = 0 ; i < 5 ; i++)
//{
// int off = i * 16;
// if (asset.Data.Length <= off)
// break;
// int len = 16;
// if (asset.Data.Length < off + len)
// len = asset.Data.Length - off;
// byte[] line = new byte[len];
// Array.Copy(asset.Data, off, line, 0, len);
// string text = BitConverter.ToString(line);
// MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
//}
}
void HandleDeleteAsset(string module, string[] args)
{
//if (args.Length < 3)
//{
// MainConsole.Instance.Output("Syntax: delete asset <ID>");
// return;
//}
//AssetBase asset = Get(args[2]);
//if (asset == null || asset.Data.Length == 0)
// MainConsole.Instance.Output("Asset not found");
// return;
//}
//Delete(args[2]);
////MainConsole.Instance.Output("Asset deleted");
//// TODO: Implement this
//MainConsole.Instance.Output("Asset deletion not supported by database");
}
} }
} }

View File

@ -263,59 +263,55 @@ namespace OpenSim.Services.Interfaces
kvp["uuid"] = RegionID.ToString(); kvp["uuid"] = RegionID.ToString();
kvp["locX"] = RegionLocX.ToString(); kvp["locX"] = RegionLocX.ToString();
kvp["locY"] = RegionLocY.ToString(); kvp["locY"] = RegionLocY.ToString();
kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); kvp["regionName"] = RegionName;
kvp["external_port"] = ExternalEndPoint.Port.ToString(); kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
kvp["external_host_name"] = ExternalHostName; kvp["serverHttpPort"] = HttpPort.ToString();
kvp["http_port"] = HttpPort.ToString(); kvp["serverURI"] = ServerURI;
kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); kvp["serverPort"] = InternalEndPoint.Port.ToString();
kvp["internal_port"] = InternalEndPoint.Port.ToString();
kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
kvp["server_uri"] = ServerURI;
return kvp; return kvp;
} }
public GridRegion(Dictionary<string, object> kvp) public GridRegion(Dictionary<string, object> kvp)
{ {
if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) if (kvp.ContainsKey("uuid"))
RegionID = new UUID((string)kvp["uuid"]);
if (kvp.ContainsKey("locX"))
RegionLocX = Convert.ToInt32((string)kvp["locX"]);
if (kvp.ContainsKey("locY"))
RegionLocY = Convert.ToInt32((string)kvp["locY"]);
if (kvp.ContainsKey("regionName"))
RegionName = (string)kvp["regionName"];
if (kvp.ContainsKey("serverIP"))
{ {
int port = 0; //int port = 0;
Int32.TryParse((string)kvp["external_port"], out port); //Int32.TryParse((string)kvp["serverPort"], out port);
IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
ExternalEndPoint = ep; ExternalHostName = (string)kvp["serverIP"];
} }
else else
ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); ExternalHostName = "127.0.0.1";
if (kvp["external_host_name"] != null) if (kvp.ContainsKey("serverPort"))
ExternalHostName = (string)kvp["external_host_name"]; {
Int32 port = 0;
Int32.TryParse((string)kvp["serverPort"], out port);
InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
}
if (kvp["http_port"] != null) if (kvp.ContainsKey("serverHttpPort"))
{ {
UInt32 port = 0; UInt32 port = 0;
UInt32.TryParse((string)kvp["http_port"], out port); UInt32.TryParse((string)kvp["serverHttpPort"], out port);
HttpPort = port; HttpPort = port;
} }
if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) if (kvp.ContainsKey("serverURI"))
{ ServerURI = (string)kvp["serverURI"];
int port = 0;
Int32.TryParse((string)kvp["internal_port"], out port);
IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port);
InternalEndPoint = ep;
}
else
InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
if (kvp["alternate_ports"] != null)
{
bool alts = false;
Boolean.TryParse((string)kvp["alternate_ports"], out alts);
m_allow_alternate_ports = alts;
}
if (kvp["server_uri"] != null)
ServerURI = (string)kvp["server_uri"];
} }
} }

View File

@ -0,0 +1,177 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using OpenMetaverse;
using log4net;
using log4net.Appender;
using log4net.Layout;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Services.Connectors;
namespace OpenSim.Tests.Clients.GridClient
{
public class GridClient
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
public static void Main(string[] args)
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout =
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
log4net.Config.BasicConfigurator.Configure(consoleAppender);
string serverURI = "http://127.0.0.1:8002";
GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
Console.WriteLine("[GRID CLIENT]: *** Registering region 1");
bool success = m_Connector.RegisterRegion(UUID.Zero, r1);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
else
Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
Console.WriteLine("[GRID CLIENT]: *** Registering region 2");
success = m_Connector.RegisterRegion(UUID.Zero, r2);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
else
Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
Console.WriteLine("[GRID CLIENT]: *** Registering region 3");
success = m_Connector.RegisterRegion(UUID.Zero, r3);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
else
Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
success = m_Connector.DeregisterRegion(r3.RegionID);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
else
Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again");
success = m_Connector.RegisterRegion(UUID.Zero, r3);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
else
Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1");
List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
if (regions == null)
Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
else if (regions.Count > 0)
{
if (regions.Count != 1)
Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
else
Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
}
else
Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)");
GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
if (region == null)
Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
else
Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)");
region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
if (region == null)
Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
else
Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)");
region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
if (region == null)
Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
else
Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)");
region = m_Connector.GetRegionByName(UUID.Zero, "Foo");
if (region == null)
Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
else
Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)");
regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10);
if (regions == null)
Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null");
else
Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions");
Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
regions = m_Connector.GetRegionRange(UUID.Zero,
900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize,
900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize);
if (regions == null)
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
else
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
regions = m_Connector.GetRegionRange(UUID.Zero,
900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize,
900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize);
if (regions == null)
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
else
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
Console.Write("Proceed to deregister? Press enter...");
Console.ReadLine();
// Deregister them all
Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1");
success = m_Connector.DeregisterRegion(r1.RegionID);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1");
else
Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister");
Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2");
success = m_Connector.DeregisterRegion(r2.RegionID);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2");
else
Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister");
Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
success = m_Connector.DeregisterRegion(r3.RegionID);
if (success)
Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
else
Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
}
private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
{
GridRegion region = new GridRegion(xcell, ycell);
region.RegionName = name;
region.RegionID = UUID.Random();
region.ExternalHostName = "127.0.0.1";
region.HttpPort = 9000;
region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
return region;
}
}
}

View File

@ -0,0 +1,11 @@
<html>
<form name="input" action="http://127.0.0.1:8002/grid" method="post">
xmin:<input type="text" name="XMIN" value="0">
xmax:<input type="text" name="XMAX" value="0">
ymin:<input type="text" name="YMIN" value="0">
ymax:<input type="text" name="YMAX" value="0">
<input type="hidden" name="METHOD" value="get_region_range">
<input type="submit" value="Submit" />
</form>
</html>

View File

@ -0,0 +1,35 @@
; * The startup section lists all the connectors to start up in this server
; * instance. This may be only one, or it may be the entire server suite.
; * Multiple connectors should be seaprated by commas.
; *
; * These are the IN connectors the server uses, the in connectors
; * read this config file and load the needed OUT and database connectors
; *
; *
[Startup]
ServiceConnectors = "OpenSim.Server.Handlers.dll:GridServiceConnector"
; * This is common for all services, it's the network setup for the entire
; * server instance
; *
[Network]
port = 8002
; * The following are for the remote console
; * They have no effect for the local or basic console types
; * Leave commented to diable logins to the console
;ConsoleUser = Test
;ConsolePass = secret
; * As an example, the below configuration precisely mimicks the legacy
; * asset server. It is read by the asset IN connector (defined above)
; * and it then loads the OUT connector (a local database module). That,
; * in turn, reads the asset loader and database connection information
; *
[GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
;StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData"
;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;"
Realm = "regions"

View File

@ -1311,7 +1311,7 @@
;NoticesEnabled = true ;NoticesEnabled = true
; This makes the Groups modules very chatty on the console. ; This makes the Groups modules very chatty on the console.
;DebugEnabled = true DebugEnabled = false
; Specify which messaging module to use for groups messaging and if it's enabled ; Specify which messaging module to use for groups messaging and if it's enabled
;MessagingModule = GroupsMessagingModule ;MessagingModule = GroupsMessagingModule

View File

@ -3221,6 +3221,35 @@
</Files> </Files>
</Project> </Project>
<!-- Test Clients -->
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Clients.GridClient" path="OpenSim/Tests/Clients/Grid" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Services.Interfaces" />
<Reference name="OpenSim.Services.Connectors" />
<Reference name="Nini.dll" />
<Reference name="log4net.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<!-- Test assemblies --> <!-- Test assemblies -->
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Common" path="OpenSim/Tests/Common" type="Library"> <Project frameworkVersion="v3_5" name="OpenSim.Tests.Common" path="OpenSim/Tests/Common" type="Library">
<Configuration name="Debug"> <Configuration name="Debug">