blob: 3671b03e0e5a376dd6a2edd40a4e5624b5b65eba [file] [log] [blame]
Pier Ventre229fd0b2016-10-31 16:49:19 -07001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Pier Ventre229fd0b2016-10-31 16:49:19 -07003 *
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.segmentrouting.grouphandler;
18
Pier Ventre229fd0b2016-10-31 16:49:19 -070019import org.onosproject.net.DeviceId;
20
Pier Ventre229fd0b2016-10-31 16:49:19 -070021/**
Saurav Das62ae6792017-05-15 15:34:25 -070022 * Extends its super class modifying its internal behavior.
Pier Ventre229fd0b2016-10-31 16:49:19 -070023 * Pick a neighbor will pick a random neighbor.
24 */
Saurav Das261c3002017-06-13 15:35:54 -070025public class RandomDestinationSet extends DestinationSet {
Pier Ventre229fd0b2016-10-31 16:49:19 -070026
Saurav Das261c3002017-06-13 15:35:54 -070027 public RandomDestinationSet(DeviceId dstSw) {
28 super(true, dstSw);
Pier Ventre229fd0b2016-10-31 16:49:19 -070029 }
30
Saurav Das261c3002017-06-13 15:35:54 -070031 public RandomDestinationSet(int edgeLabel,
Saurav Das62ae6792017-05-15 15:34:25 -070032 DeviceId dstSw) {
Saurav Das261c3002017-06-13 15:35:54 -070033 super(true, edgeLabel, dstSw);
Pier Ventre229fd0b2016-10-31 16:49:19 -070034 }
35
Saurav Das261c3002017-06-13 15:35:54 -070036 public RandomDestinationSet() {
Pier Ventre229fd0b2016-10-31 16:49:19 -070037 super();
38 }
39
Saurav Das261c3002017-06-13 15:35:54 -070040 // XXX revisit the need for this class since neighbors no longer stored here
41 // will be handled when we fix pseudowires for dual-Tor scenarios
42
43
44 /*@Override
Pier Ventre229fd0b2016-10-31 16:49:19 -070045 public DeviceId getFirstNeighbor() {
46 if (getDeviceIds().isEmpty()) {
47 return DeviceId.NONE;
48 }
49 int size = getDeviceIds().size();
50 int index = RandomUtils.nextInt(0, size);
51 return Iterables.get(getDeviceIds(), index);
Saurav Das261c3002017-06-13 15:35:54 -070052 }*/
Pier Ventre229fd0b2016-10-31 16:49:19 -070053
54 @Override
55 public String toString() {
Saurav Das261c3002017-06-13 15:35:54 -070056 return " RandomNeighborset Sw: " //+ getDeviceIds()
57 + " and Label: " //+ getEdgeLabel()
58 + " for destination: "; // + getDestinationSw();
Pier Ventre229fd0b2016-10-31 16:49:19 -070059 }
60}