diff options
author | MW | 2007-03-08 13:21:24 +0000 |
---|---|---|
committer | MW | 2007-03-08 13:21:24 +0000 |
commit | f60bc970eb925cd245cc77b1ae700b28d4589163 (patch) | |
tree | d279883582f00232bad87bf17e5727ff263027a4 /src/LocalStorage/Db4LocalStorage | |
parent | Brought OGS.sql back into trunk (diff) | |
download | opensim-SC_OLD-f60bc970eb925cd245cc77b1ae700b28d4589163.zip opensim-SC_OLD-f60bc970eb925cd245cc77b1ae700b28d4589163.tar.gz opensim-SC_OLD-f60bc970eb925cd245cc77b1ae700b28d4589163.tar.bz2 opensim-SC_OLD-f60bc970eb925cd245cc77b1ae700b28d4589163.tar.xz |
Another attemp to fix the Session Logout bug
World map data is now saved in database and recovered on startup.
Primitives are now backed up to a local database and reloaded on startup.
Diffstat (limited to 'src/LocalStorage/Db4LocalStorage')
4 files changed, 210 insertions, 0 deletions
diff --git a/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs new file mode 100644 index 0000000..6610606 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/AssemblyInfo.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // Information about this assembly is defined by the following | ||
6 | // attributes. | ||
7 | // | ||
8 | // change them to the information which is associated with the assembly | ||
9 | // you compile. | ||
10 | |||
11 | [assembly: AssemblyTitle("Db4LocalStorage")] | ||
12 | [assembly: AssemblyDescription("")] | ||
13 | [assembly: AssemblyConfiguration("")] | ||
14 | [assembly: AssemblyCompany("")] | ||
15 | [assembly: AssemblyProduct("Db4LocalStorage")] | ||
16 | [assembly: AssemblyCopyright("")] | ||
17 | [assembly: AssemblyTrademark("")] | ||
18 | [assembly: AssemblyCulture("")] | ||
19 | |||
20 | // This sets the default COM visibility of types in the assembly to invisible. | ||
21 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
22 | [assembly: ComVisible(false)] | ||
23 | |||
24 | // The assembly version has following format : | ||
25 | // | ||
26 | // Major.Minor.Build.Revision | ||
27 | // | ||
28 | // You can specify all values by your own or you can build default build and revision | ||
29 | // numbers with the '*' character (the default): | ||
30 | |||
31 | [assembly: AssemblyVersion("1.0.*")] | ||
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs new file mode 100644 index 0000000..9dc81a1 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.cs | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using Db4objects.Db4o; | ||
30 | using Db4objects.Db4o.Query; | ||
31 | using libsecondlife; | ||
32 | using GridInterfaces; | ||
33 | |||
34 | namespace Db4LocalStorage | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// | ||
38 | /// </summary> | ||
39 | public class Db4LocalStorage : ILocalStorage | ||
40 | { | ||
41 | private IObjectContainer db; | ||
42 | |||
43 | public Db4LocalStorage() | ||
44 | { | ||
45 | try | ||
46 | { | ||
47 | db = Db4oFactory.OpenFile("localworld.yap"); | ||
48 | ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage creation"); | ||
49 | } | ||
50 | catch(Exception e) | ||
51 | { | ||
52 | db.Close(); | ||
53 | ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured"); | ||
54 | ServerConsole.MainConsole.Instance.WriteLine(e.ToString()); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public void StorePrim(PrimStorage prim) | ||
59 | { | ||
60 | IObjectSet result = db.Query(new UUIDQuery(prim.FullID)); | ||
61 | if(result.Count>0) | ||
62 | { | ||
63 | //prim already in storage | ||
64 | //so update it | ||
65 | PrimStorage found = (PrimStorage) result.Next(); | ||
66 | found.Data = prim.Data; | ||
67 | found.Position = prim.Position; | ||
68 | found.Rotation = prim.Rotation; | ||
69 | db.Set(found); | ||
70 | } | ||
71 | else | ||
72 | { | ||
73 | //not in storage | ||
74 | db.Set(prim); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public void RemovePrim(LLUUID primID) | ||
79 | { | ||
80 | IObjectSet result = db.Query(new UUIDQuery(primID)); | ||
81 | if(result.Count>0) | ||
82 | { | ||
83 | PrimStorage found = (PrimStorage) result.Next(); | ||
84 | db.Delete(found); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | |||
89 | public void LoadPrimitives(ILocalStorageReceiver receiver) | ||
90 | { | ||
91 | IObjectSet result = db.Get(typeof(PrimStorage)); | ||
92 | ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count); | ||
93 | foreach (PrimStorage prim in result) { | ||
94 | receiver.PrimFromStorage(prim); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void ShutDown() | ||
99 | { | ||
100 | db.Commit(); | ||
101 | db.Close(); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | public class UUIDQuery : Predicate | ||
106 | { | ||
107 | private LLUUID _findID; | ||
108 | |||
109 | public UUIDQuery(LLUUID find) | ||
110 | { | ||
111 | _findID = find; | ||
112 | } | ||
113 | public bool Match(PrimStorage prim) | ||
114 | { | ||
115 | return (prim.FullID == _findID); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | } | ||
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj new file mode 100644 index 0000000..9b5c487 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.csproj | |||
@@ -0,0 +1,53 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Library</OutputType> | ||
4 | <RootNamespace>Db4LocalStorage</RootNamespace> | ||
5 | <AssemblyName>Db4LocalStorage</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{74784F23-B0FD-484C-82C1-96C0215733DC}</ProjectGuid> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
11 | <OutputPath>bin\Debug\</OutputPath> | ||
12 | <Optimize>False</Optimize> | ||
13 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
14 | <DebugSymbols>True</DebugSymbols> | ||
15 | <DebugType>Full</DebugType> | ||
16 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
19 | <OutputPath>bin\Release\</OutputPath> | ||
20 | <Optimize>True</Optimize> | ||
21 | <DefineConstants>TRACE</DefineConstants> | ||
22 | <DebugSymbols>False</DebugSymbols> | ||
23 | <DebugType>None</DebugType> | ||
24 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
25 | </PropertyGroup> | ||
26 | <ItemGroup> | ||
27 | <Reference Include="System" /> | ||
28 | <Reference Include="System.Xml" /> | ||
29 | <Reference Include="Db4objects.Db4o"> | ||
30 | <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath> | ||
31 | <SpecificVersion>False</SpecificVersion> | ||
32 | </Reference> | ||
33 | <Reference Include="libsecondlife"> | ||
34 | <HintPath>..\..\..\..\..\..\..\Libsecond-dailys\libsl07-03\trunk\libsecondlife-cs\obj\Debug\libsecondlife.dll</HintPath> | ||
35 | <SpecificVersion>False</SpecificVersion> | ||
36 | </Reference> | ||
37 | </ItemGroup> | ||
38 | <ItemGroup> | ||
39 | <Compile Include="Db4LocalStorage.cs" /> | ||
40 | <Compile Include="AssemblyInfo.cs" /> | ||
41 | </ItemGroup> | ||
42 | <ItemGroup> | ||
43 | <ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj"> | ||
44 | <Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project> | ||
45 | <Name>GridInterfaces</Name> | ||
46 | </ProjectReference> | ||
47 | <ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj"> | ||
48 | <Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project> | ||
49 | <Name>ServerConsole</Name> | ||
50 | </ProjectReference> | ||
51 | </ItemGroup> | ||
52 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
53 | </Project> \ No newline at end of file | ||
diff --git a/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln new file mode 100644 index 0000000..89e4710 --- /dev/null +++ b/src/LocalStorage/Db4LocalStorage/Db4LocalStorage.sln | |||
@@ -0,0 +1,7 @@ | |||
1 | | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}" | ||
5 | EndProject | ||
6 | Global | ||
7 | EndGlobal | ||