|
8 | 8 | "strconv" |
9 | 9 | "time" |
10 | 10 |
|
| 11 | + "github.com/serverledge-faas/serverledge/internal/config" |
11 | 12 | "github.com/serverledge-faas/serverledge/internal/function" |
12 | 13 | "github.com/serverledge-faas/serverledge/internal/metrics" |
13 | 14 | "github.com/serverledge-faas/serverledge/internal/node" |
@@ -216,14 +217,27 @@ func (policy *IlpOffloadingPolicy) Evaluate(r *Request, p *Progress) (Offloading |
216 | 217 |
|
217 | 218 | // Distances to Cloud and Data Store |
218 | 219 | // TODO: we assume distance to Cloud == distance to DS (for all Edge nodes) |
219 | | - distanceToCloud := 0.100 // TODO: measure Cloud latency (ping? or, retrieve from offloadingLatency ) |
220 | | - for _, n := range params.EdgeNodes { |
221 | | - params.NodeLatency[tupleKey(n, CLOUD)] = distanceToCloud |
222 | | - params.NodeLatency[tupleKey(CLOUD, n)] = distanceToCloud |
223 | | - params.DSLatency[n] = distanceToCloud |
| 220 | + cloudAddress := config.GetString(config.CLOUD_URL, "") |
| 221 | + // TODO: what if we have multiple cloud nodes? one per region? CloudLatency already stores latency towards all of them |
| 222 | + distanceToCloud, found := registration.Reg.CloudLatency[cloudAddress] |
| 223 | + if found { |
| 224 | + for _, n := range params.EdgeNodes { |
| 225 | + params.NodeLatency[tupleKey(n, CLOUD)] = distanceToCloud |
| 226 | + params.NodeLatency[tupleKey(CLOUD, n)] = distanceToCloud |
| 227 | + params.DSLatency[n] = distanceToCloud |
| 228 | + } |
| 229 | + params.NodeLatency[tupleKey(CLOUD, CLOUD)] = 0.0 |
| 230 | + params.DSLatency[CLOUD] = 0.001 |
| 231 | + } else { |
| 232 | + // TODO: this branch is for testing purposes only. Remove it. |
| 233 | + for _, n := range params.EdgeNodes { |
| 234 | + params.NodeLatency[tupleKey(n, CLOUD)] = distanceToCloud |
| 235 | + params.NodeLatency[tupleKey(CLOUD, n)] = distanceToCloud |
| 236 | + params.DSLatency[n] = distanceToCloud |
| 237 | + } |
| 238 | + params.NodeLatency[tupleKey(CLOUD, CLOUD)] = 0.0 |
| 239 | + params.DSLatency[CLOUD] = 0.001 |
224 | 240 | } |
225 | | - params.NodeLatency[tupleKey(CLOUD, CLOUD)] = 0.0 |
226 | | - params.DSLatency[CLOUD] = 0.001 |
227 | 241 |
|
228 | 242 | // Bandwidth (we assume identical) |
229 | 243 | dsBandwidth := 100.0 // TODO: read from configuration? |
|
0 commit comments