1 | package de.uka.ipd.sdq.simucomframework.probes; |
2 | |
3 | import javax.measure.Measure; |
4 | import javax.measure.quantity.Dimensionless; |
5 | |
6 | import de.uka.ipd.sdq.probespec.framework.ProbeSample; |
7 | import de.uka.ipd.sdq.probespec.framework.ProbeType; |
8 | import de.uka.ipd.sdq.probespec.framework.probes.IProbeStrategy; |
9 | import de.uka.ipd.sdq.simucomframework.resources.AbstractScheduledResource; |
10 | |
11 | /** |
12 | * ProbeStrategy which is able to measure the state of a |
13 | * {@link AbstractScheduledResource}. The state is the total job count of the |
14 | * resource. |
15 | * |
16 | * @author Philipp Merkle |
17 | * |
18 | */ |
19 | public class TakeScheduledResourceStateStrategy implements IProbeStrategy { |
20 | |
21 | /** |
22 | * @param o |
23 | * expects a {@link Integer} representing the resource state |
24 | */ |
25 | public ProbeSample<Integer, Dimensionless> takeSample(String probeId, |
26 | Object... o) { |
27 | Integer state = null; |
28 | if (o.length >= 1 && o[0] instanceof Integer) { |
29 | state = (Integer) o[0]; |
30 | } else { |
31 | throw new IllegalArgumentException("Expected an argument of type " |
32 | + Integer.class.getSimpleName() + "."); |
33 | } |
34 | |
35 | Measure<Integer, Dimensionless> stateMeasure = Measure.valueOf(state, |
36 | Dimensionless.UNIT); |
37 | ProbeSample<Integer, Dimensionless> sample = new ProbeSample<Integer, Dimensionless>( |
38 | stateMeasure, probeId, ProbeType.RESOURCE_STATE); |
39 | |
40 | return sample; |
41 | } |
42 | |
43 | } |