Bug 740: Forwardingrules-Manager support for DataChangeListeners 55/6255/5
authorVaclav Demcak <vdemcak@cisco.com>
Tue, 15 Apr 2014 16:26:20 +0000 (18:26 +0200)
committerVaclav Demcak <vdemcak@cisco.com>
Wed, 30 Apr 2014 09:46:12 +0000 (11:46 +0200)
+ Bug 619 - Eliminate the use of xtend in md-sal/forwardingrules-manager

migration from xtend to java files FRM
add DataChangeListener to FRM (Flow, Meter, Group)
remove FRM handlers (Flow, Meter, Group)
fix delete changes registration (in ImmutableDataChangeEvent -> old DataStore)

Change-Id: I56003833519d9689a489ed5f77b3f7fc4ac2e204
Signed-off-by: Vaclav Demcak <vdemcak@cisco.com>
24 files changed:
opendaylight/md-sal/forwardingrules-manager/pom.xml
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractTransaction.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowCommitHandler.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransaction.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransactionValidator.java
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupCommitHandler.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupTransaction.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupTransactionValidator.java
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterChangeListener.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterCommitHandler.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.java [new file with mode: 0644]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterTransaction.xtend [deleted file]
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterTransactionValidator.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/ImmutableDataChangeEvent.java

index 919a53c..9bd63d3 100644 (file)
           </instructions>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.eclipse.xtend</groupId>
