blob: 9be6809548e3902ac2038dd6d267ca5b1400de8e [file] [log] [blame]
Jonathan Hart96c5a4a2015-07-31 14:23:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jonathan Hart96c5a4a2015-07-31 14:23:33 -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 */
16package org.onosproject.net.intent.constraint;
17
Jonathan Hart96c5a4a2015-07-31 14:23:33 -070018import org.onosproject.net.intent.ConnectivityIntent;
Jonathan Hart96c5a4a2015-07-31 14:23:33 -070019import org.onosproject.net.intent.Intent;
Jonathan Hart96c5a4a2015-07-31 14:23:33 -070020
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 HIGUCHIe37560f2017-02-02 19:53:26 -080026public final class PartialFailureConstraint extends MarkerConstraint {
Jonathan Hart96c5a4a2015-07-31 14:23:33 -070027
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 HIGUCHId0598ee2016-12-20 18:11:34 -080036
37 @Override
38 public String toString() {
39 return "PartialFailureConstraint";
40 }
Jonathan Hart96c5a4a2015-07-31 14:23:33 -070041}