Improved code readability / indentation 24/29324/1
authorGabriel Robitaille-Montpetit <grmontpetit@inocybe.com>
Thu, 5 Nov 2015 15:56:45 +0000 (10:56 -0500)
committerGabriel Robitaille-Montpetit <grmontpetit@inocybe.com>
Thu, 5 Nov 2015 15:56:45 +0000 (10:56 -0500)
Change-Id: I256bb5f3db0d0fa97a0305e8bfc7b36d38c04cc4
Signed-off-by: Gabriel Robitaille-Montpetit <grmontpetit@inocybe.com>
impl/src/main/java/org/opendaylight/unimgr/command/EvcCreateCommand.java
impl/src/main/java/org/opendaylight/unimgr/command/UniCreateCommand.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrDataChangeListener.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrMapper.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrProvider.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java

index 466f225cd15b6cb048291455b35670243d92483f..8346220f23aedbc349254863d801af7a853f1e48 100644 (file)
@@ -35,6 +35,7 @@ public class EvcCreateCommand extends AbstractCreateCommand {
         super.changes = changes;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public void execute() {
         for (Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
index 764e775249676ca979d7cf5fd8020198076bfac9..d5e66e5bcb2df870c99baa83e11cb889a071c25c 100644 (file)
@@ -163,6 +163,7 @@ public class UniCreateCommand extends AbstractCreateCommand {
                                           .getConnectionInfo()
                                           .getRemoteIp()
                                           .equals(uniAugmentation.getIpAddress())) {
+                                @SuppressWarnings("unchecked")
                                 InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) created.getKey();
                                 Optional<Node> ovsdbNode = UnimgrUtils.readNode(dataBroker,
                                                                                 LogicalDatastoreType.OPERATIONAL,
index 249a6dd192cf9588445927d98351f39b62d64ee0..2bdc6afdfe656a8dee8fc3b7f1ce054c4c5d4337 100644 (file)
@@ -44,27 +44,31 @@ public class UnimgrDataChangeListener  implements IUnimgrDataChangeListener {
         this.dataBroker = dataBroker;
         this.invoker = invoker;
         listeners = new HashSet<ListenerRegistration<DataChangeListener>>();
-        listeners.add(dataBroker.registerDataChangeListener(
-                LogicalDatastoreType.CONFIGURATION, UnimgrMapper.createUniIid()
-                , this, DataChangeScope.SUBTREE));
-        listeners.add(dataBroker.registerDataChangeListener(
-                LogicalDatastoreType.CONFIGURATION, UnimgrMapper.createEvcIid()
-                , this, DataChangeScope.SUBTREE));
-        listeners.add(dataBroker.registerDataChangeListener(
-                LogicalDatastoreType.OPERATIONAL, UnimgrMapper.getOvsdbTopologyIdentifier()
-                , this, DataChangeScope.SUBTREE));
+        listeners.add(dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+                                                            UnimgrMapper.createUniIid(),
+                                                            this,
+                                                            DataChangeScope.SUBTREE));
+        listeners.add(dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+                                                            UnimgrMapper.createEvcIid(),
+                                                            this,
+                                                            DataChangeScope.SUBTREE));
+        listeners.add(dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                                                            UnimgrMapper.getOvsdbTopologyIdentifier(),
+                                                            this,
+                                                            DataChangeScope.SUBTREE));
     }
 
     @Override
-    public void onDataChanged(
-            AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+    public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>,
+                              DataObject> change) {
         create(change.getCreatedData());
         update(change.getUpdatedData());
         delete(change);
     }
 
     @Override
-    public void create(Map<InstanceIdentifier<?>, DataObject> changes) {
+    public void create(Map<InstanceIdentifier<?>,
+                       DataObject> changes) {
         if (changes != null) {
             List<Command> commands = new ArrayList<Command>();
             commands.add(new UniCreateCommand(dataBroker, changes));
@@ -75,7 +79,8 @@ public class UnimgrDataChangeListener  implements IUnimgrDataChangeListener {
     }
 
     @Override
-    public void update(Map<InstanceIdentifier<?>, DataObject> changes) {
+    public void update(Map<InstanceIdentifier<?>,
+                       DataObject> changes) {
         if (changes != null) {
             List<Command> commands = new ArrayList<Command>();
             commands.add(new UniUpdateCommand(dataBroker, changes));
@@ -86,8 +91,8 @@ public class UnimgrDataChangeListener  implements IUnimgrDataChangeListener {
     }
 
     @Override
-    public void delete(
-            AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+    public void delete(AsyncDataChangeEvent<InstanceIdentifier<?>,
+                       DataObject> changes) {
         if (changes != null) {
             List<Command> commands = new ArrayList<Command>();
             commands.add(new UniDeleteCommand(dataBroker, changes));
index a478a50a948c5e579a3bdf0747268d77352a4a96..5eeda0fff9d5f40902c4638b58280fb722638254 100755 (executable)
@@ -34,18 +34,23 @@ public class UnimgrMapper {
 
     public static InstanceIdentifier<Node> getOvsdbNodeIID(NodeId nodeId) {
         InstanceIdentifier<Node> nodePath = InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
-                .child(Node.class,new NodeKey(nodeId));
+                                                .create(NetworkTopology.class)
+                                                .child(Topology.class,
+                                                        new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+                                                .child(Node.class,
+                                                        new NodeKey(nodeId));
         return nodePath;
     }
 
-    public static InstanceIdentifier<Node> getOvsdbBridgeNodeIID(NodeId ovsdbNode, String bridgeName) {
+    public static InstanceIdentifier<Node> getOvsdbBridgeNodeIID(NodeId ovsdbNode,
+                                                                 String bridgeName) {
         NodeId bridgeNodeId = new NodeId(ovsdbNode + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX + bridgeName);
         InstanceIdentifier<Node> nodePath = InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
-                .child(Node.class,new NodeKey(bridgeNodeId));
+                                                .create(NetworkTopology.class)
+                                                .child(Topology.class,
+                                                        new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+                                                .child(Node.class,
+                                                        new NodeKey(bridgeNodeId));
         return nodePath;
     }
 
@@ -55,28 +60,34 @@ public class UnimgrMapper {
                 + ":"
                 + UnimgrConstants.OVSDB_PORT;
         InstanceIdentifier<Node> nodePath = InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
-                .child(Node.class,new NodeKey(new NodeId(nodeId)));
+                                                .create(NetworkTopology.class)
+                                                .child(Topology.class,
+                                                        new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+                                                .child(Node.class,
+                                                        new NodeKey(new NodeId(nodeId)));
         return nodePath;
     }
 
     public static InstanceIdentifier<Node> getOvsdbTopologyIdentifier() {
         InstanceIdentifier<Node> path = InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class,
-                        new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
-                .child(Node.class);
+                                            .create(NetworkTopology.class)
+                                            .child(Topology.class,
+                                                    new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+                                            .child(Node.class);
         return path;
     }
 
     public static InstanceIdentifier<TerminationPoint> createTerminationPointInstanceIdentifier(
-            Node bridgeNode, String portName) {
-        InstanceIdentifier<TerminationPoint> terminationPointPath = InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
-                .child(Node.class,bridgeNode.getKey())
-                .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
+                                                           Node bridgeNode,
+                                                           String portName) {
+        InstanceIdentifier<TerminationPoint> terminationPointPath =
+                                                 InstanceIdentifier
+                                                     .create(NetworkTopology.class)
+                                                     .child(Topology.class,
+                                                             new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+                                                     .child(Node.class,bridgeNode.getKey())
+                                                     .child(TerminationPoint.class,
+                                                             new TerminationPointKey(new TpId(portName)));
 
         LOG.debug("Termination point InstanceIdentifier generated : {}",terminationPointPath);
         return terminationPointPath;
@@ -89,15 +100,18 @@ public class UnimgrMapper {
         return iid;
     }
 
-    public static InstanceIdentifier<Node> createUniIid(DataBroker dataBroker, IpAddress ip) {
+    public static InstanceIdentifier<Node> createUniIid(DataBroker dataBroker,
+                                                        IpAddress ip) {
         List<Node> uniNodes = UnimgrUtils.getUniNodes(dataBroker);
         for (Node node: uniNodes) {
             UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
             if (uniAugmentation.getIpAddress().equals(ip)) {
                 InstanceIdentifier<Node> uniNode = InstanceIdentifier
-                        .create(NetworkTopology.class)
-                        .child(Topology.class, new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID))
-                        .child(Node.class, new NodeKey(node.getKey()));
+                                                       .create(NetworkTopology.class)
+                                                       .child(Topology.class,
+                                                               new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID))
+                                                       .child(Node.class,
+                                                               new NodeKey(node.getKey()));
                 return uniNode;
             }
         }
@@ -105,23 +119,28 @@ public class UnimgrMapper {
     }
 
     public static InstanceIdentifier<Node> createEvcIid() {
-        InstanceIdentifier<Node> iid = InstanceIdentifier.create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
-                .child(Node.class);
+        InstanceIdentifier<Node> iid = InstanceIdentifier
+                                           .create(NetworkTopology.class)
+                                           .child(Topology.class,
+                                                   new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
+                                           .child(Node.class);
         return iid;
     }
 
     public static InstanceIdentifier<Topology> createTopologyIid() {
-        InstanceIdentifier<Topology> iid = InstanceIdentifier.create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID));
+        InstanceIdentifier<Topology> iid = InstanceIdentifier
+                                               .create(NetworkTopology.class)
+                                               .child(Topology.class,
+                                                       new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID));
         return iid;
     }
 
     public static InstanceIdentifier<Link> getEvcLinkIID(LinkId id) {
         InstanceIdentifier<Link> linkPath = InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
-                .child(Link.class,new LinkKey(id));
+                                                .create(NetworkTopology.class)
+                                                .child(Topology.class,
+                                                        new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
+                                                .child(Link.class,new LinkKey(id));
         return linkPath;
     }
 }
index 97339cb0e7e723a05cc347d53de3c115ba4f981d..f0871b6387fa1a926784a0a45d4efd16df83b2f9 100755 (executable)
@@ -50,19 +50,28 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
     public void onSessionInitiated(ProviderContext session) {
         LOG.info("UnimgrProvider Session Initiated");
 
+        // Retrieve the data broker to create transactions
         dataBroker =  session.getSALService(DataBroker.class);
         invoker = new  TransactionInvoker();
 
+        // Register the unimgr OSGi CLI
         BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-        unimgrConsoleRegistration = context.registerService(IUnimgrConsoleProvider.class, this, null);
+        unimgrConsoleRegistration = context.registerService(IUnimgrConsoleProvider.class,
+                                                            this,
+                                                            null);
 
+        // Register the uni data change listener
         listener = new UnimgrDataChangeListener(dataBroker, invoker);
 
         // Initialize operational and default config data in MD-SAL data store
-        initDatastore(LogicalDatastoreType.CONFIGURATION, UnimgrConstants.UNI_TOPOLOGY_ID);
-        initDatastore(LogicalDatastoreType.OPERATIONAL, UnimgrConstants.UNI_TOPOLOGY_ID);
-        initDatastore(LogicalDatastoreType.CONFIGURATION, UnimgrConstants.EVC_TOPOLOGY_ID);
-        initDatastore(LogicalDatastoreType.OPERATIONAL, UnimgrConstants.EVC_TOPOLOGY_ID);
+        initDatastore(LogicalDatastoreType.CONFIGURATION,
+                      UnimgrConstants.UNI_TOPOLOGY_ID);
+        initDatastore(LogicalDatastoreType.OPERATIONAL,
+                      UnimgrConstants.UNI_TOPOLOGY_ID);
+        initDatastore(LogicalDatastoreType.CONFIGURATION,
+                      UnimgrConstants.EVC_TOPOLOGY_ID);
+        initDatastore(LogicalDatastoreType.OPERATIONAL,
+                      UnimgrConstants.EVC_TOPOLOGY_ID);
     }
 
     @Override
@@ -72,13 +81,16 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
         listener.close();
     }
 
-    protected void initDatastore(final LogicalDatastoreType type, TopologyId topoId) {
+    protected void initDatastore(final LogicalDatastoreType type,
+                                 TopologyId topoId) {
         InstanceIdentifier<Topology> path = InstanceIdentifier
-                .create(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(topoId));
+                                                .create(NetworkTopology.class)
+                                                .child(Topology.class,
+                                                        new TopologyKey(topoId));
         initializeTopology(type);
         ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
-        CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = transaction.read(type, path);
+        CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = transaction.read(type,
+                                                                                           path);
         try {
             if (!unimgrTp.get().isPresent()) {
                 TopologyBuilder tpb = new TopologyBuilder();
@@ -112,7 +124,7 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
 
     @Override
     public boolean addUni(Uni uni) {
-        //TODO Uncomment
+        //TODO This code was left commented as an example
         if (uni.getIpAddress() == null || uni.getMacAddress() == null) {
             return false;
         }
index 558e1e774216fd42ced9c2e8410ee95db692f4be..895e213b432dc0a8b5d029570de8f05ab75d1276 100644 (file)
@@ -112,6 +112,7 @@ public class UnimgrUtils {
         }
     }
 
+    @SuppressWarnings("unchecked")
     public static void createBridgeNode(DataBroker dataBroker,
                                         Node ovsdbNode,
                                         UniAugmentation uni,