MCPcopy Create free account
hub / github.com/apache/sirona / Unit

Class Unit

api/src/main/java/org/apache/sirona/counters/Unit.java:37–214  ·  view source on GitHub ↗

Units allow monitored data to have get typed. A primary unit is the finest unit for a data type. A primary unit can have derived units, that represent the same data type, but with a scale factor. A primary Unit is created with the Unit#Unit(String) constructor. A derived Unit is created with

Source from the content-addressed store, hash-verified

35 *
36 */
37public class Unit implements Comparable<Unit>, Serializable {
38 private static final Map<String, Unit> UNITS = new ConcurrentHashMap<String, Unit>();
39
40 /**
41 * Time based units
42 */
43 public static class Time extends Unit {
44 public static final Unit NANOSECOND = new Unit("ns");
45 public static final Unit MICROSECOND = new Unit("us", NANOSECOND, 1000);
46 public static final Unit MILLISECOND = new Unit("ms", MICROSECOND, 1000);
47 public static final Unit SECOND = new Unit("s", MILLISECOND, 1000);
48 public static final Unit MINUTE = new Unit("min", SECOND, 60);
49 public static final Unit HOUR = new Unit("h", MINUTE, 60);
50 public static final Unit DAY = new Unit("day", HOUR, 24);
51
52 public Time(String name) {
53 super(name);
54 }
55
56 public Time(String name, Unit derived, long scale) {
57 super(name, derived, scale);
58 }
59
60 }
61
62 /**
63 * Binary data units
64 */
65 public static class Binary
66 extends Unit {
67
68 public static final Unit BYTE = new Unit("b");
69
70 public static final Unit KBYTE = new Unit("Kb", BYTE, 1024);
71
72 public static final Unit MBYTE = new Unit("Mb", KBYTE, 1024);
73
74 public static final Unit GBYTE = new Unit("Gb", MBYTE, 1024);
75
76 public Binary(String name) {
77 super(name);
78 }
79
80 public Binary(String name, Unit derived, long scale) {
81 super(name, derived, scale);
82 }
83
84
85 }
86
87 /**
88 * unit for basic item counters & gauges
89 */
90 // "BILLION" does not have same signification depending on country (10^12 or 10^9).
91 // We use International system of unit names to avoid confusion
92 // @see http://en.wikipedia.org/wiki/SI
93 public static final Unit UNARY = new Unit("u");
94 public static final Unit DECA = new Unit("*10", UNARY, 10);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected