blob: 5c7f1d391d8f300e1ef5cdb64de33f2d79f28d76 [file] [log] [blame]
Charles Chanf7b1b4b2019-01-16 15:30:39 -08001/*
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
17package org.onosproject.portloadbalancer.api;
18
19import org.onosproject.core.ApplicationId;
20import org.onosproject.event.ListenerService;
21
22import java.util.Map;
23
24/**
25 * Port load balance service.
26 */
27public interface PortLoadBalancerService extends ListenerService<PortLoadBalancerEvent, PortLoadBalancerListener> {
28 /**
29 * Gets all port load balancers from the store.
30 *
31 * @return port load balancer ID and port load balancer information mapping
32 */
33 Map<PortLoadBalancerId, PortLoadBalancer> getPortLoadBalancers();
34
35 /**
36 * Gets port load balancer that matches given device ID and key, or null if not found.
37 *
38 * @param portLoadBalancerId port load balancer id
39 * @return port load balancer information
40 */
41 PortLoadBalancer getPortLoadBalancer(PortLoadBalancerId portLoadBalancerId);
42
43 /**
44 * Gets the mapping between port load balancer id and
45 * the next objective id that represents the port load balancer.
46 *
47 * @return port load balancer id and next id mapping
48 */
49 Map<PortLoadBalancerId, Integer> getPortLoadBalancerNexts();
50
51 /**
52 * Gets port load balancer next id that matches given device Id and key, or null if not found.
53 *
54 * @param portLoadBalancerId port load balancer id
55 * @return next ID
56 */
57 int getPortLoadBalancerNext(PortLoadBalancerId portLoadBalancerId);
58
59 /**
60 * Reserves a port load balancer. Only one application
61 * at time can reserve a given port load balancer.
62 *
63 * @param portLoadBalancerId the port load balancer id
64 * @param appId the application id
65 * @return true if reservation was successful false otherwise
66 */
67 boolean reserve(PortLoadBalancerId portLoadBalancerId, ApplicationId appId);
68
69 /**
70 * Releases a port load balancer. Once released
71 * by the owner the port load balancer is eligible
72 * for removal.
73 *
74 * @param portLoadBalancerId the port load balancer id
75 * @param appId the application id
76 * @return true if release was successful false otherwise
77 */
78 boolean release(PortLoadBalancerId portLoadBalancerId, ApplicationId appId);
79
80 /**
81 * Gets reservation of a port load balancer. Only one application
82 * at time can reserve a given port load balancer.
83 *
84 * @param portLoadBalancerId the port load balancer id
85 * @return the id of the application using the port load balancer
86 */
87 ApplicationId getReservation(PortLoadBalancerId portLoadBalancerId);
88
89 /**
90 * Gets port load balancer reservations. Only one application
91 * at time can reserve a given port load balancer.
92 *
93 * @return reservations of the port load balancer resources
94 */
95 Map<PortLoadBalancerId, ApplicationId> getReservations();
96
97}