Jonathan Hart | 96c5a4a | 2015-07-31 14:23:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Jonathan Hart | 96c5a4a | 2015-07-31 14:23:33 -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 | package org.onosproject.net.intent.constraint; |
| 17 | |
Jonathan Hart | 96c5a4a | 2015-07-31 14:23:33 -0700 | [diff] [blame] | 18 | import org.onosproject.net.intent.ConnectivityIntent; |
Jonathan Hart | 96c5a4a | 2015-07-31 14:23:33 -0700 | [diff] [blame] | 19 | import org.onosproject.net.intent.Intent; |
Jonathan Hart | 96c5a4a | 2015-07-31 14:23:33 -0700 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * A constraint that allows intents that can only be partially compiled |
| 23 | * (i.e. MultiPointToSinglePointIntent or SinglePointToMultiPointIntent) |
| 24 | * to be installed when some endpoints or paths are not found. |
| 25 | */ |
Yuta HIGUCHI | e37560f | 2017-02-02 19:53:26 -0800 | [diff] [blame] | 26 | public final class PartialFailureConstraint extends MarkerConstraint { |
Jonathan Hart | 96c5a4a | 2015-07-31 14:23:33 -0700 | [diff] [blame] | 27 | |
| 28 | public static boolean intentAllowsPartialFailure(Intent intent) { |
| 29 | if (intent instanceof ConnectivityIntent) { |
| 30 | ConnectivityIntent connectivityIntent = (ConnectivityIntent) intent; |
| 31 | return connectivityIntent.constraints().stream() |
| 32 | .anyMatch(c -> c instanceof PartialFailureConstraint); |
| 33 | } |
| 34 | return false; |
| 35 | } |
Yuta HIGUCHI | d0598ee | 2016-12-20 18:11:34 -0800 | [diff] [blame] | 36 | |
| 37 | @Override |
| 38 | public String toString() { |
| 39 | return "PartialFailureConstraint"; |
| 40 | } |
Jonathan Hart | 96c5a4a | 2015-07-31 14:23:33 -0700 | [diff] [blame] | 41 | } |