Committed by
Gerrit Code Review
Move OmsPortHelper annotation keys to OpticalAnnotations
Change-Id: I80ad924a8dfde61ac2fbc1d9836d3f145bfc48dc
Showing
2 changed files
with
32 additions
and
21 deletions
... | @@ -26,12 +26,32 @@ public final class OpticalAnnotations { | ... | @@ -26,12 +26,32 @@ public final class OpticalAnnotations { |
26 | private OpticalAnnotations() {} | 26 | private OpticalAnnotations() {} |
27 | 27 | ||
28 | /** | 28 | /** |
29 | + * Annotation key for mininum frequency in Hz. | ||
30 | + * Value is expected to be an integer. | ||
31 | + */ | ||
32 | + public static final String MIN_FREQ_HZ = "minFrequency"; | ||
33 | + | ||
34 | + /** | ||
35 | + * Annotation key for maximum frequency in Hz. | ||
36 | + * Value is expected be an integer. | ||
37 | + */ | ||
38 | + public static final String MAX_FREQ_HZ = "maxFrequency"; | ||
39 | + | ||
40 | + /** | ||
41 | + * Annotation key for grid in Hz. | ||
42 | + * Value is expected to be an integer. | ||
43 | + */ | ||
44 | + public static final String GRID_HZ = "grid"; | ||
45 | + | ||
46 | + /** | ||
29 | * Annotation key for optical port's target power. | 47 | * Annotation key for optical port's target power. |
48 | + * Value is expected to be an integer. | ||
30 | */ | 49 | */ |
31 | public static final String TARGET_POWER = "targetPower"; | 50 | public static final String TARGET_POWER = "targetPower"; |
32 | 51 | ||
33 | /** | 52 | /** |
34 | * Annotation key for optical port's current power. | 53 | * Annotation key for optical port's current power. |
54 | + * Value is expected to be an integer. | ||
35 | */ | 55 | */ |
36 | public static final String CURRENT_POWER = "currentPower"; | 56 | public static final String CURRENT_POWER = "currentPower"; |
37 | 57 | ||
... | @@ -42,6 +62,7 @@ public final class OpticalAnnotations { | ... | @@ -42,6 +62,7 @@ public final class OpticalAnnotations { |
42 | 62 | ||
43 | /** | 63 | /** |
44 | * Annotation key for optical port's neighbor's PortNumber#toString(). | 64 | * Annotation key for optical port's neighbor's PortNumber#toString(). |
65 | + * Value is expected to be an integer. | ||
45 | */ | 66 | */ |
46 | public static final String NEIGHBOR_PORT = "neighborPort"; | 67 | public static final String NEIGHBOR_PORT = "neighborPort"; |
47 | } | 68 | } | ... | ... |
... | @@ -29,6 +29,7 @@ import org.onosproject.net.DefaultAnnotations.Builder; | ... | @@ -29,6 +29,7 @@ import org.onosproject.net.DefaultAnnotations.Builder; |
29 | import org.onosproject.net.device.DefaultPortDescription; | 29 | import org.onosproject.net.device.DefaultPortDescription; |
30 | import org.onosproject.net.device.PortDescription; | 30 | import org.onosproject.net.device.PortDescription; |
31 | import org.onosproject.net.optical.OmsPort; | 31 | import org.onosproject.net.optical.OmsPort; |
32 | +import org.onosproject.net.optical.OpticalAnnotations; | ||
32 | import org.onosproject.net.optical.impl.DefaultOmsPort; | 33 | import org.onosproject.net.optical.impl.DefaultOmsPort; |
33 | import org.slf4j.Logger; | 34 | import org.slf4j.Logger; |
34 | 35 | ||
... | @@ -43,20 +44,6 @@ public final class OmsPortHelper { | ... | @@ -43,20 +44,6 @@ public final class OmsPortHelper { |
43 | 44 | ||
44 | private static final Logger log = getLogger(OmsPortHelper.class); | 45 | private static final Logger log = getLogger(OmsPortHelper.class); |
45 | 46 | ||
46 | - // Annotation keys | ||
47 | - /** | ||
48 | - * minFrequency in Hz. | ||
49 | - */ | ||
50 | - private static final String MIN_FREQ_HZ = "minFrequency"; | ||
51 | - /** | ||
52 | - * maxFrequency in Hz. | ||
53 | - */ | ||
54 | - private static final String MAX_FREQ_HZ = "maxFrequency"; | ||
55 | - /** | ||
56 | - * grid in Hz. | ||
57 | - */ | ||
58 | - private static final String GRID_HZ = "grid"; | ||
59 | - | ||
60 | /** | 47 | /** |
61 | * Creates OMS port description based on the supplied information. | 48 | * Creates OMS port description based on the supplied information. |
62 | * | 49 | * |
... | @@ -78,9 +65,9 @@ public final class OmsPortHelper { | ... | @@ -78,9 +65,9 @@ public final class OmsPortHelper { |
78 | Builder builder = DefaultAnnotations.builder(); | 65 | Builder builder = DefaultAnnotations.builder(); |
79 | builder.putAll(annotations); | 66 | builder.putAll(annotations); |
80 | 67 | ||
81 | - builder.set(MIN_FREQ_HZ, String.valueOf(minFrequency.asHz())); | 68 | + builder.set(OpticalAnnotations.MIN_FREQ_HZ, String.valueOf(minFrequency.asHz())); |
82 | - builder.set(MAX_FREQ_HZ, String.valueOf(maxFrequency.asHz())); | 69 | + builder.set(OpticalAnnotations.MAX_FREQ_HZ, String.valueOf(maxFrequency.asHz())); |
83 | - builder.set(GRID_HZ, String.valueOf(grid.asHz())); | 70 | + builder.set(OpticalAnnotations.GRID_HZ, String.valueOf(grid.asHz())); |
84 | 71 | ||
85 | long portSpeed = 0; | 72 | long portSpeed = 0; |
86 | return new DefaultPortDescription(number, isEnabled, Port.Type.OMS, portSpeed, builder.build()); | 73 | return new DefaultPortDescription(number, isEnabled, Port.Type.OMS, portSpeed, builder.build()); |
... | @@ -133,9 +120,9 @@ public final class OmsPortHelper { | ... | @@ -133,9 +120,9 @@ public final class OmsPortHelper { |
133 | try { | 120 | try { |
134 | Annotations an = port.annotations(); | 121 | Annotations an = port.annotations(); |
135 | 122 | ||
136 | - Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(MIN_FREQ_HZ))); | 123 | + Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MIN_FREQ_HZ))); |
137 | - Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(MAX_FREQ_HZ))); | 124 | + Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MAX_FREQ_HZ))); |
138 | - Frequency grid = Frequency.ofHz(Long.parseLong(an.value(GRID_HZ))); | 125 | + Frequency grid = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.GRID_HZ))); |
139 | 126 | ||
140 | return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid)); | 127 | return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid)); |
141 | 128 | ||
... | @@ -153,7 +140,10 @@ public final class OmsPortHelper { | ... | @@ -153,7 +140,10 @@ public final class OmsPortHelper { |
153 | * @return filtered view of given {@link Annotations} | 140 | * @return filtered view of given {@link Annotations} |
154 | */ | 141 | */ |
155 | public static Annotations stripHandledAnnotations(Annotations input) { | 142 | public static Annotations stripHandledAnnotations(Annotations input) { |
156 | - return new FilteredAnnotation(input, ImmutableSet.of(MIN_FREQ_HZ, MAX_FREQ_HZ, GRID_HZ)); | 143 | + return new FilteredAnnotation(input, ImmutableSet.of( |
144 | + OpticalAnnotations.MIN_FREQ_HZ, | ||
145 | + OpticalAnnotations.MAX_FREQ_HZ, | ||
146 | + OpticalAnnotations.GRID_HZ)); | ||
157 | } | 147 | } |
158 | 148 | ||
159 | // not meant to be instantiated | 149 | // not meant to be instantiated | ... | ... |
-
Please register or login to post a comment