karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2023-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 | package org.onosproject.netflow.impl; |
| 17 | |
| 18 | import org.jboss.netty.channel.ChannelPipeline; |
| 19 | import org.jboss.netty.channel.ChannelPipelineFactory; |
| 20 | import org.jboss.netty.channel.Channels; |
senthil | 7f2018e | 2023-06-21 22:00:44 +0530 | [diff] [blame] | 21 | import org.onosproject.netflow.NetflowController; |
karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Creates a ChannelPipeline for a server-side netflow message channel. |
| 25 | */ |
| 26 | public class NetflowPipelineFactory implements ChannelPipelineFactory { |
| 27 | |
senthil | 7f2018e | 2023-06-21 22:00:44 +0530 | [diff] [blame] | 28 | private NetflowController controller; |
| 29 | |
karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame] | 30 | /** |
| 31 | * Constructor to initialize the values. |
senthil | 7f2018e | 2023-06-21 22:00:44 +0530 | [diff] [blame] | 32 | * |
| 33 | * @param controller netflow controller. |
karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame] | 34 | */ |
senthil | 7f2018e | 2023-06-21 22:00:44 +0530 | [diff] [blame] | 35 | public NetflowPipelineFactory(NetflowController controller) { |
karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame] | 36 | super(); |
senthil | 7f2018e | 2023-06-21 22:00:44 +0530 | [diff] [blame] | 37 | this.controller = controller; |
karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Get server-side pipe line channel. |
| 42 | * |
| 43 | * @return ChannelPipeline server-side pipe line channel |
| 44 | * @throws Exception on while getting pipe line |
| 45 | */ |
| 46 | @Override |
| 47 | public ChannelPipeline getPipeline() throws Exception { |
senthil | 7f2018e | 2023-06-21 22:00:44 +0530 | [diff] [blame] | 48 | NeflowChannelHandler handler = new NeflowChannelHandler(controller); |
karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame] | 49 | |
| 50 | ChannelPipeline pipeline = Channels.pipeline(); |
| 51 | pipeline.addLast("netflowmessagedecoder", new NetflowMessageDecoder()); |
| 52 | pipeline.addLast("ActiveHandler", handler); |
| 53 | return pipeline; |
| 54 | } |
| 55 | |
| 56 | } |
| 57 | |