blob: b9d106d793ca673131fa679d243856d052b5d77c [file] [log] [blame]
Seyeon Jeong357bcec2020-02-28 01:17:34 -08001/*
2 * Copyright 2020-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 */
16
17package org.onosproject.t3.api;
18
19import com.google.common.collect.ImmutableMap;
20import com.google.common.collect.ImmutableSet;
21import org.onosproject.mcast.api.McastRoute;
22import org.onosproject.mcast.api.McastRouteData;
23
24import java.util.Map;
25import java.util.Set;
26
27/**
28 * Represents Network Information Base (NIB) for multicast routes
29 * and supports alternative functions to
30 * {@link org.onosproject.mcast.api.MulticastRouteService} for offline data.
31 */
32public class MulticastRouteNib {
33
34 private Map<McastRoute, McastRouteData> mcastRoutes;
35
36 // use the singleton helper to create the instance
37 protected MulticastRouteNib() {
38 }
39
40 public void setMcastRoutes(Map<McastRoute, McastRouteData> mcastRoutes) {
41 this.mcastRoutes = mcastRoutes;
42 }
43
44 public Map<McastRoute, McastRouteData> getMcastRoutes() {
45 return ImmutableMap.copyOf(mcastRoutes);
46 }
47
48 /**
49 * Gets all Multicast routes in the system.
50 *
51 * @return set of Multicast routes
52 */
53 public Set<McastRoute> getRoutes() {
54 return ImmutableSet.copyOf(mcastRoutes.keySet());
55 }
56
57 /**
58 * Return the Multicast data for this route.
59 *
60 * @param route route
61 * @return the mcast route data
62 */
63 public McastRouteData routeData(McastRoute route) {
64 return mcastRoutes.get(route);
65 }
66
67 /**
68 * Returns the singleton instance of multicast routes NIB.
69 *
70 * @return instance of multicast routes NIB
71 */
72 public static MulticastRouteNib getInstance() {
73 return MulticastRouteNib.SingletonHelper.INSTANCE;
74 }
75
76 private static class SingletonHelper {
77 private static final MulticastRouteNib INSTANCE = new MulticastRouteNib();
78 }
79
80}