Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [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 | |
Carmelo Cascone | 39c28ca | 2017-11-15 13:03:57 -0800 | [diff] [blame] | 17 | package org.onosproject.net.pi.service; |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 18 | |
| 19 | import com.google.common.annotations.Beta; |
Carmelo Cascone | 75a9a89 | 2019-04-22 12:12:23 -0700 | [diff] [blame] | 20 | import org.onosproject.event.ListenerService; |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.pi.model.PiPipeconf; |
| 23 | import org.onosproject.net.pi.model.PiPipeconfId; |
| 24 | |
| 25 | import java.util.Optional; |
| 26 | |
| 27 | /** |
| 28 | * A service to manage the configurations of protocol-independent pipelines. |
| 29 | */ |
| 30 | @Beta |
Carmelo Cascone | 75a9a89 | 2019-04-22 12:12:23 -0700 | [diff] [blame] | 31 | public interface PiPipeconfService extends ListenerService<PiPipeconfEvent, PiPipeconfListener> { |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 32 | |
| 33 | // TODO: we might want to extend ListenerService to support the broadcasting of PipeconfEvent. |
| 34 | |
| 35 | /** |
Carmelo Cascone | 75a9a89 | 2019-04-22 12:12:23 -0700 | [diff] [blame] | 36 | * Registers the given pipeconf making it available to other subsystems. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 37 | * |
| 38 | * @param pipeconf a pipeconf |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 39 | * @throws IllegalStateException if the same pipeconf identifier is already |
| 40 | * registered. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 41 | */ |
| 42 | void register(PiPipeconf pipeconf) throws IllegalStateException; |
| 43 | |
| 44 | /** |
Carmelo Cascone | 75a9a89 | 2019-04-22 12:12:23 -0700 | [diff] [blame] | 45 | * Unregisters the given pipeconf. Once unregistered, other subsystems will |
| 46 | * not be able to access the pipeconf content. |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 47 | * |
| 48 | * @param pipeconfId a pipeconfId |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 49 | * @throws IllegalStateException if the same pipeconf identifier is already |
| 50 | * registered. |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 51 | */ |
Carmelo Cascone | 75a9a89 | 2019-04-22 12:12:23 -0700 | [diff] [blame] | 52 | void unregister(PiPipeconfId pipeconfId) throws IllegalStateException; |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 53 | |
| 54 | /** |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 55 | * Returns all pipeconfs registered. |
| 56 | * |
| 57 | * @return a collection of pipeconfs |
| 58 | */ |
| 59 | Iterable<PiPipeconf> getPipeconfs(); |
| 60 | |
| 61 | /** |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 62 | * Returns the pipeconf instance associated with the given identifier, if |
| 63 | * present. If not present, it means that no pipeconf with such identifier |
| 64 | * has been registered so far. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 65 | * |
| 66 | * @param id a pipeconf identifier |
| 67 | * @return an optional pipeconf |
| 68 | */ |
| 69 | Optional<PiPipeconf> getPipeconf(PiPipeconfId id); |
| 70 | |
| 71 | /** |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 72 | * Returns the pipeconf instance associated with the given device, if |
| 73 | * present. If not present, it means no pipeconf has been associated with |
| 74 | * that device so far. |
| 75 | * |
| 76 | * @param deviceId a device identifier |
| 77 | * @return an optional pipeconf |
| 78 | */ |
| 79 | Optional<PiPipeconf> getPipeconf(DeviceId deviceId); |
| 80 | |
| 81 | /** |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 82 | * Signals that the given pipeconf is associated to the given infrastructure |
| 83 | * device. As a result of this method, the pipeconf for the given device can |
| 84 | * be later retrieved using {@link #ofDevice(DeviceId)} |
| 85 | * |
| 86 | * @param pipeconfId a pipeconf identifier |
| 87 | * @param deviceId a device identifier |
| 88 | */ |
| 89 | void bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId); |
| 90 | |
| 91 | /** |
| 92 | * Returns the name of a driver that is equivalent to the base driver of the |
| 93 | * given device plus all the pipeline-specific behaviors exposed by the |
| 94 | * given pipeconf (previously registered using {@link |
| 95 | * #register(PiPipeconf)}). If such driver does not exist, this method |
| 96 | * creates one and registers is with all necessary ONOS subsystems, such |
| 97 | * that the returned name can be used to retrieve the driver instance using |
| 98 | * {@link org.onosproject.net.driver.DriverService#getDriver(String)}. |
| 99 | * <p> |
| 100 | * This method needs to be called on all nodes of the cluster that wants to |
| 101 | * use such merged driver. |
| 102 | * <p> |
| 103 | * Returns null if such merged driver cannot be created. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 104 | * |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 105 | * @param deviceId a device identifier |
Andrea Campanella | bc112a9 | 2017-06-26 19:06:43 +0200 | [diff] [blame] | 106 | * @param pipeconfId a pipeconf identifier |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 107 | * @return driver name or null. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 108 | */ |
Carmelo Cascone | 0761cd3 | 2018-08-29 19:22:50 -0700 | [diff] [blame] | 109 | String getMergedDriver(DeviceId deviceId, PiPipeconfId pipeconfId); |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 110 | |
| 111 | /** |
Carmelo Cascone | 158b8c4 | 2018-07-04 19:42:37 +0200 | [diff] [blame] | 112 | * Returns the pipeconf identifier currently associated with the given |
| 113 | * device identifier, if present. If not present, it means no pipeconf has |
| 114 | * been associated with that device so far. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 115 | * |
| 116 | * @param deviceId device identifier |
| 117 | * @return an optional pipeconf identifier |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 118 | * @deprecated in ONOS 2.1 use {@link #getPipeconf(DeviceId)} instead |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 119 | */ |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame] | 120 | @Deprecated |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 121 | Optional<PiPipeconfId> ofDevice(DeviceId deviceId); |
Andrea Campanella | f9c409a | 2017-07-13 14:14:41 +0200 | [diff] [blame] | 122 | |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 123 | } |