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 2015-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 | package org.onosproject.net.driver; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | |
| 20 | import java.util.concurrent.CompletableFuture; |
| 21 | |
| 22 | /** |
Carmelo Cascone | 9e4972c | 2018-08-30 00:29:16 -0700 | [diff] [blame] | 23 | * Abstraction of handler behaviour used to set-up and tear-down connections |
| 24 | * with a device. |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 25 | */ |
| 26 | @Beta |
| 27 | public interface DeviceConnect extends HandlerBehaviour { |
| 28 | |
| 29 | /** |
Carmelo Cascone | 9e4972c | 2018-08-30 00:29:16 -0700 | [diff] [blame] | 30 | * Connects to the device, for example by opening the transport session that |
| 31 | * will be later used to send control messages. Returns true if the |
| 32 | * connection was initiated successfully, false otherwise. |
| 33 | * <p> |
| 34 | * Calling multiple times this method while a connection to the device is |
| 35 | * open should result in a no-op. |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 36 | * |
| 37 | * @return CompletableFuture with true if the operation was successful |
| 38 | */ |
| 39 | CompletableFuture<Boolean> connect(); |
| 40 | |
| 41 | /** |
Carmelo Cascone | 9e4972c | 2018-08-30 00:29:16 -0700 | [diff] [blame] | 42 | * Returns true if a connection to the device is open, false otherwise. |
| 43 | * |
| 44 | * @return true if the connection is open, false otherwise |
| 45 | */ |
| 46 | boolean isConnected(); |
| 47 | |
| 48 | /** |
| 49 | * Disconnects from the device, for example closing the transport session |
| 50 | * previously opened. Returns true if the disconnection procedure was |
| 51 | * successful, false otherwise. |
| 52 | * <p> |
| 53 | * Calling multiple times this method while a connection to the device is |
| 54 | * closed should result in a no-op. |
Andrea Campanella | 241896c | 2017-05-10 13:11:04 -0700 | [diff] [blame] | 55 | * |
| 56 | * @return CompletableFuture with true if the operation was successful |
| 57 | */ |
| 58 | CompletableFuture<Boolean> disconnect(); |
| 59 | |
| 60 | } |