jiangrui
Committed by Gerrit Code Review

[ONOS-2753]: add vtnRsc event, listenner and feedback

Change-Id: I3a2054daa4b0e72ed1225be856a0321adbd4b504
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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.vtnrsc.event;
17 +
18 +import org.onosproject.event.AbstractEvent;
19 +
20 +
21 +/**
22 + * Describes network vtnrsc event.
23 + */
24 +public class VtnRscEvent
25 + extends AbstractEvent<VtnRscEvent.Type, VtnRscEventFeedback> {
26 +
27 + /**
28 + * Type of vtnrsc events.
29 + */
30 + public enum Type {
31 + /**
32 + * Signifies that floating IP has create.
33 + */
34 + FLOATINGIP_PUT,
35 + /**
36 + * Signifies that floating IP has delete.
37 + */
38 + FLOATINGIP_DELETE,
39 + /**
40 + * Signifies that router has create.
41 + */
42 + ROUTER_PUT,
43 + /**
44 + * Signifies that router has delete.
45 + */
46 + ROUTER_DELETE,
47 + /**
48 + * Signifies that router interface has add.
49 + */
50 + ROUTER_INTERFACE_PUT,
51 + /**
52 + * Signifies that router interface has remove.
53 + */
54 + ROUTER_INTERFACE_DELETE
55 + }
56 +
57 + /**
58 + * Creates an event of a given type and for the specified vtn event feedback.
59 + *
60 + * @param type Vtnrsc event type
61 + * @param vtnFeedback event VtnrscEventFeedback subject
62 + */
63 + public VtnRscEvent(Type type, VtnRscEventFeedback vtnFeedback) {
64 + super(type, vtnFeedback);
65 + }
66 +
67 + /**
68 + * Creates an event of a given type and for the specified vtn event feedback.
69 + *
70 + * @param type Vtnrsc event type
71 + * @param vtnFeedback event VtnrscEventFeedback subject
72 + * @param time occurrence time
73 + */
74 + public VtnRscEvent(Type type, VtnRscEventFeedback vtnFeedback, long time) {
75 + super(type, vtnFeedback, time);
76 + }
77 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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.vtnrsc.event;
17 +
18 +import java.util.Objects;
19 +
20 +import org.onosproject.vtnrsc.FloatingIp;
21 +import org.onosproject.vtnrsc.Router;
22 +import org.onosproject.vtnrsc.RouterInterface;
23 +
24 +import static com.google.common.base.MoreObjects.toStringHelper;
25 +import static com.google.common.base.Preconditions.checkNotNull;
26 +
27 +/**
28 + * Representation of a VtnRsc event feedback.
29 + */
30 +public class VtnRscEventFeedback {
31 + private final FloatingIp floaingtIp;
32 + private final Router router;
33 + private final RouterInterface routerInterface;
34 +
35 + /**
36 + * Creates VtnRscEventFeedback object.
37 + *
38 + * @param floatingIp the floating Ip
39 + */
40 + public VtnRscEventFeedback(FloatingIp floatingIp) {
41 + this.floaingtIp = checkNotNull(floatingIp, "floaintIp cannot be null");
42 + this.router = null;
43 + this.routerInterface = null;
44 + }
45 +
46 + /**
47 + * Creates VtnRscEventFeedback object.
48 + *
49 + * @param router the router
50 + */
51 + public VtnRscEventFeedback(Router router) {
52 + this.floaingtIp = null;
53 + this.router = checkNotNull(router, "router cannot be null");
54 + this.routerInterface = null;
55 + }
56 +
57 + /**
58 + * Creates VtnRscEventFeedback object.
59 + *
60 + * @param routerInterface the router interface
61 + */
62 + public VtnRscEventFeedback(RouterInterface routerInterface) {
63 + this.floaingtIp = null;
64 + this.router = null;
65 + this.routerInterface = checkNotNull(routerInterface,
66 + "routerInterface cannot be null");
67 + }
68 +
69 + /**
70 + * Returns floating IP.
71 + *
72 + * @return floaingtIp the floating IP
73 + */
74 + public FloatingIp floatingIp() {
75 + return floaingtIp;
76 + }
77 +
78 + /**
79 + * Returns router.
80 + *
81 + * @return router the router
82 + */
83 + public Router router() {
84 + return router;
85 + }
86 +
87 + /**
88 + * Returns router interface.
89 + *
90 + * @return routerInterface the router interface
91 + */
92 + public RouterInterface routerInterface() {
93 + return routerInterface;
94 + }
95 +
96 + @Override
97 + public int hashCode() {
98 + return Objects.hash(floaingtIp, router, routerInterface);
99 + }
100 +
101 + @Override
102 + public boolean equals(Object obj) {
103 + if (this == obj) {
104 + return true;
105 + }
106 + if (obj instanceof VtnRscEventFeedback) {
107 + final VtnRscEventFeedback that = (VtnRscEventFeedback) obj;
108 + return Objects.equals(this.floaingtIp, that.floaingtIp)
109 + && Objects.equals(this.router, that.router)
110 + && Objects.equals(this.routerInterface, that.routerInterface);
111 + }
112 + return false;
113 + }
114 +
115 + @Override
116 + public String toString() {
117 + return toStringHelper(this)
118 + .add("router", router)
119 + .add("floaingtIp", floaingtIp)
120 + .add("routerInterface", routerInterface)
121 + .toString();
122 + }
123 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 +
17 +package org.onosproject.vtnrsc.event;
18 +
19 +import org.onosproject.event.EventListener;
20 +
21 +/**
22 + * Entity capable of VtnRsc related events.
23 + */
24 +public interface VtnRscListener extends EventListener<VtnRscEvent> {
25 +
26 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 +
17 +/**
18 + * Event of VtnRsc for VtnRsc service.
19 + */
20 +package org.onosproject.vtnrsc.event;