Charles Chan | 7f987c5 | 2018-07-31 18:22:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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 | |
| 17 | package org.onosproject.l2lb.api; |
| 18 | |
pier | ddc59d9 | 2018-11-20 15:06:43 +0100 | [diff] [blame^] | 19 | import org.onosproject.core.ApplicationId; |
Charles Chan | 7f987c5 | 2018-07-31 18:22:46 -0700 | [diff] [blame] | 20 | import org.onosproject.event.ListenerService; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | |
| 23 | import java.util.Map; |
| 24 | |
| 25 | /** |
| 26 | * L2 load balance service. |
| 27 | */ |
| 28 | public interface L2LbService extends ListenerService<L2LbEvent, L2LbListener> { |
| 29 | /** |
| 30 | * Gets all L2 load balancers from the store. |
| 31 | * |
| 32 | * @return L2 load balancer ID and L2 load balancer information mapping |
| 33 | */ |
| 34 | Map<L2LbId, L2Lb> getL2Lbs(); |
| 35 | |
| 36 | /** |
| 37 | * Gets L2 load balancer that matches given device ID and key, or null if not found. |
| 38 | * |
| 39 | * @param deviceId Device ID |
| 40 | * @param key L2 load balancer key |
| 41 | * @return L2 load balancer information |
| 42 | */ |
| 43 | L2Lb getL2Lb(DeviceId deviceId, int key); |
| 44 | |
| 45 | /** |
| 46 | * Gets L2 load balancer next ids from the store. |
| 47 | * |
| 48 | * @return L2 load balancer id and next id mapping |
| 49 | */ |
| 50 | Map<L2LbId, Integer> getL2LbNexts(); |
| 51 | |
| 52 | /** |
| 53 | * Gets L2 load balancer next id that matches given device Id and key, or null if not found. |
| 54 | * |
| 55 | * @param deviceId Device ID |
| 56 | * @param key L2 load balancer key |
| 57 | * @return next ID |
| 58 | */ |
| 59 | int getL2LbNexts(DeviceId deviceId, int key); |
pier | ddc59d9 | 2018-11-20 15:06:43 +0100 | [diff] [blame^] | 60 | |
| 61 | /** |
| 62 | * Reserves a l2 load balancer. Only one application |
| 63 | * at time can reserve a given l2 load balancer. |
| 64 | * |
| 65 | * @param l2LbId the l2 load balancer id |
| 66 | * @param appId the application id |
| 67 | * @return true if reservation was successful false otherwise |
| 68 | */ |
| 69 | boolean reserve(L2LbId l2LbId, ApplicationId appId); |
| 70 | |
| 71 | /** |
| 72 | * Releases a l2 load balancer. Once released |
| 73 | * by the owner the l2 load balancer is eligible |
| 74 | * for removal. |
| 75 | * |
| 76 | * @param l2LbId the l2 load balancer id |
| 77 | * @param appId the application id |
| 78 | * @return true if release was successful false otherwise |
| 79 | */ |
| 80 | boolean release(L2LbId l2LbId, ApplicationId appId); |
| 81 | |
| 82 | /** |
| 83 | * Gets reservation of a l2 load balancer. Only one application |
| 84 | * at time can reserve a given l2 load balancer. |
| 85 | * |
| 86 | * @param l2LbId the l2 load balancer id |
| 87 | * @return the id of the application using the l2 load balancer |
| 88 | */ |
| 89 | ApplicationId getReservation(L2LbId l2LbId); |
| 90 | |
| 91 | /** |
| 92 | * Gets l2 load balancer reservations. Only one application |
| 93 | * at time can reserve a given l2 load balancer. |
| 94 | * |
| 95 | * @return reservations of the l2 load balancer resources |
| 96 | */ |
| 97 | Map<L2LbId, ApplicationId> getReservations(); |
| 98 | |
Charles Chan | 7f987c5 | 2018-07-31 18:22:46 -0700 | [diff] [blame] | 99 | } |