C# 클래스 Bamboo.Prevalence.PrevalenceEngine

Object prevalence engine. Provides transparent object persistence to deterministic systems.

The prevalent system class must be serializable and deterministic: two instances of the same class when exposed to the same set of commands and queries must reach the same final state and yield the same query results.

In order to be deterministic, the prevalent system class must use PrevalenceEngine.Clock or PrevalenceEngine.Now for all its date/time related functions.

Any change to the prevalent system must be represented by a serializable command object (ICommand) executed through ExecuteCommand.

Queries to the prevalent system are best implemented as query objects (IQuery) executed through ExecuteQuery.

The prevalence engine employs a reader/writer lock strategy to coordenate the work of command and query objects - that way multiple query objects are allowed to execute in paralell and command objects are only allowed to execute one by one.

The great news is that if you design your prevalent system in such a way that its state is only manipulated and queried through command and query objects you don't have to worry about synchronization, to a simple example of such a system please refer to the Bamboo.Prevalence.Tests project.

Optionally, if you don't like the idea of designing your system around command and query objects and would rather use simple method calls onto your prevalent system class, take a look at PrevalenceActivator.CreateTransparentEngine or Bamboo.Prevalence.Attributes.TransparentPrevalenceAttribute.

상속: System.MarshalByRefObject
파일 보기 프로젝트 열기: bamboo/Bamboo.Prevalence 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
_system object

공개 메소드들

메소드 설명
AssertNotPaused ( ) : void
ExecuteCommand ( ICommand command ) : object

Executes a serializable command object. If the command throws an exception it WILL NOT be saved to the output log therefore any exception throwing command MUST NOT cause any change to the system state to occur.

ExecuteQuery ( Bamboo query ) : object

Executes a query object against the prevalent system.

HandsOffOutputLog ( ) : void

Closes the output log file so that it can be read/copied/deleted. Useful for testing.

Pause ( ) : void

Pauses the engine. When paused the engine will not accept any commands (ExecuteCommand will throw PausedEngineException instead). The engine never stops accepting queries. The engine will accept commands again after Resume.

Resume ( ) : void

Resumes the normal operations of the engine.

TakeSnapshot ( ) : void

Writes a snapshot of the current state of the system to disk to speed up the next start up.

보호된 메소드들

메소드 설명
OnExceptionDuringRecovery ( ExceptionDuringRecoveryHandler handler, ICommand command, Exception exception ) : void

Called whenever a exception is thrown by a command during recovery.
Notify the specified delegate of the exception.

비공개 메소드들

메소드 설명
AcquireReaderLock ( ) : void
AcquireWriterLock ( ) : void
AfterQuery ( ) : void
ApplyCommandDecorators ( ICommand command ) : ICommand
BeforeQuery ( ) : void
CheckPrevalenceBase ( string prevalenceBase ) : DirectoryInfo
DoExecuteCommand ( ICommand command ) : object
GetCommandDecorators ( System systemType ) : ICommandDecorator[]
GetCurrent ( string methodName ) : PrevalenceEngine
PrevalenceEngine ( System systemType, string prevalenceBase, BinaryFormatter formatter ) : System

See PrevalenceActivator.CreateEngine(System.Type, string)

PrevalenceEngine ( System systemType, string prevalenceBase, BinaryFormatter formatter, ExceptionDuringRecoveryHandler handler ) : System

See PrevalenceActivator.CreateEngine(System.Type, string)

RecoverCommands ( Bamboo.Prevalence.Implementation.CommandLogReader reader, ExceptionDuringRecoveryHandler handler ) : void
RecoverSystem ( System systemType, Bamboo.Prevalence.Implementation.CommandLogReader reader, ExceptionDuringRecoveryHandler handler ) : void
ReleaseReaderLock ( ) : void
ReleaseWriterLock ( ) : void
ShareCurrentObject ( ) : void
UnshareCurrentObject ( ) : void

메소드 상세

AssertNotPaused() 공개 메소드

public AssertNotPaused ( ) : void
리턴 void

ExecuteCommand() 공개 메소드

Executes a serializable command object. If the command throws an exception it WILL NOT be saved to the output log therefore any exception throwing command MUST NOT cause any change to the system state to occur.
when the engine
public ExecuteCommand ( ICommand command ) : object
command ICommand serializable command object that will be executed
리턴 object

ExecuteQuery() 공개 메소드

Executes a query object against the prevalent system.
public ExecuteQuery ( Bamboo query ) : object
query Bamboo the query object
리턴 object

HandsOffOutputLog() 공개 메소드

Closes the output log file so that it can be read/copied/deleted. Useful for testing.
public HandsOffOutputLog ( ) : void
리턴 void

OnExceptionDuringRecovery() 보호된 메소드

Called whenever a exception is thrown by a command during recovery.
Notify the specified delegate of the exception.
protected OnExceptionDuringRecovery ( ExceptionDuringRecoveryHandler handler, ICommand command, Exception exception ) : void
handler ExceptionDuringRecoveryHandler a delegate that should be notified of the exception
command ICommand commands that has thrown the exception
exception System.Exception the exception
리턴 void

Pause() 공개 메소드

Pauses the engine. When paused the engine will not accept any commands (ExecuteCommand will throw PausedEngineException instead). The engine never stops accepting queries. The engine will accept commands again after Resume.
public Pause ( ) : void
리턴 void

Resume() 공개 메소드

Resumes the normal operations of the engine.
public Resume ( ) : void
리턴 void

TakeSnapshot() 공개 메소드

Writes a snapshot of the current state of the system to disk to speed up the next start up.
public TakeSnapshot ( ) : void
리턴 void

프로퍼티 상세

_system 보호되어 있는 프로퍼티

the prevalent system.
protected object _system
리턴 object