-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started to do ack2 message and processing
- Loading branch information
Showing
8 changed files
with
207 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Class { | ||
#name : #GossipAck2MessageTest, | ||
#superclass : #TestCase, | ||
#category : #'Gossip-Tests' | ||
} | ||
|
||
{ #category : #tests } | ||
GossipAck2MessageTest >> testRemoteNeedsAllStates [ | ||
| localEndpoint endpoints endpointState ack remoteEndpoint ack2 | | ||
remoteEndpoint := GossipEndpoint example1. | ||
localEndpoint := GossipEndpoint example2. | ||
endpoints := GossipEndpoints new. | ||
ack := GossipAckMessage new | ||
sender: remoteEndpoint; | ||
digests: { remoteEndpoint generation: 4321 version: 0 }. | ||
endpointState := (endpoints endpointStateAt: remoteEndpoint) | ||
generation: 4321; | ||
applicationStateAt: #foo put: #bar; | ||
yourself. | ||
ack2 := GossipAck2Message new | ||
sender: localEndpoint; | ||
initializeFromAckMessage: ack andEndpoints: endpoints . | ||
self assert: ack2 delta size equals: 1. | ||
self assert: (ack2 delta at: remoteEndpoint) applicationStates values first version equals: 2 | ||
] | ||
|
||
{ #category : #tests } | ||
GossipAck2MessageTest >> testRemoteNeedsDeltaStates [ | ||
| localEndpoint endpoints endpointState ack remoteEndpoint ack2 | | ||
remoteEndpoint := GossipEndpoint example1. | ||
localEndpoint := GossipEndpoint example2. | ||
endpoints := GossipEndpoints new. | ||
ack := GossipAckMessage new | ||
sender: remoteEndpoint; | ||
digests: { remoteEndpoint generation: 4321 version: 3 }. | ||
endpointState := (endpoints endpointStateAt: remoteEndpoint) | ||
generation: 4321; | ||
applicationStateAt: #one put: 1; | ||
applicationStateAt: #two put: 2; | ||
applicationStateAt: #three put: 3; | ||
applicationStateAt: #four put: 4; | ||
applicationStateAt: #five put: 5; | ||
|
||
yourself. | ||
ack2 := GossipAck2Message new | ||
sender: localEndpoint; | ||
initializeFromAckMessage: ack andEndpoints: endpoints . | ||
self assert: ack2 delta size equals: 1. | ||
self assert: (ack2 delta at: remoteEndpoint) applicationStates size equals: 3. | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Class { | ||
#name : #GossipEndpointStateDelta, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'heartbeatState', | ||
'applicationStates' | ||
], | ||
#category : #Gossip | ||
} | ||
|
||
{ #category : #accessing } | ||
GossipEndpointStateDelta >> applicationStateAt: aString [ | ||
^ applicationStates | ||
at: aString | ||
ifAbsent: [ KeyNotFound signal: 'state ', aString printString, ' not found' ] | ||
] | ||
|
||
{ #category : #accessing } | ||
GossipEndpointStateDelta >> applicationStates [ | ||
^ applicationStates | ||
] | ||
|
||
{ #category : #accessing } | ||
GossipEndpointStateDelta >> applicationStates: aCollection [ | ||
applicationStates := aCollection | ||
] | ||
|
||
{ #category : #accessing } | ||
GossipEndpointStateDelta >> generation [ | ||
^ self heartbeatState generation | ||
] | ||
|
||
{ #category : #accessing } | ||
GossipEndpointStateDelta >> generation: anInteger [ | ||
heartbeatState generation: anInteger | ||
] | ||
|
||
{ #category : #accessing } | ||
GossipEndpointStateDelta >> heartbeatState [ | ||
^ heartbeatState | ||
] | ||
|
||
{ #category : #accessing } | ||
GossipEndpointStateDelta >> heartbeatState: aGossipHeartbeatState [ | ||
heartbeatState := aGossipHeartbeatState | ||
] | ||
|
||
{ #category : #initialization } | ||
GossipEndpointStateDelta >> initialize [ | ||
super initialize. | ||
applicationStates := Dictionary new | ||
] | ||
|
||
{ #category : #testing } | ||
GossipEndpointStateDelta >> isEmpty [ | ||
^ applicationStates isEmpty | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters