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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
pub type WorkerIdentifier = usize;
pub type Logger<Event> = ::logging_core::Logger<Event, WorkerIdentifier>;
pub type TimelyLogger = Logger<TimelyEvent>;
use std::time::Duration;
use dataflow::operators::capture::{Event, EventPusher};
pub struct BatchLogger<T, E, P> where P: EventPusher<Duration, (Duration, E, T)> {
time: Duration,
event_pusher: P,
_phantom: ::std::marker::PhantomData<(E, T)>,
}
impl<T, E, P> BatchLogger<T, E, P> where P: EventPusher<Duration, (Duration, E, T)> {
pub fn new(event_pusher: P) -> Self {
BatchLogger {
time: Default::default(),
event_pusher,
_phantom: ::std::marker::PhantomData,
}
}
pub fn publish_batch(&mut self, time: &Duration, data: &mut Vec<(Duration, E, T)>) {
let new_frontier = time.clone();
let old_frontier = self.time.clone();
self.event_pusher.push(Event::Messages(self.time, ::std::mem::replace(data, Vec::new())));
self.event_pusher.push(Event::Progress(vec![(new_frontier, 1), (old_frontier, -1)]));
self.time = time.clone();
}
}
impl<T, E, P> Drop for BatchLogger<T, E, P> where P: EventPusher<Duration, (Duration, E, T)> {
fn drop(&mut self) {
self.event_pusher.push(Event::Progress(vec![(self.time, -1)]));
}
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct OperatesEvent {
pub id: usize,
pub addr: Vec<usize>,
pub name: String,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ChannelsEvent {
pub id: usize,
pub scope_addr: Vec<usize>,
pub source: (usize, usize),
pub target: (usize, usize),
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ProgressEvent {
pub is_send: bool,
pub source: usize,
pub channel: usize,
pub seq_no: usize,
pub addr: Vec<usize>,
pub messages: Vec<(usize, usize, String, i64)>,
pub internal: Vec<(usize, usize, String, i64)>,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct PushProgressEvent {
pub op_id: usize,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct MessagesEvent {
pub is_send: bool,
pub channel: usize,
pub source: usize,
pub target: usize,
pub seq_no: usize,
pub length: usize,
}
#[derive(Abomonation, Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
pub enum StartStop {
Start,
Stop {
activity: bool
},
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ScheduleEvent {
pub id: usize,
pub start_stop: StartStop,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ApplicationEvent {
pub id: usize,
pub is_start: bool,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct GuardedMessageEvent {
pub is_start: bool,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct GuardedProgressEvent {
pub is_start: bool,
}
#[derive(Abomonation, Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub struct TimelySetup {
pub index: usize,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub enum CommChannelKind {
Progress,
Data,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct CommChannelsEvent {
pub identifier: usize,
pub kind: CommChannelKind,
}
#[derive(Abomonation, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct InputEvent {
pub start_stop: StartStop,
}
#[derive(Debug, Clone, Abomonation, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub enum TimelyEvent {
Operates(OperatesEvent),
Channels(ChannelsEvent),
Progress(ProgressEvent),
PushProgress(PushProgressEvent),
Messages(MessagesEvent),
Schedule(ScheduleEvent),
Application(ApplicationEvent),
GuardedMessage(GuardedMessageEvent),
GuardedProgress(GuardedProgressEvent),
CommChannels(CommChannelsEvent),
Input(InputEvent),
Text(String),
}
impl From<OperatesEvent> for TimelyEvent {
fn from(v: OperatesEvent) -> TimelyEvent { TimelyEvent::Operates(v) }
}
impl From<ChannelsEvent> for TimelyEvent {
fn from(v: ChannelsEvent) -> TimelyEvent { TimelyEvent::Channels(v) }
}
impl From<ProgressEvent> for TimelyEvent {
fn from(v: ProgressEvent) -> TimelyEvent { TimelyEvent::Progress(v) }
}
impl From<PushProgressEvent> for TimelyEvent {
fn from(v: PushProgressEvent) -> TimelyEvent { TimelyEvent::PushProgress(v) }
}
impl From<MessagesEvent> for TimelyEvent {
fn from(v: MessagesEvent) -> TimelyEvent { TimelyEvent::Messages(v) }
}
impl From<ScheduleEvent> for TimelyEvent {
fn from(v: ScheduleEvent) -> TimelyEvent { TimelyEvent::Schedule(v) }
}
impl From<ApplicationEvent> for TimelyEvent {
fn from(v: ApplicationEvent) -> TimelyEvent { TimelyEvent::Application(v) }
}
impl From<GuardedMessageEvent> for TimelyEvent {
fn from(v: GuardedMessageEvent) -> TimelyEvent { TimelyEvent::GuardedMessage(v) }
}
impl From<GuardedProgressEvent> for TimelyEvent {
fn from(v: GuardedProgressEvent) -> TimelyEvent { TimelyEvent::GuardedProgress(v) }
}
impl From<CommChannelsEvent> for TimelyEvent {
fn from(v: CommChannelsEvent) -> TimelyEvent { TimelyEvent::CommChannels(v) }
}
impl From<InputEvent> for TimelyEvent {
fn from(v: InputEvent) -> TimelyEvent { TimelyEvent::Input(v) }
}