diff options
Diffstat (limited to 'OpenSim/Grid/AssetServer')
-rw-r--r-- | OpenSim/Grid/AssetServer/Main.cs | 46 | ||||
-rw-r--r-- | OpenSim/Grid/AssetServer/RestService.cs | 23 |
2 files changed, 33 insertions, 36 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index a95ea71..35e6495 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs | |||
@@ -43,6 +43,8 @@ namespace OpenSim.Grid.AssetServer | |||
43 | /// </summary> | 43 | /// </summary> |
44 | public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback | 44 | public class OpenAsset_Main : BaseOpenSimServer, conscmd_callback |
45 | { | 45 | { |
46 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
46 | public AssetConfig m_config; | 48 | public AssetConfig m_config; |
47 | 49 | ||
48 | public static OpenAsset_Main assetserver; | 50 | public static OpenAsset_Main assetserver; |
@@ -55,7 +57,9 @@ namespace OpenSim.Grid.AssetServer | |||
55 | [STAThread] | 57 | [STAThread] |
56 | public static void Main(string[] args) | 58 | public static void Main(string[] args) |
57 | { | 59 | { |
58 | Console.WriteLine("Starting...\n"); | 60 | log4net.Config.XmlConfigurator.Configure(); |
61 | |||
62 | m_log.Info("Starting...\n"); | ||
59 | 63 | ||
60 | assetserver = new OpenAsset_Main(); | 64 | assetserver = new OpenAsset_Main(); |
61 | assetserver.Startup(); | 65 | assetserver.Startup(); |
@@ -65,42 +69,32 @@ namespace OpenSim.Grid.AssetServer | |||
65 | 69 | ||
66 | private void Work() | 70 | private void Work() |
67 | { | 71 | { |
68 | m_log.Notice("Enter help for a list of commands"); | 72 | m_console.Notice("Enter help for a list of commands"); |
69 | 73 | ||
70 | while (true) | 74 | while (true) |
71 | { | 75 | { |
72 | m_log.MainLogPrompt(); | 76 | m_console.Prompt(); |
73 | } | 77 | } |
74 | } | 78 | } |
75 | 79 | ||
76 | private OpenAsset_Main() | 80 | private OpenAsset_Main() |
77 | { | 81 | { |
78 | if (!Directory.Exists(Util.logDir())) | 82 | m_console = new ConsoleBase("OpenAsset", this); |
79 | { | ||
80 | Directory.CreateDirectory(Util.logDir()); | ||
81 | } | ||
82 | |||
83 | m_log = | ||
84 | new LogBase( | ||
85 | (Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), | ||
86 | "OpenAsset", | ||
87 | this, | ||
88 | true); | ||
89 | 83 | ||
90 | MainLog.Instance = m_log; | 84 | MainConsole.Instance = m_console; |
91 | } | 85 | } |
92 | 86 | ||
93 | public void Startup() | 87 | public void Startup() |
94 | { | 88 | { |
95 | m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); | 89 | m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); |
96 | 90 | ||
97 | m_log.Verbose("ASSET", "Setting up asset DB"); | 91 | m_log.Info("[ASSET]: Setting up asset DB"); |
98 | setupDB(m_config); | 92 | setupDB(m_config); |
99 | 93 | ||
100 | m_log.Verbose("ASSET", "Loading default asset set.."); | 94 | m_log.Info("[ASSET]: Loading default asset set.."); |
101 | LoadDefaultAssets(); | 95 | LoadDefaultAssets(); |
102 | 96 | ||
103 | m_log.Verbose("ASSET", "Starting HTTP process"); | 97 | m_log.Info("[ASSET]: Starting HTTP process"); |
104 | BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); | 98 | BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); |
105 | 99 | ||
106 | StatsManager.StartCollectingAssetStats(); | 100 | StatsManager.StartCollectingAssetStats(); |
@@ -118,7 +112,7 @@ namespace OpenSim.Grid.AssetServer | |||
118 | 112 | ||
119 | public IAssetProvider LoadDatabasePlugin(string FileName) | 113 | public IAssetProvider LoadDatabasePlugin(string FileName) |
120 | { | 114 | { |
121 | MainLog.Instance.Verbose("ASSET SERVER", "LoadDatabasePlugin: Attempting to load " + FileName); | 115 | m_log.Info("[ASSET SERVER]: LoadDatabasePlugin: Attempting to load " + FileName); |
122 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 116 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); |
123 | IAssetProvider assetPlugin = null; | 117 | IAssetProvider assetPlugin = null; |
124 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 118 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
@@ -134,7 +128,7 @@ namespace OpenSim.Grid.AssetServer | |||
134 | assetPlugin = plug; | 128 | assetPlugin = plug; |
135 | assetPlugin.Initialise(); | 129 | assetPlugin.Initialise(); |
136 | 130 | ||
137 | MainLog.Instance.Verbose("ASSET SERVER", "Added " + assetPlugin.Name + " " + assetPlugin.Version); | 131 | m_log.Info("[ASSET SERVER]: Added " + assetPlugin.Name + " " + assetPlugin.Version); |
138 | break; | 132 | break; |
139 | } | 133 | } |
140 | 134 | ||
@@ -153,14 +147,14 @@ namespace OpenSim.Grid.AssetServer | |||
153 | m_assetProvider = LoadDatabasePlugin(config.DatabaseProvider); | 147 | m_assetProvider = LoadDatabasePlugin(config.DatabaseProvider); |
154 | if (m_assetProvider == null) | 148 | if (m_assetProvider == null) |
155 | { | 149 | { |
156 | MainLog.Instance.Error("ASSET", "Failed to load a database plugin, server halting"); | 150 | m_log.Error("[ASSET]: Failed to load a database plugin, server halting"); |
157 | Environment.Exit(-1); | 151 | Environment.Exit(-1); |
158 | } | 152 | } |
159 | } | 153 | } |
160 | catch (Exception e) | 154 | catch (Exception e) |
161 | { | 155 | { |
162 | MainLog.Instance.Warn("ASSET", "setupDB() - Exception occured"); | 156 | m_log.Warn("[ASSET]: setupDB() - Exception occured"); |
163 | MainLog.Instance.Warn("ASSET", e.ToString()); | 157 | m_log.Warn("[ASSET]: " + e.ToString()); |
164 | } | 158 | } |
165 | } | 159 | } |
166 | 160 | ||
@@ -181,18 +175,18 @@ namespace OpenSim.Grid.AssetServer | |||
181 | switch (cmd) | 175 | switch (cmd) |
182 | { | 176 | { |
183 | case "help": | 177 | case "help": |
184 | m_log.Notice( | 178 | m_console.Notice( |
185 | @"shutdown - shutdown this asset server (USE CAUTION!) | 179 | @"shutdown - shutdown this asset server (USE CAUTION!) |
186 | stats - statistical information for this server"); | 180 | stats - statistical information for this server"); |
187 | 181 | ||
188 | break; | 182 | break; |
189 | 183 | ||
190 | case "stats": | 184 | case "stats": |
191 | m_log.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); | 185 | m_console.Notice("STATS", Environment.NewLine + StatsManager.AssetStats.Report()); |
192 | break; | 186 | break; |
193 | 187 | ||
194 | case "shutdown": | 188 | case "shutdown": |
195 | m_log.Close(); | 189 | m_console.Close(); |
196 | Environment.Exit(0); | 190 | Environment.Exit(0); |
197 | break; | 191 | break; |
198 | } | 192 | } |
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs index 5c497b6..cb9e1ae 100644 --- a/OpenSim/Grid/AssetServer/RestService.cs +++ b/OpenSim/Grid/AssetServer/RestService.cs | |||
@@ -41,6 +41,8 @@ namespace OpenSim.Grid.AssetServer | |||
41 | { | 41 | { |
42 | public class GetAssetStreamHandler : BaseStreamHandler | 42 | public class GetAssetStreamHandler : BaseStreamHandler |
43 | { | 43 | { |
44 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
44 | private OpenAsset_Main m_assetManager; | 46 | private OpenAsset_Main m_assetManager; |
45 | private IAssetProvider m_assetProvider; | 47 | private IAssetProvider m_assetProvider; |
46 | 48 | ||
@@ -52,7 +54,7 @@ namespace OpenSim.Grid.AssetServer | |||
52 | public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) | 54 | public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) |
53 | : base("GET", "/assets") | 55 | : base("GET", "/assets") |
54 | { | 56 | { |
55 | MainLog.Instance.Verbose("REST", "In Get Request"); | 57 | m_log.Info("[REST]: In Get Request"); |
56 | m_assetManager = assetManager; | 58 | m_assetManager = assetManager; |
57 | m_assetProvider = assetProvider; | 59 | m_assetProvider = assetProvider; |
58 | } | 60 | } |
@@ -71,8 +73,8 @@ namespace OpenSim.Grid.AssetServer | |||
71 | 73 | ||
72 | if (!LLUUID.TryParse(p[0], out assetID)) | 74 | if (!LLUUID.TryParse(p[0], out assetID)) |
73 | { | 75 | { |
74 | MainLog.Instance.Verbose( | 76 | m_log.Info(String.Format( |
75 | "REST", "GET:/asset ignoring request with malformed UUID {0}", p[0]); | 77 | "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0])); |
76 | return result; | 78 | return result; |
77 | } | 79 | } |
78 | 80 | ||
@@ -94,10 +96,9 @@ namespace OpenSim.Grid.AssetServer | |||
94 | 96 | ||
95 | result = ms.GetBuffer(); | 97 | result = ms.GetBuffer(); |
96 | 98 | ||
97 | MainLog.Instance.Verbose( | 99 | m_log.Info(String.Format( |
98 | "REST", | 100 | "[REST]: GET:/asset found {0} with name {1}, size {2} bytes", |
99 | "GET:/asset found {0} with name {1}, size {2} bytes", | 101 | assetID, asset.Name, result.Length)); |
100 | assetID, asset.Name, result.Length); | ||
101 | 102 | ||
102 | Array.Resize<byte>(ref result, (int) ms.Length); | 103 | Array.Resize<byte>(ref result, (int) ms.Length); |
103 | } | 104 | } |
@@ -106,13 +107,13 @@ namespace OpenSim.Grid.AssetServer | |||
106 | if (StatsManager.AssetStats != null) | 107 | if (StatsManager.AssetStats != null) |
107 | StatsManager.AssetStats.AddNotFoundRequest(); | 108 | StatsManager.AssetStats.AddNotFoundRequest(); |
108 | 109 | ||
109 | MainLog.Instance.Verbose("REST", "GET:/asset failed to find {0}", assetID); | 110 | m_log.Info(String.Format("[REST]: GET:/asset failed to find {0}", assetID)); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | } | 113 | } |
113 | catch (Exception e) | 114 | catch (Exception e) |
114 | { | 115 | { |
115 | MainLog.Instance.Error(e.ToString()); | 116 | m_log.Error(e.ToString()); |
116 | } | 117 | } |
117 | return result; | 118 | return result; |
118 | } | 119 | } |
@@ -120,6 +121,8 @@ namespace OpenSim.Grid.AssetServer | |||
120 | 121 | ||
121 | public class PostAssetStreamHandler : BaseStreamHandler | 122 | public class PostAssetStreamHandler : BaseStreamHandler |
122 | { | 123 | { |
124 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
125 | |||
123 | private OpenAsset_Main m_assetManager; | 126 | private OpenAsset_Main m_assetManager; |
124 | private IAssetProvider m_assetProvider; | 127 | private IAssetProvider m_assetProvider; |
125 | 128 | ||
@@ -135,7 +138,7 @@ namespace OpenSim.Grid.AssetServer | |||
135 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); | 138 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); |
136 | AssetBase asset = (AssetBase) xs.Deserialize(request); | 139 | AssetBase asset = (AssetBase) xs.Deserialize(request); |
137 | 140 | ||
138 | MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID); | 141 | m_log.Info(String.Format("[REST]: StoreAndCommitAsset {0}", asset.FullID)); |
139 | m_assetProvider.CreateAsset(asset); | 142 | m_assetProvider.CreateAsset(asset); |
140 | m_assetProvider.CommitAssets(); | 143 | m_assetProvider.CommitAssets(); |
141 | 144 | ||