-        <artifactId>xtend-maven-plugin</artifactId>
-      </plugin>
     </plugins>
   </build>
 
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractChangeListener.java
new file mode 100644 (file)
index 0000000..426f4ba
--- /dev/null
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * 
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public abstract class AbstractChangeListener implements DataChangeListener {
+
+    private final AtomicLong txNum = new AtomicLong();
+    private String transactionId;
+
+    @Override
+    public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+        this.transactionId = this.newTransactionIdentifier().toString();
+
+        final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> createdEntries = 
+                changeEvent.getCreatedConfigurationData().entrySet();
+        final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updatedEntries = 
+                new HashSet<Entry<InstanceIdentifier<? extends DataObject>, DataObject>>();
+
+        Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updateConfigEntrySet = 
+                changeEvent.getUpdatedConfigurationData().entrySet();
+        updatedEntries.addAll(updateConfigEntrySet);
+        updatedEntries.removeAll(createdEntries);
+
+        final Set<InstanceIdentifier<? extends DataObject>> removeEntriesInstanceIdentifiers = 
+                changeEvent.getRemovedConfigurationData();
+
+        for (final Entry<InstanceIdentifier<? extends DataObject>, DataObject> createdEntry : createdEntries) {
+            InstanceIdentifier<? extends DataObject> c_key = createdEntry.getKey();
+            DataObject c_value = createdEntry.getValue();
+            this.add(c_key, c_value);
+        }
+
+        for (final Entry<InstanceIdentifier<?>, DataObject> updatedEntrie : updatedEntries) {
+            Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData = 
+                    changeEvent.getOriginalConfigurationData();
+
+            InstanceIdentifier<? extends Object> u_key = updatedEntrie.getKey();
+            final DataObject originalFlow = origConfigData.get(u_key);
+            final DataObject updatedFlow = updatedEntrie.getValue();
+            this.update(u_key, originalFlow, updatedFlow);
+        }
+
+        for (final InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers) {
+            Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData = 
+                    changeEvent.getOriginalConfigurationData();
+
+            final DataObject removeValue = origConfigData.get(instanceId);
+            this.remove(instanceId, removeValue);
+        }
+    }
+
+    public String getTransactionId() {
+        return this.transactionId;
+    }
+
+    private Object newTransactionIdentifier() {
+        return "DOM-" + txNum.getAndIncrement();
+    }
+
+    protected abstract void validate() throws IllegalStateException;
+
+    protected abstract void remove(
+            final InstanceIdentifier<? extends DataObject> identifier,
+            final DataObject remove);
+
+    protected abstract void update(
+            final InstanceIdentifier<? extends DataObject> identifier,
+            final DataObject original, final DataObject update);
+
+    protected abstract void add(
+            final InstanceIdentifier<? extends DataObject> identifier,
+            final DataObject add);
+}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractTransaction.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractTransaction.xtend
deleted file mode 100644 (file)
index cb1e90d..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm
-
-import java.util.Collections
-import java.util.HashSet
-import java.util.Map.Entry
-import java.util.Set
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.controller.sal.common.util.Rpcs
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.common.RpcError
-
-abstract class AbstractTransaction implements DataCommitTransaction<InstanceIdentifier<?extends DataObject>, DataObject> {
-        
-    @Property
-    val DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
-    
-    new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
-        _modification = modification;
-    }
-    
-    def void validate() throws IllegalStateException
-    
-    override finish() throws IllegalStateException {
-        validate()
-        callRpcs();
-        return Rpcs.getRpcResult(true, null, Collections.<RpcError>emptySet());     
-    }
-    
-    override getModification() {
-        return _modification;
-    }
-    
-    override rollback() throws IllegalStateException {
-        rollbackRpcs();
-        return Rpcs.getRpcResult(true, null, Collections.<RpcError>emptySet());
-    }
-    
-    def private callRpcs() {
-        val Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> createdEntries = _modification.getCreatedConfigurationData().entrySet();
-
-        /*
-         * This little dance is because updatedEntries contains both created and modified entries
-         * The reason I created a new HashSet is because the collections we are returned are immutable.
-         */
-        val Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updatedEntries = new HashSet<Entry<InstanceIdentifier<? extends DataObject>, DataObject>>();
-        updatedEntries.addAll(_modification.getUpdatedConfigurationData().entrySet());
-        updatedEntries.removeAll(createdEntries);
-
-        val Set<InstanceIdentifier<? extends DataObject>> removeEntriesInstanceIdentifiers = _modification.getRemovedConfigurationData();
-        for (Entry<InstanceIdentifier<? extends DataObject >, DataObject> entry : createdEntries) {
-            add(entry.key,entry.value);
-        }
-        for (Entry<InstanceIdentifier<?>, DataObject> entry : updatedEntries) {
-                val originalFlow = _modification.originalConfigurationData.get(entry.key);
-                val updatedFlow = entry.value
-                update(entry.key, originalFlow ,updatedFlow);
-        }
-
-        for (InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers ) {
-            val removeValue = _modification.getOriginalConfigurationData.get(instanceId);
-                remove(instanceId,removeValue);
-        }
-    }
-    
-    def void remove(InstanceIdentifier<?> identifier, DataObject remove)
-    
-    def void update(InstanceIdentifier<?> identifier, DataObject original, DataObject update)
-    
-    def void add(InstanceIdentifier<?> identifier, DataObject add)
-    
-    def private rollbackRpcs() {
-        val Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> createdEntries = _modification.getCreatedConfigurationData().entrySet();
-
-        /*
-         * This little dance is because updatedEntries contains both created and modified entries
-         * The reason I created a new HashSet is because the collections we are returned are immutable.
-         */
-        val Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updatedEntries = new HashSet<Entry<InstanceIdentifier<? extends DataObject>, DataObject>>();
-        updatedEntries.addAll(_modification.getUpdatedConfigurationData().entrySet());
-        updatedEntries.removeAll(createdEntries);
-
-        val Set<InstanceIdentifier<? >> removeEntriesInstanceIdentifiers = _modification.getRemovedConfigurationData();
-        for (Entry<InstanceIdentifier<?>, DataObject> entry : createdEntries) {
-            remove(entry.key,entry.value); // because we are rolling back, remove what we would have added.            
-        }
-        for (Entry<InstanceIdentifier<?>, DataObject> entry : updatedEntries) {
-            val originalFlow = _modification.originalConfigurationData.get(entry.key);
-            val updatedFlow = entry.value
-            update(entry.key, updatedFlow ,originalFlow);// because we are rolling back, replace the updated with the original
-        }
-
-        for (InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers ) {
-            val removeValue = _modification.getOriginalConfigurationData.get(instanceId);
-            add(instanceId,removeValue);// because we are rolling back, add what we would have removed.
-        }
-    }    
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.java
new file mode 100644 (file)
index 0000000..929c489
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm;
+
+import org.opendaylight.controller.frm.flow.FlowProvider;
+import org.opendaylight.controller.frm.group.GroupProvider;
+import org.opendaylight.controller.frm.meter.MeterProvider;
+import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FRMActivator extends AbstractBindingAwareProvider {
+
+    private final static Logger LOG = LoggerFactory.getLogger(FRMActivator.class);
+
+    private static FlowProvider flowProvider = new FlowProvider(); 
+    private static GroupProvider groupProvider = new GroupProvider();
+    private static MeterProvider meterProvider = new MeterProvider();
+    
+    @Override
+    public void onSessionInitiated(final ProviderContext session) {
+        DataProviderService flowSalService = session.<DataProviderService>getSALService(DataProviderService.class);
+        FRMActivator.flowProvider.setDataService(flowSalService);
+        SalFlowService rpcFlowSalService = session.<SalFlowService>getRpcService(SalFlowService.class);
+        FRMActivator.flowProvider.setSalFlowService(rpcFlowSalService);
+        FRMActivator.flowProvider.start();
+        DataProviderService groupSalService = session.<DataProviderService>getSALService(DataProviderService.class);
+        FRMActivator.groupProvider.setDataService(groupSalService);
+        SalGroupService rpcGroupSalService = session.<SalGroupService>getRpcService(SalGroupService.class);
+        FRMActivator.groupProvider.setSalGroupService(rpcGroupSalService);
+        FRMActivator.groupProvider.start();
+        DataProviderService meterSalService = session.<DataProviderService>getSALService(DataProviderService.class);
+        FRMActivator.meterProvider.setDataService(meterSalService);
+        SalMeterService rpcMeterSalService = session.<SalMeterService>getRpcService(SalMeterService.class);
+        FRMActivator.meterProvider.setSalMeterService(rpcMeterSalService);
+        FRMActivator.meterProvider.start();
+    }
+    
+    @Override
+    protected void stopImpl(final BundleContext context) {
+        try {
+            FRMActivator.flowProvider.close();
+            FRMActivator.groupProvider.close();
+            FRMActivator.meterProvider.close();
+        } catch (Throwable e) {
+            LOG.error("Unexpected error by stopping FRMActivator", e);
+            throw new RuntimeException(e);
+        }
+    }
+  }
\ No newline at end of file
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.xtend
deleted file mode 100644 (file)
index 8ec9d79..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * 
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm
-
-import org.opendaylight.controller.frm.flow.FlowProvider
-import org.opendaylight.controller.frm.group.GroupProvider
-import org.opendaylight.controller.frm.meter.MeterProvider
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService
-import org.osgi.framework.BundleContext
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService
-
-class FRMActivator extends AbstractBindingAwareProvider {
-
-    static var FlowProvider provider = new FlowProvider();
-    static var GroupProvider groupProvider = new GroupProvider();
-    static var MeterProvider meterProvider = new MeterProvider();
-
-    override onSessionInitiated(ProviderContext session) {
-        provider.dataService = session.getSALService(DataProviderService)
-        provider.salFlowService = session.getRpcService(SalFlowService);
-        provider.start();
-        
-        groupProvider.dataService = session.getSALService(DataProviderService)
-        groupProvider.salGroupService = session.getRpcService(SalGroupService)
-        groupProvider.start();
-        
-        meterProvider.dataService = session.getSALService(DataProviderService)
-        meterProvider.salMeterService = session.getRpcService(SalMeterService)
-        meterProvider.start();
-    }
-
-    override protected stopImpl(BundleContext context) {
-        provider.close();
-        groupProvider.close();
-        meterProvider.close();
-    }
-
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowChangeListener.java
new file mode 100644 (file)
index 0000000..df086c7
--- /dev/null
@@ -0,0 +1,120 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm.flow;
+
+import org.opendaylight.controller.frm.AbstractChangeListener;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class FlowChangeListener extends AbstractChangeListener {
+
+    private final static Logger LOG = LoggerFactory.getLogger(FlowChangeListener.class);
+
+    private final SalFlowService salFlowService;
+
+    public SalFlowService getSalFlowService() {
+        return this.salFlowService;
+    }
+    
+    public FlowChangeListener(final SalFlowService manager) {
+        this.salFlowService = manager;
+    }
+
+    @Override
+    protected void validate() throws IllegalStateException {
+        FlowTransactionValidator.validate(this);
+    }
+
+    @Override
+    protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
+        if ((removeDataObj instanceof Flow)) {
+            
+            final Flow flow = ((Flow) removeDataObj);
+            final InstanceIdentifier<Table> tableInstanceId = identifier.<Table> firstIdentifierOf(Table.class);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(flow);
+            
+            builder.setFlowRef(new FlowRef(identifier));
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setFlowTable(new FlowTableRef(tableInstanceId));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            this.salFlowService.removeFlow((RemoveFlowInput) builder.build());
+            LOG.debug("Transaction {} - Removed Flow has removed flow: {}", new Object[]{uri, removeDataObj});
+        }
+    }
+
+    @Override
+    protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
+        if (original instanceof Flow && update instanceof Flow) {
+            
+            final Flow originalFlow = ((Flow) original);
+            final Flow updatedFlow = ((Flow) update);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node>firstIdentifierOf(Node.class);
+            final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setFlowRef(new FlowRef(identifier));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            
+            builder.setUpdatedFlow((UpdatedFlow) (new UpdatedFlowBuilder(updatedFlow)).build());
+            builder.setOriginalFlow((OriginalFlow) (new OriginalFlowBuilder(originalFlow)).build());
+            
+            this.salFlowService.updateFlow((UpdateFlowInput) builder.build());
+            LOG.debug("Transaction {} - Update Flow has updated flow {} with {}", new Object[]{uri, original, update});
+      }
+    }
+
+    @Override
+    protected void add(InstanceIdentifier<? extends DataObject> identifier, DataObject addDataObj) {
+        if ((addDataObj instanceof Flow)) {
+            
+            final Flow flow = ((Flow) addDataObj);
+            final InstanceIdentifier<Table> tableInstanceId = identifier.<Table> firstIdentifierOf(Table.class);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow);
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setFlowRef(new FlowRef(identifier));
+            builder.setFlowTable(new FlowTableRef(tableInstanceId));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            this.salFlowService.addFlow((AddFlowInput) builder.build());
+            LOG.debug("Transaction {} - Add Flow has added flow: {}", new Object[]{uri, addDataObj});
+        }
+    }
+}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowCommitHandler.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowCommitHandler.xtend
deleted file mode 100644 (file)
index 188bfcd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.flow
-
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-
-class FlowCommitHandler implements DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
-       
-    @Property
-    val SalFlowService salFlowService;
-    
-    new(SalFlowService manager) {
-        _salFlowService = manager;
-    }
-    
-    override requestCommit(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
-        return new FlowTransaction(modification,salFlowService);
-    }
-    
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.java
new file mode 100644 (file)
index 0000000..afdd628
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm.flow;
+
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FlowProvider implements AutoCloseable {
+
+    private final static Logger LOG = LoggerFactory.getLogger(FlowProvider.class);
+
+    private SalFlowService salFlowService;
+    private DataProviderService dataService;
+
+    /* DataChangeListener */
+    private FlowChangeListener flowDataChangeListener;
+    ListenerRegistration<DataChangeListener> flowDataChangeListenerRegistration;
+
+    public void start() {
+        /* Build Path */
+        InstanceIdentifierBuilder<Nodes> nodesBuilder = InstanceIdentifier.<Nodes> builder(Nodes.class);
+        InstanceIdentifierBuilder<Node> nodeChild = nodesBuilder.<Node> child(Node.class);
+        InstanceIdentifierBuilder<FlowCapableNode> augmentFlowCapNode = nodeChild.<FlowCapableNode> augmentation(FlowCapableNode.class);
+        InstanceIdentifierBuilder<Table> tableChild = augmentFlowCapNode.<Table> child(Table.class);
+        InstanceIdentifierBuilder<Flow> flowChild = tableChild.<Flow> child(Flow.class);
+        final InstanceIdentifier<? extends DataObject> flowDataObjectPath = flowChild.toInstance();
+        
+        /* DataChangeListener registration */
+        this.flowDataChangeListener = new FlowChangeListener(this.salFlowService);
+        this.flowDataChangeListenerRegistration = this.dataService.registerDataChangeListener(flowDataObjectPath, flowDataChangeListener);
+        LOG.info("Flow Config Provider started.");
+    }
+
+    protected DataModificationTransaction startChange() {
+        return this.dataService.beginTransaction();
+    }
+
+    @Override
+    public void close() throws Exception {
+        if(flowDataChangeListenerRegistration != null){
+            flowDataChangeListenerRegistration.close();
+        }
+    }
+
+    public void setDataService(final DataProviderService dataService) {
+        this.dataService = dataService;
+    }
+
+    public void setSalFlowService(final SalFlowService salFlowService) {
+        this.salFlowService = salFlowService;
+    }
+}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.xtend
deleted file mode 100644 (file)
index d2ed541..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.flow
-
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yangtools.concepts.Registration
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.slf4j.LoggerFactory
-
-class FlowProvider implements AutoCloseable {
-    
-    @Property
-    DataProviderService dataService;
-    
-    @Property
-    SalFlowService salFlowService;
-    
-    FlowCommitHandler commitHandler
-
-    Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>,DataObject>> commitHandlerRegistration;
-    
-    static val LOG = LoggerFactory.getLogger(FlowProvider);
-    
-    def void start() {
-        commitHandler = new FlowCommitHandler(salFlowService)
-        val InstanceIdentifier<? extends DataObject> path = InstanceIdentifier.builder(Nodes)
-            .child(Node)
-            .augmentation(FlowCapableNode)
-            .child(Table)
-            .child(Flow)
-            .toInstance();
-        commitHandlerRegistration = dataService.registerCommitHandler(path,commitHandler);
-        LOG.info("Flow Config Provider started.");
-    }
-
-    protected def startChange() {
-        return dataService.beginTransaction;
-    }
-    
-    override close() throws Exception {
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")
-    }
-    
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransaction.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransaction.xtend
deleted file mode 100644 (file)
index 26846ad..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.flow
-
-import org.opendaylight.controller.frm.AbstractTransaction
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
-
-class FlowTransaction extends AbstractTransaction {
-    
-    @Property
-    val SalFlowService salFlowService;   
-    
-    
-    new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,SalFlowService salFlowService) {
-        super(modification)        
-        _salFlowService = salFlowService;
-    }
-    
-    override remove(InstanceIdentifier<?> instanceId, DataObject obj) {
-        if(obj instanceof Flow) {
-            val flow = (obj as Flow)
-            val tableInstanceId = instanceId.firstIdentifierOf(Table);
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new RemoveFlowInputBuilder(flow);
-            builder.setFlowRef(new FlowRef(instanceId));            
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setFlowTable(new FlowTableRef(tableInstanceId));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            _salFlowService.removeFlow(builder.build());            
-        }
-    }
-    
-    override update(InstanceIdentifier<?> instanceId, DataObject originalObj, DataObject updatedObj) {
-        if(originalObj instanceof Flow && updatedObj instanceof Flow) {
-            val originalFlow = (originalObj as Flow)
-            val updatedFlow = (updatedObj as Flow)
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new UpdateFlowInputBuilder();
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setFlowRef(new FlowRef(instanceId));
-            val ufb = new UpdatedFlowBuilder(updatedFlow);
-            builder.setUpdatedFlow((ufb.build()));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            val ofb = new OriginalFlowBuilder(originalFlow);
-            builder.setOriginalFlow(ofb.build());      
-            _salFlowService.updateFlow(builder.build());
-           
-        }
-    }
-    
-    override add(InstanceIdentifier<?> instanceId, DataObject obj) {
-        if(obj instanceof Flow) {
-            val flow = (obj as Flow)
-            val tableInstanceId = instanceId.firstIdentifierOf(Table);
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new AddFlowInputBuilder(flow);
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            builder.setFlowRef(new FlowRef(instanceId));
-            builder.setFlowTable(new FlowTableRef(tableInstanceId));
-            _salFlowService.addFlow(builder.build());            
-        }
-    }
-    
-    override validate() throws IllegalStateException {
-        FlowTransactionValidator.validate(this)
-    }  
-}
index 7c6f1ff..4ef93a5 100644 (file)
@@ -1,6 +1,6 @@
-/*
+/**
  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * 
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,8 +9,7 @@ package org.opendaylight.controller.frm.flow;
 
 public class FlowTransactionValidator {
 
-    public static void validate(FlowTransaction transaction) throws IllegalStateException {
+    public static void validate(FlowChangeListener transaction) throws IllegalStateException {
         // NOOP
     }
-
 }
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupChangeListener.java
new file mode 100644 (file)
index 0000000..1260f0e
--- /dev/null
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm.group;
+
+import org.opendaylight.controller.frm.AbstractChangeListener;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class GroupChangeListener extends AbstractChangeListener {
+
+    private final static Logger LOG = LoggerFactory.getLogger(GroupChangeListener.class);
+
+    private final SalGroupService salGroupService;
+
+    public SalGroupService getSalGroupService() {
+        return this.salGroupService;
+    }
+    
+    public GroupChangeListener(final SalGroupService manager) {
+        this.salGroupService = manager;
+    }
+
+    @Override
+    protected void validate() throws IllegalStateException {
+        GroupTransactionValidator.validate(this);
+    }
+
+    @Override
+    protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
+        if ((removeDataObj instanceof Group)) {
+            
+            final Group group = ((Group) removeDataObj);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group);
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setGroupRef(new GroupRef(identifier));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            this.salGroupService.removeGroup((RemoveGroupInput) builder.build());
+            LOG.debug("Transaction {} - Remove Group has removed group: {}", new Object[]{uri, removeDataObj});
+        }
+    }
+
+    @Override
+    protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
+        if (original instanceof Group && update instanceof Group) {
+            
+            final Group originalGroup = ((Group) original);
+            final Group updatedGroup = ((Group) update);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setGroupRef(new GroupRef(identifier));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            
+            builder.setUpdatedGroup((UpdatedGroup) (new UpdatedGroupBuilder(updatedGroup)).build());
+            builder.setOriginalGroup((OriginalGroup) (new OriginalGroupBuilder(originalGroup)).build());
+            
+            this.salGroupService.updateGroup((UpdateGroupInput) builder.build());
+            LOG.debug("Transaction {} - Update Group has updated group {} with group {}", new Object[]{uri, original, update});
+        }
+    }
+
+    @Override
+    protected void add(InstanceIdentifier<? extends DataObject> identifier, DataObject addDataObj) {
+        if ((addDataObj instanceof Group)) {
+            final Group group = ((Group) addDataObj);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final AddGroupInputBuilder builder = new AddGroupInputBuilder(group);
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setGroupRef(new GroupRef(identifier));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            this.salGroupService.addGroup((AddGroupInput) builder.build());
+            LOG.debug("Transaction {} - Add Group has added group: {}", new Object[]{uri, addDataObj});
+        }
+    }
+}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupCommitHandler.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupCommitHandler.xtend
deleted file mode 100644 (file)
index b6d3851..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.group
-
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-
-class GroupCommitHandler implements DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
-       
-    @Property
-    val SalGroupService groupService;
-    
-    new(SalGroupService groupService) {
-        _groupService = groupService;
-    }
-    
-    override requestCommit(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
-        return new GroupTransaction(modification,groupService);
-    }
-    
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.java
new file mode 100644 (file)
index 0000000..14b1b6f
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm.group;
+
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GroupProvider implements AutoCloseable {
+
+    private final static Logger LOG = LoggerFactory.getLogger(GroupProvider.class);
+
+    private SalGroupService salGroupService;
+    private DataProviderService dataService;
+
+    /* DataChangeListener */
+    private GroupChangeListener groupDataChangeListener;
+    ListenerRegistration<DataChangeListener> groupDataChangeListenerRegistration;
+
+    public void start() {
+        /* Build Path */
+        InstanceIdentifierBuilder<Nodes> nodesBuilder = InstanceIdentifier.<Nodes> builder(Nodes.class);
+        InstanceIdentifierBuilder<Node> nodeChild = nodesBuilder.<Node> child(Node.class);
+        InstanceIdentifierBuilder<FlowCapableNode> augmentFlowCapNode = nodeChild.<FlowCapableNode> augmentation(FlowCapableNode.class);
+        InstanceIdentifierBuilder<Group> groupChild = augmentFlowCapNode.<Group> child(Group.class);
+        final InstanceIdentifier<? extends DataObject> groupDataObjectPath = groupChild.toInstance();
+
+        /* DataChangeListener registration */
+        this.groupDataChangeListener = new GroupChangeListener(this.salGroupService);
+        this.groupDataChangeListenerRegistration = this.dataService.registerDataChangeListener(groupDataObjectPath, groupDataChangeListener);
+        LOG.info("Group Config Provider started.");
+    }
+    
+    protected DataModificationTransaction startChange() {
+        return this.dataService.beginTransaction();
+    }
+    
+    public void close() throws Exception {
+        if(groupDataChangeListenerRegistration != null){
+            groupDataChangeListenerRegistration.close();
+        }
+    }
+
+    public void setDataService(final DataProviderService dataService) {
+        this.dataService = dataService;
+    }
+
+    public void setSalGroupService(final SalGroupService salGroupService) {
+        this.salGroupService = salGroupService;
+    }
+}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.xtend
deleted file mode 100644 (file)
index 4ded8b6..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.group
-
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yangtools.concepts.Registration
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.slf4j.LoggerFactory
-
-class GroupProvider implements AutoCloseable {
-    
-    @Property
-    DataProviderService dataService;
-    
-    @Property
-    SalGroupService salGroupService;
-    
-    GroupCommitHandler commitHandler
-
-    Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>,DataObject>> commitHandlerRegistration;
-    
-    static val LOG = LoggerFactory.getLogger(GroupProvider);
-    
-    def void start() {
-        commitHandler = new GroupCommitHandler(salGroupService)
-        val InstanceIdentifier<? extends DataObject> path = InstanceIdentifier.builder(Nodes)
-            .child(Node)
-            .augmentation(FlowCapableNode)
-            .child(Group)
-            .toInstance();
-        commitHandlerRegistration = dataService.registerCommitHandler(path,commitHandler);
-        LOG.info("Group Config Provider started.");
-    }
-
-    protected def startChange() {
-        return dataService.beginTransaction;
-    }
-    
-    override close() throws Exception {
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")
-    }
-    
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupTransaction.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupTransaction.xtend
deleted file mode 100644 (file)
index e8d9982..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.group
-
-import org.opendaylight.controller.frm.AbstractTransaction
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
-
-class GroupTransaction extends AbstractTransaction {
-    
-    @Property
-    val SalGroupService groupService;
-        
-    new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,SalGroupService groupService) {
-        super(modification)        
-        _groupService = groupService;
-    }
-    
-    override remove(InstanceIdentifier<?> instanceId, DataObject obj) {
-        if(obj instanceof Group) {
-            val group = (obj as Group)
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new RemoveGroupInputBuilder(group);
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            builder.setGroupRef(new GroupRef(instanceId));
-            _groupService.removeGroup(builder.build());            
-        }
-    }
-    
-    override update(InstanceIdentifier<?> instanceId, DataObject originalObj, DataObject updatedObj) {
-        if(originalObj instanceof Group && updatedObj instanceof Group) {
-            val originalGroup = (originalObj as Group)
-            val updatedGroup = (updatedObj as Group)
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new UpdateGroupInputBuilder();
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setGroupRef(new GroupRef(instanceId));
-            val ufb = new UpdatedGroupBuilder(updatedGroup);
-            builder.setUpdatedGroup((ufb.build()));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            val ofb = new OriginalGroupBuilder(originalGroup);
-            builder.setOriginalGroup(ofb.build());      
-            _groupService.updateGroup(builder.build());
-           
-        }
-    }
-    
-    override add(InstanceIdentifier<?> instanceId, DataObject obj) {
-        if(obj instanceof Group) {
-            val group = (obj as Group)
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new AddGroupInputBuilder(group);
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setGroupRef(new GroupRef(instanceId));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            _groupService.addGroup(builder.build());            
-        }
-    }
-    
-    override validate() throws IllegalStateException {
-        GroupTransactionValidator.validate(this)
-    }  
-}
index 92baf7b..88eea0d 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -9,8 +9,7 @@ package org.opendaylight.controller.frm.group;
 
 public class GroupTransactionValidator {
 
-    public static void validate(GroupTransaction transaction) throws IllegalStateException {
+    public static void validate(GroupChangeListener transaction) throws IllegalStateException {
         // NOOP
     }
-
 }
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterChangeListener.java
new file mode 100644 (file)
index 0000000..839e556
--- /dev/null
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm.meter;
+
+import org.opendaylight.controller.frm.AbstractChangeListener;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
+ *
+ */
+public class MeterChangeListener extends AbstractChangeListener {
+
+    private final static Logger LOG = LoggerFactory.getLogger(MeterChangeListener.class);
+
+    private final SalMeterService salMeterService;
+
+    public SalMeterService getSalMeterService() {
+        return this.salMeterService;
+    }
+    
+    public MeterChangeListener(final SalMeterService manager) {
+        this.salMeterService = manager;
+    }
+
+    @Override
+    protected void validate() throws IllegalStateException {
+        MeterTransactionValidator.validate(this);
+    }
+
+    @Override
+    protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
+        if ((removeDataObj instanceof Meter)) {
+            
+            final Meter meter = ((Meter) removeDataObj);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(meter);
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setMeterRef(new MeterRef(identifier));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            this.salMeterService.removeMeter((RemoveMeterInput) builder.build());
+            LOG.debug("Transaction {} - Remove Meter has removed meter: {}", new Object[]{uri, removeDataObj});
+        }
+    }
+
+    @Override
+    protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
+        if (original instanceof Meter && update instanceof Meter) {
+            
+            final Meter originalMeter = ((Meter) original);
+            final Meter updatedMeter = ((Meter) update);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final UpdateMeterInputBuilder builder = new UpdateMeterInputBuilder();
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setMeterRef(new MeterRef(identifier));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            
+            builder.setUpdatedMeter((UpdatedMeter) (new UpdatedMeterBuilder(updatedMeter)).build());
+            builder.setOriginalMeter((OriginalMeter) (new OriginalMeterBuilder(originalMeter)).build());
+            
+            this.salMeterService.updateMeter((UpdateMeterInput) builder.build());
+            LOG.debug("Transaction {} - Update Meter has updated meter {} with {}", new Object[]{uri, original, update});
+        }
+    }
+
+    @Override
+    protected void add(InstanceIdentifier<? extends DataObject> identifier, DataObject addDataObj) {
+        if ((addDataObj instanceof Meter)) {
+            
+            final Meter meter = ((Meter) addDataObj);
+            final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
+            final AddMeterInputBuilder builder = new AddMeterInputBuilder(meter);
+            
+            builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setMeterRef(new MeterRef(identifier));
+            
+            Uri uri = new Uri(this.getTransactionId());
+            builder.setTransactionUri(uri);
+            this.salMeterService.addMeter((AddMeterInput) builder.build());
+            LOG.debug("Transaction {} - Add Meter has added meter: {}", new Object[]{uri, addDataObj});
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterCommitHandler.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterCommitHandler.xtend
deleted file mode 100644 (file)
index d5292f0..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.meter
-
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-
-class FlowCommitHandler implements DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
-       
-    @Property
-    val SalMeterService salMeterService;
-    
-    new(SalMeterService manager) {
-        _salMeterService = manager;
-    }
-    
-    override requestCommit(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
-        return new MeterTransaction(modification,salMeterService);
-    }
-    
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.java
new file mode 100644 (file)
index 0000000..620801f
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.frm.meter;
+
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MeterProvider implements AutoCloseable {
+
+    private final static Logger LOG = LoggerFactory.getLogger(MeterProvider.class);
+
+    private DataProviderService dataService;
+    private SalMeterService salMeterService;
+
+    /* DataChangeListener */
+    private MeterChangeListener meterDataChangeListener;
+    ListenerRegistration<DataChangeListener> meterDataChangeListenerRegistration;
+
+    public void start() {
+        /* Build Path */
+        InstanceIdentifierBuilder<Nodes> nodesBuilder = InstanceIdentifier.<Nodes> builder(Nodes.class);
+        InstanceIdentifierBuilder<Node> nodeChild = nodesBuilder.<Node> child(Node.class);
+        InstanceIdentifierBuilder<FlowCapableNode> augmentFlowCapNode = nodeChild.<FlowCapableNode> augmentation(FlowCapableNode.class);
+        InstanceIdentifierBuilder<Meter> meterChild = augmentFlowCapNode.<Meter> child(Meter.class);
+        final InstanceIdentifier<? extends DataObject> meterDataObjectPath = meterChild.toInstance();
+
+        /* DataChangeListener registration */
+        this.meterDataChangeListener = new MeterChangeListener(this.salMeterService);
+        this.meterDataChangeListenerRegistration = this.dataService.registerDataChangeListener(meterDataObjectPath, meterDataChangeListener);
+        LOG.info("Meter Config Provider started.");
+    }
+    
+    protected DataModificationTransaction startChange() {
+        return this.dataService.beginTransaction();
+    }
+
+    public void close() throws Exception {
+        if(meterDataChangeListenerRegistration != null){
+            meterDataChangeListenerRegistration.close();
+        }
+    }
+
+    public void setDataService(final DataProviderService dataService) {
+        this.dataService = dataService;
+    }
+
+    public void setSalMeterService(final SalMeterService salMeterService) {
+        this.salMeterService = salMeterService;
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.xtend
deleted file mode 100644 (file)
index 323da57..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.meter
-
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService
-import org.opendaylight.yangtools.concepts.Registration
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.slf4j.LoggerFactory
-
-class MeterProvider implements AutoCloseable {
-    
-    @Property
-    DataProviderService dataService;
-    
-    @Property
-    SalMeterService salMeterService;
-    
-    FlowCommitHandler commitHandler
-
-    Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>,DataObject>> commitHandlerRegistration;
-    
-    static val LOG = LoggerFactory.getLogger(MeterProvider);
-    
-    def void start() {
-        commitHandler = new FlowCommitHandler(salMeterService)
-        val InstanceIdentifier<? extends DataObject> path = InstanceIdentifier.builder(Nodes)
-            .child(Node)
-            .augmentation(FlowCapableNode)
-            .child(Meter)
-            .toInstance();
-        commitHandlerRegistration = dataService.registerCommitHandler(path,commitHandler);
-        LOG.info("Meter Config Provider started.");
-    }
-
-    protected def startChange() {
-        return dataService.beginTransaction;
-    }
-    
-    override close() throws Exception {
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")
-    }
-    
-}
diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterTransaction.xtend b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterTransaction.xtend
deleted file mode 100644 (file)
index 491fa08..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.frm.meter
-
-import org.opendaylight.controller.frm.AbstractTransaction
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
-
-class MeterTransaction extends AbstractTransaction {
-    
-    @Property
-    val SalMeterService salMeterService;
-        
-    new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,SalMeterService salMeterService) {
-        super(modification)    
-        _salMeterService = salMeterService;
-    }
-    
-    override remove(InstanceIdentifier<?> instanceId, DataObject obj) {
-        if(obj instanceof Meter) {
-            val meter = (obj as Meter)
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new RemoveMeterInputBuilder(meter);
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setMeterRef(new MeterRef(instanceId));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            _salMeterService.removeMeter(builder.build());            
-        }
-    }
-    
-    override update(InstanceIdentifier<?> instanceId, DataObject originalObj, DataObject updatedObj) {
-        if(originalObj instanceof Meter && updatedObj instanceof Meter) {
-            val originalMeter = (originalObj as Meter)
-            val updatedMeter = (updatedObj as Meter)
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new UpdateMeterInputBuilder();
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setMeterRef(new MeterRef(instanceId));
-            val ufb = new UpdatedMeterBuilder(updatedMeter);
-            builder.setUpdatedMeter((ufb.build()));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            val ofb = new OriginalMeterBuilder(originalMeter);
-            builder.setOriginalMeter(ofb.build());      
-            _salMeterService.updateMeter(builder.build());
-           
-        }
-    }
-    
-    override add(InstanceIdentifier<?> instanceId, DataObject obj) {
-        if(obj instanceof Meter) {
-            val meter = (obj as Meter)
-            val nodeInstanceId = instanceId.firstIdentifierOf(Node);
-            val builder = new AddMeterInputBuilder(meter);
-            builder.setNode(new NodeRef(nodeInstanceId));
-            builder.setMeterRef(new MeterRef(instanceId));
-            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
-            _salMeterService.addMeter(builder.build());            
-        }
-    }
-    
-    override validate() throws IllegalStateException {
-        MeterTransactionValidator.validate(this)
-    }  
-}
index b16739c..c8fba23 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -9,8 +9,7 @@ package org.opendaylight.controller.frm.meter;
 
 public class MeterTransactionValidator {
 
-    public static void validate(MeterTransaction transaction) throws IllegalStateException {
+    public static void validate(MeterChangeListener transaction) throws IllegalStateException {
         // NOOP
     }
-
 }
index a91799d..19235d2 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
 public final class ImmutableDataChangeEvent<P extends Path<P>, D> implements DataChangeEvent<P,D> {
 
@@ -127,6 +128,8 @@ public final class ImmutableDataChangeEvent<P extends Path<P>, D> implements Dat
             originalOperational.putAll(Maps.filterKeys(data.getOriginalOperationalData(), keyFilter));
             createdOperational.putAll(Maps.filterKeys(data.getCreatedOperationalData(), keyFilter));
             createdConfiguration.putAll(Maps.filterKeys(data.getCreatedConfigurationData(), keyFilter));
+            removedOperational.addAll(Sets.filter(data.getRemovedOperationalData(), keyFilter));
+            removedConfiguration.addAll(Sets.filter(data.getRemovedConfigurationData(), keyFilter));
             return this;
         }