-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndpoint.java
More file actions
38 lines (30 loc) · 1.03 KB
/
Endpoint.java
File metadata and controls
38 lines (30 loc) · 1.03 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
public class Endpoint {
double score = 0;
int latencyToDatacenter;
int cachesConnected;
int[][] caches;
public Map<Integer, Integer> videos_requested = new HashMap<Integer, Integer>();
Endpoint(int latency, int nr_cache){
latencyToDatacenter = latency;
cachesConnected = nr_cache;
caches = new int[nr_cache][2];
}
public void calculateScore(){
if(cachesConnected == 0)
score = 0;
else{
for(Map.Entry<Integer, Integer> entry : videos_requested.entrySet()){
Integer key = entry.getKey();
Integer value = entry.getValue();
score += value/Main.videos.get(key);
}
score = score / cachesConnected * latencyToDatacenter; //de testat fara fractie si de tinut cont latencyToDB
}
}
}