Made a few changes so that once we enable the sqlite data store (simple line change in OpenSimMain), then basic ( with a few limits at moment) prim database backup will work.
parent
6063d2ce5f
commit
94c7e41ef1
|
@ -151,15 +151,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
Avatars = new Dictionary<LLUUID, ScenePresence>();
|
Avatars = new Dictionary<LLUUID, ScenePresence>();
|
||||||
Prims = new Dictionary<LLUUID, SceneObjectGroup>();
|
Prims = new Dictionary<LLUUID, SceneObjectGroup>();
|
||||||
|
|
||||||
MainLog.Instance.Verbose("Loading objects from datastore");
|
|
||||||
List<SceneObjectGroup> PrimsFromDB = storageManager.DataStore.LoadObjects();
|
|
||||||
foreach (SceneObjectGroup prim in PrimsFromDB)
|
|
||||||
{
|
|
||||||
AddEntity(prim);
|
|
||||||
}
|
|
||||||
MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " object(s)");
|
|
||||||
|
|
||||||
|
|
||||||
MainLog.Instance.Verbose("Creating LandMap");
|
MainLog.Instance.Verbose("Creating LandMap");
|
||||||
Terrain = new TerrainEngine((int)this.RegionInfo.RegionLocX, (int)this.RegionInfo.RegionLocY);
|
Terrain = new TerrainEngine((int)this.RegionInfo.RegionLocX, (int)this.RegionInfo.RegionLocY);
|
||||||
|
|
||||||
|
@ -238,7 +229,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
//backup scene data
|
//backup scene data
|
||||||
storageCount++;
|
storageCount++;
|
||||||
if (storageCount > 1200) //set to how often you want to backup
|
if (storageCount > 600) //set to how often you want to backup
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
storageCount = 0;
|
storageCount = 0;
|
||||||
|
@ -462,12 +453,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void LoadPrimsFromStorage()
|
public void LoadPrimsFromStorage()
|
||||||
{
|
{
|
||||||
MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
|
MainLog.Instance.Verbose("Loading objects from datastore");
|
||||||
List<SceneObjectGroup> NewObjectsList = storageManager.DataStore.LoadObjects();
|
List<SceneObjectGroup> PrimsFromDB = storageManager.DataStore.LoadObjects();
|
||||||
foreach (SceneObjectGroup obj in NewObjectsList)
|
foreach (SceneObjectGroup prim in PrimsFromDB)
|
||||||
{
|
{
|
||||||
this.Objects.Add(obj.UUID, obj);
|
AddEntityFromStorage(prim);
|
||||||
}
|
}
|
||||||
|
MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " object(s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -520,6 +512,17 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddEntityFromStorage(SceneObjectGroup sceneObject)
|
||||||
|
{
|
||||||
|
sceneObject.RegionHandle = this.m_regionHandle;
|
||||||
|
sceneObject.SetScene(this);
|
||||||
|
foreach (SceneObjectPart part in sceneObject.Children.Values)
|
||||||
|
{
|
||||||
|
part.LocalID = this.PrimIDAllocate();
|
||||||
|
}
|
||||||
|
this.AddEntity(sceneObject);
|
||||||
|
}
|
||||||
|
|
||||||
public void AddEntity(SceneObjectGroup sceneObject)
|
public void AddEntity(SceneObjectGroup sceneObject)
|
||||||
{
|
{
|
||||||
Entities.Add(sceneObject.UUID, sceneObject);
|
Entities.Add(sceneObject.UUID, sceneObject);
|
||||||
|
@ -781,7 +784,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if (ent is SceneObjectGroup)
|
if (ent is SceneObjectGroup)
|
||||||
{
|
{
|
||||||
// ((SceneObject) ent).SendAllChildPrimsToClient(client);
|
((SceneObjectGroup) ent).SendFullUpdateToClient(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,27 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
set { m_parts = value; }
|
set { m_parts = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SceneObjectPart RootPart
|
||||||
|
{
|
||||||
|
set { m_rootPart = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ulong RegionHandle
|
||||||
|
{
|
||||||
|
get { return m_regionHandle; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_regionHandle = value;
|
||||||
|
lock (this.m_parts)
|
||||||
|
{
|
||||||
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
||||||
|
{
|
||||||
|
part.RegionHandle = m_regionHandle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override LLVector3 Pos
|
public override LLVector3 Pos
|
||||||
{
|
{
|
||||||
get { return m_rootPart.GroupPosition; }
|
get { return m_rootPart.GroupPosition; }
|
||||||
|
@ -79,9 +100,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Added because the Parcel code seems to use it
|
/// Added because the Parcel code seems to use it
|
||||||
/// but not sure a object should have this
|
/// but not sure a object should have this
|
||||||
/// as what does it tell us? that some avatar has selected it
|
/// as what does it tell us? that some avatar has selected it (but not what Avatar/user)
|
||||||
/// think really there should be a list (or whatever) in each scenepresence
|
/// think really there should be a list (or whatever) in each scenepresence
|
||||||
/// saying what prim(s) that user has selected at any time.
|
/// saying what prim(s) that user has selected.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool m_isSelected = false;
|
protected bool m_isSelected = false;
|
||||||
public bool IsSelected
|
public bool IsSelected
|
||||||
|
@ -114,7 +135,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
m_regionHandle = regionHandle;
|
m_regionHandle = regionHandle;
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
|
|
||||||
this.Pos = pos;
|
// this.Pos = pos;
|
||||||
LLVector3 rootOffset = new LLVector3(0, 0, 0);
|
LLVector3 rootOffset = new LLVector3(0, 0, 0);
|
||||||
SceneObjectPart newPart = new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset);
|
SceneObjectPart newPart = new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset);
|
||||||
this.m_parts.Add(newPart.UUID, newPart);
|
this.m_parts.Add(newPart.UUID, newPart);
|
||||||
|
@ -136,6 +157,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
dupe.m_regionHandle = this.m_regionHandle;
|
dupe.m_regionHandle = this.m_regionHandle;
|
||||||
|
|
||||||
dupe.CopyRootPart(this.m_rootPart);
|
dupe.CopyRootPart(this.m_rootPart);
|
||||||
|
m_scene.EventManager.OnBackup += dupe.ProcessBackup;
|
||||||
|
|
||||||
foreach (SceneObjectPart part in this.m_parts.Values)
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
||||||
{
|
{
|
||||||
|
@ -147,6 +169,23 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
return dupe;
|
return dupe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Added as a way for the storage provider to reset the scene,
|
||||||
|
/// most likely a better way to do this sort of thing but for now...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scene"></param>
|
||||||
|
public void SetScene(Scene scene)
|
||||||
|
{
|
||||||
|
m_scene = scene;
|
||||||
|
m_scene.EventManager.OnBackup += this.ProcessBackup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddPart(SceneObjectPart part)
|
||||||
|
{
|
||||||
|
part.SetParent(this);
|
||||||
|
this.m_parts.Add(part.UUID, part);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -619,6 +658,17 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
return m_scene.RequestAvatarList();
|
return m_scene.RequestAvatarList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendFullUpdateToClient(IClientAPI remoteClient)
|
||||||
|
{
|
||||||
|
lock (this.m_parts)
|
||||||
|
{
|
||||||
|
foreach (SceneObjectPart part in this.m_parts.Values)
|
||||||
|
{
|
||||||
|
this.SendPartFullUpdate(remoteClient, part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -249,6 +249,14 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public void SetParent(SceneObjectGroup parent)
|
||||||
|
{
|
||||||
|
m_parentGroup = parent;
|
||||||
|
}
|
||||||
|
|
||||||
#region Copying
|
#region Copying
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
|
@ -556,6 +556,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Border Crossing Methods
|
#region Border Crossing Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
using OpenSim.Region.Environment.LandManagement;
|
using OpenSim.Region.Environment.LandManagement;
|
||||||
|
@ -8,11 +9,12 @@ using OpenSim.Region.Environment;
|
||||||
using OpenSim.Region.Interfaces;
|
using OpenSim.Region.Interfaces;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Types;
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.SqlTypes;
|
using System.Data.SqlTypes;
|
||||||
// Yes, this won't compile on MS, need to deal with that later
|
|
||||||
using Mono.Data.SqliteClient;
|
using Mono.Data.SqliteClient;
|
||||||
|
|
||||||
namespace OpenSim.DataStore.MonoSqliteStorage
|
namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
|
@ -47,6 +49,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
// TODO: see if the linkage actually holds.
|
// TODO: see if the linkage actually holds.
|
||||||
// primDa.FillSchema(ds, SchemaType.Source, "PrimSchema");
|
// primDa.FillSchema(ds, SchemaType.Source, "PrimSchema");
|
||||||
primDa.Fill(ds, "prims");
|
primDa.Fill(ds, "prims");
|
||||||
|
shapeDa.Fill(ds, "primshapes");
|
||||||
ds.AcceptChanges();
|
ds.AcceptChanges();
|
||||||
|
|
||||||
DataTable prims = ds.Tables["prims"];
|
DataTable prims = ds.Tables["prims"];
|
||||||
|
@ -54,7 +57,6 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
setupPrimCommands(primDa, conn);
|
setupPrimCommands(primDa, conn);
|
||||||
|
|
||||||
// shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema");
|
// shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema");
|
||||||
shapeDa.Fill(ds, "primshapes");
|
|
||||||
DataTable shapes = ds.Tables["primshapes"];
|
DataTable shapes = ds.Tables["primshapes"];
|
||||||
shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] };
|
shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] };
|
||||||
setupShapeCommands(shapeDa, conn);
|
setupShapeCommands(shapeDa, conn);
|
||||||
|
@ -378,6 +380,11 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
// text TODO: this isn't right] = but I'm not sure the right
|
// text TODO: this isn't right] = but I'm not sure the right
|
||||||
// way to specify this as a blob atm
|
// way to specify this as a blob atm
|
||||||
// s.TextureEntry = (byte[])row["Texture"];
|
// s.TextureEntry = (byte[])row["Texture"];
|
||||||
|
|
||||||
|
//following hack will only save the default face texture, any other textures on other faces
|
||||||
|
//won't be saved or restored.
|
||||||
|
LLObject.TextureEntry texture = new LLObject.TextureEntry( new LLUUID((string)row["Texture"]));
|
||||||
|
s.TextureEntry = texture.ToBytes();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +421,15 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
row["ProfileHollow"] = s.ProfileHollow;
|
row["ProfileHollow"] = s.ProfileHollow;
|
||||||
// text TODO: this isn't right] = but I'm not sure the right
|
// text TODO: this isn't right] = but I'm not sure the right
|
||||||
// way to specify this as a blob atm
|
// way to specify this as a blob atm
|
||||||
row["Texture"] = s.TextureEntry;
|
|
||||||
|
// And I couldn't work out how to save binary data either
|
||||||
|
// seems that the texture colum is being treated as a string in the Datarow
|
||||||
|
// if you do a .getType() on it, it returns string, while the other columns return correct type
|
||||||
|
//following hack will only save the default face texture, any other textures on other faces
|
||||||
|
//won't be saved or restored.
|
||||||
|
// MW[10-08-07]
|
||||||
|
LLObject.TextureEntry text = new LLObject.TextureEntry(s.TextureEntry, 0, s.TextureEntry.Length);
|
||||||
|
row["Texture"] = text.DefaultTexture.TextureID.ToStringHyphenated();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,9 +464,10 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
addPrim(prim);
|
addPrim(prim);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainLog.Instance.Verbose("Attempting to do update....");
|
MainLog.Instance.Verbose("Attempting to do database update....");
|
||||||
primDa.Update(ds, "prims");
|
primDa.Update(ds, "prims");
|
||||||
MainLog.Instance.Verbose("Dump of prims:", ds.GetXml());
|
shapeDa.Update(ds, "primshapes");
|
||||||
|
// MainLog.Instance.Verbose("Dump of prims:", ds.GetXml());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveObject(LLUUID obj)
|
public void RemoveObject(LLUUID obj)
|
||||||
|
@ -472,15 +488,23 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
SceneObjectGroup group = new SceneObjectGroup();
|
SceneObjectGroup group = new SceneObjectGroup();
|
||||||
SceneObjectPart prim = buildPrim(primRow);
|
SceneObjectPart prim = buildPrim(primRow);
|
||||||
DataRow shapeRow = shapes.Rows.Find(prim.UUID);
|
DataRow shapeRow = shapes.Rows.Find(prim.UUID);
|
||||||
if (shapeRow != null) {
|
if (shapeRow != null)
|
||||||
|
{
|
||||||
prim.Shape = buildShape(shapeRow);
|
prim.Shape = buildShape(shapeRow);
|
||||||
}
|
}
|
||||||
group.Children.Add(prim.UUID, prim);
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("No shape found for prim in storage, so setting default box shape");
|
||||||
|
prim.Shape = BoxShape.Default;
|
||||||
|
}
|
||||||
|
group.AddPart(prim);
|
||||||
// TODO: there are a couple of known issues to get this to work
|
// TODO: there are a couple of known issues to get this to work
|
||||||
// * While we can add Children, we can't set the root part (or
|
// * While we can add Children, we can't set the root part (or
|
||||||
// or even figure out which should be the root part)
|
// or even figure out which should be the root part)
|
||||||
// * region handle may need to be persisted, it isn't now
|
// * region handle may need to be persisted, it isn't now
|
||||||
// retvals.Add(group);
|
group.RootPart = prim;
|
||||||
|
|
||||||
|
retvals.Add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " objects");
|
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " objects");
|
||||||
|
@ -517,5 +541,14 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
{
|
{
|
||||||
// TODO: DataSet commit
|
// TODO: DataSet commit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SaveAssetToFile(string filename, byte[] data)
|
||||||
|
{
|
||||||
|
FileStream fs = File.Create(filename);
|
||||||
|
BinaryWriter bw = new BinaryWriter(fs);
|
||||||
|
bw.Write(data);
|
||||||
|
bw.Close();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -636,7 +636,7 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<Project name="OpenSim.DataStore.MonoSqlite" path="OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite" type="Library">
|
<Project name="OpenSim.DataStore.MonoSqlite1" path="OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
<OutputPath>../../../../bin/</OutputPath>
|
<OutputPath>../../../../bin/</OutputPath>
|
||||||
|
|
Loading…
Reference in New Issue