LogRecordSequence.ReserveAndAppend 方法
定义
自动生成一个预留,并向序列中追加一条记录。Automatically makes a single reservation and appends a record to the sequence.
重载
| ReserveAndAppend(IList<ArraySegment<Byte>>, SequenceNumber, SequenceNumber, RecordAppendOptions, ReservationCollection, Int64[]) |
自动生成一个预留,并向序列中追加一条记录。Automatically makes a single reservation and appends a record to the sequence. 无法继承此方法。This method cannot be inherited. |
| ReserveAndAppend(ArraySegment<Byte>, SequenceNumber, SequenceNumber, RecordAppendOptions, ReservationCollection, Int64[]) |
自动生成一个预留,并向序列中追加一条记录。Automatically makes a single reservation and appends a record to the sequence. 无法继承此方法。This method cannot be inherited. |
ReserveAndAppend(IList<ArraySegment<Byte>>, SequenceNumber, SequenceNumber, RecordAppendOptions, ReservationCollection, Int64[])
自动生成一个预留,并向序列中追加一条记录。Automatically makes a single reservation and appends a record to the sequence. 无法继承此方法。This method cannot be inherited.
public:
virtual System::IO::Log::SequenceNumber ReserveAndAppend(System::Collections::Generic::IList<ArraySegment<System::Byte>> ^ data, System::IO::Log::SequenceNumber userRecord, System::IO::Log::SequenceNumber previousRecord, System::IO::Log::RecordAppendOptions recordAppendOptions, System::IO::Log::ReservationCollection ^ reservationCollection, ... cli::array <long> ^ reservations);
public System.IO.Log.SequenceNumber ReserveAndAppend (System.Collections.Generic.IList<ArraySegment<byte>> data, System.IO.Log.SequenceNumber userRecord, System.IO.Log.SequenceNumber previousRecord, System.IO.Log.RecordAppendOptions recordAppendOptions, System.IO.Log.ReservationCollection reservationCollection, params long[] reservations);
abstract member ReserveAndAppend : System.Collections.Generic.IList<ArraySegment<byte>> * System.IO.Log.SequenceNumber * System.IO.Log.SequenceNumber * System.IO.Log.RecordAppendOptions * System.IO.Log.ReservationCollection * int64[] -> System.IO.Log.SequenceNumber
override this.ReserveAndAppend : System.Collections.Generic.IList<ArraySegment<byte>> * System.IO.Log.SequenceNumber * System.IO.Log.SequenceNumber * System.IO.Log.RecordAppendOptions * System.IO.Log.ReservationCollection * int64[] -> System.IO.Log.SequenceNumber
Public Function ReserveAndAppend (data As IList(Of ArraySegment(Of Byte)), userRecord As SequenceNumber, previousRecord As SequenceNumber, recordAppendOptions As RecordAppendOptions, reservationCollection As ReservationCollection, ParamArray reservations As Long()) As SequenceNumber
参数
- data
- IList<ArraySegment<Byte>>
将连接在一起并以记录形式追加的字节数组段的列表。A list of byte array segments that will be concatenated and appended as the record.
- userRecord
- SequenceNumber
用户指定顺序中下一条记录的序列号。The sequence number of the next record in the user-specified order.
- previousRecord
- SequenceNumber
“上一个”顺序中下一条记录的序列号。The sequence number of the next record in Previous order.
- recordAppendOptions
- RecordAppendOptions
RecordAppendOptions 的一个有效值,用于指定应如何写入数据。A valid value of RecordAppendOptions that specifies how the data should be written.
- reservationCollection
- ReservationCollection
要在其中生成预留的预留集合。The reservation collection to make reservations in.
- reservations
- Int64[]
要生成的预留(以字节为单位)。The reservations to make, in bytes.
返回
追加的日志记录的序列号。The sequence number of the appended log record.
实现
例外
一个或多个自变量无效。One or more of the arguments is invalid.
追加记录时,发生了 I/O 错误。An I/O error occurred while appending the record.
记录序列无法获得足够的可用空间来容纳新记录或生成预留。The record sequence could not make enough free space to contain the new record, or to make the reservation.
该方法是在序列已释放之后调用的。The method was called after the sequence has been disposed of.
一个或多个参数为 null。One or more of the arguments are null.
userRecord 或 previousRecord 不在此序列的基序列号和最新序列号之间。userRecord or previousRecord is not between the base and last sequence numbers of this sequence.
由于记录序列是通过只读访问权限打开的,因此无法执行该操作。The operation cannot be performed because the record sequence was opened with read-only access.
没有足够的内存来继续执行该程序。There is not enough memory to continue the execution of the program.
操作系统拒绝了对指定的日志序列的访问。Access for the specified log sequence is denied by the operating system.
在 data 中找不到足以容纳 reservations 的预留。No reservation large enough to fit data can be found in reservations.
注解
包含在 data 参数中的数据将连接成单个字节数组,以便以记录形式追加。Data contained in the data parameter will be concatenated into a single byte array for appending as the record. 但在读取记录时,无法将数据重新拆分为数组段。However, no provision is made for splitting data back into array segments when the record is read.
在原子操作中,使用记录追加操作将指定的预留添加到所提供的预留集合。The specified reservations are added to the provided reservation collection in an atomic operation with a record append operation. 如果追加失败,将不保留任何空间。If the append fails, no space is reserved.
通常,此方法可以在写入记录之前完成。Normally, this method may complete before the record has been written. 若要确保记录已写入,请使用 ForceFlush 参数指定 recordAppendOptions 标志,或者调用 Flush 方法。To ensure that a record has been written, either specify the ForceFlush flag using the recordAppendOptions parameter, or call the Flush method.
适用于
ReserveAndAppend(ArraySegment<Byte>, SequenceNumber, SequenceNumber, RecordAppendOptions, ReservationCollection, Int64[])
自动生成一个预留,并向序列中追加一条记录。Automatically makes a single reservation and appends a record to the sequence. 无法继承此方法。This method cannot be inherited.
public:
virtual System::IO::Log::SequenceNumber ReserveAndAppend(ArraySegment<System::Byte> data, System::IO::Log::SequenceNumber nextUndoRecord, System::IO::Log::SequenceNumber previousRecord, System::IO::Log::RecordAppendOptions recordAppendOptions, System::IO::Log::ReservationCollection ^ reservationCollection, ... cli::array <long> ^ reservations);
public System.IO.Log.SequenceNumber ReserveAndAppend (ArraySegment<byte> data, System.IO.Log.SequenceNumber nextUndoRecord, System.IO.Log.SequenceNumber previousRecord, System.IO.Log.RecordAppendOptions recordAppendOptions, System.IO.Log.ReservationCollection reservationCollection, params long[] reservations);
abstract member ReserveAndAppend : ArraySegment<byte> * System.IO.Log.SequenceNumber * System.IO.Log.SequenceNumber * System.IO.Log.RecordAppendOptions * System.IO.Log.ReservationCollection * int64[] -> System.IO.Log.SequenceNumber
override this.ReserveAndAppend : ArraySegment<byte> * System.IO.Log.SequenceNumber * System.IO.Log.SequenceNumber * System.IO.Log.RecordAppendOptions * System.IO.Log.ReservationCollection * int64[] -> System.IO.Log.SequenceNumber
Public Function ReserveAndAppend (data As ArraySegment(Of Byte), nextUndoRecord As SequenceNumber, previousRecord As SequenceNumber, recordAppendOptions As RecordAppendOptions, reservationCollection As ReservationCollection, ParamArray reservations As Long()) As SequenceNumber
参数
- data
- ArraySegment<Byte>
将连接在一起并以记录形式追加的字节数组段的列表。A list of byte array segments that will be concatenated and appended as the record.
- nextUndoRecord
- SequenceNumber
用户指定顺序中下一条记录的序列号。The sequence number of the next record in the user-specified order.
- previousRecord
- SequenceNumber
“上一个”顺序中下一条记录的序列号。The sequence number of the next record in Previous order.
- recordAppendOptions
- RecordAppendOptions
RecordAppendOptions 的一个有效值,用于指定应如何写入数据。A valid value of RecordAppendOptions that specifies how the data should be written.
- reservationCollection
- ReservationCollection
一个 ReservationCollection,它包含要在其中生成预留的集合。A ReservationCollection that contains the collection to make reservations in.
- reservations
- Int64[]
要生成的预留(以字节为单位)。The reservations to make, in bytes.
返回
追加的日志记录的序列号。The sequence number of the appended log record.
实现
例外
nextUndoRecord 或 previousRecord 对此序列无效。nextUndoRecord or previousRecord is not valid for this sequence.
- 或 --or-
无法追加 data,原因是它比最大记录大小要大。data cannot be appended because it is larger than the maximum record size.
- 或 --or-
reservations 不是由此记录序列创建的。reservations was not created by this record sequence.
一个或多个参数为 null。One or more of the arguments are null.
nextUndoRecord 或 previousRecord 不在此序列的基序列号和最新序列号之间。nextUndoRecord or previousRecord is not between the base and last sequence numbers of this sequence.
由于出现意外的 I/O 异常,因此无法执行该请求。The request could not be performed because of an unexpected I/O exception.
- 或 --or-
由于出现 I/O 设备错误,因此无法执行该请求。The request could not be performed because of an I/O device error.
由于记录序列是通过只读访问权限打开的,因此无法执行该操作。The operation cannot be performed because the record sequence was opened with read-only access.
该方法是在序列已释放之后调用的。The method was called after the sequence has been disposed of.
没有足够的内存来继续执行该程序。There is not enough memory to continue the execution of the program.
记录序列已满。The record sequence is full.
操作系统拒绝了对指定的日志序列的访问。Access for the specified log sequence is denied by the operating system.
在 data 中找不到足以容纳 reservations 的预留。No reservation large enough to fit data can be found in reservations.
示例
下面的示例演示如何使用此方法来生成预留。The following example shows how to use this method to make reservations. 请注意,只有在使用基于 CLFS 的 LogRecordSequence 类时才能执行此任务。Notice that this task can only be performed when using the CLFS-based LogRecordSequence class.
ReservationCollection reservations = recordSequence.CreateReservationCollection();
long[] lengthOfUndoRecords = new long[] { 1000 };
recordSequence.ReserveAndAppend(recordData,
userSqn,
previousSqn,
RecordSequenceAppendOptions.None,
reservations,
lengthOfUndoRecords);
recordSequence.Append(undoRecordData, // If necessary …
userSqn,
previousSqn,
RecordSequenceAppendOptions.ForceFlush,
reservations);
注解
包含在 data 参数中的数据将连接成单个字节数组,以便以记录形式追加。Data contained in the data parameter will be concatenated into a single byte array for appending as the record. 但在读取记录时,无法将数据重新拆分为数组段。However, no provision is made for splitting data back into array segments when the record is read.
在原子操作中,使用记录追加操作将指定的预留添加到所提供的预留集合。The specified reservations are added to the provided reservation collection in an atomic operation with a record append operation. 如果追加失败,将不保留任何空间。If the append fails, no space is reserved.
通常,此方法可以在写入记录之前完成。Normally, this method may complete before the record has been written. 若要确保记录已写入,请使用 ForceFlush 参数指定 recordAppendOptions 标志,或者调用 Flush 方法。To ensure that a record has been written, either specify the ForceFlush flag using the recordAppendOptions parameter, or call the Flush method.