LogPolicy 类

定义

表示与 LogStore 相关联的策略。Represents the policy associated with a LogStore.

public ref class LogPolicy sealed
public sealed class LogPolicy
type LogPolicy = class
Public NotInheritable Class LogPolicy
继承
LogPolicy

示例

此示例演示如何使用 LogPolicy 类来设置日志记录序列的策略。This example shows how to use the LogPolicy class to set policy for a log record sequence.

// SET LOG POLICY

LogPolicy policy = sequence.LogStore.Policy;

// Set AutoGrow policy. This enables the log to automatically grow
// when the existing extents are full. New extents are added until
// we reach the MaximumExtentCount extents.
// AutoGrow policy is supported only in Windows Vista and not available in R2.

//policy.AutoGrow = true;

// Set the Growth Rate in terms of extents. This policy specifies
// "how much" the log should grow. 
policy.GrowthRate = new PolicyUnit(2, PolicyUnitType.Extents);

// Set the AutoShrink policy. This enables the log to automatically
// shrink if the available free space exceeds the shrink percentage. 
// AutoGrow/shrink policy is supported only in Windows Vista and not available in R2.

//policy.AutoShrinkPercentage = new PolicyUnit(30, PolicyUnitType.Percentage);

// Set the PinnedTailThreshold policy.
// A tail pinned event is triggered when there is no
// log space available and log space may be freed by advancing the base.
// The user must handle the tail pinned event by advancing the base of the log. 
// If the user is not able to move the base of the log, the user should report with exception in
// the tail pinned handler.
// PinnedTailThreashold policy dictates the amount of space that the TailPinned event requests 
// for advancing the base of the log. The amount of space can be in percentage or in terms of bytes 
// which is rounded off to the nearest containers in CLFS. The default is 35 percent.

policy.PinnedTailThreshold = new PolicyUnit(10, PolicyUnitType.Percentage);

// Set the maximum extents the log can have.
policy.MaximumExtentCount = 6;

// Set the minimum extents the log can have.
policy.MinimumExtentCount = 2;

// Set the prefix for new containers that are added. 
// when AutoGrow is enabled.
//policy.NewExtentPrefix = "MyLogPrefix";

// Set the suffix number for new containers that are added.
// when AutoGrow is enabled. 
policy.NextExtentSuffix = 3;

// Commit the log policy.
policy.Commit();

// Refresh updates the IO.Log policy properties with current log policy 
// set in the log. 
policy.Refresh();

// LOG POLICY END
// 
' SET LOG POLICY

Dim policy As LogPolicy = sequence.LogStore.Policy

' Set AutoGrow policy. This enables the log to automatically grow
' when the existing extents are full. New extents are added until
' we reach the MaximumExtentCount extents.
' AutoGrow policy is supported only in Windows Vista and not available in R2.

'policy.AutoGrow = true;

' Set the Growth Rate in terms of extents. This policy specifies
' "how much" the log should grow. 
policy.GrowthRate = New PolicyUnit(2, PolicyUnitType.Extents)

' Set the AutoShrink policy. This enables the log to automatically
' shrink if the available free space exceeds the shrink percentage. 
' AutoGrow/shrink policy is supported only in Windows Vista and not available in R2.

'policy.AutoShrinkPercentage = new PolicyUnit(30, PolicyUnitType.Percentage);

' Set the PinnedTailThreshold policy.
' A tail pinned event is triggered when there is no
' log space available and log space may be freed by advancing the base.
' The user must handle the tail pinned event by advancing the base of the log. 
' If the user is not able to move the base of the log, the user should report with exception in
' the tail pinned handler.
' PinnedTailThreashold policy dictates the amount of space that the TailPinned event requests 
' for advancing the base of the log. The amount of space can be in percentage or in terms of bytes 
' which is rounded off to the nearest containers in CLFS. The default is 35 percent.


policy.PinnedTailThreshold = New PolicyUnit(10, PolicyUnitType.Percentage)

' Set the maximum extents the log can have.
policy.MaximumExtentCount = 6

' Set the minimum extents the log can have.
policy.MinimumExtentCount = 2

' Set the prefix for new containers that are added. 
' when AutoGrow is enabled.
'policy.NewExtentPrefix = "MyLogPrefix";

' Set the suffix number for new containers that are added.
' when AutoGrow is enabled. 
policy.NextExtentSuffix = 3

' Commit the log policy.
policy.Commit()

' Refresh updates the IO.Log policy properties with current log policy 
' set in the log. 
policy.Refresh()

' LOG POLICY END
' 

注解

策略是一组规则,LogStore 实例及其客户端需要遵守这些规则。A policy is a set of rules to be followed by a LogStore instance and its clients. LogPolicy 实例用于检查和修改与特定 LogStore 相关联的策略。A LogPolicy instance is used to examine and modify the policy associated with a specific LogStore. 策略可描述允许的最小和最大日志大小,或者 LogStore 实例的允许增长方式。A policy can describe the minimum and maximum allowable log sizes, or how the LogStore instance is allowed to grow. 此外,还可以控制是否能够存档 LogStore 实例。In addition, you can also control whether a LogStore instance can be archived.

更改任何属性之后,都应使用 Commit 方法,以确保将更改应用于 LogStoreAfter changing any of the properties, you should use the Commit method to ensure that the changes are applied to the LogStore. 调用 Refresh 方法可以放弃更改,或获得最新策略。You can call the Refresh method to discard changes or to get the most current policy.

属性

AutoGrow

获取或设置一个值,该值指示 LogStore 是否能够自动增长。Gets or sets a value indicating whether the LogStore can grow automatically.

AutoShrinkPercentage

获取或设置 LogStore 可收缩的可用空间百分比。Gets or sets the percentage of free space the LogStore can shrink.

GrowthRate

获取或设置 LogStore 的自动增长率。Gets or sets the rate of automatic growth of the LogStore.

MaximumExtentCount

获取或设置 LogExtent 最多能够包含的 LogStore 实例数。Gets or sets the maximum number of LogExtent instances the LogStore can contain.

MinimumExtentCount

获取或设置 LogExtent 最少能够包含的 LogStore 实例数。Gets or sets the minimum number of LogExtent instances the LogStore can contain.

NewExtentPrefix

获取或设置用于自动创建的范围的前缀字符串。Gets or sets the prefix string for automatically created extents.

NextExtentSuffix

获取或设置新范围的后缀数。Gets or sets the suffix number for new extents.

PinnedTailThreshold

获取或设置 TailPinned 事件前调日志基数所要求的空间量。Gets or sets the amount of space that the TailPinned event requires for advancing the base of the log.

方法

Commit()

将此策略设置为 LogStore 的当前策略。Sets this policy as the current policy for the LogStore.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Refresh()

读取 LogStore 的当前策略,放弃已做的所有更改。Reads the current policy for the LogStore, discarding any changes that may have been made.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于