blob: 82fc40c22a4059d2353dc0c84db22f8c6ee4cb92 [file] [log] [blame]
Yi Tseng5f7fef52018-11-05 11:30:47 -08001/*
2 * Copyright 2018-present Open Networking Foundation
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
17package org.onosproject.drivers.gnmi;
18
19import org.onosproject.gnmi.api.GnmiClient;
20import org.onosproject.gnmi.api.GnmiController;
Carmelo Casconec2be50a2019-04-10 00:15:39 -070021import org.onosproject.grpc.utils.AbstractGrpcHandshaker;
Yi Tseng5f7fef52018-11-05 11:30:47 -080022import org.onosproject.net.MastershipRole;
23import org.onosproject.net.device.DeviceHandshaker;
24
25import java.util.concurrent.CompletableFuture;
26
27/**
28 * Implementation of DeviceHandshaker for gNMI.
29 */
Carmelo Casconec2be50a2019-04-10 00:15:39 -070030public class GnmiHandshaker
31 extends AbstractGrpcHandshaker<GnmiClient, GnmiController>
32 implements DeviceHandshaker {
Yi Tseng5f7fef52018-11-05 11:30:47 -080033
Carmelo Cascone3977ea42019-02-28 13:43:42 -080034
Carmelo Casconec2be50a2019-04-10 00:15:39 -070035 public GnmiHandshaker() {
36 super(GnmiController.class);
Carmelo Cascone3977ea42019-02-28 13:43:42 -080037 }
38
39 @Override
40 public boolean isAvailable() {
41 return isReachable();
42 }
43
44 @Override
45 public CompletableFuture<Boolean> probeAvailability() {
46 return probeReachability();
Yi Tseng5f7fef52018-11-05 11:30:47 -080047 }
48
49 @Override
50 public void roleChanged(MastershipRole newRole) {
51 throw new UnsupportedOperationException("Mastership operation not supported");
52 }
53
54 @Override
55 public MastershipRole getRole() {
56 throw new UnsupportedOperationException("Mastership operation not supported");
57 }
Yi Tseng5f7fef52018-11-05 11:30:47 -080058}