Updated implementation of Netconf, fixed DOM Mountpoint
authorTony Tkacik <ttkacik@cisco.com>
Wed, 15 Jan 2014 13:04:02 +0000 (14:04 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Wed, 15 Jan 2014 18:03:25 +0000 (19:03 +0100)
Change-Id: Ia0d4f92a65174e891a8111571ced24182d9f47c6
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
12 files changed:
opendaylight/md-sal/sal-common-util/pom.xml
opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Arguments.java
opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/CommitHandlerTransactions.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Futures.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountInstance.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/$ModuleInfo.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java

index ff15e72ba6fc3d1106a46bfadd08dfcd2e67bd60..adbe3d2a4997e183d6ce73d2420fe67b50db8dab 100644 (file)
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    
   </dependencies>
 
   <packaging>bundle</packaging>
index 2d10fba8a5fd77c18b872991669d576f9aae7a7e..902665d1a6fa137d41d7f1bc89cf8116fbb52ee1 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * 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.sal.common.util;
 
 public class Arguments {
diff --git a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/CommitHandlerTransactions.java b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/CommitHandlerTransactions.java
new file mode 100644 (file)
index 0000000..bffeb59
--- /dev/null
@@ -0,0 +1,38 @@
+package org.opendaylight.controller.sal.common.util;
+
+import java.util.Collections;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public class CommitHandlerTransactions {
+
+    private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
+        
+        private final  DataModification<P, D> modification;
+
+        public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
+            this.modification = modification;
+        }
+        @Override
+        public RpcResult<Void> rollback() throws IllegalStateException {
+            return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
+        }
+        @Override
+        public RpcResult<Void> finish() throws IllegalStateException {
+            return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
+        }
+        
+        @Override
+        public DataModification<P, D> getModification() {
+            return modification;
+        }
+    }
+    
+    public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification)  {
+        return new AllwaysSuccessfulTransaction<>(modification);
+    }
+}
index d9cf5cc477aa2a81cd33796dd6b5f90b488fb1b9..42b00ba03d113dbcf0eb67958f068d5370491792 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * 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.sal.common.util;
 
 import java.util.concurrent.ExecutionException;
index c326bab7a4677bf5db471f940ad2a35768b11dc0..951d5b142e76561485c5cd7f52e12fb84a462cce 100644 (file)
@@ -4,7 +4,7 @@ import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
 
