diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/DataSnapshot/LLSDDiscovery.cs | 92 | ||||
-rw-r--r-- | OpenSim/Region/DataSnapshot/SnapshotStore.cs | 632 |
3 files changed, 375 insertions, 375 deletions
diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs index 697d313..447aec6 100644 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs | |||
@@ -1,13 +1,13 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.Xml; | 4 | using System.Xml; |
5 | 5 | ||
6 | namespace OpenSim.Region.DataSnapshot.Interfaces | 6 | namespace OpenSim.Region.DataSnapshot.Interfaces |
7 | { | 7 | { |
8 | public interface IDataSnapshot | 8 | public interface IDataSnapshot |
9 | { | 9 | { |
10 | XmlDocument GetSnapshot(string regionName); | 10 | XmlDocument GetSnapshot(string regionName); |
11 | void MakeEverythingStale(); | 11 | void MakeEverythingStale(); |
12 | } | 12 | } |
13 | } | 13 | } |
diff --git a/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs b/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs index 7b4f4ec..209f804 100644 --- a/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs +++ b/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs | |||
@@ -1,46 +1,46 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using OpenSim.Framework.Communications.Capabilities; | 30 | using OpenSim.Framework.Communications.Capabilities; |
31 | 31 | ||
32 | namespace OpenSim.Region.DataSnapshot | 32 | namespace OpenSim.Region.DataSnapshot |
33 | { | 33 | { |
34 | [LLSDMap] | 34 | [LLSDMap] |
35 | public class LLSDDiscoveryResponse | 35 | public class LLSDDiscoveryResponse |
36 | { | 36 | { |
37 | public LLSDArray snapshot_resources; | 37 | public LLSDArray snapshot_resources; |
38 | } | 38 | } |
39 | 39 | ||
40 | [LLSDMap] | 40 | [LLSDMap] |
41 | public class LLSDDiscoveryDataURL | 41 | public class LLSDDiscoveryDataURL |
42 | { | 42 | { |
43 | public string snapshot_format; | 43 | public string snapshot_format; |
44 | public string snapshot_url; | 44 | public string snapshot_url; |
45 | } | 45 | } |
46 | } | 46 | } |
diff --git a/OpenSim/Region/DataSnapshot/SnapshotStore.cs b/OpenSim/Region/DataSnapshot/SnapshotStore.cs index 05d5640..7e2c060 100644 --- a/OpenSim/Region/DataSnapshot/SnapshotStore.cs +++ b/OpenSim/Region/DataSnapshot/SnapshotStore.cs | |||
@@ -1,316 +1,316 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Xml; | 32 | using System.Xml; |
33 | using System.IO; | 33 | using System.IO; |
34 | using OpenSim.Region.Environment.Scenes; | 34 | using OpenSim.Region.Environment.Scenes; |
35 | using OpenSim.Region.DataSnapshot.Interfaces; | 35 | using OpenSim.Region.DataSnapshot.Interfaces; |
36 | using libsecondlife; | 36 | using libsecondlife; |
37 | 37 | ||
38 | namespace OpenSim.Region.DataSnapshot | 38 | namespace OpenSim.Region.DataSnapshot |
39 | { | 39 | { |
40 | public class SnapshotStore | 40 | public class SnapshotStore |
41 | { | 41 | { |
42 | #region Class Members | 42 | #region Class Members |
43 | private String m_directory = "unyuu"; //not an attempt at adding RM references to core SVN, honest | 43 | private String m_directory = "unyuu"; //not an attempt at adding RM references to core SVN, honest |
44 | private Dictionary<Scene, bool> m_scenes = null; | 44 | private Dictionary<Scene, bool> m_scenes = null; |
45 | private List<IDataSnapshotProvider> m_providers = null; | 45 | private List<IDataSnapshotProvider> m_providers = null; |
46 | private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 46 | private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
47 | private Dictionary<String, String> m_gridinfo = null; | 47 | private Dictionary<String, String> m_gridinfo = null; |
48 | private bool m_cacheEnabled = true; | 48 | private bool m_cacheEnabled = true; |
49 | private string m_listener_port = "9000"; //TODO: Set default port over 9000 | 49 | private string m_listener_port = "9000"; //TODO: Set default port over 9000 |
50 | private string m_hostname = "127.0.0.1"; | 50 | private string m_hostname = "127.0.0.1"; |
51 | #endregion | 51 | #endregion |
52 | 52 | ||
53 | public SnapshotStore(string directory, Dictionary<String, String> gridinfo, string port, string hostname) { | 53 | public SnapshotStore(string directory, Dictionary<String, String> gridinfo, string port, string hostname) { |
54 | m_directory = directory; | 54 | m_directory = directory; |
55 | m_scenes = new Dictionary<Scene, bool>(); | 55 | m_scenes = new Dictionary<Scene, bool>(); |
56 | m_providers = new List<IDataSnapshotProvider>(); | 56 | m_providers = new List<IDataSnapshotProvider>(); |
57 | m_gridinfo = gridinfo; | 57 | m_gridinfo = gridinfo; |
58 | m_listener_port = port; | 58 | m_listener_port = port; |
59 | m_hostname = hostname; | 59 | m_hostname = hostname; |
60 | 60 | ||
61 | if (Directory.Exists(m_directory)) | 61 | if (Directory.Exists(m_directory)) |
62 | { | 62 | { |
63 | m_log.Info("[DATASNAPSHOT]: Repsonse and fragment cache directory already exists."); | 63 | m_log.Info("[DATASNAPSHOT]: Repsonse and fragment cache directory already exists."); |
64 | } | 64 | } |
65 | else | 65 | else |
66 | { | 66 | { |
67 | // Try to create the directory. | 67 | // Try to create the directory. |
68 | m_log.Info("[DATASNAPSHOT]: Creating directory " + m_directory); | 68 | m_log.Info("[DATASNAPSHOT]: Creating directory " + m_directory); |
69 | try | 69 | try |
70 | { | 70 | { |
71 | Directory.CreateDirectory(m_directory); | 71 | Directory.CreateDirectory(m_directory); |
72 | } | 72 | } |
73 | catch (Exception e) | 73 | catch (Exception e) |
74 | { | 74 | { |
75 | m_log.Error("[DATASNAPSHOT]: Failed to create directory " + m_directory, e); | 75 | m_log.Error("[DATASNAPSHOT]: Failed to create directory " + m_directory, e); |
76 | 76 | ||
77 | //This isn't a horrible problem, just disable cacheing. | 77 | //This isn't a horrible problem, just disable cacheing. |
78 | m_cacheEnabled = false; | 78 | m_cacheEnabled = false; |
79 | m_log.Error("[DATASNAPSHOT]: Could not create directory, response cache has been disabled."); | 79 | m_log.Error("[DATASNAPSHOT]: Could not create directory, response cache has been disabled."); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | public void ForceSceneStale(Scene scene) { | 84 | public void ForceSceneStale(Scene scene) { |
85 | m_scenes[scene] = true; | 85 | m_scenes[scene] = true; |
86 | } | 86 | } |
87 | 87 | ||
88 | #region Fragment storage | 88 | #region Fragment storage |
89 | public XmlNode GetFragment(IDataSnapshotProvider provider, XmlDocument factory) | 89 | public XmlNode GetFragment(IDataSnapshotProvider provider, XmlDocument factory) |
90 | { | 90 | { |
91 | XmlNode data = null; | 91 | XmlNode data = null; |
92 | 92 | ||
93 | if (provider.Stale || !m_cacheEnabled) | 93 | if (provider.Stale || !m_cacheEnabled) |
94 | { | 94 | { |
95 | data = provider.RequestSnapshotData(factory); | 95 | data = provider.RequestSnapshotData(factory); |
96 | 96 | ||
97 | if (m_cacheEnabled) | 97 | if (m_cacheEnabled) |
98 | { | 98 | { |
99 | String path = DataFileNameFragment(provider.GetParentScene, provider.Name); | 99 | String path = DataFileNameFragment(provider.GetParentScene, provider.Name); |
100 | 100 | ||
101 | using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) | 101 | using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) |
102 | { | 102 | { |
103 | snapXWriter.Formatting = Formatting.Indented; | 103 | snapXWriter.Formatting = Formatting.Indented; |
104 | snapXWriter.WriteStartDocument(); | 104 | snapXWriter.WriteStartDocument(); |
105 | data.WriteTo(snapXWriter); | 105 | data.WriteTo(snapXWriter); |
106 | snapXWriter.WriteEndDocument(); | 106 | snapXWriter.WriteEndDocument(); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | //mark provider as not stale, parent scene as stale | 110 | //mark provider as not stale, parent scene as stale |
111 | provider.Stale = false; | 111 | provider.Stale = false; |
112 | m_scenes[provider.GetParentScene] = true; | 112 | m_scenes[provider.GetParentScene] = true; |
113 | 113 | ||
114 | m_log.Info("[DATASNAPSHOT]: Generated fragment response for provider type " + provider.Name); | 114 | m_log.Info("[DATASNAPSHOT]: Generated fragment response for provider type " + provider.Name); |
115 | } | 115 | } |
116 | else | 116 | else |
117 | { | 117 | { |
118 | String path = DataFileNameFragment(provider.GetParentScene, provider.Name); | 118 | String path = DataFileNameFragment(provider.GetParentScene, provider.Name); |
119 | 119 | ||
120 | XmlDocument fragDocument = new XmlDocument(); | 120 | XmlDocument fragDocument = new XmlDocument(); |
121 | fragDocument.PreserveWhitespace = true; | 121 | fragDocument.PreserveWhitespace = true; |
122 | fragDocument.Load(path); | 122 | fragDocument.Load(path); |
123 | foreach (XmlNode node in fragDocument) | 123 | foreach (XmlNode node in fragDocument) |
124 | { | 124 | { |
125 | data = factory.ImportNode(node, true); | 125 | data = factory.ImportNode(node, true); |
126 | } | 126 | } |
127 | 127 | ||
128 | m_log.Info("[DATASNAPSHOT]: Retrieved fragment response for provider type " + provider.Name); | 128 | m_log.Info("[DATASNAPSHOT]: Retrieved fragment response for provider type " + provider.Name); |
129 | } | 129 | } |
130 | 130 | ||
131 | return data; | 131 | return data; |
132 | } | 132 | } |
133 | #endregion | 133 | #endregion |
134 | 134 | ||
135 | #region Response storage | 135 | #region Response storage |
136 | public XmlNode GetScene(Scene scene, XmlDocument factory) | 136 | public XmlNode GetScene(Scene scene, XmlDocument factory) |
137 | { | 137 | { |
138 | m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.RegionInfo.RegionName); | 138 | m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.RegionInfo.RegionName); |
139 | 139 | ||
140 | if (!m_scenes.ContainsKey(scene)) { | 140 | if (!m_scenes.ContainsKey(scene)) { |
141 | m_scenes.Add(scene, true); //stale by default | 141 | m_scenes.Add(scene, true); //stale by default |
142 | } | 142 | } |
143 | 143 | ||
144 | XmlNode regionElement = null; | 144 | XmlNode regionElement = null; |
145 | 145 | ||
146 | if (!m_scenes[scene]) | 146 | if (!m_scenes[scene]) |
147 | { | 147 | { |
148 | m_log.Info("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache."); | 148 | m_log.Info("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache."); |
149 | //get snapshot from cache | 149 | //get snapshot from cache |
150 | String path = DataFileNameScene(scene); | 150 | String path = DataFileNameScene(scene); |
151 | 151 | ||
152 | XmlDocument fragDocument = new XmlDocument(); | 152 | XmlDocument fragDocument = new XmlDocument(); |
153 | fragDocument.PreserveWhitespace = true; | 153 | fragDocument.PreserveWhitespace = true; |
154 | 154 | ||
155 | fragDocument.Load(path); | 155 | fragDocument.Load(path); |
156 | 156 | ||
157 | foreach (XmlNode node in fragDocument) | 157 | foreach (XmlNode node in fragDocument) |
158 | { | 158 | { |
159 | regionElement = factory.ImportNode(node, true); | 159 | regionElement = factory.ImportNode(node, true); |
160 | } | 160 | } |
161 | 161 | ||
162 | m_log.Info("[DATASNAPSHOT]: Obtained snapshot from cache for " + scene.RegionInfo.RegionName); | 162 | m_log.Info("[DATASNAPSHOT]: Obtained snapshot from cache for " + scene.RegionInfo.RegionName); |
163 | } | 163 | } |
164 | else | 164 | else |
165 | { | 165 | { |
166 | m_log.Info("[DATASNAPSHOT]: Attempting to generate snapshot."); | 166 | m_log.Info("[DATASNAPSHOT]: Attempting to generate snapshot."); |
167 | //make snapshot | 167 | //make snapshot |
168 | regionElement = MakeRegionNode(scene, factory); | 168 | regionElement = MakeRegionNode(scene, factory); |
169 | 169 | ||
170 | regionElement.AppendChild(GetGridSnapshotData(factory)); | 170 | regionElement.AppendChild(GetGridSnapshotData(factory)); |
171 | XmlNode regionData = factory.CreateNode(XmlNodeType.Element, "data", ""); | 171 | XmlNode regionData = factory.CreateNode(XmlNodeType.Element, "data", ""); |
172 | 172 | ||
173 | foreach (IDataSnapshotProvider dataprovider in m_providers) | 173 | foreach (IDataSnapshotProvider dataprovider in m_providers) |
174 | { | 174 | { |
175 | if (dataprovider.GetParentScene == scene) | 175 | if (dataprovider.GetParentScene == scene) |
176 | { | 176 | { |
177 | regionData.AppendChild(GetFragment(dataprovider, factory)); | 177 | regionData.AppendChild(GetFragment(dataprovider, factory)); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | regionElement.AppendChild(regionData); | 181 | regionElement.AppendChild(regionData); |
182 | 182 | ||
183 | factory.AppendChild(regionElement); | 183 | factory.AppendChild(regionElement); |
184 | 184 | ||
185 | //save snapshot | 185 | //save snapshot |
186 | String path = DataFileNameScene(scene); | 186 | String path = DataFileNameScene(scene); |
187 | 187 | ||
188 | using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) | 188 | using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) |
189 | { | 189 | { |
190 | snapXWriter.Formatting = Formatting.Indented; | 190 | snapXWriter.Formatting = Formatting.Indented; |
191 | snapXWriter.WriteStartDocument(); | 191 | snapXWriter.WriteStartDocument(); |
192 | regionElement.WriteTo(snapXWriter); | 192 | regionElement.WriteTo(snapXWriter); |
193 | snapXWriter.WriteEndDocument(); | 193 | snapXWriter.WriteEndDocument(); |
194 | } | 194 | } |
195 | 195 | ||
196 | m_scenes[scene] = false; | 196 | m_scenes[scene] = false; |
197 | 197 | ||
198 | m_log.Info("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName); | 198 | m_log.Info("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName); |
199 | } | 199 | } |
200 | 200 | ||
201 | return regionElement; | 201 | return regionElement; |
202 | } | 202 | } |
203 | 203 | ||
204 | #endregion | 204 | #endregion |
205 | 205 | ||
206 | #region Helpers | 206 | #region Helpers |
207 | private string DataFileNameFragment(Scene scene, String fragmentName) | 207 | private string DataFileNameFragment(Scene scene, String fragmentName) |
208 | { | 208 | { |
209 | return Path.Combine(m_directory, Path.ChangeExtension(scene.RegionInfo.RegionName + "_" + fragmentName, "xml")); | 209 | return Path.Combine(m_directory, Path.ChangeExtension(scene.RegionInfo.RegionName + "_" + fragmentName, "xml")); |
210 | } | 210 | } |
211 | 211 | ||
212 | private string DataFileNameScene(Scene scene) | 212 | private string DataFileNameScene(Scene scene) |
213 | { | 213 | { |
214 | return Path.Combine(m_directory, Path.ChangeExtension(scene.RegionInfo.RegionName, "xml")); | 214 | return Path.Combine(m_directory, Path.ChangeExtension(scene.RegionInfo.RegionName, "xml")); |
215 | //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml"); | 215 | //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml"); |
216 | } | 216 | } |
217 | 217 | ||
218 | private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc) | 218 | private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc) |
219 | { | 219 | { |
220 | XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", ""); | 220 | XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", ""); |
221 | 221 | ||
222 | XmlAttribute attr = basedoc.CreateAttribute("category"); | 222 | XmlAttribute attr = basedoc.CreateAttribute("category"); |
223 | attr.Value = GetRegionCategory(scene); | 223 | attr.Value = GetRegionCategory(scene); |
224 | docElement.Attributes.Append(attr); | 224 | docElement.Attributes.Append(attr); |
225 | 225 | ||
226 | attr = basedoc.CreateAttribute("entities"); | 226 | attr = basedoc.CreateAttribute("entities"); |
227 | attr.Value = scene.Entities.Count.ToString(); | 227 | attr.Value = scene.Entities.Count.ToString(); |
228 | docElement.Attributes.Append(attr); | 228 | docElement.Attributes.Append(attr); |
229 | 229 | ||
230 | //attr = basedoc.CreateAttribute("parcels"); | 230 | //attr = basedoc.CreateAttribute("parcels"); |
231 | //attr.Value = scene.LandManager.landList.Count.ToString(); | 231 | //attr.Value = scene.LandManager.landList.Count.ToString(); |
232 | //docElement.Attributes.Append(attr); | 232 | //docElement.Attributes.Append(attr); |
233 | 233 | ||
234 | 234 | ||
235 | XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", ""); | 235 | XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", ""); |
236 | 236 | ||
237 | XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", ""); | 237 | XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", ""); |
238 | infopiece.InnerText = scene.RegionInfo.RegionID.ToString(); | 238 | infopiece.InnerText = scene.RegionInfo.RegionID.ToString(); |
239 | infoblock.AppendChild(infopiece); | 239 | infoblock.AppendChild(infopiece); |
240 | 240 | ||
241 | infopiece = basedoc.CreateNode(XmlNodeType.Element, "url", ""); | 241 | infopiece = basedoc.CreateNode(XmlNodeType.Element, "url", ""); |
242 | infopiece.InnerText = "http://" + m_hostname + ":" + m_listener_port; | 242 | infopiece.InnerText = "http://" + m_hostname + ":" + m_listener_port; |
243 | infoblock.AppendChild(infopiece); | 243 | infoblock.AppendChild(infopiece); |
244 | 244 | ||
245 | infopiece = basedoc.CreateNode(XmlNodeType.Element, "name", ""); | 245 | infopiece = basedoc.CreateNode(XmlNodeType.Element, "name", ""); |
246 | infopiece.InnerText = scene.RegionInfo.RegionName; | 246 | infopiece.InnerText = scene.RegionInfo.RegionName; |
247 | infoblock.AppendChild(infopiece); | 247 | infoblock.AppendChild(infopiece); |
248 | 248 | ||
249 | docElement.AppendChild(infoblock); | 249 | docElement.AppendChild(infoblock); |
250 | 250 | ||
251 | m_log.Debug("[DATASNAPSHOT]: Generated region node"); | 251 | m_log.Debug("[DATASNAPSHOT]: Generated region node"); |
252 | return docElement; | 252 | return docElement; |
253 | } | 253 | } |
254 | 254 | ||
255 | private String GetRegionCategory(Scene scene) | 255 | private String GetRegionCategory(Scene scene) |
256 | { | 256 | { |
257 | 257 | ||
258 | //Boolean choice between: | 258 | //Boolean choice between: |
259 | // "PG" - Mormontown | 259 | // "PG" - Mormontown |
260 | // "Mature" - Sodom and Gomorrah | 260 | // "Mature" - Sodom and Gomorrah |
261 | // (Depreciated) "Patriotic Nigra Testing Sandbox" - Abandon Hope All Ye Who Enter Here | 261 | // (Depreciated) "Patriotic Nigra Testing Sandbox" - Abandon Hope All Ye Who Enter Here |
262 | if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.Mature) == Simulator.SimAccess.Mature) | 262 | if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.Mature) == Simulator.SimAccess.Mature) |
263 | { | 263 | { |
264 | return "Mature"; | 264 | return "Mature"; |
265 | } | 265 | } |
266 | else if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.PG) == Simulator.SimAccess.PG) | 266 | else if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.PG) == Simulator.SimAccess.PG) |
267 | { | 267 | { |
268 | return "PG"; | 268 | return "PG"; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | { | 271 | { |
272 | return "Unknown"; | 272 | return "Unknown"; |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | private XmlNode GetGridSnapshotData(XmlDocument factory) | 276 | private XmlNode GetGridSnapshotData(XmlDocument factory) |
277 | { | 277 | { |
278 | XmlNode griddata = factory.CreateNode(XmlNodeType.Element, "grid", ""); | 278 | XmlNode griddata = factory.CreateNode(XmlNodeType.Element, "grid", ""); |
279 | 279 | ||
280 | foreach (KeyValuePair<String, String> GridData in m_gridinfo) | 280 | foreach (KeyValuePair<String, String> GridData in m_gridinfo) |
281 | { | 281 | { |
282 | //TODO: make it lowercase tag names for diva | 282 | //TODO: make it lowercase tag names for diva |
283 | XmlNode childnode = factory.CreateNode(XmlNodeType.Element, GridData.Key, ""); | 283 | XmlNode childnode = factory.CreateNode(XmlNodeType.Element, GridData.Key, ""); |
284 | childnode.InnerText = GridData.Value; | 284 | childnode.InnerText = GridData.Value; |
285 | griddata.AppendChild(childnode); | 285 | griddata.AppendChild(childnode); |
286 | } | 286 | } |
287 | 287 | ||
288 | m_log.Debug("[DATASNAPSHOT]: Got grid snapshot data"); | 288 | m_log.Debug("[DATASNAPSHOT]: Got grid snapshot data"); |
289 | 289 | ||
290 | return griddata; | 290 | return griddata; |
291 | } | 291 | } |
292 | #endregion | 292 | #endregion |
293 | 293 | ||
294 | #region Manage internal collections | 294 | #region Manage internal collections |
295 | public void AddScene(Scene newScene) | 295 | public void AddScene(Scene newScene) |
296 | { | 296 | { |
297 | m_scenes.Add(newScene, true); | 297 | m_scenes.Add(newScene, true); |
298 | } | 298 | } |
299 | 299 | ||
300 | public void RemoveScene(Scene deadScene) | 300 | public void RemoveScene(Scene deadScene) |
301 | { | 301 | { |
302 | m_scenes.Remove(deadScene); | 302 | m_scenes.Remove(deadScene); |
303 | } | 303 | } |
304 | 304 | ||
305 | public void AddProvider(IDataSnapshotProvider newProvider) | 305 | public void AddProvider(IDataSnapshotProvider newProvider) |
306 | { | 306 | { |
307 | m_providers.Add(newProvider); | 307 | m_providers.Add(newProvider); |
308 | } | 308 | } |
309 | 309 | ||
310 | public void RemoveProvider(IDataSnapshotProvider deadProvider) | 310 | public void RemoveProvider(IDataSnapshotProvider deadProvider) |
311 | { | 311 | { |
312 | m_providers.Remove(deadProvider); | 312 | m_providers.Remove(deadProvider); |
313 | } | 313 | } |
314 | #endregion | 314 | #endregion |
315 | } | 315 | } |
316 | } | 316 | } |