Skip to content

Commit

Permalink
Using a dedicate document, instead of WarningMessages, which is no lo…
Browse files Browse the repository at this point in the history
…nger used
  • Loading branch information
ayende committed Nov 27, 2011
1 parent 2c5954b commit ba7b0d5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Bundles/Raven.Bundles.Quotas/Size/SizeQuotaConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Raven.Database.Commercial;
using Raven.Database.Plugins;
using Raven.Abstractions.Extensions;
using Raven.Json.Linq;

namespace Raven.Bundles.Quotas
{
Expand All @@ -15,8 +16,6 @@ public class SizeQuotaConfiguration
private VetoResult skipCheck = VetoResult.Allowed;
private bool recheckOnDelete;

public const string WarningPrefixName = "Size Quota";

public static SizeQuotaConfiguration GetConfiguration(DocumentDatabase database)
{
return
Expand Down Expand Up @@ -71,7 +70,7 @@ private void UpdateSkippedCheck()
var totalSizeOnDisk = database.GetTotalSizeOnDisk();
if (totalSizeOnDisk <= softLimit)
{
WarningMessagesHolder.RemoveWarnings(database, WarningPrefixName);
database.Delete("Raven/Quotas/Size", null, null);
skipCheck = VetoResult.Allowed;
recheckOnDelete = false;
return;
Expand All @@ -85,15 +84,22 @@ private void UpdateSkippedCheck()
msg = string.Format("Database size is {0:#,#} KB, which is over the allowed quota of {1:#,#} KB. No more documents are allowed in.",
totalSizeOnDisk / 1024, hardLimit / 1024);

WarningMessagesHolder.AddWarning(database, WarningPrefixName, msg);
database.Put("Raven/Quotas/Size", null, new RavenJObject
{
{"Message", msg}
}, new RavenJObject(), null);

skipCheck = VetoResult.Deny(msg);
}
else // still before the hard limit, warn, but allow
{
msg = string.Format("Database size is {0:#,#} KB, which is close to the allowed quota of {1:#,#} KB",
totalSizeOnDisk / 1024, softLimit / 1024);

WarningMessagesHolder.AddWarning(database, WarningPrefixName, msg);
database.Put("Raven/Quotas/Size", null, new RavenJObject
{
{"Message", msg}
}, new RavenJObject(), null);
skipCheck = VetoResult.Allowed;
}
}
Expand Down

0 comments on commit ba7b0d5

Please sign in to comment.