-public interface RpcProvisionRegistry {
+public interface RpcProvisionRegistry extends BrokerService {
 
     /**
      * Registers an implementation of the rpc.
index 910c7cb62365d01ca43e6d30dec43966f1a8f233..18c854646cca6aa08596a84ddaeba77959129219 100644 (file)
@@ -6,7 +6,6 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-
 package org.opendaylight.controller.sal.core.api.mount;
 
 import java.util.concurrent.Future;
@@ -18,9 +17,11 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public interface MountInstance extends NotificationService, DataBrokerService {
+public interface MountInstance extends //
+        NotificationService, //
+        DataBrokerService {
 
     Future<RpcResult<CompositeNode>> rpc(QName type, CompositeNode input);
-    
+
     SchemaContext getSchemaContext();
 }
index fade7d341b2bf7d69ee0ad41ad0d4f4e64042acf..c1f873c3af4694395d8cd8a141c06814ecc11bbf 100644 (file)
@@ -1,5 +1,8 @@
 package org.opendaylight.controller.sal.core.api.mount;
 
+import java.util.EventListener;
+
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
 public interface MountProvisionService extends MountService {
@@ -10,4 +13,14 @@ public interface MountProvisionService extends MountService {
     MountProvisionInstance createMountPoint(InstanceIdentifier path);
     
     MountProvisionInstance createOrGetMountPoint(InstanceIdentifier path);
+    
+    ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener);
+    
+    public  interface MountProvisionListener extends EventListener {
+        
+        void onMountPointCreated(InstanceIdentifier path);
+        
+        void onMountPointRemoved(InstanceIdentifier path);
+        
+    }
 }
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/$ModuleInfo.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/$ModuleInfo.java
new file mode 100644 (file)
index 0000000..3cc5a61
--- /dev/null
@@ -0,0 +1,6 @@
+package org.opendaylight.controller.sal.dom.broker;
+
+public class $ModuleInfo {
+
+    
+}
index 56eae97848b71c9556c0eb3108c6d7f92e38b200..8f62be97d801f7a557026a1aacd054bdaf5f6936 100644 (file)
@@ -13,6 +13,8 @@ import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
+import com.google.common.util.concurrent.MoreExecutors;
+
 public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier, CompositeNode, DataChangeListener> implements
         DataProviderService, AutoCloseable {
 
@@ -21,6 +23,7 @@ public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier, Compo
     
     public DataBrokerImpl() {
         setDataReadRouter(new DataReaderRouter());
+        setExecutor(MoreExecutors.sameThreadExecutor());
     }
     
     public AtomicLong getCreatedTransactionsCount() {
index ab5b145064c828cfa083f74a21beff4e66e9074a..b4fccff3b0fe745ae71088942ed05e92429f5e0e 100644 (file)
@@ -36,7 +36,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 public class MountPointImpl implements MountProvisionInstance {
 
     private final RpcRouter rpcs;
-    private final DataReaderRouter dataReader;
+    private final DataBrokerImpl dataReader;
     private final NotificationRouter notificationRouter;
     private final DataReader<InstanceIdentifier,CompositeNode> readWrapper;
     
@@ -48,7 +48,7 @@ public class MountPointImpl implements MountProvisionInstance {
     public MountPointImpl(InstanceIdentifier path) {
         this.mountPath = path;
         rpcs = new RpcRouterImpl("");
-        dataReader = new DataReaderRouter();
+        dataReader = new DataBrokerImpl();
         notificationRouter = new NotificationRouterImpl();
         readWrapper = new ReadWrapper();
     }
@@ -124,15 +124,13 @@ public class MountPointImpl implements MountProvisionInstance {
 
     @Override
     public DataModificationTransaction beginTransaction() {
-        // TODO Auto-generated method stub
-        return null;
+        return dataReader.beginTransaction();
     }
 
     @Override
     public ListenerRegistration<DataChangeListener> registerDataChangeListener(InstanceIdentifier path,
             DataChangeListener listener) {
-        // TODO Auto-generated method stub
-        return null;
+        return dataReader.registerDataChangeListener(path, listener);
     }
 
     @Override
@@ -143,8 +141,7 @@ public class MountPointImpl implements MountProvisionInstance {
     @Override
     public Registration<DataCommitHandler<InstanceIdentifier, CompositeNode>> registerCommitHandler(
             InstanceIdentifier path, DataCommitHandler<InstanceIdentifier, CompositeNode> commitHandler) {
-        // TODO Auto-generated method stub
-        return null;
+        return dataReader.registerCommitHandler(path, commitHandler);
     }
     
     @Override
@@ -208,7 +205,6 @@ public class MountPointImpl implements MountProvisionInstance {
     @Override
     public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>>> registerCommitHandlerListener(
             RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>> commitHandlerListener) {
-        // TODO Auto-generated method stub
-        return null;
+        return dataReader.registerCommitHandlerListener(commitHandlerListener);
     }
 }
index 19634d79c2203fafe5aaa0156c41bf45a62f905f..5d441bddbd0f23e263c452695da13afe9ecacc3e 100644 (file)
@@ -7,12 +7,16 @@ import java.util.concurrent.ConcurrentMap
 import java.util.concurrent.ConcurrentHashMap
 import static com.google.common.base.Preconditions.*;
 import org.opendaylight.controller.sal.core.api.data.DataProviderService
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry
 
 class MountPointManagerImpl implements MountProvisionService {
     
     @Property
     DataProviderService dataBroker;
     
+    val ListenerRegistry<MountProvisionListener> listeners = ListenerRegistry.create()
+    
     ConcurrentMap<InstanceIdentifier,MountPointImpl> mounts = new ConcurrentHashMap();
     
     override createMountPoint(InstanceIdentifier path) {
@@ -20,15 +24,26 @@ class MountPointManagerImpl implements MountProvisionService {
         val mount = new MountPointImpl(path);
         registerMountPoint(mount);
         mounts.put(path,mount);
+        notifyMountCreated(path);
         return mount;
     }
     
+    def notifyMountCreated(InstanceIdentifier identifier) {
+        for(listener : listeners) {
+            listener.instance.onMountPointCreated(identifier);
+        }
+    }
+    
     def registerMountPoint(MountPointImpl impl) {
         dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
         dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
         
     }
     
+    override registerProvisionListener(MountProvisionListener listener) {
+        listeners.register(listener)
+    }
+    
     
     override createOrGetMountPoint(InstanceIdentifier path) {
         val mount = mounts.get(path);
index 0d18cb323a8dace4eda4ab023de87fa433d638ed..0021dd8f0f3a707a282ccd1831dc332e1dfadd73 100644 (file)
@@ -3,6 +3,7 @@ package org.opendaylight.controller.sal.dom.broker.osgi;
 import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.osgi.framework.ServiceReference;
 
@@ -24,4 +25,9 @@ public class MountProviderServiceProxy extends AbstractBrokerServiceProxy<MountP
     public MountProvisionInstance createOrGetMountPoint(InstanceIdentifier path) {
         return getDelegate().createOrGetMountPoint(path);
     }
+    
+    @Override
+    public ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener) {
+        return getDelegate().registerProvisionListener(listener);
+    }
 }