blob: 37df47916d5a9ba70d4976bb64b06f535e18abc2 [file] [log] [blame]
karthik1977c8999f42024-02-15 11:53:58 +05301/*
2 * Copyright 2024-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 */
16package org.onosproject.sflow.impl;
17
18import org.jboss.netty.channel.ChannelPipeline;
19import org.jboss.netty.channel.ChannelPipelineFactory;
20import org.jboss.netty.channel.Channels;
21import org.onosproject.sflow.SflowController;
22
23/**
24 * Creates a ChannelPipeline for a server-side sFlow message channel.
25 */
26public class SflowPipelineFactory implements ChannelPipelineFactory {
27
28 private SflowController controller;
29
30 /**
31 * Constructor to initialize the values.
32 *
33 * @param controller sFlow controller.
34 */
35 public SflowPipelineFactory(SflowController controller) {
36 super();
37 this.controller = controller;
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 {
karthik19776806c982024-02-17 18:46:43 +053048 SflowChannelHandler handler = new SflowChannelHandler(controller);
49
karthik1977c8999f42024-02-15 11:53:58 +053050 ChannelPipeline pipeline = Channels.pipeline();
karthik19776806c982024-02-17 18:46:43 +053051 pipeline.addLast("sflowmessagedecoder", new SflowMessageDecoder());
52 pipeline.addLast("ActiveHandler", handler);
karthik1977c8999f42024-02-15 11:53:58 +053053 return pipeline;
54 }
55
56}
57