1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
package net.sf.infrared.web.util; |
24 |
|
|
25 |
|
import java.util.Date; |
26 |
|
import java.util.Set; |
27 |
|
import net.sf.infrared.base.model.StatisticsSnapshot; |
28 |
|
|
29 |
|
import org.apache.log4j.Logger; |
30 |
|
|
31 |
|
import net.sf.infrared.base.model.ApplicationStatistics; |
32 |
|
import net.sf.infrared.base.util.LoggingFactory; |
33 |
|
import net.sf.infrared.collector.Collector; |
34 |
|
|
35 |
0 |
public class DataFetchUtil { |
36 |
|
|
37 |
|
static Collector collector; |
38 |
|
static final String SEPERATOR = "#"; |
39 |
0 |
private static final Logger logger = LoggingFactory.getLogger(DataFetchUtil.class); |
40 |
|
|
41 |
|
|
42 |
|
public static PerformanceDataSnapshot getPerfData(Set appNameSet, Set instNameSet){ |
43 |
|
|
44 |
0 |
StatisticsSnapshot mergedStats = getCollector().fetchStats(appNameSet, instNameSet); |
45 |
0 |
PerformanceDataSnapshot snapShot = new PerformanceDataSnapshot(); |
46 |
0 |
snapShot.setApplicationNames(appNameSet); |
47 |
0 |
snapShot.setInstanceNames(instNameSet); |
48 |
0 |
snapShot.setStats(mergedStats); |
49 |
|
|
50 |
0 |
return snapShot; |
51 |
|
} |
52 |
|
|
53 |
|
public static PerformanceDataSnapshot reset(){ |
54 |
0 |
getCollector().clearStats(); |
55 |
|
|
56 |
0 |
PerformanceDataSnapshot snapShot = new PerformanceDataSnapshot(); |
57 |
0 |
return snapShot; |
58 |
|
} |
59 |
|
|
60 |
|
public static PerformanceDataSnapshot getDataFromDB(Set applications, Set instances, |
61 |
|
Date fromDate, Date toDate){ |
62 |
0 |
StatisticsSnapshot stats = getCollector().fetchStatsFromDB(applications, instances, |
63 |
|
fromDate, toDate); |
64 |
0 |
PerformanceDataSnapshot snapShot = new PerformanceDataSnapshot(); |
65 |
0 |
snapShot.setApplicationNames(applications); |
66 |
0 |
snapShot.setInstanceNames(instances); |
67 |
0 |
snapShot.setStats(stats); |
68 |
|
|
69 |
0 |
return snapShot; |
70 |
|
|
71 |
|
} |
72 |
|
|
73 |
|
public static Set getApplicationNames(){ |
74 |
0 |
return getCollector().getApplicationNames(); |
75 |
|
} |
76 |
|
|
77 |
|
public static Set getInstanceNames(Set applicationNames){ |
78 |
0 |
return getCollector().getInstanceNames(applicationNames); |
79 |
|
} |
80 |
|
|
81 |
|
public static void setCollector(Collector collectorImpl){ |
82 |
0 |
collector = collectorImpl; |
83 |
0 |
} |
84 |
|
|
85 |
|
public static Collector getCollector(){ |
86 |
0 |
if(collector == null){ |
87 |
0 |
logger.error("Collector has not been initialized."); |
88 |
0 |
throw new RuntimeException("Collector has not been initialized"); |
89 |
|
} |
90 |
0 |
return collector; |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
} |