diff options
author | Oren Hurvitz | 2014-04-24 14:21:05 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-04-24 15:58:43 +0100 |
commit | bc06db3df45d8dd61338c5b1426fd0161731f7cd (patch) | |
tree | 5df8409d6a24215e4c1df125b5176609fc7926ee /OpenSim | |
parent | Changed how UserProfile performs a fallback call using the OpenProfile API, b... (diff) | |
download | opensim-SC_OLD-bc06db3df45d8dd61338c5b1426fd0161731f7cd.zip opensim-SC_OLD-bc06db3df45d8dd61338c5b1426fd0161731f7cd.tar.gz opensim-SC_OLD-bc06db3df45d8dd61338c5b1426fd0161731f7cd.tar.bz2 opensim-SC_OLD-bc06db3df45d8dd61338c5b1426fd0161731f7cd.tar.xz |
- Created a standard function to send XML-RPC requests, which logs them like we do for other types of HTTP activity.
- Changed OpenProfileClient to use the new XML-RPC sending function
- Improved logging in WebUtil
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 212 | ||||
-rw-r--r-- | OpenSim/Services/Interfaces/OpenProfileClient.cs | 69 |
3 files changed, 145 insertions, 138 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 4f71db9..e8aa278 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -705,7 +705,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
705 | } | 705 | } |
706 | } | 706 | } |
707 | 707 | ||
708 | WebUtil.LogResponseDetail(output); | 708 | WebUtil.LogResponseDetail(null, output); |
709 | } | 709 | } |
710 | 710 | ||
711 | if (!response.SendChunked && response.ContentLength64 <= 0) | 711 | if (!response.SendChunked && response.ContentLength64 <= 0) |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 8f5bc0c..d7f6bc8 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -39,7 +39,9 @@ using System.Text; | |||
39 | using System.Web; | 39 | using System.Web; |
40 | using System.Xml; | 40 | using System.Xml; |
41 | using System.Xml.Serialization; | 41 | using System.Xml.Serialization; |
42 | using System.Xml.Linq; | ||
42 | using log4net; | 43 | using log4net; |
44 | using Nwc.XmlRpc; | ||
43 | using OpenMetaverse.StructuredData; | 45 | using OpenMetaverse.StructuredData; |
44 | using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper; | 46 | using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper; |
45 | 47 | ||
@@ -191,9 +193,9 @@ namespace OpenSim.Framework | |||
191 | } | 193 | } |
192 | } | 194 | } |
193 | 195 | ||
194 | public static void LogOutgoingDetail(string output) | 196 | public static void LogOutgoingDetail(string type, int reqnum, string output) |
195 | { | 197 | { |
196 | LogOutgoingDetail("", output); | 198 | LogOutgoingDetail(string.Format("{0} {1}: ", type, reqnum), output); |
197 | } | 199 | } |
198 | 200 | ||
199 | public static void LogOutgoingDetail(string context, string output) | 201 | public static void LogOutgoingDetail(string context, string output) |
@@ -207,14 +209,15 @@ namespace OpenSim.Framework | |||
207 | m_log.DebugFormat("[LOGHTTP]: {0}{1}", context, Util.BinaryToASCII(output)); | 209 | m_log.DebugFormat("[LOGHTTP]: {0}{1}", context, Util.BinaryToASCII(output)); |
208 | } | 210 | } |
209 | 211 | ||
210 | public static void LogResponseDetail(Stream inputStream) | 212 | public static void LogResponseDetail(int reqnum, Stream inputStream) |
211 | { | 213 | { |
212 | LogOutgoingDetail("RESPONSE: ", inputStream); | 214 | LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), inputStream); |
213 | } | 215 | } |
214 | 216 | ||
215 | public static void LogResponseDetail(string input) | 217 | public static void LogResponseDetail(int? reqnum, string input) |
216 | { | 218 | { |
217 | LogOutgoingDetail("RESPONSE: ", input); | 219 | string context = (reqnum == null) ? "" : string.Format("RESPONSE {0}: ", reqnum.Value); |
220 | LogOutgoingDetail(context, input); | ||
218 | } | 221 | } |
219 | 222 | ||
220 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc) | 223 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc) |
@@ -222,9 +225,8 @@ namespace OpenSim.Framework | |||
222 | int reqnum = RequestNumber++; | 225 | int reqnum = RequestNumber++; |
223 | 226 | ||
224 | if (DebugLevel >= 3) | 227 | if (DebugLevel >= 3) |
225 | m_log.DebugFormat( | 228 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} JSON-RPC {1} to {2}", |
226 | "[LOGHTTP]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})", | 229 | reqnum, method, url); |
227 | reqnum, method, url, timeout, compressed); | ||
228 | 230 | ||
229 | string errorMessage = "unknown error"; | 231 | string errorMessage = "unknown error"; |
230 | int tickstart = Util.EnvironmentTickCount(); | 232 | int tickstart = Util.EnvironmentTickCount(); |
@@ -247,7 +249,7 @@ namespace OpenSim.Framework | |||
247 | strBuffer = OSDParser.SerializeJsonString(data); | 249 | strBuffer = OSDParser.SerializeJsonString(data); |
248 | 250 | ||
249 | if (DebugLevel >= 5) | 251 | if (DebugLevel >= 5) |
250 | LogOutgoingDetail(strBuffer); | 252 | LogOutgoingDetail("SEND", reqnum, strBuffer); |
251 | 253 | ||
252 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); | 254 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); |
253 | 255 | ||
@@ -291,9 +293,8 @@ namespace OpenSim.Framework | |||
291 | using (StreamReader reader = new StreamReader(responseStream)) | 293 | using (StreamReader reader = new StreamReader(responseStream)) |
292 | { | 294 | { |
293 | string responseStr = reader.ReadToEnd(); | 295 | string responseStr = reader.ReadToEnd(); |
294 | // m_log.DebugFormat("[LOGHTTP]: <{0}> response is <{1}>",reqnum,responseStr); | ||
295 | if (WebUtil.DebugLevel >= 5) | 296 | if (WebUtil.DebugLevel >= 5) |
296 | WebUtil.LogResponseDetail(responseStr); | 297 | WebUtil.LogResponseDetail(reqnum, responseStr); |
297 | return CanonicalizeResults(responseStr); | 298 | return CanonicalizeResults(responseStr); |
298 | } | 299 | } |
299 | } | 300 | } |
@@ -316,24 +317,23 @@ namespace OpenSim.Framework | |||
316 | { | 317 | { |
317 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 318 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
318 | if (tickdiff > LongCallTime) | 319 | if (tickdiff > LongCallTime) |
320 | { | ||
319 | m_log.InfoFormat( | 321 | m_log.InfoFormat( |
320 | "[LOGHTTP]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing, {5}", | 322 | "[LOGHTTP]: Slow JSON-RPC request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", |
321 | reqnum, | 323 | reqnum, method, url, tickdiff, tickdata, |
322 | method, | ||
323 | url, | ||
324 | tickdiff, | ||
325 | tickdata, | ||
326 | strBuffer != null | 324 | strBuffer != null |
327 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) | 325 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) |
328 | : ""); | 326 | : ""); |
327 | } | ||
329 | else if (DebugLevel >= 4) | 328 | else if (DebugLevel >= 4) |
330 | m_log.DebugFormat( | 329 | { |
331 | "[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", | 330 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", |
332 | reqnum, tickdiff, tickdata); | 331 | reqnum, tickdiff, tickdata); |
332 | } | ||
333 | } | 333 | } |
334 | 334 | ||
335 | m_log.DebugFormat( | 335 | m_log.DebugFormat( |
336 | "[LOGHTTP]: ServiceOSD request {0} {1} {2} FAILED: {3}", reqnum, url, method, errorMessage); | 336 | "[LOGHTTP]: JSON-RPC request {0} {1} to {2} FAILED: {3}", reqnum, method, url, errorMessage); |
337 | 337 | ||
338 | return ErrorResponseMap(errorMessage); | 338 | return ErrorResponseMap(errorMessage); |
339 | } | 339 | } |
@@ -411,9 +411,8 @@ namespace OpenSim.Framework | |||
411 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; | 411 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; |
412 | 412 | ||
413 | if (DebugLevel >= 3) | 413 | if (DebugLevel >= 3) |
414 | m_log.DebugFormat( | 414 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} ServiceForm '{1}' to {2}", |
415 | "[LOGHTTP]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})", | 415 | reqnum, method, url); |
416 | reqnum, method, url, timeout); | ||
417 | 416 | ||
418 | string errorMessage = "unknown error"; | 417 | string errorMessage = "unknown error"; |
419 | int tickstart = Util.EnvironmentTickCount(); | 418 | int tickstart = Util.EnvironmentTickCount(); |
@@ -435,7 +434,7 @@ namespace OpenSim.Framework | |||
435 | queryString = BuildQueryString(data); | 434 | queryString = BuildQueryString(data); |
436 | 435 | ||
437 | if (DebugLevel >= 5) | 436 | if (DebugLevel >= 5) |
438 | LogOutgoingDetail(queryString); | 437 | LogOutgoingDetail("SEND", reqnum, queryString); |
439 | 438 | ||
440 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); | 439 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); |
441 | 440 | ||
@@ -457,7 +456,7 @@ namespace OpenSim.Framework | |||
457 | { | 456 | { |
458 | string responseStr = reader.ReadToEnd(); | 457 | string responseStr = reader.ReadToEnd(); |
459 | if (WebUtil.DebugLevel >= 5) | 458 | if (WebUtil.DebugLevel >= 5) |
460 | WebUtil.LogResponseDetail(responseStr); | 459 | WebUtil.LogResponseDetail(reqnum, responseStr); |
461 | OSD responseOSD = OSDParser.Deserialize(responseStr); | 460 | OSD responseOSD = OSDParser.Deserialize(responseStr); |
462 | 461 | ||
463 | if (responseOSD.Type == OSDType.Map) | 462 | if (responseOSD.Type == OSDType.Map) |
@@ -483,23 +482,22 @@ namespace OpenSim.Framework | |||
483 | { | 482 | { |
484 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 483 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
485 | if (tickdiff > LongCallTime) | 484 | if (tickdiff > LongCallTime) |
485 | { | ||
486 | m_log.InfoFormat( | 486 | m_log.InfoFormat( |
487 | "[LOGHTTP]: Slow ServiceForm request {0} {1} {2} took {3}ms, {4}ms writing, {5}", | 487 | "[LOGHTTP]: Slow ServiceForm request {0} '{1}' to {2} took {3}ms, {4}ms writing, {5}", |
488 | reqnum, | 488 | reqnum, method, url, tickdiff, tickdata, |
489 | method, | ||
490 | url, | ||
491 | tickdiff, | ||
492 | tickdata, | ||
493 | queryString != null | 489 | queryString != null |
494 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString | 490 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString |
495 | : ""); | 491 | : ""); |
492 | } | ||
496 | else if (DebugLevel >= 4) | 493 | else if (DebugLevel >= 4) |
497 | m_log.DebugFormat( | 494 | { |
498 | "[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", | 495 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", |
499 | reqnum, tickdiff, tickdata); | 496 | reqnum, tickdiff, tickdata); |
497 | } | ||
500 | } | 498 | } |
501 | 499 | ||
502 | m_log.WarnFormat("[LOGHTTP]: ServiceForm request {0} {1} {2} failed: {2}", reqnum, method, url, errorMessage); | 500 | m_log.WarnFormat("[LOGHTTP]: ServiceForm request {0} '{1}' to {2} failed: {3}", reqnum, method, url, errorMessage); |
503 | 501 | ||
504 | return ErrorResponseMap(errorMessage); | 502 | return ErrorResponseMap(errorMessage); |
505 | } | 503 | } |
@@ -779,8 +777,7 @@ namespace OpenSim.Framework | |||
779 | int reqnum = WebUtil.RequestNumber++; | 777 | int reqnum = WebUtil.RequestNumber++; |
780 | 778 | ||
781 | if (WebUtil.DebugLevel >= 3) | 779 | if (WebUtil.DebugLevel >= 3) |
782 | m_log.DebugFormat( | 780 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} AsynchronousRequestObject {1} to {2}", |
783 | "[LOGHTTP]: HTTP OUT {0} AsynchronousRequestObject {1} {2}", | ||
784 | reqnum, verb, requestUrl); | 781 | reqnum, verb, requestUrl); |
785 | 782 | ||
786 | int tickstart = Util.EnvironmentTickCount(); | 783 | int tickstart = Util.EnvironmentTickCount(); |
@@ -822,7 +819,7 @@ namespace OpenSim.Framework | |||
822 | byte[] data = buffer.ToArray(); | 819 | byte[] data = buffer.ToArray(); |
823 | 820 | ||
824 | if (WebUtil.DebugLevel >= 5) | 821 | if (WebUtil.DebugLevel >= 5) |
825 | WebUtil.LogOutgoingDetail(System.Text.Encoding.UTF8.GetString(data)); | 822 | WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); |
826 | 823 | ||
827 | request.BeginGetRequestStream(delegate(IAsyncResult res) | 824 | request.BeginGetRequestStream(delegate(IAsyncResult res) |
828 | { | 825 | { |
@@ -840,7 +837,8 @@ namespace OpenSim.Framework | |||
840 | { | 837 | { |
841 | using (Stream respStream = response.GetResponseStream()) | 838 | using (Stream respStream = response.GetResponseStream()) |
842 | { | 839 | { |
843 | deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, response.ContentLength); | 840 | deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>( |
841 | reqnum, respStream, response.ContentLength); | ||
844 | } | 842 | } |
845 | } | 843 | } |
846 | catch (System.InvalidOperationException) | 844 | catch (System.InvalidOperationException) |
@@ -867,7 +865,8 @@ namespace OpenSim.Framework | |||
867 | { | 865 | { |
868 | using (Stream respStream = response.GetResponseStream()) | 866 | using (Stream respStream = response.GetResponseStream()) |
869 | { | 867 | { |
870 | deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, response.ContentLength); | 868 | deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>( |
869 | reqnum, respStream, response.ContentLength); | ||
871 | } | 870 | } |
872 | } | 871 | } |
873 | catch (System.InvalidOperationException) | 872 | catch (System.InvalidOperationException) |
@@ -938,18 +937,13 @@ namespace OpenSim.Framework | |||
938 | } | 937 | } |
939 | 938 | ||
940 | m_log.InfoFormat( | 939 | m_log.InfoFormat( |
941 | "[LOGHTTP]: [ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", | 940 | "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", |
942 | reqnum, | 941 | reqnum, verb, requestUrl, tickdiff, tickdata, |
943 | verb, | ||
944 | requestUrl, | ||
945 | tickdiff, | ||
946 | tickdata, | ||
947 | originalRequest); | 942 | originalRequest); |
948 | } | 943 | } |
949 | else if (WebUtil.DebugLevel >= 4) | 944 | else if (WebUtil.DebugLevel >= 4) |
950 | { | 945 | { |
951 | m_log.DebugFormat( | 946 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", |
952 | "[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
953 | reqnum, tickdiff, tickdata); | 947 | reqnum, tickdiff, tickdata); |
954 | } | 948 | } |
955 | } | 949 | } |
@@ -981,8 +975,7 @@ namespace OpenSim.Framework | |||
981 | int reqnum = WebUtil.RequestNumber++; | 975 | int reqnum = WebUtil.RequestNumber++; |
982 | 976 | ||
983 | if (WebUtil.DebugLevel >= 3) | 977 | if (WebUtil.DebugLevel >= 3) |
984 | m_log.DebugFormat( | 978 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SynchronousRestForms {1} to {2}", |
985 | "[LOGHTTP]: HTTP OUT {0} SynchronousRestForms {1} {2}", | ||
986 | reqnum, verb, requestUrl); | 979 | reqnum, verb, requestUrl); |
987 | 980 | ||
988 | int tickstart = Util.EnvironmentTickCount(); | 981 | int tickstart = Util.EnvironmentTickCount(); |
@@ -1012,7 +1005,7 @@ namespace OpenSim.Framework | |||
1012 | byte[] data = buffer.ToArray(); | 1005 | byte[] data = buffer.ToArray(); |
1013 | 1006 | ||
1014 | if (WebUtil.DebugLevel >= 5) | 1007 | if (WebUtil.DebugLevel >= 5) |
1015 | WebUtil.LogOutgoingDetail(System.Text.Encoding.UTF8.GetString(data)); | 1008 | WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); |
1016 | 1009 | ||
1017 | Stream requestStream = null; | 1010 | Stream requestStream = null; |
1018 | try | 1011 | try |
@@ -1058,21 +1051,20 @@ namespace OpenSim.Framework | |||
1058 | 1051 | ||
1059 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 1052 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
1060 | if (tickdiff > WebUtil.LongCallTime) | 1053 | if (tickdiff > WebUtil.LongCallTime) |
1054 | { | ||
1061 | m_log.InfoFormat( | 1055 | m_log.InfoFormat( |
1062 | "[LOGHTTP]: [FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", | 1056 | "[LOGHTTP]: Slow SynchronousRestForms request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", |
1063 | reqnum, | 1057 | reqnum, verb, requestUrl, tickdiff, tickdata, |
1064 | verb, | ||
1065 | requestUrl, | ||
1066 | tickdiff, | ||
1067 | tickdata, | ||
1068 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); | 1058 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); |
1059 | } | ||
1069 | else if (WebUtil.DebugLevel >= 4) | 1060 | else if (WebUtil.DebugLevel >= 4) |
1070 | m_log.DebugFormat( | 1061 | { |
1071 | "[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", | 1062 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", |
1072 | reqnum, tickdiff, tickdata); | 1063 | reqnum, tickdiff, tickdata); |
1064 | } | ||
1073 | 1065 | ||
1074 | if (WebUtil.DebugLevel >= 5) | 1066 | if (WebUtil.DebugLevel >= 5) |
1075 | WebUtil.LogResponseDetail(respstring); | 1067 | WebUtil.LogResponseDetail(reqnum, respstring); |
1076 | 1068 | ||
1077 | return respstring; | 1069 | return respstring; |
1078 | } | 1070 | } |
@@ -1114,8 +1106,7 @@ namespace OpenSim.Framework | |||
1114 | int reqnum = WebUtil.RequestNumber++; | 1106 | int reqnum = WebUtil.RequestNumber++; |
1115 | 1107 | ||
1116 | if (WebUtil.DebugLevel >= 3) | 1108 | if (WebUtil.DebugLevel >= 3) |
1117 | m_log.DebugFormat( | 1109 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SynchronousRestObject {1} to {2}", |
1118 | "[LOGHTTP]: HTTP OUT {0} SynchronousRestObject {1} {2}", | ||
1119 | reqnum, verb, requestUrl); | 1110 | reqnum, verb, requestUrl); |
1120 | 1111 | ||
1121 | int tickstart = Util.EnvironmentTickCount(); | 1112 | int tickstart = Util.EnvironmentTickCount(); |
@@ -1155,7 +1146,7 @@ namespace OpenSim.Framework | |||
1155 | byte[] data = buffer.ToArray(); | 1146 | byte[] data = buffer.ToArray(); |
1156 | 1147 | ||
1157 | if (WebUtil.DebugLevel >= 5) | 1148 | if (WebUtil.DebugLevel >= 5) |
1158 | WebUtil.LogOutgoingDetail(System.Text.Encoding.UTF8.GetString(data)); | 1149 | WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); |
1159 | 1150 | ||
1160 | try | 1151 | try |
1161 | { | 1152 | { |
@@ -1185,7 +1176,8 @@ namespace OpenSim.Framework | |||
1185 | { | 1176 | { |
1186 | using (Stream respStream = resp.GetResponseStream()) | 1177 | using (Stream respStream = resp.GetResponseStream()) |
1187 | { | 1178 | { |
1188 | deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, resp.ContentLength); | 1179 | deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>( |
1180 | reqnum, respStream, resp.ContentLength); | ||
1189 | } | 1181 | } |
1190 | } | 1182 | } |
1191 | else | 1183 | else |
@@ -1236,18 +1228,13 @@ namespace OpenSim.Framework | |||
1236 | } | 1228 | } |
1237 | 1229 | ||
1238 | m_log.InfoFormat( | 1230 | m_log.InfoFormat( |
1239 | "[LOGHTTP]: [SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", | 1231 | "[LOGHTTP]: Slow SynchronousRestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", |
1240 | reqnum, | 1232 | reqnum, verb, requestUrl, tickdiff, tickdata, |
1241 | verb, | ||
1242 | requestUrl, | ||
1243 | tickdiff, | ||
1244 | tickdata, | ||
1245 | originalRequest); | 1233 | originalRequest); |
1246 | } | 1234 | } |
1247 | else if (WebUtil.DebugLevel >= 4) | 1235 | else if (WebUtil.DebugLevel >= 4) |
1248 | { | 1236 | { |
1249 | m_log.DebugFormat( | 1237 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", |
1250 | "[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1251 | reqnum, tickdiff, tickdata); | 1238 | reqnum, tickdiff, tickdata); |
1252 | } | 1239 | } |
1253 | } | 1240 | } |
@@ -1263,7 +1250,7 @@ namespace OpenSim.Framework | |||
1263 | 1250 | ||
1264 | public static class XMLResponseHelper | 1251 | public static class XMLResponseHelper |
1265 | { | 1252 | { |
1266 | public static TResponse LogAndDeserialize<TRequest, TResponse>(Stream respStream, long contentLength) | 1253 | public static TResponse LogAndDeserialize<TRequest, TResponse>(int reqnum, Stream respStream, long contentLength) |
1267 | { | 1254 | { |
1268 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | 1255 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); |
1269 | 1256 | ||
@@ -1272,7 +1259,7 @@ namespace OpenSim.Framework | |||
1272 | byte[] data = new byte[contentLength]; | 1259 | byte[] data = new byte[contentLength]; |
1273 | Util.ReadStream(respStream, data); | 1260 | Util.ReadStream(respStream, data); |
1274 | 1261 | ||
1275 | WebUtil.LogResponseDetail(System.Text.Encoding.UTF8.GetString(data)); | 1262 | WebUtil.LogResponseDetail(reqnum, System.Text.Encoding.UTF8.GetString(data)); |
1276 | 1263 | ||
1277 | using (MemoryStream temp = new MemoryStream(data)) | 1264 | using (MemoryStream temp = new MemoryStream(data)) |
1278 | return (TResponse)deserializer.Deserialize(temp); | 1265 | return (TResponse)deserializer.Deserialize(temp); |
@@ -1284,4 +1271,81 @@ namespace OpenSim.Framework | |||
1284 | } | 1271 | } |
1285 | } | 1272 | } |
1286 | } | 1273 | } |
1274 | |||
1275 | |||
1276 | public static class XMLRPCRequester | ||
1277 | { | ||
1278 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
1279 | |||
1280 | public static Hashtable SendRequest(Hashtable ReqParams, string method, string url) | ||
1281 | { | ||
1282 | int reqnum = WebUtil.RequestNumber++; | ||
1283 | |||
1284 | if (WebUtil.DebugLevel >= 3) | ||
1285 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} XML-RPC '{1}' to {2}", | ||
1286 | reqnum, method, url); | ||
1287 | |||
1288 | int tickstart = Util.EnvironmentTickCount(); | ||
1289 | string responseStr = null; | ||
1290 | |||
1291 | try | ||
1292 | { | ||
1293 | ArrayList SendParams = new ArrayList(); | ||
1294 | SendParams.Add(ReqParams); | ||
1295 | |||
1296 | XmlRpcRequest Req = new XmlRpcRequest(method, SendParams); | ||
1297 | |||
1298 | if (WebUtil.DebugLevel >= 5) | ||
1299 | { | ||
1300 | string str = Req.ToString(); | ||
1301 | str = XElement.Parse(str).ToString(SaveOptions.DisableFormatting); | ||
1302 | WebUtil.LogOutgoingDetail("SEND", reqnum, str); | ||
1303 | } | ||
1304 | |||
1305 | XmlRpcResponse Resp = Req.Send(url, 30000); | ||
1306 | |||
1307 | try | ||
1308 | { | ||
1309 | responseStr = Resp.ToString(); | ||
1310 | responseStr = XElement.Parse(responseStr).ToString(SaveOptions.DisableFormatting); | ||
1311 | |||
1312 | if (WebUtil.DebugLevel >= 5) | ||
1313 | WebUtil.LogResponseDetail(reqnum, responseStr); | ||
1314 | } | ||
1315 | catch (Exception e) | ||
1316 | { | ||
1317 | m_log.Error("Error parsing XML-RPC response", e); | ||
1318 | } | ||
1319 | |||
1320 | if (Resp.IsFault) | ||
1321 | { | ||
1322 | m_log.DebugFormat( | ||
1323 | "[LOGHTTP]: XML-RPC request {0} '{1}' to {2} FAILED: FaultCode={3}, FaultMessage={4}", | ||
1324 | reqnum, method, url, Resp.FaultCode, Resp.FaultString); | ||
1325 | return null; | ||
1326 | } | ||
1327 | |||
1328 | Hashtable RespData = (Hashtable)Resp.Value; | ||
1329 | return RespData; | ||
1330 | } | ||
1331 | finally | ||
1332 | { | ||
1333 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | ||
1334 | if (tickdiff > WebUtil.LongCallTime) | ||
1335 | { | ||
1336 | m_log.InfoFormat( | ||
1337 | "[LOGHTTP]: Slow XML-RPC request {0} '{1}' to {2} took {3}ms, {4}", | ||
1338 | reqnum, method, url, tickdiff, | ||
1339 | responseStr != null | ||
1340 | ? (responseStr.Length > WebUtil.MaxRequestDiagLength ? responseStr.Remove(WebUtil.MaxRequestDiagLength) : responseStr) | ||
1341 | : ""); | ||
1342 | } | ||
1343 | else if (WebUtil.DebugLevel >= 4) | ||
1344 | { | ||
1345 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", reqnum, tickdiff); | ||
1346 | } | ||
1347 | } | ||
1348 | } | ||
1349 | |||
1350 | } | ||
1287 | } | 1351 | } |
diff --git a/OpenSim/Services/Interfaces/OpenProfileClient.cs b/OpenSim/Services/Interfaces/OpenProfileClient.cs index 099b0c3..4126c35 100644 --- a/OpenSim/Services/Interfaces/OpenProfileClient.cs +++ b/OpenSim/Services/Interfaces/OpenProfileClient.cs | |||
@@ -35,7 +35,6 @@ using System.Reflection; | |||
35 | using System.Text; | 35 | using System.Text; |
36 | using System.Xml; | 36 | using System.Xml; |
37 | using log4net; | 37 | using log4net; |
38 | using Nwc.XmlRpc; | ||
39 | using OpenMetaverse; | 38 | using OpenMetaverse; |
40 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
41 | 40 | ||
@@ -79,7 +78,12 @@ namespace OpenSim.Services.UserProfilesService | |||
79 | Hashtable ReqHash = new Hashtable(); | 78 | Hashtable ReqHash = new Hashtable(); |
80 | ReqHash["avatar_id"] = props.UserId.ToString(); | 79 | ReqHash["avatar_id"] = props.UserId.ToString(); |
81 | 80 | ||
82 | Hashtable profileData = GenericXMLRPCRequest(ReqHash, "avatar_properties_request", m_serverURI); | 81 | Hashtable profileData = XMLRPCRequester.SendRequest(ReqHash, "avatar_properties_request", m_serverURI); |
82 | |||
83 | if (profileData == null) | ||
84 | return false; | ||
85 | if (!profileData.ContainsKey("data")) | ||
86 | return false; | ||
83 | 87 | ||
84 | ArrayList dataArray = (ArrayList)profileData["data"]; | 88 | ArrayList dataArray = (ArrayList)profileData["data"]; |
85 | 89 | ||
@@ -128,66 +132,5 @@ namespace OpenSim.Services.UserProfilesService | |||
128 | 132 | ||
129 | return true; | 133 | return true; |
130 | } | 134 | } |
131 | |||
132 | private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method, string server) | ||
133 | { | ||
134 | ArrayList SendParams = new ArrayList(); | ||
135 | SendParams.Add(ReqParams); | ||
136 | |||
137 | XmlRpcResponse Resp; | ||
138 | try | ||
139 | { | ||
140 | XmlRpcRequest Req = new XmlRpcRequest(method, SendParams); | ||
141 | Resp = Req.Send(server, 30000); | ||
142 | } | ||
143 | catch (WebException ex) | ||
144 | { | ||
145 | m_log.ErrorFormat("[PROFILE]: Unable to connect to Profile " + | ||
146 | "Server {0}. Exception {1}", server, ex); | ||
147 | |||
148 | Hashtable ErrorHash = new Hashtable(); | ||
149 | ErrorHash["success"] = false; | ||
150 | ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; | ||
151 | ErrorHash["errorURI"] = ""; | ||
152 | |||
153 | return ErrorHash; | ||
154 | } | ||
155 | catch (SocketException ex) | ||
156 | { | ||
157 | m_log.ErrorFormat( | ||
158 | "[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " + | ||
159 | "Exception {3}", server, method, ReqParams, ex); | ||
160 | |||
161 | Hashtable ErrorHash = new Hashtable(); | ||
162 | ErrorHash["success"] = false; | ||
163 | ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; | ||
164 | ErrorHash["errorURI"] = ""; | ||
165 | |||
166 | return ErrorHash; | ||
167 | } | ||
168 | catch (XmlException ex) | ||
169 | { | ||
170 | m_log.ErrorFormat( | ||
171 | "[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " + | ||
172 | "Exception {3}", server, method, ReqParams.ToString(), ex); | ||
173 | Hashtable ErrorHash = new Hashtable(); | ||
174 | ErrorHash["success"] = false; | ||
175 | ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; | ||
176 | ErrorHash["errorURI"] = ""; | ||
177 | |||
178 | return ErrorHash; | ||
179 | } | ||
180 | if (Resp.IsFault) | ||
181 | { | ||
182 | Hashtable ErrorHash = new Hashtable(); | ||
183 | ErrorHash["success"] = false; | ||
184 | ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; | ||
185 | ErrorHash["errorURI"] = ""; | ||
186 | return ErrorHash; | ||
187 | } | ||
188 | Hashtable RespData = (Hashtable)Resp.Value; | ||
189 | |||
190 | return RespData; | ||
191 | } | ||
192 | } | 135 | } |
193 | } | 136 | } |