Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -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 | |
| 17 | package org.onosproject.net.device; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import org.onosproject.net.MastershipRole; |
| 21 | import org.onosproject.net.driver.DeviceConnect; |
| 22 | |
| 23 | import java.util.concurrent.CompletableFuture; |
| 24 | |
| 25 | /** |
| 26 | * Behavior to test device's reachability and change the mastership role on that |
| 27 | * device. |
| 28 | */ |
| 29 | @Beta |
| 30 | public interface DeviceHandshaker extends DeviceConnect { |
| 31 | |
| 32 | /** |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 33 | * Checks the reachability (connectivity) of a device. Reachability, unlike |
| 34 | * availability, denotes whether THIS particular node can send messages and |
| 35 | * receive replies from the specified device. |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 36 | * |
| 37 | * @return CompletableFuture eventually true if reachable, false otherwise |
| 38 | */ |
| 39 | CompletableFuture<Boolean> isReachable(); |
| 40 | |
| 41 | /** |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 42 | * Notifies the device a mastership role change as decided by the core. The |
| 43 | * implementation of this method should trigger a {@link DeviceAgentEvent} |
| 44 | * signaling the mastership role accepted by the device. |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 45 | * |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 46 | * @param newRole new mastership role |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 47 | */ |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 48 | void roleChanged(MastershipRole newRole); |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 49 | |
Andrea Campanella | 1e57344 | 2018-05-17 17:07:13 +0200 | [diff] [blame] | 50 | /** |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 51 | * Adds a device agent listener. |
Andrea Campanella | 1e57344 | 2018-05-17 17:07:13 +0200 | [diff] [blame] | 52 | * |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 53 | * @param listener device agent listener |
Andrea Campanella | 1e57344 | 2018-05-17 17:07:13 +0200 | [diff] [blame] | 54 | */ |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 55 | default void addDeviceAgentListener(DeviceAgentListener listener) { |
| 56 | throw new UnsupportedOperationException( |
| 57 | "Device agent listener registration not supported"); |
Andrea Campanella | 1e57344 | 2018-05-17 17:07:13 +0200 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /** |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 61 | * Removes a device agent listener. |
Andrea Campanella | 1e57344 | 2018-05-17 17:07:13 +0200 | [diff] [blame] | 62 | * |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 63 | * @param listener device agent listener |
Andrea Campanella | 1e57344 | 2018-05-17 17:07:13 +0200 | [diff] [blame] | 64 | */ |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 65 | default void removeDeviceAgentListener(DeviceAgentListener listener) { |
| 66 | throw new UnsupportedOperationException( |
| 67 | "Device agent listener removal not supported"); |
Andrea Campanella | 1e57344 | 2018-05-17 17:07:13 +0200 | [diff] [blame] | 68 | } |
| 69 | |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 70 | } |