Refactor concurrency handling to introduce STALE_HEARTBEAT_THRESHOLD_MS constant and utilize SweepstoreWorkerTicketSnapshot for improved state management
This commit is contained in:
@@ -54,24 +54,25 @@ void main() async {
|
||||
// display each ticket
|
||||
for (int i = 0; i < concurrency.numberOfWorkers; i++) {
|
||||
final ticket = concurrency[i];
|
||||
final snapshot = ticket.snapshot();
|
||||
|
||||
print('--- Ticket #$i ---');
|
||||
print(' Identifier: ${ticket.identifier}');
|
||||
print(' Identifier: ${snapshot.identifier}');
|
||||
|
||||
int workerAge = now32 - ticket.workerHeartbeat;
|
||||
int workerAge = now32 - snapshot.workerHeartbeat;
|
||||
String workerStatus = workerAge > 5 ? "(stale)" : "(active)";
|
||||
String workerPrevious = previousWorkerHeartbeats.containsKey(i) ? "(previously ${previousWorkerHeartbeats[i]})" : "";
|
||||
print(' Heartbeat: ${ticket.workerHeartbeat} $workerStatus $workerPrevious');
|
||||
print(' Heartbeat: ${snapshot.workerHeartbeat} $workerStatus $workerPrevious');
|
||||
|
||||
print(' State: ${ticket.ticketState.name}');
|
||||
print(' Operation: ${ticket.ticketOperation.name}');
|
||||
print(' Key Hash: ${ticket.keyHash}');
|
||||
print(' Write Ptr: ${ticket.writePointer}');
|
||||
print(' Write Size: ${ticket.writeSize} bytes');
|
||||
print(' State: ${snapshot.ticketState.name}');
|
||||
print(' Operation: ${snapshot.ticketOperation.name}');
|
||||
print(' Key Hash: ${snapshot.keyHash}');
|
||||
print(' Write Ptr: ${snapshot.writePointer}');
|
||||
print(' Write Size: ${snapshot.writeSize} bytes');
|
||||
print('');
|
||||
|
||||
// update previous heartbeat
|
||||
previousWorkerHeartbeats[i] = ticket.workerHeartbeat;
|
||||
previousWorkerHeartbeats[i] = snapshot.workerHeartbeat;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user