blob: bc870d3e657e4a284acf432aad08ea0312099007 [file] [log] [blame]
Andrea Campanella241896c2017-05-10 13:11:04 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Andrea Campanella241896c2017-05-10 13:11:04 -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 */
16
17package org.onosproject.net.device;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.MastershipRole;
21import org.onosproject.net.driver.DeviceConnect;
22
23import 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
30public interface DeviceHandshaker extends DeviceConnect {
31
32 /**
Carmelo Casconee5b28722018-06-22 17:28:28 +020033 * 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 Campanella241896c2017-05-10 13:11:04 -070036 *
37 * @return CompletableFuture eventually true if reachable, false otherwise
38 */
39 CompletableFuture<Boolean> isReachable();
40
41 /**
Carmelo Casconee5b28722018-06-22 17:28:28 +020042 * 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 Campanella241896c2017-05-10 13:11:04 -070045 *
Carmelo Casconee5b28722018-06-22 17:28:28 +020046 * @param newRole new mastership role
Andrea Campanella241896c2017-05-10 13:11:04 -070047 */
Carmelo Casconee5b28722018-06-22 17:28:28 +020048 void roleChanged(MastershipRole newRole);
Andrea Campanella241896c2017-05-10 13:11:04 -070049
Andrea Campanella1e573442018-05-17 17:07:13 +020050 /**
Carmelo Casconee5b28722018-06-22 17:28:28 +020051 * Adds a device agent listener.
Andrea Campanella1e573442018-05-17 17:07:13 +020052 *
Carmelo Casconee5b28722018-06-22 17:28:28 +020053 * @param listener device agent listener
Andrea Campanella1e573442018-05-17 17:07:13 +020054 */
Carmelo Casconee5b28722018-06-22 17:28:28 +020055 default void addDeviceAgentListener(DeviceAgentListener listener) {
56 throw new UnsupportedOperationException(
57 "Device agent listener registration not supported");
Andrea Campanella1e573442018-05-17 17:07:13 +020058 }
59
60 /**
Carmelo Casconee5b28722018-06-22 17:28:28 +020061 * Removes a device agent listener.
Andrea Campanella1e573442018-05-17 17:07:13 +020062 *
Carmelo Casconee5b28722018-06-22 17:28:28 +020063 * @param listener device agent listener
Andrea Campanella1e573442018-05-17 17:07:13 +020064 */
Carmelo Casconee5b28722018-06-22 17:28:28 +020065 default void removeDeviceAgentListener(DeviceAgentListener listener) {
66 throw new UnsupportedOperationException(
67 "Device agent listener removal not supported");
Andrea Campanella1e573442018-05-17 17:07:13 +020068 }
69
Andrea Campanella241896c2017-05-10 13:11:04 -070070}