X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsamples%2Fl2switch%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsample%2Fl2switch%2Fmd%2Faddresstracker%2FAddressTracker.java;fp=opendaylight%2Fmd-sal%2Fsamples%2Fl2switch%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsample%2Fl2switch%2Fmd%2Faddresstracker%2FAddressTracker.java;h=0000000000000000000000000000000000000000;hb=034cd42ff377039471c19c75d7e57d8199525723;hp=ae5f03110cd3cb6e5232c595238c2f1682e18057;hpb=139937c2e646894af6a9b2b8a8a1047c6ef82485;p=controller.git diff --git a/opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/addresstracker/AddressTracker.java b/opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/addresstracker/AddressTracker.java deleted file mode 100644 index ae5f03110c..0000000000 --- a/opendaylight/md-sal/samples/l2switch/implementation/src/main/java/org/opendaylight/controller/sample/l2switch/md/addresstracker/AddressTracker.java +++ /dev/null @@ -1,102 +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.sample.l2switch.md.addresstracker; - -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; -import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.address.tracker.rev140402.L2Addresses; -import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.address.tracker.rev140402.l2.addresses.L2Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.address.tracker.rev140402.l2.addresses.L2AddressBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.address.tracker.rev140402.l2.addresses.L2AddressKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.Future; - -/** - * AddressTracker manages the MD-SAL data tree for L2Address (mac, node connector pairings) information. - */ -public class AddressTracker { - - private final static Logger _logger = LoggerFactory.getLogger(AddressTracker.class); - private DataBrokerService dataService; - - /** - * Construct an AddressTracker with the specified inputs - * @param dataService The DataBrokerService for the AddressTracker - */ - public AddressTracker(DataBrokerService dataService) { - this.dataService = dataService; - } - - /** - * Get all the L2 Addresses in the MD-SAL data tree - * @return All the L2 Addresses in the MD-SAL data tree - */ - public L2Addresses getAddresses() { - return (L2Addresses)dataService.readOperationalData(InstanceIdentifier.builder(L2Addresses.class).toInstance()); - } - - /** - * Get a specific L2 Address in the MD-SAL data tree - * @param macAddress A MacAddress associated with an L2 Address object - * @return The L2 Address corresponding to the specified macAddress - */ - public L2Address getAddress(MacAddress macAddress) { - return (L2Address) dataService.readOperationalData(createPath(macAddress)); - } - - /** - * Add L2 Address into the MD-SAL data tree - * @param macAddress The MacAddress of the new L2Address object - * @param nodeConnectorRef The NodeConnectorRef of the new L2Address object - * @return Future containing the result of the add operation - */ - public Future> addAddress(MacAddress macAddress, NodeConnectorRef nodeConnectorRef) { - if(macAddress == null || nodeConnectorRef == null) { - return null; - } - - // Create L2Address - final L2AddressBuilder builder = new L2AddressBuilder(); - builder.setKey(new L2AddressKey(macAddress)) - .setMac(macAddress) - .setNodeConnectorRef(nodeConnectorRef); - - // Add L2Address to MD-SAL data tree - final DataModificationTransaction it = dataService.beginTransaction(); - it.putOperationalData(createPath(macAddress), builder.build()); - return it.commit(); - } - - /** - * Remove L2Address from the MD-SAL data tree - * @param macAddress The MacAddress of an L2Address object - * @return Future containing the result of the remove operation - */ - public Future> removeHost(MacAddress macAddress) { - final DataModificationTransaction it = dataService.beginTransaction(); - it.removeOperationalData(createPath(macAddress)); - return it.commit(); - } - - /** - * Create InstanceIdentifier path for an L2Address in the MD-SAL data tree - * @param macAddress The MacAddress of an L2Address object - * @return InstanceIdentifier of the L2Address corresponding to the specified macAddress - */ - private InstanceIdentifier createPath(MacAddress macAddress) { - return InstanceIdentifier.builder(L2Addresses.class) - .child(L2Address.class, new L2AddressKey(macAddress)).toInstance(); - } -} \ No newline at end of file