class InventoryReader implements DataTreeChangeListener<DataObject> {

    public NodeConnectorRef getNodeConnector(InstanceIdentifier<Node> nodeInsId, MacAddress macAddress) {
        if (nodeInsId == null || macAddress == null) {
            return null;
        }

        NodeConnectorRef destNodeConnector = null;
        long latest = -1;
        ReadOnlyTransaction readOnlyTransaction = dataService.newReadOnlyTransaction();
        try {
            Optional<Node> dataObjectOptional = null;
            dataObjectOptional = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeInsId).get();
            if (dataObjectOptional.isPresent()) {
                Node node = dataObjectOptional.get();
                LOG.debug("Looking address{} in node : {}", macAddress, nodeInsId);
                if (node.getNodeConnector() != null) {
                    for (NodeConnector nc : node.getNodeConnector()) {
                        // Don't look for mac in discarding node connectors
                        StpStatusAwareNodeConnector saNodeConnector = nc
                                .getAugmentation(StpStatusAwareNodeConnector.class);
                        if (saNodeConnector != null && StpStatus.Discarding.equals(saNodeConnector.getStatus())) {
                            continue;
                        }
                        LOG.debug("Looking address{} in nodeconnector : {}", macAddress, nc.getKey());
                        AddressCapableNodeConnector acnc = nc.getAugmentation(AddressCapableNodeConnector.class);
                        if (acnc != null) {
                            List<Addresses> addressesList = acnc.getAddresses();
                            for (Addresses add : addressesList) {
                                if (macAddress.equals(add.getMac())) {
                                    if (add.getLastSeen() > latest) {
                                        destNodeConnector = new NodeConnectorRef(
                                                nodeInsId.child(NodeConnector.class, nc.getKey()));
                                        latest = add.getLastSeen();
                                        LOG.debug("Found address{} in nodeconnector : {}", macAddress, nc.getKey());
                                        break;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    LOG.debug("Node connectors data is not present for node {}", node.getId());
                }
            }
        } catch (InterruptedException e) {
            LOG.error("Failed to read nodes from Operation data store.");
            readOnlyTransaction.close();
            throw new RuntimeException("Failed to read nodes from Operation data store.", e);
        } catch (ExecutionException e) {
            LOG.error("Failed to read nodes from Operation data store.");
            readOnlyTransaction.close();
            throw new RuntimeException("Failed to read nodes from Operation data store.", e);
        }
        readOnlyTransaction.close();
        return destNodeConnector;
    }

    public  InventoryReader(DataBroker dataService);

}