blob: 3a5bf22e7010f1351bdc8be3f2701a3bfa94bbc1 [file] [log] [blame]
slowrdb071b22017-07-07 11:10:25 -07001/*
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -07002 * Copyright 2017-present Open Networking Foundation
slowrdb071b22017-07-07 11:10:25 -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 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070016package org.onosproject.artemis;
slowrdb071b22017-07-07 11:10:25 -070017
18import org.onlab.packet.IpPrefix;
19
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070020import java.util.Arrays;
21import java.util.Optional;
22
slowrdb071b22017-07-07 11:10:25 -070023/**
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070024 * Interface for Monitors.
slowrdb071b22017-07-07 11:10:25 -070025 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070026public interface Monitors {
slowrdb071b22017-07-07 11:10:25 -070027 /**
28 * Get prefix of the specific monitor.
29 *
30 * @return prefix
31 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070032 IpPrefix getPrefix();
slowrdb071b22017-07-07 11:10:25 -070033
34 /**
35 * Set prefix for monitor.
36 *
37 * @param prefix prefix
38 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070039 void setPrefix(IpPrefix prefix);
slowrdb071b22017-07-07 11:10:25 -070040
41 /**
42 * Start monitor to begin capturing incoming BGP packets.
43 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070044 void startMonitor();
slowrdb071b22017-07-07 11:10:25 -070045
46 /**
47 * Stop monitor from capturing incoming BGP packets.
48 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070049 void stopMonitor();
slowrdb071b22017-07-07 11:10:25 -070050
51 /**
52 * Check if monitor is running.
53 *
54 * @return true if running
55 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070056 boolean isRunning();
slowrdb071b22017-07-07 11:10:25 -070057
58 /**
59 * Get host alias e.g. IP address, name.
60 *
61 * @return host alias
62 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070063 String getHost();
slowrdb071b22017-07-07 11:10:25 -070064
65 /**
66 * Set alias of host.
67 *
68 * @param host alias
69 */
Dimitrios Mavrommatisf0c06322017-10-31 23:49:04 -070070 void setHost(String host);
71
72 /**
73 * Match enum type with monitor type inside configuration to map them.
74 */
75 enum Types {
76 RIPE("ripe") {
77 @Override
78 public String toString() {
79 return "ripe";
80 }
81 },
82 EXABGP("exabgp") {
83 @Override
84 public String toString() {
85 return "exabgp";
86 }
87 };
88
89 private String name;
90
91 Types(String name) {
92 this.name = name;
93 }
94
95 public static Types getEnum(String name) {
96 Optional<Types> any = Arrays.stream(Types.values()).filter(typeStr -> typeStr.name.equals(name)).findAny();
97 if (any.isPresent()) {
98 return any.get();
99 }
100 throw new IllegalArgumentException("No enum defined for string: " + name);
101 }
102 }
slowrdb071b22017-07-07 11:10:25 -0700103}