+
+ public void syncSetUpFlow(FlowEntity flowEntity, long delay, boolean isRemove) {
+ s_logger.trace("syncSetUpFlow for flowEntity {} ", flowEntity);
+ if (flowEntity.getCookie() == null) {
+ flowEntity.setCookie(new BigInteger("0110000", 16));
+ }
+ Flow flow = flowEntity.getFlowBuilder().build();
+ String flowId = flowEntity.getFlowId();
+ BigInteger dpId = flowEntity.getDpnId();
+ short tableId = flowEntity.getTableId();
+ Match matches = flow.getMatch();
+ FlowKey flowKey = new FlowKey( new FlowId(flowId));
+ Node nodeDpn = buildDpnNode(dpId);
+ InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+ .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
+ Runnable notifyTask = new NotifyTask();
+ FlowInfoKey flowInfoKey = new FlowInfoKey(dpId, tableId, matches, flowId);
+ synchronized (flowInfoKey.toString().intern()) {
+ flowMap.put(flowInfoKey, notifyTask);
+ if (isRemove) {
+ MDSALUtil.syncDelete(m_dataBroker, LogicalDatastoreType.CONFIGURATION, flowInstanceId);
+ } else {
+ MDSALUtil.syncWrite(m_dataBroker, LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow);
+ }
+ synchronized (notifyTask) {
+ try {
+ notifyTask.wait(delay);
+ } catch (InterruptedException e){}
+ }
+ }
+ }
+
+ public void syncSetUpGroup(GroupEntity groupEntity, long delayTime, boolean isRemove) {
+ s_logger.trace("syncSetUpGroup for groupEntity {} ", groupEntity);
+ Group group = groupEntity.getGroupBuilder().build();
+ BigInteger dpId = groupEntity.getDpnId();
+ Node nodeDpn = buildDpnNode(dpId);
+ long groupId = groupEntity.getGroupId();
+ GroupKey groupKey = new GroupKey(new GroupId(groupId));
+ InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+ .child(Group.class, groupKey).build();
+ Runnable notifyTask = new NotifyTask();
+ GroupInfoKey groupInfoKey = new GroupInfoKey(dpId, groupId);
+ synchronized (groupInfoKey.toString().intern()) {
+ s_logger.trace("syncsetupGroupKey groupKey {}", groupInfoKey);
+ groupMap.put(groupInfoKey, notifyTask);
+ if (isRemove) {
+ MDSALUtil.syncDelete(m_dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId);
+ } else {
+ MDSALUtil.syncWrite(m_dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId, group);
+ }
+ synchronized (notifyTask) {
+ try {
+ notifyTask.wait(delayTime);
+ } catch (InterruptedException e){}
+ }
+ }
+ }
+