Abstract topology framework apis 50/28450/7
authorTomas Cere <tcere@cisco.com>
Thu, 15 Oct 2015 13:52:03 +0000 (15:52 +0200)
committerTomas Cere <tcere@cisco.com>
Fri, 27 Nov 2015 14:40:57 +0000 (15:40 +0100)
Change-Id: Ib3d8b9fab7132a25313094fe31c9a77028bb4ea0
Signed-off-by: Tomas Cere <tcere@cisco.com>
18 files changed:
opendaylight/netconf/abstract-topology/pom.xml [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/InitialStateProvider.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeListener.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeManager.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeManagerCallback.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RemoteNodeListener.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeListener.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeStrategy.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/StateAggregator.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/TopologyManager.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/TopologyManagerCallback.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/NodeWriter.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/CustomIdentifyMessage.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/CustomIdentifyMessageReply.java [new file with mode: 0644]
opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/NormalizedNodeMessage.java [new file with mode: 0644]
opendaylight/netconf/netconf-artifacts/pom.xml
opendaylight/netconf/pom.xml
pom.xml

diff --git a/opendaylight/netconf/abstract-topology/pom.xml b/opendaylight/netconf/abstract-topology/pom.xml
new file mode 100644 (file)
index 0000000..4ae07be
--- /dev/null
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>netconf-subsystem</artifactId>
+        <groupId>org.opendaylight.netconf</groupId>
+        <version>1.0.0-SNAPSHOT</version>
+        <relativePath>../</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>abstract-topology</artifactId>
+    <packaging>bundle</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-topology</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>sal-netconf-connector</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-clustering-commons</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.scala-lang</groupId>
+            <artifactId>scala-library</artifactId>
+            <version>${scala.major.version}.${scala.minor.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-actor_${scala.major.version}</artifactId>
+            <version>${akka.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-remote_${scala.major.version}</artifactId>
+            <version>${akka.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-cluster_2.11</artifactId>
+            <version>2.3.14</version>
+        </dependency>
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-osgi_2.11</artifactId>
+            <version>2.3.14</version>
+        </dependency>
+        <dependency>
+            <groupId>com.typesafe</groupId>
+            <artifactId>config</artifactId>
+            <version>${typesafe.config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.typesafe</groupId>
+            <artifactId>config</artifactId>
+            <version>1.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.jayway.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+            <version>1.6.5</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Import-Package>*</Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>config</id>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+                                    <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+                                    <additionalConfiguration>
+                                        <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+                                    </additionalConfiguration>
+                                </generator>
+                                <generator>
+                                    <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+                                    <outputBaseDir>${salGeneratorPath}</outputBaseDir>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.controller</groupId>
+                        <artifactId>yang-jmx-generator-plugin</artifactId>
+                        <version>${config.version}</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.8</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.build.directory}/generated-sources/config</source>;
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/InitialStateProvider.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/InitialStateProvider.java
new file mode 100644 (file)
index 0000000..ed3623d
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+
+/**
+ * Provides initial and failed state for NodeManagers
+ */
+@Beta
+public interface InitialStateProvider {
+    @Nonnull
+    Node getInitialState(@Nonnull final NodeId nodeId, @Nonnull final Node configNode);
+
+    @Nonnull
+    Node getFailedState(@Nonnull final NodeId nodeId, @Nonnull final Node configNode);
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeListener.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeListener.java
new file mode 100644 (file)
index 0000000..b49d3bb
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+
+/**
+ * Node events that happen on a single node on cluster, for a method to notify remote nodes of these events look into RemoteNodeListener
+ */
+@Beta
+public interface NodeListener extends RoleChangeListener {
+
+    @Nonnull ListenableFuture<Node> onNodeCreated(@Nonnull NodeId nodeId, @Nonnull Node configNode);
+
+    @Nonnull ListenableFuture<Node> onNodeUpdated(@Nonnull NodeId nodeId, @Nonnull Node configNode);
+
+    @Nonnull ListenableFuture<Void> onNodeDeleted(@Nonnull NodeId nodeId);
+
+    @Nonnull ListenableFuture<Node> getCurrentStatusForNode(@Nonnull NodeId nodeId);
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeManager.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeManager.java
new file mode 100644 (file)
index 0000000..b4b26a8
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import akka.actor.TypedActor.Receiver;
+import com.google.common.annotations.Beta;
+
+/**
+ * Node manager that handles communication between node managers and delegates calls to the customizable NodeManagerCallback
+ */
+@Beta
+public interface NodeManager extends InitialStateProvider, NodeListener, Receiver, RemoteNodeListener {
+
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeManagerCallback.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/NodeManagerCallback.java
new file mode 100644 (file)
index 0000000..fd0444a
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import akka.actor.ActorSystem;
+import akka.actor.TypedActor.Receiver;
+import com.google.common.annotations.Beta;
+
+/**
+ * Customizable layer that handles communication with your application.
+ */
+@Beta
+public interface NodeManagerCallback extends InitialStateProvider, NodeListener, Receiver {
+
+    interface NodeManagerCallbackFactory<M> {
+        NodeManagerCallback create(String nodeId, String topologyId, ActorSystem actorSystem);
+    }
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RemoteNodeListener.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RemoteNodeListener.java
new file mode 100644 (file)
index 0000000..7a8dc59
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.netconf.topology.util.messages.NormalizedNodeMessage;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import scala.concurrent.Future;
+
+/**
+ * Interface that provides methods of calling node events on a remote actor.
+ * Use these when you want to call node events asynchronously similar to akka ask()
+ */
+@Beta
+public interface RemoteNodeListener {
+
+    /**
+     * This is called when a remote node is informing you that a new configuration was recieved.
+     * @param message - serializable message to send
+     * @return response from the remote node
+     */
+    Future<NormalizedNodeMessage> onRemoteNodeCreated(NormalizedNodeMessage message);
+
+    /**
+     * This is called when a remote node is informing you that a configuration was updated.
+     * @param message - serializable message to send
+     * @return response from the remote node
+     */
+    Future<NormalizedNodeMessage> onRemoteNodeUpdated(NormalizedNodeMessage message);
+
+    /**
+     * This is called when a remote node is informing you that a new configuration was deleted.
+     * @param nodeId - id of the node which was deleted
+     * @return void future success if delete succeed, failure otherwise
+     */
+    Future<Void> onRemoteNodeDeleted(NodeId nodeId);
+
+    /**
+     * Called when a remote node is requesting a node's status, after a status change notification(f.ex sessionUp, sessionDown)
+     * on lower level
+     * @param nodeId - id of the node which status we want to retrieve
+     * @return status for the node requested
+     */
+    Future<NormalizedNodeMessage> remoteGetCurrentStatusForNode(NodeId nodeId);
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeListener.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeListener.java
new file mode 100644 (file)
index 0000000..5cf4250
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * A listener that recieves {@link #onRoleChanged(RoleChangeDTO)} callbacks when a role change occurs
+ */
+@Beta
+public interface RoleChangeListener {
+
+    /**
+     * Called when a role change occurs
+     * @param roleChangeDTO a DTO that wraps the current ownership status
+     */
+    void onRoleChanged(RoleChangeDTO roleChangeDTO);
+
+    /**
+     * A DTO that wraps an ownership change status
+     */
+    class RoleChangeDTO {
+
+        private final boolean wasOwner;
+        private final boolean isOwner;
+        private final boolean hasOwner;
+
+        public RoleChangeDTO(boolean wasOwner, boolean isOwner, boolean hasOwner) {
+            this.wasOwner = wasOwner;
+            this.isOwner = isOwner;
+            this.hasOwner = hasOwner;
+        }
+
+        public boolean wasOwner() {
+            return wasOwner;
+        }
+
+        public boolean isOwner() {
+            return isOwner;
+        }
+
+        public boolean hasOwner() {
+            return hasOwner;
+        }
+    }
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeStrategy.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeStrategy.java
new file mode 100644 (file)
index 0000000..39cccf6
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * A customizable strategy that gets executed when a BaseTopologyManager|BaseNodeManager is created.
+ * If the election should be executed at another moment, you need to pass the NoopRoleChangeStrategy into the Manager
+ * and the role candidate registration needs to happen in your implemented Node/Topology callback
+ */
+@Beta
+public interface RoleChangeStrategy extends RoleChangeListener {
+
+    /**
+     * Your pre-election and election logic goes here, e.g you should register your candidate into the ElectionService
+     * @param electionCandidate NodeListener that should receive the subsequent onRoleChanged callback
+     *                          when a role change occurs.
+     */
+    void registerRoleCandidate(NodeListener electionCandidate);
+
+    /**
+     * Invoke whenever you want to stop candidate from partaking in election.
+     */
+    void unregisterRoleCandidate();
+
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/StateAggregator.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/StateAggregator.java
new file mode 100644 (file)
index 0000000..d72d280
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+
+/**
+ * Aggregate different node states into a single state
+ */
+@Beta
+public interface StateAggregator {
+
+    ListenableFuture<Node> combineCreateAttempts(final List<ListenableFuture<Node>> stateFutures);
+
+    ListenableFuture<Node> combineUpdateAttempts(final List<ListenableFuture<Node>> stateFutures);
+
+    ListenableFuture<Void> combineDeleteAttempts(final List<ListenableFuture<Void>> stateFutures);
+
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/TopologyManager.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/TopologyManager.java
new file mode 100644 (file)
index 0000000..3de1677
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import akka.actor.TypedActor.PostStop;
+import akka.actor.TypedActor.PreStart;
+import akka.actor.TypedActor.Receiver;
+import com.google.common.annotations.Beta;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import scala.concurrent.Future;
+
+/**
+ * Top level topology manager that handles comunication between nodes, aggregates results, and handles writes into the datastore
+ */
+@Beta
+public interface TopologyManager extends NodeListener, Receiver, RemoteNodeListener, PreStart, PostStop{
+
+    /**
+     * ask if this manager is master
+     * @return true/false based on ownership status
+     */
+    Future<Boolean> isMaster();
+
+    /**
+     *
+     * @param nodeId - id of the node that sessionUp/Down happened on
+     */
+    void notifyNodeStatusChange(NodeId nodeId);
+
+    boolean hasAllPeersUp();
+
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/TopologyManagerCallback.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/TopologyManagerCallback.java
new file mode 100644 (file)
index 0000000..ea7d05d
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology;
+
+import akka.actor.ActorSystem;
+import akka.actor.TypedActor.Receiver;
+import com.google.common.annotations.Beta;
+
+/**
+ * Customizable extension layer between the top level TopologyManager and NodeManager
+ */
+@Beta
+public interface TopologyManagerCallback extends NodeListener, Receiver, RoleChangeListener {
+
+    interface TopologyManagerCallbackFactory {
+        TopologyManagerCallback create(ActorSystem actorSystem, String topologyId);
+    }
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/NodeWriter.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/NodeWriter.java
new file mode 100644 (file)
index 0000000..0b0d7b8
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology.util;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+
+/**
+ * Customizable code that gets executed after result aggregation, meant for custom writes
+ * into the datastore, but any user code can be run here if desired.
+ */
+@Beta
+public interface NodeWriter {
+
+    void init(@Nonnull final NodeId id, @Nonnull final Node operationalDataNode);
+
+    void update(@Nonnull final NodeId id, @Nonnull final Node operationalDataNode);
+
+    void delete(@Nonnull final NodeId id);
+
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/CustomIdentifyMessage.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/CustomIdentifyMessage.java
new file mode 100644 (file)
index 0000000..721dcf6
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology.util.messages;
+
+import akka.actor.Address;
+import java.io.Serializable;
+
+public class CustomIdentifyMessage implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private final Address address;
+
+    public CustomIdentifyMessage(final Address addressFrom) {
+        address = addressFrom;
+    }
+
+    public Address getAddress() {
+        return address;
+    }
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/CustomIdentifyMessageReply.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/CustomIdentifyMessageReply.java
new file mode 100644 (file)
index 0000000..62a5b43
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology.util.messages;
+
+import akka.actor.Address;
+
+// Marker message, that signals that actor should not reply to this one
+public class CustomIdentifyMessageReply extends CustomIdentifyMessage {
+    private static final long serialVersionUID = 1L;
+
+    public CustomIdentifyMessageReply(final Address addressFrom) {
+        super(addressFrom);
+    }
+}
diff --git a/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/NormalizedNodeMessage.java b/opendaylight/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/util/messages/NormalizedNodeMessage.java
new file mode 100644 (file)
index 0000000..9129c26
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015 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.netconf.topology.util.messages;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
+
+public class NormalizedNodeMessage implements Externalizable{
+    private static final long serialVersionUID = 1L;
+
+    private YangInstanceIdentifier identifier = null;
+    private NormalizedNode<?, ?> node = null;
+
+    public NormalizedNodeMessage() {
+
+    }
+
+    public NormalizedNodeMessage(YangInstanceIdentifier identifier, NormalizedNode<?, ?> node) {
+        this.identifier = identifier;
+        this.node = node;
+    }
+
+    public YangInstanceIdentifier getIdentifier() {
+        return identifier;
+    }
+
+    public NormalizedNode<?, ?> getNode() {
+        return node;
+    }
+
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException {
+        final NormalizedNodeOutputStreamWriter streamWriter = new NormalizedNodeOutputStreamWriter(out);
+        final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(streamWriter);
+
+        streamWriter.writeYangInstanceIdentifier(identifier);
+        normalizedNodeWriter.write(node);
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        final NormalizedNodeInputStreamReader streamReader = new NormalizedNodeInputStreamReader(in);
+
+        identifier = streamReader.readYangInstanceIdentifier();
+        node = streamReader.readNormalizedNode();
+    }
+}
index 8a223c4317914720ae36cbd74fdf858a6427c600..f11e9810fdf2908d050619d0775c9a2d87905f4a 100644 (file)
                 <artifactId>aaa-authn-odl-plugin</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>abstract-topology</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>netconf-config-dispatcher</artifactId>
index f1474e11b436e5b97675bd2235b421a0df4e2aa4..657819072e44aaedc1bb33f69ad6236f67b82ebc 100644 (file)
@@ -36,6 +36,7 @@
     <module>netconf-notifications-impl</module>
     <module>netconf-notifications-api</module>
     <module>netconf-topology</module>
+    <module>abstract-topology</module>
     <module>netconf-topology-config</module>
     <module>sal-netconf-connector</module>
     <module>messagebus-netconf</module>
diff --git a/pom.xml b/pom.xml
index 4ebdea4a83714c192422fac2bbc616ef37b87374..4993e137c0d0982ca56113177b53a55a37febf6b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <config.netconf.topology.configfile>02-netconf-topology.xml</config.netconf.topology.configfile>
         <config.netconf.mdsal.configfile>08-mdsal-netconf.xml</config.netconf.mdsal.configfile>
         <config.restconf.configfile>10-rest-connector.xml</config.restconf.configfile>
-         <config.restconf.service.configfile>10-restconf-service.xml</config.restconf.service.configfile>
+        <config.restconf.service.configfile>10-restconf-service.xml</config.restconf.service.configfile>
         <config.netconf.connector.configfile>99-netconf-connector.xml</config.netconf.connector.configfile>
 
         <aaa.version>0.3.0-SNAPSHOT</aaa.version>
+        <akka.version>2.3.14</akka.version>
         <commons.logback_settings.version>0.2.0-SNAPSHOT</commons.logback_settings.version>
         <commons.opendaylight.version>1.6.0-SNAPSHOT</commons.opendaylight.version>
         <config.version>0.4.0-SNAPSHOT</config.version>
         <restconf.version>1.3.0-SNAPSHOT</restconf.version>
         <protocol-framework.version>0.7.0-SNAPSHOT</protocol-framework.version>
         <sshd-core.version>0.14.0</sshd-core.version>
+        <scala.major.version>2.11</scala.major.version>
+        <scala.minor.version>5</scala.minor.version>
         <surefire.version>2.15</surefire.version>
+        <typesafe.config.version>1.2.1</typesafe.config.version>
         <yangtools.version>0.8.0-SNAPSHOT</yangtools.version>
 
         <jmxGeneratorPath>src/main/yang-gen-config</jmxGeneratorPath>