public DatabaseSizeInfo GetDatabaseSize(DirectoryDatabase database) { DatabaseSizeInfo result; using (ExRpcAdmin exRpcAdminForDatabase = this.GetExRpcAdminForDatabase(database)) { ulong bytesValue; ulong bytesValue2; exRpcAdminForDatabase.GetDatabaseSize(database.Guid, out bytesValue, out bytesValue2); ByteQuantifiedSize byteQuantifiedSize = ByteQuantifiedSize.FromBytes(bytesValue); ByteQuantifiedSize byteQuantifiedSize2 = ByteQuantifiedSize.FromBytes(bytesValue2); if (byteQuantifiedSize2 > byteQuantifiedSize) { this.logger.LogWarning("Database {0} has more free space ({1}) than its total size ({2}), assuming sparse EDB file with no free pages.", new object[] { database.Name, byteQuantifiedSize2, byteQuantifiedSize }); byteQuantifiedSize2 = ByteQuantifiedSize.Zero; } result = new DatabaseSizeInfo { AvailableWhitespace = byteQuantifiedSize2, CurrentPhysicalSize = byteQuantifiedSize }; } return(result); }
protected override void Initialize(RequestContext r) { base.Initialize(r); DatabaseSizeInfo.BindType(); // We need a valid request context MessageUnauthorizedDatabase = __("You are not authorized to access this database"); }
public LoadContainer ToLoadContainer() { DatabaseSizeInfo size = this.GetSize(); LoadContainer loadContainer = new LoadContainer(this, ContainerType.Database); loadContainer.RelativeLoadWeight = this.RelativeLoadCapacity; loadContainer.CanAcceptRegularLoad = (!this.IsExcludedFromProvisioning && size.CurrentPhysicalSize < this.MaximumSize); loadContainer.CanAcceptBalancingLoad = (!this.IsExcludedFromInitialProvisioning && loadContainer.CanAcceptRegularLoad); loadContainer.MaximumLoad[PhysicalSize.Instance] = (long)this.MaximumSize.ToBytes(); loadContainer.MaximumLoad[LogicalSize.Instance] = (long)this.MaximumSize.ToBytes(); loadContainer.ReusableCapacity[LogicalSize.Instance] = (long)size.AvailableWhitespace.ToBytes(); loadContainer.ReusableCapacity[PhysicalSize.Instance] = (long)size.AvailableWhitespace.ToBytes(); ByteQuantifiedSize byteQuantifiedSize = size.CurrentPhysicalSize - size.AvailableWhitespace; loadContainer.ConsumedLoad[LogicalSize.Instance] = (long)byteQuantifiedSize.ToBytes(); loadContainer.ConsumedLoad[PhysicalSize.Instance] = (long)byteQuantifiedSize.ToBytes(); return(loadContainer); }