Cherry-pick from https://gerrit.onos.onlab.us/#/c/334

Changes for fixing reactiveFlow bugs
*Because of my test enviroment, I haven't tested this on the multiple onos instance enviroment.
*IDeviceStorage transaction close issue will be committed later.

-Implemented confirming flow add event feature and made some forwarding class changes to work with it.
-Made checking strictly the state of forwarding class.
-Added plus 2 sec of idle timeout for all flow entries except the head flow entry to avoid leaving a intermittent path.

Change-Id: I737c29da6241686c73079566c1b22947801c6e48
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
index 1a2563d..fa1394e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
@@ -56,6 +56,8 @@
 
     /** The logger. */
     private final static Logger log = LoggerFactory.getLogger(FlowEventHandler.class);
+    
+    private final int FLOW_IDLE_TIMEOUT_ADDED_SECONDS = 2;
 
     private DBOperation dbHandler;
 
@@ -1316,10 +1318,20 @@
 	    //
 	    // Copy the Flow timeouts
 	    //
-	    newFlowEntry.setIdleTimeout(flowPath.idleTimeout());
 	    newFlowEntry.setHardTimeout(flowPath.hardTimeout());
 	    newFlowEntry.setPriority(flowPath.priority());
 
+	    if (flowPath.idleTimeout() > 0) {
+	    	if (idx == 0) {
+	    		newFlowEntry.setIdleTimeout(flowPath.idleTimeout());
+	    	}
+	    	else {
+	    		newFlowEntry.setIdleTimeout(flowPath.idleTimeout() + FLOW_IDLE_TIMEOUT_ADDED_SECONDS);
+	    	}
+	     } else if(flowPath.idleTimeout() == 0) {
+	    	newFlowEntry.setIdleTimeout(flowPath.idleTimeout());
+	     }
+
 	    //
 	    // Allocate the FlowEntryMatch by copying the default one
 	    // from the FlowPath (if set).