diff options
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
3 files changed, 127 insertions, 126 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index a374df2..b17f65a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs | |||
@@ -1,29 +1,29 @@ | |||
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 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
@@ -57,11 +57,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
57 | { | 57 | { |
58 | SetUpAssetDatabase(); | 58 | SetUpAssetDatabase(); |
59 | } | 59 | } |
60 | |||
61 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); | ||
62 | this._localAssetServerThread.IsBackground = true; | ||
63 | this._localAssetServerThread.Start(); | ||
64 | |||
65 | } | 60 | } |
66 | 61 | ||
67 | public void CreateAndCommitAsset(AssetBase asset) | 62 | public void CreateAndCommitAsset(AssetBase asset) |
@@ -76,6 +71,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
76 | 71 | ||
77 | override public void Close() | 72 | override public void Close() |
78 | { | 73 | { |
74 | base.Close(); | ||
75 | |||
79 | if (db != null) | 76 | if (db != null) |
80 | { | 77 | { |
81 | MainLog.Instance.Verbose("Closing local asset server database"); | 78 | MainLog.Instance.Verbose("Closing local asset server database"); |
@@ -83,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
83 | } | 80 | } |
84 | } | 81 | } |
85 | 82 | ||
86 | private void RunRequests() | 83 | override protected void RunRequests() |
87 | { | 84 | { |
88 | while (true) | 85 | while (true) |
89 | { | 86 | { |
@@ -135,12 +132,12 @@ namespace OpenSim.Framework.Communications.Cache | |||
135 | db.Commit(); | 132 | db.Commit(); |
136 | } | 133 | } |
137 | 134 | ||
138 | private void SetUpAssetDatabase() | 135 | protected virtual void SetUpAssetDatabase() |
139 | { | 136 | { |
140 | MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); | 137 | MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); |
141 | 138 | ||
142 | ForEachDefaultAsset(this, StoreAsset); | 139 | ForEachDefaultAsset(StoreAsset); |
143 | ForEachXmlAsset(this, StoreAsset); | 140 | ForEachXmlAsset(StoreAsset); |
144 | } | 141 | } |
145 | } | 142 | } |
146 | 143 | ||
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7073000..858019f 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs | |||
@@ -22,78 +22,27 @@ namespace OpenSim.Framework.Communications.Cache | |||
22 | protected abstract void StoreAsset(AssetBase asset); | 22 | protected abstract void StoreAsset(AssetBase asset); |
23 | protected abstract void CommitAssets(); | 23 | protected abstract void CommitAssets(); |
24 | 24 | ||
25 | protected abstract void RunRequests(); | ||
26 | |||
25 | public void LoadDefaultAssets() | 27 | public void LoadDefaultAssets() |
26 | { | 28 | { |
27 | MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); | 29 | MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); |
28 | 30 | ||
29 | ForEachDefaultAsset( this, StoreAsset ); | 31 | ForEachDefaultAsset(StoreAsset ); |
30 | ForEachXmlAsset( this, StoreAsset ); | 32 | ForEachXmlAsset(StoreAsset ); |
31 | 33 | ||
32 | CommitAssets(); | 34 | CommitAssets(); |
33 | } | 35 | } |
34 | 36 | ||
35 | 37 | ||
36 | public static AssetBase CreateAsset(IAssetServer assetServer, string assetIdStr, string name, string filename, bool isImage) | ||
37 | { | ||
38 | AssetBase asset = new AssetBase( | ||
39 | new LLUUID(assetIdStr), | ||
40 | name | ||
41 | ); | ||
42 | |||
43 | if (!String.IsNullOrEmpty(filename)) | ||
44 | { | ||
45 | MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); | ||
46 | |||
47 | assetServer.LoadAsset(asset, isImage, filename); | ||
48 | } | ||
49 | else | ||
50 | { | ||
51 | MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); | ||
52 | } | ||
53 | |||
54 | return asset; | ||
55 | } | ||
56 | |||
57 | private static AssetBase CreateImageAsset(IAssetServer assetServer, string assetIdStr, string name, string filename) | ||
58 | { | ||
59 | return CreateAsset(assetServer, assetIdStr, name, filename, true); | ||
60 | } | ||
61 | |||
62 | public static List<AssetBase> GetDefaultAssets(IAssetServer assetServer) | ||
63 | { | ||
64 | List<AssetBase> assets = new List<AssetBase>(); | ||
65 | |||
66 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); | ||
67 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); | ||
68 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); | ||
69 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); | ||
70 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); | ||
71 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); | ||
72 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); | ||
73 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); | ||
74 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); | ||
75 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); | ||
76 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); | ||
77 | assets.Add(CreateImageAsset(assetServer, "00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); | ||
78 | |||
79 | assets.Add(CreateAsset(assetServer, "77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); | ||
80 | assets.Add(CreateAsset(assetServer, "66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); | ||
81 | assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); | ||
82 | assets.Add(CreateAsset(assetServer, "00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); | ||
83 | |||
84 | return assets; | ||
85 | } | ||
86 | |||
87 | public static void ForEachDefaultAsset(IAssetServer assetServer, Action<AssetBase> action) | ||
88 | { | ||
89 | List<AssetBase> assets = GetDefaultAssets(assetServer); | ||
90 | assets.ForEach(action); | ||
91 | } | ||
92 | |||
93 | public AssetServerBase() | 38 | public AssetServerBase() |
94 | { | 39 | { |
95 | System.Console.WriteLine("Starting Db4o asset storage system"); | 40 | System.Console.WriteLine("Starting Db4o asset storage system"); |
96 | this._assetRequests = new BlockingQueue<ARequest>(); | 41 | this._assetRequests = new BlockingQueue<ARequest>(); |
42 | |||
43 | this._localAssetServerThread = new Thread( RunRequests ); | ||
44 | this._localAssetServerThread.IsBackground = true; | ||
45 | this._localAssetServerThread.Start(); | ||
97 | } | 46 | } |
98 | 47 | ||
99 | public void LoadAsset(AssetBase info, bool image, string filename) | 48 | public void LoadAsset(AssetBase info, bool image, string filename) |
@@ -115,30 +64,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
115 | //info.loaded=true; | 64 | //info.loaded=true; |
116 | } | 65 | } |
117 | 66 | ||
118 | public static void ForEachXmlAsset(IAssetServer assetServer, Action<AssetBase> action) | ||
119 | { | ||
120 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | ||
121 | if (File.Exists(filePath)) | ||
122 | { | ||
123 | XmlConfigSource source = new XmlConfigSource(filePath); | ||
124 | |||
125 | for (int i = 0; i < source.Configs.Count; i++) | ||
126 | { | ||
127 | string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); | ||
128 | string name = source.Configs[i].GetString("name", ""); | ||
129 | sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); | ||
130 | sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); | ||
131 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
132 | |||
133 | AssetBase newAsset = CreateAsset(assetServer, assetIdStr, name, fileName, false); | ||
134 | |||
135 | newAsset.Type = type; | ||
136 | newAsset.InvType = invType; | ||
137 | |||
138 | } | ||
139 | } | ||
140 | } | ||
141 | |||
142 | public void SetReceiver(IAssetReceiver receiver) | 67 | public void SetReceiver(IAssetReceiver receiver) |
143 | { | 68 | { |
144 | this._receiver = receiver; | 69 | this._receiver = receiver; |
@@ -170,11 +95,94 @@ namespace OpenSim.Framework.Communications.Cache | |||
170 | } | 95 | } |
171 | } | 96 | } |
172 | 97 | ||
98 | public virtual void Close() | ||
99 | { | ||
100 | _localAssetServerThread.Abort( ); | ||
101 | } | ||
102 | |||
173 | public void SetServerInfo(string ServerUrl, string ServerKey) | 103 | public void SetServerInfo(string ServerUrl, string ServerKey) |
174 | { | 104 | { |
175 | 105 | ||
176 | } | 106 | } |
177 | 107 | ||
178 | public abstract void Close(); | 108 | public virtual List<AssetBase> GetDefaultAssets() |
109 | { | ||
110 | List<AssetBase> assets = new List<AssetBase>(); | ||
111 | |||
112 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); | ||
113 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); | ||
114 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); | ||
115 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); | ||
116 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); | ||
117 | assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); | ||
118 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); | ||
119 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); | ||
120 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); | ||
121 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); | ||
122 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); | ||
123 | |||
124 | assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); | ||
125 | assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); | ||
126 | assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); | ||
127 | assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); | ||
128 | |||
129 | return assets; | ||
130 | } | ||
131 | |||
132 | public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) | ||
133 | { | ||
134 | return CreateAsset(assetIdStr, name, filename, true); | ||
135 | } | ||
136 | |||
137 | public void ForEachDefaultAsset(Action<AssetBase> action) | ||
138 | { | ||
139 | List<AssetBase> assets = GetDefaultAssets(); | ||
140 | assets.ForEach(action); | ||
141 | } | ||
142 | |||
143 | public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) | ||
144 | { | ||
145 | AssetBase asset = new AssetBase( | ||
146 | new LLUUID(assetIdStr), | ||
147 | name | ||
148 | ); | ||
149 | |||
150 | if (!String.IsNullOrEmpty(filename)) | ||
151 | { | ||
152 | MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); | ||
153 | |||
154 | LoadAsset(asset, isImage, filename); | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); | ||
159 | } | ||
160 | |||
161 | return asset; | ||
162 | } | ||
163 | |||
164 | public void ForEachXmlAsset(Action<AssetBase> action) | ||
165 | { | ||
166 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | ||
167 | if (File.Exists(filePath)) | ||
168 | { | ||
169 | XmlConfigSource source = new XmlConfigSource(filePath); | ||
170 | |||
171 | for (int i = 0; i < source.Configs.Count; i++) | ||
172 | { | ||
173 | string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); | ||
174 | string name = source.Configs[i].GetString("name", ""); | ||
175 | sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); | ||
176 | sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); | ||
177 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
178 | |||
179 | AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); | ||
180 | |||
181 | newAsset.Type = type; | ||
182 | newAsset.InvType = invType; | ||
183 | |||
184 | } | ||
185 | } | ||
186 | } | ||
179 | } | 187 | } |
180 | } \ No newline at end of file | 188 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index cf54b81..379d609 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | |||
@@ -44,11 +44,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
44 | { | 44 | { |
45 | _assetRequests = new BlockingQueue<ARequest>(); | 45 | _assetRequests = new BlockingQueue<ARequest>(); |
46 | AddPlugin(pluginName); | 46 | AddPlugin(pluginName); |
47 | |||
48 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); | ||
49 | this._localAssetServerThread.IsBackground = true; | ||
50 | this._localAssetServerThread.Start(); | ||
51 | |||
52 | } | 47 | } |
53 | 48 | ||
54 | public SQLAssetServer(IAssetProvider assetProvider) | 49 | public SQLAssetServer(IAssetProvider assetProvider) |
@@ -86,12 +81,13 @@ namespace OpenSim.Framework.Communications.Cache | |||
86 | 81 | ||
87 | public override void Close() | 82 | public override void Close() |
88 | { | 83 | { |
84 | base.Close(); | ||
85 | |||
89 | m_assetProviderPlugin.CommitAssets(); | 86 | m_assetProviderPlugin.CommitAssets(); |
90 | } | 87 | } |
91 | 88 | ||
92 | private void RunRequests() | 89 | override protected void RunRequests() |
93 | { | 90 | { |
94 | |||
95 | while (true) | 91 | while (true) |
96 | { | 92 | { |
97 | ARequest req = this._assetRequests.Dequeue(); | 93 | ARequest req = this._assetRequests.Dequeue(); |