blob: f30386db79ea1df7adaccf0247466b8a2ce0f097 [file] [log] [blame]
Andrea Campanella241896c2017-05-10 13:11:04 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-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 */
16package org.onosproject.net.driver;
17
18import com.google.common.annotations.Beta;
19
20import java.util.concurrent.CompletableFuture;
21
22/**
Carmelo Cascone9e4972c2018-08-30 00:29:16 -070023 * Abstraction of handler behaviour used to set-up and tear-down connections
24 * with a device.
Andrea Campanella241896c2017-05-10 13:11:04 -070025 */
26@Beta
27public interface DeviceConnect extends HandlerBehaviour {
28
29 /**
Carmelo Cascone9e4972c2018-08-30 00:29:16 -070030 * 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 Campanella241896c2017-05-10 13:11:04 -070036 *
37 * @return CompletableFuture with true if the operation was successful
38 */
39 CompletableFuture<Boolean> connect();
40
41 /**
Carmelo Cascone9e4972c2018-08-30 00:29:16 -070042 * 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 Campanella241896c2017-05-10 13:11:04 -070055 *
56 * @return CompletableFuture with true if the operation was successful
57 */
58 CompletableFuture<Boolean> disconnect();
59
60}