
=====================
Title of the feature
=====================

gerrit filter: https://git.opendaylight.org/gerrit/#/c/60520/


Problem description
===================
In current reconciliation mechanism/algorithm we observe that there is time drop in calculating the difference between configuration datastore and data in data path node(DPN). Current reconciliation mechanism is not hitless and it is observed few groups and flows missing post reconciliation.

Use Cases
---------
Use case is to achieve the hitless resync between controller and Data path nodes with bundle based reconciliation mechanism. 

Proposed change
===============

In this spec we are covering the implemention of Bundle based Reconciliation feature which provides hitless reconciliation capability. In this feature we will batch groups, flows to provision to device. In reconciliation case where device gets disconnected from controller and reconnects, all the existing groups and flows on device will be deleted later groups, flows in configuration datastore will be pushed to device in order of group then flows.   

Yang changes
------------
Added a new leaf in module forwarding-rules-manager-config :

 leaf enable-bundle-based-recon {
            type boolean;
            default false;
        }

Configuration impact
--------------------
New configuration added in openflowplugin.cfg : 
	enable-bundle-based-recon=false;

Targeted Release
----------------
Nitrogen

Usage
=====
This feature will be user agnostic however the configuration knob in openflowplugin.cfg file allow user to enable or disable bundle based reconciliation. This mechanism will change the way how flows/groups are pushed/provisioned to datapath node today. 


Implementation
==============
2 new API's introduced in class ForwardingRulesManager 
 
 getSalBundleService();                //API to get the bundle services API's 
 boolean isBundleBasedReconEnabled();   // read the configuration from openflowplugin and use through this API
 
class FlowNodeReconciliationImpl
  method reconcileConfiguration()     // modification in this method
									  // based on the configuration to got through bundle based or normal reconciliation      
	if(provider.isBundleBasedReconEnabled()){
                BundleBasedReconciliationTask bundleBasedReconTask = new BundleBasedReconciliationTask(connectedNode);
                executor.execute(bundleBasedReconTask);
            }else{
                ReconciliationTask reconciliationTask = new ReconciliationTask(connectedNode);
                executor.execute(reconciliationTask);
            }

New private class BundleBasedReconciliationTask within FlowNodeReconciliationImpl 
	// this inner class will define creating messages, opening bundles and adding messages to bundle and committing through the following API's
	salBundleService.controlBundle(openBundleInput)
	salBundleService.addBundleMessages(addBundleMessagesInput)
	salBundleService.controlBundle(commitBundleInput)


Assignee(s)
-----------
Primary assignee:
	sunil.g.kumar@ericsson.com

Other contributors:
	suja.t@ericsson.com 



Testing
=======

Unit Tests
----------

1) Controller managed one switch
2) Switch connected to 2 VM's
3) Ping VM1 from VM2
4) We observed flows being created and ping success. We observed increase in number of packets as and when ping is made and received.
5) Disconnected switch and reconnected.
6) flows reappeared on switch.
7) packet count was reset.

Documentation Impact
====================

By this feature, controller will remove all the exisiting flows from device as soon as device is connected back to controller. Initial step would be to delete all the existing flows in the switch in order to clean up the stale flows. This needs to be documented to state that stats will not remain in device after reconciliaiton or stats will not be reconcilled. 

References
==========

https://wiki.opendaylight.org/view/OpenDaylight_OpenFlow_Plugin:Hitless_resync