*/
package org.opendaylight.openflowplugin.applications.frm.impl;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
-import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Reference;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.openflowplugin.api.openflow.FlowGroupCacheManager;
import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
+import org.opendaylight.openflowplugin.applications.frm.BundleMessagesCommiter;
import org.opendaylight.openflowplugin.applications.frm.FlowNodeReconciliation;
import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesCommiter;
import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
*
*/
@Singleton
-public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
+public final class ForwardingRulesManagerImpl implements ForwardingRulesManager {
private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerImpl.class);
- static final int STARTUP_LOOP_TICK = 500;
- static final int STARTUP_LOOP_MAX_RETRIES = 8;
+ static final int STARTUP_LOOP_TICK = 1000;
+ static final int STARTUP_LOOP_MAX_RETRIES = 240;
private static final int FRM_RECONCILIATION_PRIORITY = Integer.getInteger("frm.reconciliation.priority", 1);
private static final String SERVICE_NAME = "FRM";
private ForwardingRulesCommiter<Group> groupListener;
private ForwardingRulesCommiter<Meter> meterListener;
private ForwardingRulesCommiter<TableFeatures> tableListener;
+ private BundleMessagesCommiter<Flow> bundleFlowListener;
+ private BundleMessagesCommiter<Group> bundleGroupListener;
private FlowNodeReconciliation nodeListener;
private NotificationRegistration reconciliationNotificationRegistration;
private FlowNodeConnectorInventoryTranslatorImpl flowNodeConnectorInventoryTranslatorImpl;
private boolean isBundleBasedReconciliationEnabled;
private final OpenflowServiceRecoveryHandler openflowServiceRecoveryHandler;
private final ServiceRecoveryRegistry serviceRecoveryRegistry;
+ private final FlowGroupCacheManager flowGroupCacheManager;
+ private final ListenerRegistrationHelper registrationHelper;
@Inject
- public ForwardingRulesManagerImpl(@Reference final DataBroker dataBroker,
- @Reference final RpcConsumerRegistry rpcRegistry,
- @Reference final RpcProviderService rpcProviderService,
+ public ForwardingRulesManagerImpl(final DataBroker dataBroker,
+ final RpcConsumerRegistry rpcRegistry,
+ final RpcProviderService rpcProviderService,
final ForwardingRulesManagerConfig config,
- @Reference final MastershipChangeServiceManager mastershipChangeServiceManager,
- @Reference final ClusterSingletonServiceProvider clusterSingletonService,
- @Reference final ConfigurationService configurationService,
- @Reference final ReconciliationManager reconciliationManager,
+ final MastershipChangeServiceManager mastershipChangeServiceManager,
+ final ClusterSingletonServiceProvider clusterSingletonService,
+ final ConfigurationService configurationService,
+ final ReconciliationManager reconciliationManager,
final OpenflowServiceRecoveryHandler openflowServiceRecoveryHandler,
- @Reference final ServiceRecoveryRegistry serviceRecoveryRegistry) {
- disableReconciliation = config.isDisableReconciliation();
- staleMarkingEnabled = config.isStaleMarkingEnabled();
- reconciliationRetryCount = config.getReconciliationRetryCount();
- isBundleBasedReconciliationEnabled = config.isBundleBasedReconciliationEnabled();
- this.configurationServiceRegistration = configurationService.registerListener(this);
- this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
- this.clusterSingletonServiceProvider = Preconditions.checkNotNull(clusterSingletonService,
+ final ServiceRecoveryRegistry serviceRecoveryRegistry,
+ final FlowGroupCacheManager flowGroupCacheManager,
+ final ListenerRegistrationHelper registrationHelper) {
+ disableReconciliation = config.getDisableReconciliation();
+ staleMarkingEnabled = config.getStaleMarkingEnabled();
+ reconciliationRetryCount = config.getReconciliationRetryCount().toJava();
+ isBundleBasedReconciliationEnabled = config.getBundleBasedReconciliationEnabled();
+ configurationServiceRegistration = configurationService.registerListener(this);
+ this.registrationHelper = requireNonNull(registrationHelper, "RegistrationHelper cannot be null");
+ dataService = requireNonNull(dataBroker, "DataBroker can not be null!");
+ clusterSingletonServiceProvider = requireNonNull(clusterSingletonService,
"ClusterSingletonService provider can not be null");
this.reconciliationManager = reconciliationManager;
this.rpcProviderService = rpcProviderService;
this.mastershipChangeServiceManager = mastershipChangeServiceManager;
+ this.flowGroupCacheManager = flowGroupCacheManager;
Preconditions.checkArgument(rpcRegistry != null, "RpcProviderRegistry can not be null !");
- this.salFlowService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlowService.class),
+ salFlowService = requireNonNull(rpcRegistry.getRpcService(SalFlowService.class),
"RPC SalFlowService not found.");
- this.salGroupService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalGroupService.class),
+ salGroupService = requireNonNull(rpcRegistry.getRpcService(SalGroupService.class),
"RPC SalGroupService not found.");
- this.salMeterService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalMeterService.class),
+ salMeterService = requireNonNull(rpcRegistry.getRpcService(SalMeterService.class),
"RPC SalMeterService not found.");
- this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
+ salTableService = requireNonNull(rpcRegistry.getRpcService(SalTableService.class),
"RPC SalTableService not found.");
- this.salBundleService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalBundleService.class),
+ salBundleService = requireNonNull(rpcRegistry.getRpcService(SalBundleService.class),
"RPC SalBundlService not found.");
- this.openflowServiceRecoveryHandler = Preconditions.checkNotNull(openflowServiceRecoveryHandler,
+ this.openflowServiceRecoveryHandler = requireNonNull(openflowServiceRecoveryHandler,
"Openflow service recovery handler cannot be null");
- this.serviceRecoveryRegistry = Preconditions.checkNotNull(serviceRecoveryRegistry,
+ this.serviceRecoveryRegistry = requireNonNull(serviceRecoveryRegistry,
"Service recovery registry cannot be null");
- this.arbitratorReconciliationManager = Preconditions
- .checkNotNull(rpcRegistry.getRpcService(ArbitratorReconcileService.class),
+ arbitratorReconciliationManager =
+ requireNonNull(rpcRegistry.getRpcService(ArbitratorReconcileService.class),
"ArbitratorReconciliationManager can not be null!");
}
@PostConstruct
public void start() {
nodeConfigurator = new NodeConfiguratorImpl();
- this.devicesGroupRegistry = new DevicesGroupRegistry();
-
- this.nodeListener = new FlowNodeReconciliationImpl(this, dataService, SERVICE_NAME, FRM_RECONCILIATION_PRIORITY,
- ResultState.DONOTHING);
+ devicesGroupRegistry = new DevicesGroupRegistry();
+ nodeListener = new FlowNodeReconciliationImpl(this, dataService, SERVICE_NAME, FRM_RECONCILIATION_PRIORITY,
+ ResultState.DONOTHING, flowGroupCacheManager);
if (this.isReconciliationDisabled()) {
LOG.debug("Reconciliation is disabled by user");
} else {
- this.reconciliationNotificationRegistration = reconciliationManager.registerService(this.nodeListener);
+ reconciliationNotificationRegistration = reconciliationManager.registerService(nodeListener);
LOG.debug("Reconciliation is enabled by user and successfully registered to the reconciliation framework");
}
- this.deviceMastershipManager = new DeviceMastershipManager(clusterSingletonServiceProvider, this.nodeListener,
+ deviceMastershipManager = new DeviceMastershipManager(clusterSingletonServiceProvider, nodeListener,
dataService, mastershipChangeServiceManager, rpcProviderService,
new FrmReconciliationServiceImpl(this));
flowNodeConnectorInventoryTranslatorImpl = new FlowNodeConnectorInventoryTranslatorImpl(dataService);
- this.flowListener = new FlowForwarder(this, dataService);
- this.groupListener = new GroupForwarder(this, dataService);
- this.meterListener = new MeterForwarder(this, dataService);
- this.tableListener = new TableForwarder(this, dataService);
+ bundleFlowListener = new BundleFlowForwarder(this);
+ bundleGroupListener = new BundleGroupForwarder(this);
+ flowListener = new FlowForwarder(this, dataService, registrationHelper);
+ groupListener = new GroupForwarder(this, dataService, registrationHelper);
+ meterListener = new MeterForwarder(this, dataService, registrationHelper);
+ tableListener = new TableForwarder(this, dataService, registrationHelper);
LOG.info("ForwardingRulesManager has started successfully.");
}
public void close() throws Exception {
configurationServiceRegistration.close();
- if (this.flowListener != null) {
- this.flowListener.close();
- this.flowListener = null;
+ if (flowListener != null) {
+ flowListener.close();
+ flowListener = null;
}
- if (this.groupListener != null) {
- this.groupListener.close();
- this.groupListener = null;
+ if (groupListener != null) {
+ groupListener.close();
+ groupListener = null;
}
- if (this.meterListener != null) {
- this.meterListener.close();
- this.meterListener = null;
+ if (meterListener != null) {
+ meterListener.close();
+ meterListener = null;
}
- if (this.tableListener != null) {
- this.tableListener.close();
- this.tableListener = null;
+ if (tableListener != null) {
+ tableListener.close();
+ tableListener = null;
}
- if (this.nodeListener != null) {
- this.nodeListener.close();
- this.nodeListener = null;
+ if (nodeListener != null) {
+ nodeListener.close();
+ nodeListener = null;
}
if (deviceMastershipManager != null) {
deviceMastershipManager.close();
}
- if (this.reconciliationNotificationRegistration != null) {
- this.reconciliationNotificationRegistration.close();
- this.reconciliationNotificationRegistration = null;
+ if (reconciliationNotificationRegistration != null) {
+ reconciliationNotificationRegistration.close();
+ reconciliationNotificationRegistration = null;
}
}
@Override
public DevicesGroupRegistry getDevicesGroupRegistry() {
- return this.devicesGroupRegistry;
+ return devicesGroupRegistry;
}
@Override
return tableListener;
}
+ @Override
+ public BundleMessagesCommiter<Flow> getBundleFlowListener() {
+ return bundleFlowListener;
+ }
+
+ @Override
+ public BundleMessagesCommiter<Group> getBundleGroupListener() {
+ return bundleGroupListener;
+ }
+
@Override
public ArbitratorReconcileService getArbitratorReconciliationManager() {
return arbitratorReconciliationManager;
}
@Override
- public void onPropertyChanged(@Nonnull final String propertyName, @Nonnull final String propertyValue) {
- Optional.ofNullable(ForwardingRulesProperty.forValue(propertyName)).ifPresent(forwardingRulesProperty -> {
+ public void onPropertyChanged(@NonNull final String propertyName, @NonNull final String propertyValue) {
+ final ForwardingRulesProperty forwardingRulesProperty = ForwardingRulesProperty.forValue(propertyName);
+ if (forwardingRulesProperty != null) {
switch (forwardingRulesProperty) {
case DISABLE_RECONCILIATION:
- disableReconciliation = Boolean.valueOf(propertyValue);
+ disableReconciliation = Boolean.parseBoolean(propertyValue);
break;
case STALE_MARKING_ENABLED:
- staleMarkingEnabled = Boolean.valueOf(propertyValue);
+ staleMarkingEnabled = Boolean.parseBoolean(propertyValue);
break;
case RECONCILIATION_RETRY_COUNT:
reconciliationRetryCount = Integer.parseInt(propertyValue);
break;
case BUNDLE_BASED_RECONCILIATION_ENABLED:
- isBundleBasedReconciliationEnabled = Boolean.valueOf(propertyValue);
+ isBundleBasedReconciliationEnabled = Boolean.parseBoolean(propertyValue);
break;
default:
LOG.warn("No forwarding rule property found.");
break;
}
- });
+ }
}
}