-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata_models.py
More file actions
56 lines (42 loc) · 1.18 KB
/
data_models.py
File metadata and controls
56 lines (42 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from dataclasses import dataclass
from enum import Enum
from typing import List, Set, Tuple
# Data Models
class TransactionStatus(Enum):
ACTIVE = "ACTIVE"
COMMITTED = "COMMITTED"
ABORTED = "ABORTED"
class Operations:
READ = "READ"
WRITE = "WRITE"
class AbortType(Enum):
SITE_FAILURE = "SITE_FAILURE"
IMPOSSIBLE_READ = "IMPOSSIBLE_READ"
FIRST_COMMITTER_WRITE = "FIRST_COMMITTER_WRITE"
CONSECUTIVE_RW_CYCLE = "CONSECUTIVE_RW_CYCLE"
class EdgeType(Enum):
RW = "RW"
WW = "WW"
WR = "WR"
@dataclass
class DataLog:
value: int
timestamp: int
transaction_id: str
committed: bool
@dataclass
class Transaction:
id: str
start_time: int
status: TransactionStatus
writes: Set[str] # Set of data_ids written by this transaction
reads: Set[str] # Set of data_ids read by this transaction
is_read_only: bool
# List of sites accessed by this transaction - Tuple content - (site_id, operation, timestamp)
sites_accessed: List[Tuple[int, str, int]]
commit_time: int
@dataclass
class SiteStatus:
status: bool # True if site is up, False if down
last_failure_time: int
site_log: List[Tuple[bool, int]]