Documentation ¶
Index ¶
- func GetTestKey(k byte) []byte
- func GetTestValue(k byte, wTxn txn.TxnMeta) []byte
- func NewTestClock(start int64) clock.Clock
- func NewTestCommitRequest(wTxn txn.TxnMeta) txn.TxnRequest
- func NewTestCommitShardRequest(wTxn txn.TxnMeta) txn.TxnRequest
- func NewTestGetStatusRequest(wTxn txn.TxnMeta, shard uint64) txn.TxnRequest
- func NewTestPrepareRequest(wTxn txn.TxnMeta, shard uint64) txn.TxnRequest
- func NewTestReadRequest(k byte, rTxn txn.TxnMeta, toShard uint64) txn.TxnRequest
- func NewTestRollbackRequest(wTxn txn.TxnMeta) txn.TxnRequest
- func NewTestRollbackShardRequest(wTxn txn.TxnMeta) txn.TxnRequest
- func NewTestSpecClock(fn func() int64) clock.Clock
- func NewTestTNShard(id uint64) metadata.TNShard
- func NewTestTimestamp(ts int64) timestamp.Timestamp
- func NewTestTxn(txnID byte, ts int64, shards ...uint64) txn.TxnMeta
- func NewTestTxnStorage(log logservice.Client, clock clock.Clock) storage.TxnStorage
- func NewTestWriteRequest(k byte, wTxn txn.TxnMeta, toShard uint64) txn.TxnRequest
- type TestSender
- type TxnService
- func NewTestTxnService(t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock) TxnService
- func NewTestTxnServiceWithAllocator(t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, ...) TxnService
- func NewTestTxnServiceWithLog(t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, ...) TxnService
- func NewTestTxnServiceWithLogAndZombie(t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, ...) TxnService
- func NewTestTxnServiceWithLogAndZombieAndLockTabkeAllocator(t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, ...) TxnService
- func NewTxnService(shard metadata.TNShard, storage storage.TxnStorage, sender rpc.TxnSender, ...) TxnService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTestValue ¶ added in v0.6.0
GetTestValue encode test value based on the key and txn's snapshot timestamp
func NewTestClock ¶ added in v0.6.0
NewTestClock create test clock with start timestamp
func NewTestCommitRequest ¶ added in v0.6.0
func NewTestCommitRequest(wTxn txn.TxnMeta) txn.TxnRequest
NewTestCommitRequest create a commit request
func NewTestCommitShardRequest ¶ added in v0.6.0
func NewTestCommitShardRequest(wTxn txn.TxnMeta) txn.TxnRequest
NewTestCommitShardRequest create a commit DNShard request
func NewTestGetStatusRequest ¶ added in v0.6.0
func NewTestGetStatusRequest(wTxn txn.TxnMeta, shard uint64) txn.TxnRequest
NewTestGetStatusRequest create a get status request
func NewTestPrepareRequest ¶ added in v0.6.0
func NewTestPrepareRequest(wTxn txn.TxnMeta, shard uint64) txn.TxnRequest
NewTestPrepareRequest create a prepare request
func NewTestReadRequest ¶ added in v0.6.0
NewTestReadRequest create a read request, using GetTestKey as the KV data for the test.
func NewTestRollbackRequest ¶ added in v0.6.0
func NewTestRollbackRequest(wTxn txn.TxnMeta) txn.TxnRequest
NewTestRollbackRequest create a rollback request
func NewTestRollbackShardRequest ¶ added in v0.6.0
func NewTestRollbackShardRequest(wTxn txn.TxnMeta) txn.TxnRequest
NewTestRollbackShardRequest create a rollback DNShard request
func NewTestSpecClock ¶ added in v0.6.0
NewTestSpecClock create test clock with timestamp factory
func NewTestTNShard ¶ added in v1.0.0
NewTestTNShard create a test DNShard
func NewTestTimestamp ¶ added in v0.6.0
NewTestTimestamp create a test timestamp and set only the PhysicalTime field
func NewTestTxn ¶ added in v0.6.0
NewTestTxn create a transaction, specifying both the transaction snapshot time and the DNShard for the transaction operation.
func NewTestTxnStorage ¶ added in v0.6.0
func NewTestTxnStorage(log logservice.Client, clock clock.Clock) storage.TxnStorage
NewTestTxnStorage create a TxnStorage used to recovery tests
func NewTestWriteRequest ¶ added in v0.6.0
NewTestWriteRequest create a Write request, using GetTestKey and GetTestValue as the KV data for the test.
Types ¶
type TestSender ¶ added in v0.6.0
type TestSender struct {
// contains filtered or unexported fields
}
TestSender test TxnSender for sending messages between TxnServices
func NewTestSender ¶ added in v0.6.0
func NewTestSender(services ...TxnService) *TestSender
NewTestSender create test TxnSender
func (*TestSender) AddTxnService ¶ added in v0.6.0
func (s *TestSender) AddTxnService(ts TxnService)
AddTxnService add txnservice into test TxnSender
func (*TestSender) Close ¶ added in v0.6.0
func (s *TestSender) Close() error
Close close the test TxnSender
func (*TestSender) Send ¶ added in v0.6.0
func (s *TestSender) Send(ctx context.Context, requests []txn.TxnRequest) (*rpc.SendResult, error)
Send TxnSender send
type TxnService ¶
type TxnService interface { // Shard returns the metadata of DNShard Shard() metadata.TNShard // Start start the txn service Start() error // Close close the txn service. Destroy TxnStorage if destroy is true. Close(destroy bool) error // Read handle txn read request from CN. For reuse, the response is provided by the // TODO: only read log tail. Read(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // Write handle txn write request from CN. For reuse, the response is provided by the caller Write(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // Commit handle txn commit request from CN. For reuse, the response is provided by the caller Commit(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // Rollback handle txn rollback request from CN. For reuse, the response is provided by the caller Rollback(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // Prepare handle txn prepare request from coordinator DN. For reuse, the response is provided by // the caller Prepare(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // GetStatus handle get txn status in current DNShard request from coordinator DN. For reuse, the // response is provided by the caller. GetStatus(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // CommitTNShard handle commit txn data in current DNShard request from coordinator DN. For reuse, the // response is provided by the caller. CommitTNShard(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // RollbackTNShard handle rollback txn data in current DNShard request from coordinator DN. For reuse, // the response is provided by the caller. RollbackTNShard(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error // Debug handle txn debug request from CN. For reuse, the response is provided by the caller Debug(ctx context.Context, request *txn.TxnRequest, response *txn.TxnResponse) error }
TxnService is a transaction service that runs on the DNStore and is used to receive transaction requests from the CN. In the case of a 2 pc distributed transaction, it acts as a transaction coordinator to handle distributed transactions.
The TxnService is managed by the DNStore and a TxnService serves only one DNShard.
The txn service use Clock-SI to implement distributed transaction.
func NewTestTxnService ¶ added in v0.6.0
func NewTestTxnService( t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock) TxnService
NewTestTxnService create a test TxnService for test
func NewTestTxnServiceWithAllocator ¶ added in v0.8.0
func NewTestTxnServiceWithAllocator( t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, allocator lockservice.LockTableAllocator) TxnService
NewTestTxnServiceWithAllocator create a test TxnService for test
func NewTestTxnServiceWithLog ¶ added in v0.6.0
func NewTestTxnServiceWithLog( t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, log logservice.Client) TxnService
NewTestTxnServiceWithLog is similar to NewTestTxnService, used to recovery tests
func NewTestTxnServiceWithLogAndZombie ¶ added in v0.6.0
func NewTestTxnServiceWithLogAndZombie( t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, log logservice.Client, zombie time.Duration) TxnService
NewTestTxnServiceWithLogAndZombie is similar to NewTestTxnService, but with more args
func NewTestTxnServiceWithLogAndZombieAndLockTabkeAllocator ¶ added in v0.8.0
func NewTestTxnServiceWithLogAndZombieAndLockTabkeAllocator( t *testing.T, shard uint64, sender rpc.TxnSender, clock clock.Clock, log logservice.Client, zombie time.Duration, allocator lockservice.LockTableAllocator) TxnService
NewTestTxnServiceWithLogAndZombieAndLockTabkeAllocator is similar to NewTestTxnService, but with more args
func NewTxnService ¶ added in v0.5.1
func NewTxnService( shard metadata.TNShard, storage storage.TxnStorage, sender rpc.TxnSender, zombieTimeout time.Duration, allocator lockservice.LockTableAllocator) TxnService
NewTxnService create TxnService