<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.lib</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
</instructions>
</configuration>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- </plugin>
</plugins>
</build>
<scm>
--- /dev/null
+/**
+ * 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.md.inventory.manager;
+
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FlowCapableInventoryProvider implements AutoCloseable {
+
+ private final static Logger LOG = LoggerFactory.getLogger(FlowCapableInventoryProvider.class);
+
+ private DataProviderService dataService;
+ private NotificationProviderService notificationService;
+ private Registration<NotificationListener> listenerRegistration;
+ private final NodeChangeCommiter changeCommiter = new NodeChangeCommiter(FlowCapableInventoryProvider.this);
+
+ public void start() {
+ this.listenerRegistration = this.notificationService.registerNotificationListener(this.changeCommiter);
+ LOG.info("Flow Capable Inventory Provider started.");
+ }
+
+ protected DataModificationTransaction startChange() {
+ DataProviderService _dataService = this.dataService;
+ return _dataService.beginTransaction();
+ }
+
+ @Override
+ public void close() {
+ try {
+ LOG.info("Flow Capable Inventory Provider stopped.");
+ if (this.listenerRegistration != null) {
+ this.listenerRegistration.close();
+ }
+ } catch (Exception e) {
+ String errMsg = "Error by stop Flow Capable Inventory Provider.";
+ LOG.error(errMsg, e);
+ throw new RuntimeException(errMsg, e);
+ }
+ }
+
+ public DataProviderService getDataService() {
+ return this.dataService;
+ }
+
+ public void setDataService(final DataProviderService dataService) {
+ this.dataService = dataService;
+ }
+
+ public NotificationProviderService getNotificationService() {
+ return this.notificationService;
+ }
+
+ public void setNotificationService(
+ final NotificationProviderService notificationService) {
+ this.notificationService = notificationService;
+ }
+}
+++ /dev/null
-/*
- * 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.md.inventory.manager
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yangtools.concepts.Registration
-import org.opendaylight.yangtools.yang.binding.NotificationListener
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
-import static extension org.opendaylight.controller.md.inventory.manager.InventoryMapping.*
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
-import org.slf4j.LoggerFactory
-
-class FlowCapableInventoryProvider implements AutoCloseable {
-
-
- static val LOG = LoggerFactory.getLogger(FlowCapableInventoryProvider);
-
- @Property
- DataProviderService dataService;
-
- @Property
- NotificationProviderService notificationService;
- val NodeChangeCommiter changeCommiter = new NodeChangeCommiter(this);
-
- Registration<NotificationListener> listenerRegistration
-
- def void start() {
- listenerRegistration = notificationService.registerNotificationListener(changeCommiter);
- LOG.info("Flow Capable Inventory Provider started.");
-
- }
-
- protected def startChange() {
- return dataService.beginTransaction;
- }
-
- override close() {
- LOG.info("Flow Capable Inventory Provider stopped.");
- listenerRegistration?.close();
- }
-
-}
\ No newline at end of file
--- /dev/null
+/**
+ * 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.md.inventory.manager;
+
+import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.osgi.framework.BundleContext;
+
+public class InventoryActivator extends AbstractBindingAwareProvider {
+
+ private static FlowCapableInventoryProvider provider = new FlowCapableInventoryProvider();
+
+ @Override
+ public void onSessionInitiated(final ProviderContext session) {
+ DataProviderService salDataService = session.<DataProviderService> getSALService(DataProviderService.class);
+ NotificationProviderService salNotifiService =
+ session.<NotificationProviderService> getSALService(NotificationProviderService.class);
+ InventoryActivator.provider.setDataService(salDataService);
+ InventoryActivator.provider.setNotificationService(salNotifiService);
+ InventoryActivator.provider.start();
+ }
+
+ @Override
+ protected void stopImpl(final BundleContext context) {
+ InventoryActivator.provider.close();
+ }
+}
+++ /dev/null
-/*
- * 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.md.inventory.manager
-
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import org.osgi.framework.BundleContext
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-
-class InventoryActivator extends AbstractBindingAwareProvider {
-
- static var FlowCapableInventoryProvider provider = new FlowCapableInventoryProvider();
-
- override onSessionInitiated(ProviderContext session) {
- provider.dataService = session.getSALService(DataProviderService)
- provider.notificationService = session.getSALService(NotificationProviderService)
- provider.start();
- }
-
- override protected stopImpl(BundleContext context) {
- provider.close();
- }
-
-}
--- /dev/null
+/**
+ * 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.md.inventory.manager;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeConnector;
+
+public class InventoryMapping {
+
+ public static FlowCapableNodeConnector toInventoryAugment(final FlowNodeConnector updated) {
+ if ((updated instanceof FlowCapableNodeConnector)) {
+ return ((FlowCapableNodeConnector) updated);
+ }
+ final FlowCapableNodeConnectorBuilder builder = new FlowCapableNodeConnectorBuilder();
+ builder.setAdvertisedFeatures(updated.getAdvertisedFeatures());
+ builder.setConfiguration(updated.getConfiguration());
+ builder.setCurrentFeature(updated.getCurrentFeature());
+ builder.setCurrentSpeed(updated.getCurrentSpeed());
+ builder.setHardwareAddress(updated.getHardwareAddress());
+ builder.setMaximumSpeed(updated.getMaximumSpeed());
+ builder.setName(updated.getName());
+ builder.setPeerFeatures(updated.getPeerFeatures());
+ builder.setPortNumber(updated.getPortNumber());
+ builder.setState(updated.getState());
+ builder.setSupported(updated.getSupported());
+ return builder.build();
+ }
+
+ public static FlowCapableNode toInventoryAugment(final FlowNode source) {
+ if ((source instanceof FlowCapableNode)) {
+ return ((FlowCapableNode) source);
+ }
+ return (new FlowCapableNodeBuilder(source)).build();
+ }
+}
+++ /dev/null
-/*
- * 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.md.inventory.manager
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder
-
-class InventoryMapping {
-
- static def FlowCapableNodeConnector toInventoryAugment(FlowNodeConnector updated) {
- if (updated instanceof FlowCapableNodeConnector) {
- return updated as FlowCapableNodeConnector;
- }
- val it = new FlowCapableNodeConnectorBuilder();
- advertisedFeatures = updated.advertisedFeatures
- configuration = updated.configuration
- currentFeature = updated.currentFeature
- currentSpeed = updated.currentSpeed
- hardwareAddress = updated.hardwareAddress
- maximumSpeed = updated.maximumSpeed
- name = updated.name
- peerFeatures = updated.peerFeatures
- portNumber = updated.portNumber
- state = updated.state
- supported = updated.supported
- return build();
- }
-
- static def FlowCapableNode toInventoryAugment(FlowNode source) {
- if (source instanceof FlowCapableNode) {
- return source as FlowCapableNode;
- }
- val it = new FlowCapableNodeBuilder(source);
- return build();
- }
-
-}
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
import com.google.common.base.Objects;
-@SuppressWarnings("all")
public class NodeChangeCommiter implements OpendaylightInventoryListener {
+
private final static Logger LOG = LoggerFactory.getLogger(NodeChangeCommiter.class);
private final FlowCapableInventoryProvider manager;
final NodeConnectorRef ref = connector.getNodeConnectorRef();
final FlowCapableNodeConnectorUpdated flowConnector = connector
.getAugmentation(FlowCapableNodeConnectorUpdated.class);
- final DataModificationTransaction it = this.getManager().startChange();
+ final DataModificationTransaction it = this.manager.startChange();
final NodeConnectorBuilder data = new NodeConnectorBuilder(connector);
NodeConnectorId id = connector.getId();
NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(id);
data.addAugmentation(FlowCapableNodeConnector.class, augment);
}
InstanceIdentifier<? extends Object> value = ref.getValue();
- String string = value.toString();
- String plus = ("updating node connector : " + string);
- NodeChangeCommiter.LOG.debug(plus);
- InstanceIdentifier<? extends Object> value1 = ref.getValue();
+ NodeChangeCommiter.LOG.debug("updating node connector : {}.", value);
NodeConnector build = data.build();
- it.putOperationalData((value1), build);
+ it.putOperationalData((value), build);
Future<RpcResult<TransactionStatus>> commitResult = it.commit();
try {
commitResult.get();
public synchronized void onNodeRemoved(final NodeRemoved node) {
final NodeRef ref = node.getNodeRef();
- FlowCapableInventoryProvider manager = this.getManager();
- final DataModificationTransaction it = manager.startChange();
- InstanceIdentifier<? extends Object> value = ref.getValue();
- String string = value.toString();
- String plus = ("removing node : " + string);
- NodeChangeCommiter.LOG.debug(plus);
- InstanceIdentifier<? extends Object> value1 = ref.getValue();
- it.removeOperationalData((value1));
+ final DataModificationTransaction it = this.manager.startChange();
+ NodeChangeCommiter.LOG.debug("removing node : {}", ref.getValue());
+ it.removeOperationalData((ref.getValue()));
Future<RpcResult<TransactionStatus>> commitResult = it.commit();
try {
commitResult.get();
final NodeRef ref = node.getNodeRef();
final FlowCapableNodeUpdated flowNode = node
.<FlowCapableNodeUpdated> getAugmentation(FlowCapableNodeUpdated.class);
- FlowCapableInventoryProvider manager = this.getManager();
- final DataModificationTransaction it = manager.startChange();
- NodeBuilder nodeBuilder = new NodeBuilder(node);
- final NodeBuilder data = nodeBuilder;
- NodeId id = node.getId();
- NodeKey nodeKey = new NodeKey(id);
- data.setKey(nodeKey);
+ final DataModificationTransaction it = this.manager.startChange();
+ final NodeBuilder nodeBuilder = new NodeBuilder(node);
+ nodeBuilder.setKey(new NodeKey(node.getId()));
boolean equals = Objects.equal(flowNode, null);
if (equals) {
return;
}
final FlowCapableNode augment = InventoryMapping.toInventoryAugment(flowNode);
- data.addAugmentation(FlowCapableNode.class, augment);
+ nodeBuilder.addAugmentation(FlowCapableNode.class, augment);
InstanceIdentifier<? extends Object> value = ref.getValue();
InstanceIdentifierBuilder<Node> builder = InstanceIdentifier.<Node> builder(((InstanceIdentifier<Node>) value));
InstanceIdentifierBuilder<FlowCapableNode> augmentation = builder