Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.segmentrouting.grouphandler; |
| 18 | |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
| 20 | |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 21 | /** |
Saurav Das | c88d466 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 22 | * Extends its super class modifying its internal behavior. |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 23 | * Pick a neighbor will pick a random neighbor. |
| 24 | */ |
Saurav Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 25 | public class RandomDestinationSet extends DestinationSet { |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 26 | |
Saurav Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 27 | public RandomDestinationSet(DeviceId dstSw) { |
| 28 | super(true, dstSw); |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Saurav Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 31 | public RandomDestinationSet(int edgeLabel, |
Saurav Das | c88d466 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 32 | DeviceId dstSw) { |
Saurav Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 33 | super(true, edgeLabel, dstSw); |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Saurav Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 36 | public RandomDestinationSet() { |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 37 | super(); |
| 38 | } |
| 39 | |
Saurav Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 40 | // 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 Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 45 | 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 Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 52 | }*/ |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 53 | |
| 54 | @Override |
| 55 | public String toString() { |
Saurav Das | 7bcbe70 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 56 | return " RandomNeighborset Sw: " //+ getDeviceIds() |
| 57 | + " and Label: " //+ getEdgeLabel() |
| 58 | + " for destination: "; // + getDestinationSw(); |
Pier Ventre | 917127a | 2016-10-31 16:49:19 -0700 | [diff] [blame] | 59 | } |
| 60 | } |