Don't allow exceptions to propogate from FlotsamAssetCache which may occur when deleting expired files or stamping the region status file.

Changes various error level log lines to warn since these are not fatal to the operation of OpenSimulator
0.7.4-extended
Justin Clark-Casey (justincc) 2013-02-08 21:21:20 +00:00
parent f6ddd20413
commit 5393ecfa75
1 changed files with 59 additions and 34 deletions

View File

@ -301,7 +301,7 @@ namespace Flotsam.RegionModules.AssetCache
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}",
asset.ID, e.Message, e.StackTrace); asset.ID, e.Message, e.StackTrace);
} }
@ -341,12 +341,13 @@ namespace Flotsam.RegionModules.AssetCache
/// Try to get an asset from the file cache. /// Try to get an asset from the file cache.
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns>An asset retrieved from the file cache. null if there was a problem retrieving an asset.</returns>
private AssetBase GetFromFileCache(string id) private AssetBase GetFromFileCache(string id)
{ {
AssetBase asset = null; AssetBase asset = null;
string filename = GetFileName(id); string filename = GetFileName(id);
if (File.Exists(filename)) if (File.Exists(filename))
{ {
FileStream stream = null; FileStream stream = null;
@ -361,7 +362,7 @@ namespace Flotsam.RegionModules.AssetCache
} }
catch (System.Runtime.Serialization.SerializationException e) catch (System.Runtime.Serialization.SerializationException e)
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}",
filename, id, e.Message, e.StackTrace); filename, id, e.Message, e.StackTrace);
@ -373,7 +374,7 @@ namespace Flotsam.RegionModules.AssetCache
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}",
filename, id, e.Message, e.StackTrace); filename, id, e.Message, e.StackTrace);
} }
@ -471,7 +472,7 @@ namespace Flotsam.RegionModules.AssetCache
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Failed to expire cached file {0}. Exception {1} {2}", "[FLOTSAM ASSET CACHE]: Failed to expire cached file {0}. Exception {1} {2}",
id, e.Message, e.StackTrace); id, e.Message, e.StackTrace);
} }
@ -521,6 +522,8 @@ namespace Flotsam.RegionModules.AssetCache
/// <param name="dir"></param> /// <param name="dir"></param>
/// <param name="purgeLine"></param> /// <param name="purgeLine"></param>
private void CleanExpiredFiles(string dir, DateTime purgeLine) private void CleanExpiredFiles(string dir, DateTime purgeLine)
{
try
{ {
foreach (string file in Directory.GetFiles(dir)) foreach (string file in Directory.GetFiles(dir))
{ {
@ -544,7 +547,15 @@ namespace Flotsam.RegionModules.AssetCache
} }
else if (dirSize >= m_CacheWarnAt) else if (dirSize >= m_CacheWarnAt)
{ {
m_log.WarnFormat("[FLOTSAM ASSET CACHE]: Cache folder exceeded CacheWarnAt limit {0} {1}. Suggest increasing tiers, tier length, or reducing cache expiration", dir, dirSize); m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Cache folder exceeded CacheWarnAt limit {0} {1}. Suggest increasing tiers, tier length, or reducing cache expiration",
dir, dirSize);
}
}
catch (Exception e)
{
m_log.Warn(
string.Format("[FLOTSAM ASSET CACHE]: Could not complete clean of expired files in {0}, exception ", dir), e);
} }
} }
@ -603,7 +614,7 @@ namespace Flotsam.RegionModules.AssetCache
} }
catch (IOException e) catch (IOException e)
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Failed to write asset {0} to temporary location {1} (final {2}) on cache in {3}. Exception {4} {5}.", "[FLOTSAM ASSET CACHE]: Failed to write asset {0} to temporary location {1} (final {2}) on cache in {3}. Exception {4} {5}.",
asset.ID, tempname, filename, directory, e.Message, e.StackTrace); asset.ID, tempname, filename, directory, e.Message, e.StackTrace);
@ -682,17 +693,31 @@ namespace Flotsam.RegionModules.AssetCache
/// <summary> /// <summary>
/// This notes the last time the Region had a deep asset scan performed on it. /// This notes the last time the Region had a deep asset scan performed on it.
/// </summary> /// </summary>
/// <param name="RegionID"></param> /// <param name="regionID"></param>
private void StampRegionStatusFile(UUID RegionID) private void StampRegionStatusFile(UUID regionID)
{
string RegionCacheStatusFile = Path.Combine(m_CacheDirectory, "RegionStatus_" + regionID.ToString() + ".fac");
try
{ {
string RegionCacheStatusFile = Path.Combine(m_CacheDirectory, "RegionStatus_" + RegionID.ToString() + ".fac");
if (File.Exists(RegionCacheStatusFile)) if (File.Exists(RegionCacheStatusFile))
{ {
File.SetLastWriteTime(RegionCacheStatusFile, DateTime.Now); File.SetLastWriteTime(RegionCacheStatusFile, DateTime.Now);
} }
else else
{ {
File.WriteAllText(RegionCacheStatusFile, "Please do not delete this file unless you are manually clearing your Flotsam Asset Cache."); File.WriteAllText(
RegionCacheStatusFile,
"Please do not delete this file unless you are manually clearing your Flotsam Asset Cache.");
}
}
catch (Exception e)
{
m_log.Warn(
string.Format(
"[FLOTSAM ASSET CACHE]: Could not stamp region status file for region {0}. Exception ",
regionID),
e);
} }
} }
@ -761,7 +786,7 @@ namespace Flotsam.RegionModules.AssetCache
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Couldn't clear asset cache directory {0} from {1}. Exception {2} {3}", "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache directory {0} from {1}. Exception {2} {3}",
dir, m_CacheDirectory, e.Message, e.StackTrace); dir, m_CacheDirectory, e.Message, e.StackTrace);
} }
@ -775,7 +800,7 @@ namespace Flotsam.RegionModules.AssetCache
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.WarnFormat(
"[FLOTSAM ASSET CACHE]: Couldn't clear asset cache file {0} from {1}. Exception {1} {2}", "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache file {0} from {1}. Exception {1} {2}",
file, m_CacheDirectory, e.Message, e.StackTrace); file, m_CacheDirectory, e.Message, e.StackTrace);
} }