Committed by
Gerrit Code Review
[ONOS-2594] Channel handle to manage session handling with BGP peers
Change-Id: I6c58c674aa17e2a86b063e248af589d524ec5fe3
Showing
10 changed files
with
281 additions
and
403 deletions
... | @@ -16,6 +16,9 @@ | ... | @@ -16,6 +16,9 @@ |
16 | 16 | ||
17 | package org.onosproject.bgp.controller; | 17 | package org.onosproject.bgp.controller; |
18 | 18 | ||
19 | +import java.util.Map; | ||
20 | + | ||
21 | +import org.onosproject.bgpio.exceptions.BGPParseException; | ||
19 | import org.onosproject.bgpio.protocol.BGPMessage; | 22 | import org.onosproject.bgpio.protocol.BGPMessage; |
20 | 23 | ||
21 | /** | 24 | /** |
... | @@ -52,8 +55,9 @@ public interface BGPController { | ... | @@ -52,8 +55,9 @@ public interface BGPController { |
52 | * | 55 | * |
53 | * @param bgpId id of the peer the message arrived on | 56 | * @param bgpId id of the peer the message arrived on |
54 | * @param msg the message to process. | 57 | * @param msg the message to process. |
58 | + * @throws BGPParseException on data processing error | ||
55 | */ | 59 | */ |
56 | - void processBGPPacket(BGPId bgpId, BGPMessage msg); | 60 | + void processBGPPacket(BGPId bgpId, BGPMessage msg) throws BGPParseException; |
57 | 61 | ||
58 | /** | 62 | /** |
59 | * Close all connected BGP peers. | 63 | * Close all connected BGP peers. |
... | @@ -73,5 +77,19 @@ public interface BGPController { | ... | @@ -73,5 +77,19 @@ public interface BGPController { |
73 | * | 77 | * |
74 | * @return the integer number | 78 | * @return the integer number |
75 | */ | 79 | */ |
76 | - int getBGPConnNumber(); | 80 | + int connectedPeerCount(); |
81 | + | ||
82 | + /** | ||
83 | + * Return BGP peer manager. | ||
84 | + * | ||
85 | + * @return BGPPeerManager peer manager instance | ||
86 | + */ | ||
87 | + BgpPeerManager peerManager(); | ||
88 | + | ||
89 | + /** | ||
90 | + * Return BGP connected peers. | ||
91 | + * | ||
92 | + * @return connectedPeers connected peers | ||
93 | + */ | ||
94 | + Map<BGPId, BGPPeer> connectedPeers(); | ||
77 | } | 95 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -16,30 +16,16 @@ | ... | @@ -16,30 +16,16 @@ |
16 | package org.onosproject.bgp.controller; | 16 | package org.onosproject.bgp.controller; |
17 | import java.util.List; | 17 | import java.util.List; |
18 | import org.jboss.netty.channel.Channel; | 18 | import org.jboss.netty.channel.Channel; |
19 | +import org.onosproject.bgpio.protocol.BGPFactory; | ||
19 | import org.onosproject.bgpio.protocol.BGPMessage; | 20 | import org.onosproject.bgpio.protocol.BGPMessage; |
20 | -import org.onosproject.bgpio.protocol.BGPVersion; | ||
21 | 21 | ||
22 | /** | 22 | /** |
23 | - * Represents the peer side of an bgp peer. | 23 | + * Represents the peer side of an BGP peer. |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | public interface BGPPeer { | 26 | public interface BGPPeer { |
27 | 27 | ||
28 | /** | 28 | /** |
29 | - * Sets the BGP version for this bgp peer. | ||
30 | - * | ||
31 | - * @param bgpVersion the version to set. | ||
32 | - */ | ||
33 | - void setBgpPeerVersion(BGPVersion bgpVersion); | ||
34 | - | ||
35 | - /** | ||
36 | - * Gets the BGP version for this bgp peer. | ||
37 | - * | ||
38 | - * @return bgp identifier. | ||
39 | - */ | ||
40 | - int getBgpPeerIdentifier(); | ||
41 | - | ||
42 | - /** | ||
43 | * Sets the associated Netty channel for this bgp peer. | 29 | * Sets the associated Netty channel for this bgp peer. |
44 | * | 30 | * |
45 | * @param channel the Netty channel | 31 | * @param channel the Netty channel |
... | @@ -54,27 +40,6 @@ public interface BGPPeer { | ... | @@ -54,27 +40,6 @@ public interface BGPPeer { |
54 | Channel getChannel(); | 40 | Channel getChannel(); |
55 | 41 | ||
56 | /** | 42 | /** |
57 | - * Sets the AS Number for this bgp peer. | ||
58 | - * | ||
59 | - * @param peerASNum the autonomous system number value to set. | ||
60 | - */ | ||
61 | - void setBgpPeerASNum(short peerASNum); | ||
62 | - | ||
63 | - /** | ||
64 | - * Sets the hold time for this bgp peer. | ||
65 | - * | ||
66 | - * @param peerHoldTime the hold timer value to set. | ||
67 | - */ | ||
68 | - void setBgpPeerHoldTime(short peerHoldTime); | ||
69 | - | ||
70 | - /** | ||
71 | - * Sets the peer identifier value. | ||
72 | - * | ||
73 | - * @param peerIdentifier the bgp peer identifier value. | ||
74 | - */ | ||
75 | - void setBgpPeerIdentifier(int peerIdentifier); | ||
76 | - | ||
77 | - /** | ||
78 | * Sets whether the bgp peer is connected. | 43 | * Sets whether the bgp peer is connected. |
79 | * | 44 | * |
80 | * @param connected whether the bgp peer is connected | 45 | * @param connected whether the bgp peer is connected |
... | @@ -82,15 +47,6 @@ public interface BGPPeer { | ... | @@ -82,15 +47,6 @@ public interface BGPPeer { |
82 | void setConnected(boolean connected); | 47 | void setConnected(boolean connected); |
83 | 48 | ||
84 | /** | 49 | /** |
85 | - * Initialises the behaviour. | ||
86 | - * | ||
87 | - * @param bgpId id of bgp peer | ||
88 | - * @param bgpVersion BGP version | ||
89 | - * @param pktStats packet statistics | ||
90 | - */ | ||
91 | - void init(BGPId bgpId, BGPVersion bgpVersion, BGPPacketStats pktStats); | ||
92 | - | ||
93 | - /** | ||
94 | * Checks whether the handshake is complete. | 50 | * Checks whether the handshake is complete. |
95 | * | 51 | * |
96 | * @return true is finished, false if not. | 52 | * @return true is finished, false if not. |
... | @@ -112,18 +68,11 @@ public interface BGPPeer { | ... | @@ -112,18 +68,11 @@ public interface BGPPeer { |
112 | void sendMessage(List<BGPMessage> msgs); | 68 | void sendMessage(List<BGPMessage> msgs); |
113 | 69 | ||
114 | /** | 70 | /** |
115 | - * Gets a string version of the ID for this bgp peer. | 71 | + * Provides the factory for BGP version. |
116 | * | 72 | * |
117 | - * @return string version of the ID | 73 | + * @return BGP version specific factory. |
118 | */ | 74 | */ |
119 | - String getStringId(); | 75 | + BGPFactory factory(); |
120 | - | ||
121 | - /** | ||
122 | - * Gets the ipAddress of the peer. | ||
123 | - * | ||
124 | - * @return the peer bgpId in IPAddress format | ||
125 | - */ | ||
126 | - BGPId getBGPId(); | ||
127 | 76 | ||
128 | /** | 77 | /** |
129 | * Checks if the bgp peer is still connected. | 78 | * Checks if the bgp peer is still connected. |
... | @@ -146,16 +95,9 @@ public interface BGPPeer { | ... | @@ -146,16 +95,9 @@ public interface BGPPeer { |
146 | String channelId(); | 95 | String channelId(); |
147 | 96 | ||
148 | /** | 97 | /** |
149 | - * Gets the negotiated hold time. | 98 | + * Return the BGP session info. |
150 | - * | ||
151 | - * @return the negotiated hold time | ||
152 | - */ | ||
153 | - int getNegotiatedHoldTime(); | ||
154 | - | ||
155 | - /** | ||
156 | - * Sets negotiated hold time for the peer. | ||
157 | * | 99 | * |
158 | - * @param negotiatedHoldTime negotiated hold time | 100 | + * @return sessionInfo bgp session info |
159 | */ | 101 | */ |
160 | - void setNegotiatedHoldTime(short negotiatedHoldTime); | 102 | + BgpSessionInfo sessionInfo(); |
161 | } | 103 | } | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
5 | + * the License. You may obtain a copy of the License at | ||
6 | + * | ||
7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | + * | ||
9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
11 | + * specific language governing permissions and limitations under the License. | ||
12 | + */ | ||
13 | + | ||
14 | +package org.onosproject.bgp.controller; | ||
15 | + | ||
16 | +import org.onosproject.bgpio.protocol.BGPVersion; | ||
17 | + | ||
18 | +/** | ||
19 | + * Abstraction of an BGP session info. Maintian session parameters obtained during session creation. | ||
20 | + */ | ||
21 | +public interface BgpSessionInfo { | ||
22 | + /** | ||
23 | + * Gets the bgp session type iBGP/eBGP. | ||
24 | + * | ||
25 | + * @return isiBGPSession, true if session is of type internal, otherwise false. | ||
26 | + */ | ||
27 | + boolean isIbgpSession(); | ||
28 | + | ||
29 | + /** | ||
30 | + * Gets the negotiated hold time for the session. | ||
31 | + * | ||
32 | + * @return negotiated hold time. | ||
33 | + */ | ||
34 | + short negotiatedholdTime(); | ||
35 | + | ||
36 | + /** | ||
37 | + * Gets the BGP ID of BGP peer. | ||
38 | + * | ||
39 | + * @return bgp ID. | ||
40 | + */ | ||
41 | + BGPId remoteBgpId(); | ||
42 | + | ||
43 | + /** | ||
44 | + * Gets the BGP version of peer. | ||
45 | + * | ||
46 | + * @return bgp version. | ||
47 | + */ | ||
48 | + BGPVersion remoteBgpVersion(); | ||
49 | + | ||
50 | + /** | ||
51 | + * Gets the BGP remote bgp AS number. | ||
52 | + * | ||
53 | + * @return remoteBgpASNum peer AS number. | ||
54 | + */ | ||
55 | + long remoteBgpASNum(); | ||
56 | + | ||
57 | + /** | ||
58 | + * Gets the BGP peer hold time. | ||
59 | + * | ||
60 | + * @return bgp hold time. | ||
61 | + */ | ||
62 | + short remoteBgpHoldTime(); | ||
63 | + | ||
64 | + /** | ||
65 | + * Gets the BGP version for this bgp peer. | ||
66 | + * | ||
67 | + * @return bgp identifier. | ||
68 | + */ | ||
69 | + int remoteBgpIdentifier(); | ||
70 | +} |
This diff is collapsed. Click to expand it.
... | @@ -16,25 +16,21 @@ | ... | @@ -16,25 +16,21 @@ |
16 | 16 | ||
17 | package org.onosproject.bgp.controller.impl; | 17 | package org.onosproject.bgp.controller.impl; |
18 | 18 | ||
19 | -import static org.onlab.util.Tools.groupedThreads; | ||
20 | - | ||
21 | import java.util.concurrent.ConcurrentHashMap; | 19 | import java.util.concurrent.ConcurrentHashMap; |
22 | -import java.util.concurrent.ExecutorService; | ||
23 | -import java.util.concurrent.Executors; | ||
24 | import java.util.concurrent.locks.Lock; | 20 | import java.util.concurrent.locks.Lock; |
25 | import java.util.concurrent.locks.ReentrantLock; | 21 | import java.util.concurrent.locks.ReentrantLock; |
22 | + | ||
26 | import org.apache.felix.scr.annotations.Activate; | 23 | import org.apache.felix.scr.annotations.Activate; |
27 | import org.apache.felix.scr.annotations.Component; | 24 | import org.apache.felix.scr.annotations.Component; |
28 | import org.apache.felix.scr.annotations.Deactivate; | 25 | import org.apache.felix.scr.annotations.Deactivate; |
29 | import org.apache.felix.scr.annotations.Service; | 26 | import org.apache.felix.scr.annotations.Service; |
30 | -import org.onlab.packet.IpAddress; | ||
31 | import org.onosproject.bgp.controller.BGPCfg; | 27 | import org.onosproject.bgp.controller.BGPCfg; |
32 | import org.onosproject.bgp.controller.BGPController; | 28 | import org.onosproject.bgp.controller.BGPController; |
33 | import org.onosproject.bgp.controller.BGPId; | 29 | import org.onosproject.bgp.controller.BGPId; |
34 | -import org.onosproject.bgp.controller.BGPPacketStats; | ||
35 | import org.onosproject.bgp.controller.BGPPeer; | 30 | import org.onosproject.bgp.controller.BGPPeer; |
31 | +import org.onosproject.bgp.controller.BgpPeerManager; | ||
32 | +import org.onosproject.bgpio.exceptions.BGPParseException; | ||
36 | import org.onosproject.bgpio.protocol.BGPMessage; | 33 | import org.onosproject.bgpio.protocol.BGPMessage; |
37 | -import org.onosproject.bgpio.protocol.BGPVersion; | ||
38 | import org.slf4j.Logger; | 34 | import org.slf4j.Logger; |
39 | import org.slf4j.LoggerFactory; | 35 | import org.slf4j.LoggerFactory; |
40 | 36 | ||
... | @@ -44,16 +40,9 @@ public class BGPControllerImpl implements BGPController { | ... | @@ -44,16 +40,9 @@ public class BGPControllerImpl implements BGPController { |
44 | 40 | ||
45 | private static final Logger log = LoggerFactory.getLogger(BGPControllerImpl.class); | 41 | private static final Logger log = LoggerFactory.getLogger(BGPControllerImpl.class); |
46 | 42 | ||
47 | - private final ExecutorService executorMsgs = Executors.newFixedThreadPool(32, | ||
48 | - groupedThreads("onos/bgp", | ||
49 | - "event-stats-%d")); | ||
50 | - | ||
51 | - private final ExecutorService executorBarrier = Executors.newFixedThreadPool(4, | ||
52 | - groupedThreads("onos/bgp", | ||
53 | - "event-barrier-%d")); | ||
54 | protected ConcurrentHashMap<BGPId, BGPPeer> connectedPeers = new ConcurrentHashMap<BGPId, BGPPeer>(); | 43 | protected ConcurrentHashMap<BGPId, BGPPeer> connectedPeers = new ConcurrentHashMap<BGPId, BGPPeer>(); |
55 | 44 | ||
56 | - protected BGPPeerManager peerManager = new BGPPeerManager(); | 45 | + protected BGPPeerManagerImpl peerManager = new BGPPeerManagerImpl(); |
57 | final Controller ctrl = new Controller(this); | 46 | final Controller ctrl = new Controller(this); |
58 | 47 | ||
59 | private BGPConfig bgpconfig = new BGPConfig(); | 48 | private BGPConfig bgpconfig = new BGPConfig(); |
... | @@ -84,11 +73,11 @@ public class BGPControllerImpl implements BGPController { | ... | @@ -84,11 +73,11 @@ public class BGPControllerImpl implements BGPController { |
84 | 73 | ||
85 | @Override | 74 | @Override |
86 | public void writeMsg(BGPId bgpId, BGPMessage msg) { | 75 | public void writeMsg(BGPId bgpId, BGPMessage msg) { |
87 | - // TODO: Send message | 76 | + this.getPeer(bgpId).sendMessage(msg); |
88 | } | 77 | } |
89 | 78 | ||
90 | @Override | 79 | @Override |
91 | - public void processBGPPacket(BGPId bgpId, BGPMessage msg) { | 80 | + public void processBGPPacket(BGPId bgpId, BGPMessage msg) throws BGPParseException { |
92 | 81 | ||
93 | switch (msg.getType()) { | 82 | switch (msg.getType()) { |
94 | case OPEN: | 83 | case OPEN: |
... | @@ -122,18 +111,12 @@ public class BGPControllerImpl implements BGPController { | ... | @@ -122,18 +111,12 @@ public class BGPControllerImpl implements BGPController { |
122 | * Implementation of an BGP Peer which is responsible for keeping track of connected peers and the state in which | 111 | * Implementation of an BGP Peer which is responsible for keeping track of connected peers and the state in which |
123 | * they are. | 112 | * they are. |
124 | */ | 113 | */ |
125 | - public class BGPPeerManager { | 114 | + public class BGPPeerManagerImpl implements BgpPeerManager { |
126 | 115 | ||
127 | - private final Logger log = LoggerFactory.getLogger(BGPPeerManager.class); | 116 | + private final Logger log = LoggerFactory.getLogger(BGPPeerManagerImpl.class); |
128 | private final Lock peerLock = new ReentrantLock(); | 117 | private final Lock peerLock = new ReentrantLock(); |
129 | 118 | ||
130 | - /** | 119 | + @Override |
131 | - * Add a BGP peer that has just connected to the system. | ||
132 | - * | ||
133 | - * @param bgpId the id of bgp peer to add | ||
134 | - * @param bgpPeer the actual bgp peer object. | ||
135 | - * @return true if added, false otherwise. | ||
136 | - */ | ||
137 | public boolean addConnectedPeer(BGPId bgpId, BGPPeer bgpPeer) { | 120 | public boolean addConnectedPeer(BGPId bgpId, BGPPeer bgpPeer) { |
138 | 121 | ||
139 | if (connectedPeers.get(bgpId) != null) { | 122 | if (connectedPeers.get(bgpId) != null) { |
... | @@ -147,119 +130,49 @@ public class BGPControllerImpl implements BGPController { | ... | @@ -147,119 +130,49 @@ public class BGPControllerImpl implements BGPController { |
147 | } | 130 | } |
148 | } | 131 | } |
149 | 132 | ||
150 | - /** | 133 | + @Override |
151 | - * Checks if the activation for this bgp peer is valid. | ||
152 | - * | ||
153 | - * @param bgpId the id of bgp peer to check | ||
154 | - * @return true if valid, false otherwise | ||
155 | - */ | ||
156 | public boolean isPeerConnected(BGPId bgpId) { | 134 | public boolean isPeerConnected(BGPId bgpId) { |
157 | if (connectedPeers.get(bgpId) == null) { | 135 | if (connectedPeers.get(bgpId) == null) { |
158 | - this.log.error("Trying to activate peer but is not in " + "connected peer: bgpIp {}. Aborting ..", | 136 | + this.log.error("Is peer connected: bgpIp {}.", bgpId.toString()); |
159 | - bgpId.toString()); | ||
160 | return false; | 137 | return false; |
161 | } | 138 | } |
162 | 139 | ||
163 | return true; | 140 | return true; |
164 | } | 141 | } |
165 | 142 | ||
166 | - /** | 143 | + @Override |
167 | - * Checks if the activation for this bgp peer is valid. | ||
168 | - * | ||
169 | - * @param routerid the routerid of bgp peer to check | ||
170 | - * @return true if valid, false otherwise | ||
171 | - */ | ||
172 | - public boolean isPeerConnected(String routerid) { | ||
173 | - | ||
174 | - final BGPId bgpId; | ||
175 | - bgpId = BGPId.bgpId(IpAddress.valueOf(routerid)); | ||
176 | - | ||
177 | - if (connectedPeers.get(bgpId) != null) { | ||
178 | - this.log.info("Peer connection exist "); | ||
179 | - return true; | ||
180 | - } | ||
181 | - this.log.info("Initiate connect request to " + "peer: bgpIp {}", bgpId.toString()); | ||
182 | - | ||
183 | - return false; | ||
184 | - } | ||
185 | - | ||
186 | - /** | ||
187 | - * Clear all state in controller peer maps for a bgp peer that has | ||
188 | - * disconnected from the local controller. | ||
189 | - * | ||
190 | - * @param bgpId the id of bgp peer to remove. | ||
191 | - */ | ||
192 | public void removeConnectedPeer(BGPId bgpId) { | 144 | public void removeConnectedPeer(BGPId bgpId) { |
193 | connectedPeers.remove(bgpId); | 145 | connectedPeers.remove(bgpId); |
194 | } | 146 | } |
195 | 147 | ||
196 | - /** | 148 | + @Override |
197 | - * Clear all state in controller peer maps for a bgp peer that has | 149 | + public BGPPeer getPeer(BGPId bgpId) { |
198 | - * disconnected from the local controller. | ||
199 | - * | ||
200 | - * @param routerid the router id of bgp peer to remove. | ||
201 | - */ | ||
202 | - public void removeConnectedPeer(String routerid) { | ||
203 | - final BGPId bgpId; | ||
204 | - | ||
205 | - bgpId = BGPId.bgpId(IpAddress.valueOf(routerid)); | ||
206 | - | ||
207 | - connectedPeers.remove(bgpId); | ||
208 | - } | ||
209 | - | ||
210 | - /** | ||
211 | - * Gets bgp peer for connected peer map. | ||
212 | - * | ||
213 | - * @param routerid router id | ||
214 | - * @return peer if available, null otherwise | ||
215 | - */ | ||
216 | - public BGPPeer getPeer(String routerid) { | ||
217 | - final BGPId bgpId; | ||
218 | - bgpId = BGPId.bgpId(IpAddress.valueOf(routerid)); | ||
219 | - | ||
220 | return connectedPeers.get(bgpId); | 150 | return connectedPeers.get(bgpId); |
221 | } | 151 | } |
222 | 152 | ||
223 | /** | 153 | /** |
224 | * Gets bgp peer instance. | 154 | * Gets bgp peer instance. |
225 | * | 155 | * |
226 | - * @param bgpId bgp identifier. | 156 | + * @param bgpController controller instance. |
227 | - * @param pv bgp version. | 157 | + * @param sessionInfo bgp session info. |
228 | * @param pktStats packet statistics. | 158 | * @param pktStats packet statistics. |
229 | * @return BGPPeer peer instance. | 159 | * @return BGPPeer peer instance. |
230 | */ | 160 | */ |
231 | - public BGPPeer getBGPPeerInstance(BGPId bgpId, BGPVersion pv, BGPPacketStats pktStats) { | 161 | + public BGPPeer getBGPPeerInstance(BGPController bgpController, BgpSessionInfoImpl sessionInfo, |
232 | - BGPPeer bgpPeer = new BGPPeerImpl(); | 162 | + BGPPacketStatsImpl pktStats) { |
233 | - bgpPeer.init(bgpId, pv, pktStats); | 163 | + BGPPeer bgpPeer = new BGPPeerImpl(bgpController, sessionInfo, pktStats); |
234 | return bgpPeer; | 164 | return bgpPeer; |
235 | } | 165 | } |
236 | 166 | ||
237 | } | 167 | } |
238 | 168 | ||
239 | - /** | 169 | + @Override |
240 | - * Gets controller instance. | 170 | + public ConcurrentHashMap<BGPId, BGPPeer> connectedPeers() { |
241 | - * | ||
242 | - * @return Controller instance. | ||
243 | - */ | ||
244 | - public Controller getController() { | ||
245 | - return ctrl; | ||
246 | - } | ||
247 | - | ||
248 | - /** | ||
249 | - * Gets connected peers. | ||
250 | - * | ||
251 | - * @return connectedPeers from connected Peers Map. | ||
252 | - */ | ||
253 | - public ConcurrentHashMap<BGPId, BGPPeer> getConnectedPeers() { | ||
254 | return connectedPeers; | 171 | return connectedPeers; |
255 | } | 172 | } |
256 | 173 | ||
257 | - /** | 174 | + @Override |
258 | - * Gets peer manager. | 175 | + public BGPPeerManagerImpl peerManager() { |
259 | - * | ||
260 | - * @return peerManager. | ||
261 | - */ | ||
262 | - public BGPPeerManager getPeerManager() { | ||
263 | return peerManager; | 176 | return peerManager; |
264 | } | 177 | } |
265 | 178 | ||
... | @@ -269,7 +182,7 @@ public class BGPControllerImpl implements BGPController { | ... | @@ -269,7 +182,7 @@ public class BGPControllerImpl implements BGPController { |
269 | } | 182 | } |
270 | 183 | ||
271 | @Override | 184 | @Override |
272 | - public int getBGPConnNumber() { | 185 | + public int connectedPeerCount() { |
273 | return connectedPeers.size(); | 186 | return connectedPeers.size(); |
274 | } | 187 | } |
275 | } | 188 | } | ... | ... |
... | @@ -24,11 +24,12 @@ import java.util.concurrent.RejectedExecutionException; | ... | @@ -24,11 +24,12 @@ import java.util.concurrent.RejectedExecutionException; |
24 | 24 | ||
25 | import org.jboss.netty.channel.Channel; | 25 | import org.jboss.netty.channel.Channel; |
26 | import org.onlab.packet.IpAddress; | 26 | import org.onlab.packet.IpAddress; |
27 | -import org.onosproject.bgp.controller.BGPId; | 27 | +import org.onosproject.bgp.controller.BGPController; |
28 | -import org.onosproject.bgp.controller.BGPPacketStats; | ||
29 | import org.onosproject.bgp.controller.BGPPeer; | 28 | import org.onosproject.bgp.controller.BGPPeer; |
29 | +import org.onosproject.bgp.controller.BgpSessionInfo; | ||
30 | +import org.onosproject.bgpio.protocol.BGPFactories; | ||
31 | +import org.onosproject.bgpio.protocol.BGPFactory; | ||
30 | import org.onosproject.bgpio.protocol.BGPMessage; | 32 | import org.onosproject.bgpio.protocol.BGPMessage; |
31 | -import org.onosproject.bgpio.protocol.BGPVersion; | ||
32 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
33 | import org.slf4j.LoggerFactory; | 34 | import org.slf4j.LoggerFactory; |
34 | 35 | ||
... | @@ -43,19 +44,31 @@ public class BGPPeerImpl implements BGPPeer { | ... | @@ -43,19 +44,31 @@ public class BGPPeerImpl implements BGPPeer { |
43 | 44 | ||
44 | private static final String SHUTDOWN_MSG = "Worker has already been shutdown"; | 45 | private static final String SHUTDOWN_MSG = "Worker has already been shutdown"; |
45 | 46 | ||
47 | + private BGPController bgpController; | ||
46 | private Channel channel; | 48 | private Channel channel; |
47 | protected String channelId; | 49 | protected String channelId; |
48 | private boolean connected; | 50 | private boolean connected; |
49 | protected boolean isHandShakeComplete = false; | 51 | protected boolean isHandShakeComplete = false; |
50 | - public BGPSessionInfo sessionInfo; | 52 | + private BgpSessionInfo sessionInfo; |
51 | private BGPPacketStatsImpl pktStats; | 53 | private BGPPacketStatsImpl pktStats; |
52 | 54 | ||
55 | + | ||
53 | @Override | 56 | @Override |
54 | - public void init(BGPId bgpId, BGPVersion bgpVersion, BGPPacketStats pktStats) { | 57 | + public BgpSessionInfo sessionInfo() { |
55 | - this.sessionInfo.setRemoteBgpId(bgpId); | 58 | + return sessionInfo; |
56 | - this.sessionInfo.setRemoteBgpVersion(bgpVersion); | 59 | + } |
57 | - this.pktStats = (BGPPacketStatsImpl) pktStats; | 60 | + |
58 | - this.sessionInfo = new BGPSessionInfo(); | 61 | + /** |
62 | + * Initialize peer. | ||
63 | + * | ||
64 | + *@param bgpController controller instance | ||
65 | + *@param sessionInfo bgp session info | ||
66 | + *@param pktStats packet statistics | ||
67 | + */ | ||
68 | + public BGPPeerImpl(BGPController bgpController, BgpSessionInfo sessionInfo, BGPPacketStatsImpl pktStats) { | ||
69 | + this.bgpController = bgpController; | ||
70 | + this.sessionInfo = sessionInfo; | ||
71 | + this.pktStats = pktStats; | ||
59 | } | 72 | } |
60 | 73 | ||
61 | // ************************ | 74 | // ************************ |
... | @@ -129,53 +142,9 @@ public class BGPPeerImpl implements BGPPeer { | ... | @@ -129,53 +142,9 @@ public class BGPPeerImpl implements BGPPeer { |
129 | return channelId; | 142 | return channelId; |
130 | } | 143 | } |
131 | 144 | ||
132 | - // ************************ | ||
133 | - // BGP Peer features related | ||
134 | - // ************************ | ||
135 | - | ||
136 | - @Override | ||
137 | - public final BGPId getBGPId() { | ||
138 | - return this.sessionInfo.getRemoteBgpId(); | ||
139 | - }; | ||
140 | - | ||
141 | - @Override | ||
142 | - public final String getStringId() { | ||
143 | - return this.sessionInfo.getRemoteBgpId().toString(); | ||
144 | - } | ||
145 | - | ||
146 | - @Override | ||
147 | - public final void setBgpPeerVersion(BGPVersion peerVersion) { | ||
148 | - this.sessionInfo.setRemoteBgpVersion(peerVersion); | ||
149 | - } | ||
150 | - | ||
151 | - @Override | ||
152 | - public void setBgpPeerASNum(short peerASNum) { | ||
153 | - this.sessionInfo.setRemoteBgpASNum(peerASNum); | ||
154 | - } | ||
155 | - | ||
156 | - @Override | ||
157 | - public void setBgpPeerHoldTime(short peerHoldTime) { | ||
158 | - this.sessionInfo.setRemoteBgpHoldTime(peerHoldTime); | ||
159 | - } | ||
160 | - | ||
161 | - @Override | ||
162 | - public void setBgpPeerIdentifier(int peerIdentifier) { | ||
163 | - this.sessionInfo.setRemoteBgpIdentifier(peerIdentifier); | ||
164 | - } | ||
165 | - | ||
166 | - @Override | ||
167 | - public int getBgpPeerIdentifier() { | ||
168 | - return this.sessionInfo.getRemoteBgpIdentifier(); | ||
169 | - } | ||
170 | - | ||
171 | - @Override | ||
172 | - public int getNegotiatedHoldTime() { | ||
173 | - return this.sessionInfo.getNegotiatedholdTime(); | ||
174 | - } | ||
175 | - | ||
176 | @Override | 145 | @Override |
177 | - public void setNegotiatedHoldTime(short negotiatedHoldTime) { | 146 | + public BGPFactory factory() { |
178 | - this.sessionInfo.setNegotiatedholdTime(negotiatedHoldTime); | 147 | + return BGPFactories.getFactory(sessionInfo.remoteBgpVersion()); |
179 | } | 148 | } |
180 | 149 | ||
181 | @Override | 150 | @Override |
... | @@ -185,7 +154,8 @@ public class BGPPeerImpl implements BGPPeer { | ... | @@ -185,7 +154,8 @@ public class BGPPeerImpl implements BGPPeer { |
185 | 154 | ||
186 | @Override | 155 | @Override |
187 | public String toString() { | 156 | public String toString() { |
188 | - return MoreObjects.toStringHelper(getClass()).omitNullValues().add("channel", channelId()) | 157 | + return MoreObjects.toStringHelper(getClass()).omitNullValues() |
189 | - .add("bgpId", getBGPId()).toString(); | 158 | + .add("channel", channelId()) |
159 | + .add("bgpId", sessionInfo().remoteBgpId()).toString(); | ||
190 | } | 160 | } |
191 | } | 161 | } | ... | ... |
... | @@ -23,6 +23,7 @@ import org.jboss.netty.handler.timeout.ReadTimeoutHandler; | ... | @@ -23,6 +23,7 @@ import org.jboss.netty.handler.timeout.ReadTimeoutHandler; |
23 | import org.jboss.netty.util.ExternalResourceReleasable; | 23 | import org.jboss.netty.util.ExternalResourceReleasable; |
24 | import org.jboss.netty.util.HashedWheelTimer; | 24 | import org.jboss.netty.util.HashedWheelTimer; |
25 | import org.jboss.netty.util.Timer; | 25 | import org.jboss.netty.util.Timer; |
26 | +import org.onosproject.bgp.controller.BGPController; | ||
26 | 27 | ||
27 | /** | 28 | /** |
28 | * Creates a ChannelPipeline for a server-side bgp channel. | 29 | * Creates a ChannelPipeline for a server-side bgp channel. |
... | @@ -32,30 +33,36 @@ public class BGPPipelineFactory | ... | @@ -32,30 +33,36 @@ public class BGPPipelineFactory |
32 | 33 | ||
33 | static final Timer TIMER = new HashedWheelTimer(); | 34 | static final Timer TIMER = new HashedWheelTimer(); |
34 | protected ReadTimeoutHandler readTimeoutHandler; | 35 | protected ReadTimeoutHandler readTimeoutHandler; |
35 | - BGPControllerImpl bgpCtrlImpl; | 36 | + private boolean isBgpServ; |
37 | + private BGPController bgpController; | ||
36 | 38 | ||
37 | /** | 39 | /** |
38 | * Constructor to initialize the values. | 40 | * Constructor to initialize the values. |
39 | * | 41 | * |
40 | - * @param ctrlImpl parent ctrlImpl | 42 | + * @param bgpController parent controller |
41 | - * @param isServBgp if it is a server or not | 43 | + * @param isBgpServ if it is a server or remote peer |
42 | */ | 44 | */ |
43 | - public BGPPipelineFactory(BGPControllerImpl ctrlImpl, boolean isServBgp) { | 45 | + public BGPPipelineFactory(BGPController bgpController, boolean isBgpServ) { |
44 | super(); | 46 | super(); |
45 | - bgpCtrlImpl = ctrlImpl; | 47 | + this.isBgpServ = isBgpServ; |
46 | - /* hold time*/ | 48 | + this.bgpController = bgpController; |
47 | - readTimeoutHandler = new ReadTimeoutHandler(TIMER, bgpCtrlImpl.getConfig().getHoldTime()); | 49 | + /* hold time */ |
50 | + this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, bgpController.getConfig().getHoldTime()); | ||
48 | } | 51 | } |
49 | 52 | ||
50 | @Override | 53 | @Override |
51 | public ChannelPipeline getPipeline() throws Exception { | 54 | public ChannelPipeline getPipeline() throws Exception { |
52 | - BGPChannelHandler handler = new BGPChannelHandler(bgpCtrlImpl); | 55 | + BGPChannelHandler handler = new BGPChannelHandler(bgpController); |
53 | 56 | ||
54 | ChannelPipeline pipeline = Channels.pipeline(); | 57 | ChannelPipeline pipeline = Channels.pipeline(); |
55 | pipeline.addLast("bgpmessagedecoder", new BGPMessageDecoder()); | 58 | pipeline.addLast("bgpmessagedecoder", new BGPMessageDecoder()); |
56 | pipeline.addLast("bgpmessageencoder", new BGPMessageEncoder()); | 59 | pipeline.addLast("bgpmessageencoder", new BGPMessageEncoder()); |
57 | pipeline.addLast("holdTime", readTimeoutHandler); | 60 | pipeline.addLast("holdTime", readTimeoutHandler); |
61 | + if (isBgpServ) { | ||
58 | pipeline.addLast("PassiveHandler", handler); | 62 | pipeline.addLast("PassiveHandler", handler); |
63 | + } else { | ||
64 | + pipeline.addLast("ActiveHandler", handler); | ||
65 | + } | ||
59 | 66 | ||
60 | return pipeline; | 67 | return pipeline; |
61 | } | 68 | } | ... | ... |
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.bgp.controller.impl; | ||
18 | - | ||
19 | -import org.onosproject.bgp.controller.BGPId; | ||
20 | -import org.onosproject.bgpio.protocol.BGPVersion; | ||
21 | -import org.slf4j.Logger; | ||
22 | -import org.slf4j.LoggerFactory; | ||
23 | - | ||
24 | -/** | ||
25 | - * Class maintains BGP peer session info. | ||
26 | - */ | ||
27 | -public class BGPSessionInfo { | ||
28 | - | ||
29 | - protected final Logger log = LoggerFactory.getLogger(BGPSessionInfo.class); | ||
30 | - private BGPId remoteBgpId; | ||
31 | - private BGPVersion remoteBgpVersion; | ||
32 | - private short remoteBgpASNum; | ||
33 | - private short remoteBgpholdTime; | ||
34 | - private int remoteBgpIdentifier; | ||
35 | - private short negotiatedholdTime; | ||
36 | - | ||
37 | - /** | ||
38 | - * Gets the negotiated hold time for the session. | ||
39 | - * | ||
40 | - * @return negotiated hold time. | ||
41 | - */ | ||
42 | - public short getNegotiatedholdTime() { | ||
43 | - return negotiatedholdTime; | ||
44 | - } | ||
45 | - | ||
46 | - /** | ||
47 | - * Sets the negotiated hold time for the session. | ||
48 | - * | ||
49 | - * @param negotiatedholdTime negotiated hold time. | ||
50 | - */ | ||
51 | - public void setNegotiatedholdTime(short negotiatedholdTime) { | ||
52 | - this.negotiatedholdTime = negotiatedholdTime; | ||
53 | - } | ||
54 | - | ||
55 | - /** | ||
56 | - * Gets the BGP ID of BGP peer. | ||
57 | - * | ||
58 | - * @return bgp ID. | ||
59 | - */ | ||
60 | - public BGPId getRemoteBgpId() { | ||
61 | - return remoteBgpId; | ||
62 | - } | ||
63 | - | ||
64 | - /** | ||
65 | - * Sets the BGP ID of bgp peer. | ||
66 | - * | ||
67 | - * @param bgpId BGP ID to set. | ||
68 | - */ | ||
69 | - public void setRemoteBgpId(BGPId bgpId) { | ||
70 | - log.debug("Remote BGP ID {}", bgpId); | ||
71 | - this.remoteBgpId = bgpId; | ||
72 | - } | ||
73 | - | ||
74 | - /** | ||
75 | - * Gets the BGP version of peer. | ||
76 | - * | ||
77 | - * @return bgp version. | ||
78 | - */ | ||
79 | - public BGPVersion getRemoteBgpVersion() { | ||
80 | - return remoteBgpVersion; | ||
81 | - } | ||
82 | - | ||
83 | - /** | ||
84 | - * Sets the BGP version for this bgp peer. | ||
85 | - * | ||
86 | - * @param bgpVersion bgp version to set. | ||
87 | - */ | ||
88 | - public void setRemoteBgpVersion(BGPVersion bgpVersion) { | ||
89 | - log.debug("Remote BGP version {}", bgpVersion); | ||
90 | - this.remoteBgpVersion = bgpVersion; | ||
91 | - } | ||
92 | - | ||
93 | - /** | ||
94 | - * Gets the BGP remote bgp AS number. | ||
95 | - * | ||
96 | - * @return remoteBgpASNum peer AS number. | ||
97 | - */ | ||
98 | - public short getRemoteBgpASNum() { | ||
99 | - return remoteBgpASNum; | ||
100 | - } | ||
101 | - | ||
102 | - /** | ||
103 | - * Sets the AS Number for this bgp peer. | ||
104 | - * | ||
105 | - * @param bgpASNum the autonomous system number value to set. | ||
106 | - */ | ||
107 | - public void setRemoteBgpASNum(short bgpASNum) { | ||
108 | - log.debug("Remote BGP AS number {}", bgpASNum); | ||
109 | - this.remoteBgpASNum = bgpASNum; | ||
110 | - } | ||
111 | - | ||
112 | - /** | ||
113 | - * Gets the BGP peer hold time. | ||
114 | - * | ||
115 | - * @return bgp hold time. | ||
116 | - */ | ||
117 | - public short getRemoteBgpHoldTime() { | ||
118 | - return remoteBgpholdTime; | ||
119 | - } | ||
120 | - | ||
121 | - /** | ||
122 | - * Sets the hold time for this bgp peer. | ||
123 | - * | ||
124 | - * @param holdTime the hold timer value to set. | ||
125 | - */ | ||
126 | - public void setRemoteBgpHoldTime(short holdTime) { | ||
127 | - log.debug("Remote BGP HoldTime {}", holdTime); | ||
128 | - this.remoteBgpholdTime = holdTime; | ||
129 | - } | ||
130 | - | ||
131 | - /** | ||
132 | - * Gets the BGP version for this bgp peer. | ||
133 | - * | ||
134 | - * @return bgp identifier. | ||
135 | - */ | ||
136 | - public int getRemoteBgpIdentifier() { | ||
137 | - return remoteBgpIdentifier; | ||
138 | - } | ||
139 | - | ||
140 | - /** | ||
141 | - * Sets the peer identifier value. | ||
142 | - * | ||
143 | - * @param bgpIdentifier the bgp peer identifier value. | ||
144 | - */ | ||
145 | - public void setRemoteBgpIdentifier(int bgpIdentifier) { | ||
146 | - log.debug("Remote BGP Identifier {}", bgpIdentifier); | ||
147 | - this.remoteBgpIdentifier = bgpIdentifier; | ||
148 | - } | ||
149 | -} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
5 | + * the License. You may obtain a copy of the License at | ||
6 | + * | ||
7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | + * | ||
9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
11 | + * specific language governing permissions and limitations under the License. | ||
12 | + */ | ||
13 | + | ||
14 | +package org.onosproject.bgp.controller.impl; | ||
15 | + | ||
16 | +import org.onosproject.bgp.controller.BGPId; | ||
17 | +import org.onosproject.bgp.controller.BgpSessionInfo; | ||
18 | +import org.onosproject.bgpio.protocol.BGPVersion; | ||
19 | +import org.slf4j.Logger; | ||
20 | +import org.slf4j.LoggerFactory; | ||
21 | + | ||
22 | +/** | ||
23 | + * Class maintains BGP peer session info. | ||
24 | + */ | ||
25 | +public class BgpSessionInfoImpl implements BgpSessionInfo { | ||
26 | + | ||
27 | + protected final Logger log = LoggerFactory.getLogger(BgpSessionInfoImpl.class); | ||
28 | + private BGPId remoteBgpId; | ||
29 | + private BGPVersion remoteBgpVersion; | ||
30 | + private long remoteBgpASNum; | ||
31 | + private short remoteBgpholdTime; | ||
32 | + private int remoteBgpIdentifier; | ||
33 | + private short negotiatedholdTime; | ||
34 | + private boolean isIbgpSession; | ||
35 | + | ||
36 | + /** | ||
37 | + * Initialize session info. | ||
38 | + * | ||
39 | + *@param remoteBgpId remote peer id | ||
40 | + *@param remoteBgpVersion remote peer version | ||
41 | + *@param remoteBgpASNum remote peer AS number | ||
42 | + *@param remoteBgpholdTime remote peer hold time | ||
43 | + *@param remoteBgpIdentifier remote peer identifier | ||
44 | + *@param negotiatedholdTime negotiated hold time | ||
45 | + *@param isIbgpSession session type ibgp/ebgp | ||
46 | + */ | ||
47 | + public BgpSessionInfoImpl(BGPId remoteBgpId, BGPVersion remoteBgpVersion, long remoteBgpASNum, | ||
48 | + short remoteBgpholdTime, int remoteBgpIdentifier, short negotiatedholdTime, | ||
49 | + boolean isIbgpSession) { | ||
50 | + this.remoteBgpId = remoteBgpId; | ||
51 | + this.remoteBgpVersion = remoteBgpVersion; | ||
52 | + this.remoteBgpASNum = remoteBgpASNum; | ||
53 | + this.remoteBgpholdTime = remoteBgpholdTime; | ||
54 | + this.remoteBgpIdentifier = remoteBgpIdentifier; | ||
55 | + this.negotiatedholdTime = negotiatedholdTime; | ||
56 | + this.isIbgpSession = isIbgpSession; | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public boolean isIbgpSession() { | ||
61 | + return isIbgpSession; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public short negotiatedholdTime() { | ||
66 | + return negotiatedholdTime; | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public BGPId remoteBgpId() { | ||
71 | + return remoteBgpId; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public BGPVersion remoteBgpVersion() { | ||
76 | + return remoteBgpVersion; | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public long remoteBgpASNum() { | ||
81 | + return remoteBgpASNum; | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public short remoteBgpHoldTime() { | ||
86 | + return remoteBgpholdTime; | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public int remoteBgpIdentifier() { | ||
91 | + return remoteBgpIdentifier; | ||
92 | + } | ||
93 | +} |
... | @@ -29,6 +29,10 @@ import org.jboss.netty.channel.ChannelPipelineFactory; | ... | @@ -29,6 +29,10 @@ import org.jboss.netty.channel.ChannelPipelineFactory; |
29 | import org.jboss.netty.channel.group.ChannelGroup; | 29 | import org.jboss.netty.channel.group.ChannelGroup; |
30 | import org.jboss.netty.channel.group.DefaultChannelGroup; | 30 | import org.jboss.netty.channel.group.DefaultChannelGroup; |
31 | import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; | 31 | import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; |
32 | +import org.onosproject.bgp.controller.BGPController; | ||
33 | +import org.onosproject.bgpio.protocol.BGPFactories; | ||
34 | +import org.onosproject.bgpio.protocol.BGPFactory; | ||
35 | +import org.onosproject.bgpio.protocol.BGPVersion; | ||
32 | import org.slf4j.Logger; | 36 | import org.slf4j.Logger; |
33 | import org.slf4j.LoggerFactory; | 37 | import org.slf4j.LoggerFactory; |
34 | 38 | ||
... | @@ -38,31 +42,41 @@ import org.slf4j.LoggerFactory; | ... | @@ -38,31 +42,41 @@ import org.slf4j.LoggerFactory; |
38 | */ | 42 | */ |
39 | public class Controller { | 43 | public class Controller { |
40 | 44 | ||
41 | - protected static final Logger log = LoggerFactory.getLogger(Controller.class); | 45 | + private static final Logger log = LoggerFactory.getLogger(Controller.class); |
46 | + | ||
47 | + private static final BGPFactory FACTORY4 = BGPFactories.getFactory(BGPVersion.BGP_4); | ||
42 | 48 | ||
43 | private ChannelGroup cg; | 49 | private ChannelGroup cg; |
44 | 50 | ||
45 | // Configuration options | 51 | // Configuration options |
46 | private static final short BGP_PORT_NUM = 179; | 52 | private static final short BGP_PORT_NUM = 179; |
47 | - private int workerThreads = 16; | 53 | + private final int workerThreads = 16; |
48 | 54 | ||
49 | // Start time of the controller | 55 | // Start time of the controller |
50 | - protected long systemStartTime; | 56 | + private long systemStartTime; |
51 | 57 | ||
52 | private NioServerSocketChannelFactory serverExecFactory; | 58 | private NioServerSocketChannelFactory serverExecFactory; |
59 | + private BGPController bgpController; | ||
53 | 60 | ||
54 | // Perf. related configuration | 61 | // Perf. related configuration |
55 | - protected static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024; | 62 | + private static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024; |
56 | 63 | ||
57 | - BGPControllerImpl bgpCtrlImpl; | 64 | + /** |
65 | + * Constructor to initialize the values. | ||
66 | + * | ||
67 | + * @param bgpController bgp controller instance | ||
68 | + */ | ||
69 | + public Controller(BGPController bgpController) { | ||
70 | + this.bgpController = bgpController; | ||
71 | + } | ||
58 | 72 | ||
59 | /** | 73 | /** |
60 | - * Constructor to initialize parameter. | 74 | + * Returns factory version for processing BGP messages. |
61 | * | 75 | * |
62 | - * @param bgpCtrlImpl BGP controller Impl instance | 76 | + * @return instance of factory version |
63 | */ | 77 | */ |
64 | - public Controller(BGPControllerImpl bgpCtrlImpl) { | 78 | + static BGPFactory getBGPMessageFactory4() { |
65 | - this.bgpCtrlImpl = bgpCtrlImpl; | 79 | + return FACTORY4; |
66 | } | 80 | } |
67 | 81 | ||
68 | // *************** | 82 | // *************** |
... | @@ -95,7 +109,7 @@ public class Controller { | ... | @@ -95,7 +109,7 @@ public class Controller { |
95 | bootstrap.setOption("child.tcpNoDelay", true); | 109 | bootstrap.setOption("child.tcpNoDelay", true); |
96 | bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE); | 110 | bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE); |
97 | 111 | ||
98 | - ChannelPipelineFactory pfact = new BGPPipelineFactory(bgpCtrlImpl, true); | 112 | + ChannelPipelineFactory pfact = new BGPPipelineFactory(bgpController, true); |
99 | 113 | ||
100 | bootstrap.setPipelineFactory(pfact); | 114 | bootstrap.setPipelineFactory(pfact); |
101 | InetSocketAddress sa = new InetSocketAddress(getBgpPortNum()); | 115 | InetSocketAddress sa = new InetSocketAddress(getBgpPortNum()); | ... | ... |
-
Please register or login to post a comment