blob: b3c24dee8d63112b18c895080bb57a14919cb330 [file] [log] [blame]
Sean Condon0e89bda2017-03-21 14:23:19 +00001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.net.l2monitoring.cfm;
17
18import java.time.Duration;
19import java.util.Collection;
20
21import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
22import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
23import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
24import org.onosproject.net.NetworkResource;
25
26/**
27 * A model of the Maintenance Association.
28 *
29 * See IEEE 802.1Q Section 12.14 CFM entities
30 * Direct child of {@link org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain}
31 */
32public interface MaintenanceAssociation extends NetworkResource {
33 /**
34 * Get the ID of the Maintenance Association.
35 * @return The id object
36 */
37 MaIdShort maId();
38
39 /**
40 * Get the CCM interval for the Maintenance Association.
41 * @return An enumerated value
42 */
43 CcmInterval ccmInterval();
44
45 /**
46 * A list of components each of which can be managed in a manner essentially equivalent to an 802.1Q bridge.
47 * @return A collection of Components
48 */
49 Collection<Component> componentList();
50
51 /**
52 * Create a new component collection.
53 * @param componentList A collection of component objects
54 * @return A new Maintenance Association
55 */
56 MaintenanceAssociation withComponentList(Collection<Component> componentList);
57
58 /**
59 * Get the list of the Remote Mep Ids.
60 * @return A list of Remote Mep Ids
61 */
62 Collection<MepId> remoteMepIdList();
63
64 /**
65 * Create a new Maintenance Association from the current with the specified RemoteMepId list.
66 * @param remoteMepIdList A list of RemoteMepIds
67 * @return A new Maintenance Association
68 */
69 MaintenanceAssociation withRemoteMepIdList(Collection<MepId> remoteMepIdList);
70
71 /**
72 * Numeric identifier.
73 * Some systems require to have a placeholder for a numeric identifier in
74 * addition to the MaId
75 * @return A short numeric id that's been assigned to the MA
76 */
77 short maNumericId();
78
79 /**
80 * Enumerated values from IEEE 802.1Q Table 21-16—CCM Interval field encoding.
81 */
82 public enum CcmInterval {
83 INVALID(0),
84 INTERVAL_3MS(3),
85 INVERVAL_10MS(10),
86 INVERVAL_100MS(100),
87 INTERVAL_1S(1000),
88 INTERVAL_10S(10000),
89 INTERVAL_1MIN(60000),
90 INTERVAL_10MIN(600000);
91
92 private final int millis;
93
94 CcmInterval(int millis) {
95 this.millis = millis;
96 }
97
98 public int millis() {
99 return millis;
100 }
101
102 public Duration duration() {
103 return Duration.ofMillis(millis);
104 }
105 }
106
107 /**
108 * Builder for {@link org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation}.
109 */
110 interface MaBuilder {
111
112 MaBuilder ccmInterval(CcmInterval ccmInterval);
113
114 MaBuilder addToRemoteMepIdList(MepId remoteMep);
115
116 MaBuilder addToComponentList(Component component);
117
118 MaBuilder maNumericId(short maNumericId);
119
120 MaintenanceAssociation build() throws CfmConfigException;
121 }
122}