Open Kilda Java Documentation
ConsumerContext.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * 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
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.floodlight.kafka;
17 
18 import static java.util.Objects.requireNonNull;
19 
23 
24 import net.floodlightcontroller.core.module.FloodlightModuleContext;
25 import net.floodlightcontroller.core.module.IFloodlightService;
26 
27 import java.util.Collection;
28 
29 public class ConsumerContext extends Context {
30  private final IPathVerificationService pathVerificationService;
31  private final KafkaMessageProducer kafkaProducer;
32  private final ISwitchManager switchManager;
33  private final KafkaTopicsConfig kafkaTopicsConfig;
34 
35  public static void fillDependencies(Collection<Class<? extends IFloodlightService>> dependencies) {
36  dependencies.add(IPathVerificationService.class);
37  dependencies.add(ISwitchManager.class);
38  }
39 
40  public ConsumerContext(FloodlightModuleContext moduleContext, KafkaTopicsConfig kafkaTopicsConfig) {
41  super(moduleContext);
42 
43  pathVerificationService = moduleContext.getServiceImpl(IPathVerificationService.class);
44  switchManager = moduleContext.getServiceImpl(ISwitchManager.class);
45  kafkaProducer = moduleContext.getServiceImpl(KafkaMessageProducer.class);
46 
47  this.kafkaTopicsConfig = requireNonNull(kafkaTopicsConfig, "kafkaTopicsConfig cannot be null");
48  }
49 
51  return pathVerificationService;
52  }
53 
55  return kafkaProducer;
56  }
57 
59  return switchManager;
60  }
61 
62  public String getKafkaFlowTopic() {
63  return kafkaTopicsConfig.getFlowTopic();
64  }
65 
66  public String getKafkaTopoDiscoTopic() {
67  return kafkaTopicsConfig.getTopoDiscoTopic();
68  }
69 
70  public String getKafkaStatsTopic() {
71  return kafkaTopicsConfig.getStatsTopic();
72  }
73 
74  public String getKafkaNorthboundTopic() {
75  return kafkaTopicsConfig.getNorthboundTopic();
76  }
77 }
static void fillDependencies(Collection< Class<? extends IFloodlightService >> dependencies)
IPathVerificationService getPathVerificationService()
ConsumerContext(FloodlightModuleContext moduleContext, KafkaTopicsConfig kafkaTopicsConfig)
net
Definition: plan-b.py:46