-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExecutionChecker.h
155 lines (125 loc) · 5.13 KB
/
ExecutionChecker.h
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
#pragma once
#include <BaseLib/Status/AccessStatus.h>
#include <BaseLib/Status/FlowStatus.h>
#include <BaseLib/Status/ExecutionStatus.h>
#include <BaseLib/Policy/IncludeLibs.h>
#include"BaseLib/Export.h"
namespace BaseLib { namespace Strategy {
// ------------------------------------------------------------
// Strategies to check if state and policy allows execution
// ------------------------------------------------------------
struct DLL_STATE ComputeNumPacketsToDequeue
{
static int Perform(const Status::FlowStatus& status, const Policy::Throughput& throughput);
};
/**
* @brief The AIMDStrategy class implements the additive-increase/multiplicative-decrease (AIMD) algorithm
* is a feedback control algorithm best known for its use in TCP Congestion Avoidance.
*
* Let w(t) be the sending rate (e.g. the congestion window) during time slot t, a (a > 0) be the additive
* increase parameter, and b (0 < b < 1) be the multiplicative decrease factor.
*
* w(t + 1) = w(t) + a \\ if congestion is not detected
* w(t + 1) = w(t) x b \\ if congestion is detected
*
* In TCP, after slow start, the additive increase parameter a is typically one MSS (maximum segment size)
* per round-trip time, and the multiplicative decrease factor b is typically 1/2.
*
* Ref: http://en.wikipedia.org/wiki/Additive_increase/multiplicative_decrease
*/
struct DLL_STATE CalculateTimeRateAIMD
{
static Status::TimeRate Perform(const Status::FlowStatus& status, const Policy::Throughput& maxThroughput, const Policy::Congestion& congestion);
};
// ------------------------------------------------------------
// Strategies to check if state and policy allows execution
// ------------------------------------------------------------
struct DLL_STATE IsInLifetime
{
static bool Perform(const Status::AccessStatus& status, const Policy::Lifespan& lifespan);
};
// ------------------------------------------------------------
// Strategies to check if state and policy allows execution
// ------------------------------------------------------------
struct DLL_STATE IsInLifespan
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Lifespan& lifespan);
};
struct DLL_STATE IsInInterval
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Interval& interval);
};
struct DLL_STATE IsInRetryInterval
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Interval& interval);
};
struct DLL_STATE IsInAttempt
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Attempt& attempt);
};
struct DLL_STATE IsTimeout
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Timeout& timeout);
};
struct DLL_STATE IsIdle
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Timeout& timeout);
};
struct DLL_STATE IsReadyToExecute
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Attempt& attempt, const Policy::Interval& interval, const Policy::Interval& retryInterval);
};
// ------------------------------------------------------------
// Strategies to compute next execution time
// ------------------------------------------------------------
struct DLL_STATE ComputeTimeUntilNextExecution
{
static Duration Perform(const Status::ExecutionStatus& status, const Policy::Interval& interval);
};
struct DLL_STATE ComputeTimeUntilNextRetry
{
static Duration Perform(const Status::ExecutionStatus& status, const Policy::Interval& interval);
};
struct DLL_STATE ComputeTimeUntilTimeout
{
static Duration Perform(const Status::ExecutionStatus& status, const Policy::Timeout& timeout);
};
struct DLL_STATE ComputeEarliestReadyIn
{
static Duration Perform
(
const Status::ExecutionStatus& status,
const Policy::Attempt& attempt,
const Policy::Interval& interval,
const Policy::Interval& retryInterval,
const Policy::Timeout& timeout
);
};
struct DLL_STATE ComputeExponentialBackoff
{
static Duration Perform(const Status::ExecutionStatus& t, const Policy::Interval& retryInterval);
};
// ------------------------------------------------------------
// Strategies to check for policy violations
// ------------------------------------------------------------
struct DLL_STATE IsLifetimePolicyViolated
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Attempt& attempt);
};
struct DLL_STATE IsIntervalPolicyViolated
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Interval& interval);
};
struct DLL_STATE IsTimeoutPolicyViolated
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Timeout& timeout);
};
struct DLL_STATE IsPolicyViolated
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Interval& interval, const Policy::Timeout& timeout, const Policy::Attempt& attempt);
};
struct DLL_STATE IsCriterionMet
{
static bool Perform(const Status::ExecutionStatus& status, const Policy::Criterion& successCriterion);
};
}}