2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager;
11 import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
12 import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 public class ForwardingRulesManagerModule extends org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.AbstractForwardingRulesManagerModule {
18 private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerModule.class);
19 private static final boolean ENABLE_FGM_STALE_MARKING = false;
21 public ForwardingRulesManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
22 super(identifier, dependencyResolver);
25 public ForwardingRulesManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.ForwardingRulesManagerModule oldModule, java.lang.AutoCloseable oldInstance) {
26 super(identifier, dependencyResolver, oldModule, oldInstance);
30 public void customValidation() {
31 // add custom validation form module attributes here.
35 public java.lang.AutoCloseable createInstance() {
36 LOG.info("FRM module initialization.");
37 final ForwardingRulesManagerConfig config = readConfig();
38 final ForwardingRulesManagerImpl forwardingrulessManagerProvider =
39 new ForwardingRulesManagerImpl(getDataBrokerDependency(), getRpcRegistryDependency(), config);
40 forwardingrulessManagerProvider.start();
41 LOG.info("FRM module started successfully.");
42 return new AutoCloseable() {
44 public void close() throws Exception {
46 forwardingrulessManagerProvider.close();
47 } catch (final Exception e) {
48 LOG.warn("Unexpected error by stopping FRM", e);
50 LOG.info("FRM module stopped.");
55 private ForwardingRulesManagerConfig readConfig(){
57 final ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder fwdRulesMgrCfgBuilder = ForwardingRulesManagerConfig.builder();
58 if (getForwardingManagerSettings() != null && getForwardingManagerSettings().getStaleMarkingEnabled() != null){
59 fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(getForwardingManagerSettings().getStaleMarkingEnabled());
62 LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
63 fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(ENABLE_FGM_STALE_MARKING);
66 return fwdRulesMgrCfgBuilder.build();