2 * Copyright © 2015 ZTE and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package com.highstreet.technologies.odl.app.impl.listener;
10 import com.highstreet.technologies.odl.app.impl.tools.BandwidthCalculator;
11 import com.highstreet.technologies.odl.app.impl.tools.DataBrokerHolder;
12 import com.highstreet.technologies.odl.app.impl.tools.NeExecutor;
13 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
14 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.ltp.path.rev170615.ThresholdOfPath;
15 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.ltp.path.rev170615.threshold.of.path.Threshold;
16 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.*;
17 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration;
18 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceStatus;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
24 import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
27 * Created by odl on 17-6-6.
29 public class ACMListener implements MicrowaveModelListener
31 public ACMListener(NeExecutor ne)
36 private static final Logger LOG = LoggerFactory.getLogger(ACMListener.class);
37 private static Double bandwidth;
39 private final NeExecutor ne;
42 public void onAttributeValueChangedNotification(
43 AttributeValueChangedNotification notification)
49 if (bandwidth == null)
51 readBandwidthThreshold();
55 if (notification.getAttributeName().equalsIgnoreCase("modulationCur"))
57 LOG.info("received notification of value changed of modulationCur, changed to " + notification.getNewValue());
58 String lpId_airInterface = notification.getObjectIdRef().getValue();
59 if (ne.isLtpOfThisOnPath(lpId_airInterface))
61 AirInterfaceConfiguration airInterfaceConfiguration = ne.getUnderAirPac(
62 lpId_airInterface, AirInterfaceConfiguration.class, CONFIGURATION);
63 AirInterfaceStatus airInterfaceStatus = ne.getUnderAirPac(
64 lpId_airInterface, AirInterfaceStatus.class, OPERATIONAL);
66 Double txCapacity = new BandwidthCalculator(
67 airInterfaceConfiguration.getTxChannelBandwidth(),
68 airInterfaceStatus.getModulationCur(),
69 airInterfaceStatus.getCodeRateCur()).calc();
70 LOG.info("new txCapacity is " + txCapacity);
71 if (txCapacity < bandwidth)
73 LOG.info("new txCapacity is lower than bandwidth " + bandwidth);
80 LOG.warn("handling attribute change: " + notification + " caught exception!", e);
86 private void readBandwidthThreshold()
88 ReadOnlyTransaction readOnlyTransaction = DataBrokerHolder.getDataBroker().newReadOnlyTransaction();
89 InstanceIdentifier<Threshold> instanceIdentifier = InstanceIdentifier.create(ThresholdOfPath.class).child(
93 Threshold threshold = readOnlyTransaction.read(CONFIGURATION, instanceIdentifier).get().get();
94 bandwidth = threshold.getMinimumBandwidth().doubleValue();
100 readOnlyTransaction.close();
105 public void onObjectCreationNotification(
106 ObjectCreationNotification notification)
111 public void onObjectDeletionNotification(
112 ObjectDeletionNotification notification)
117 public void onProblemNotification(
118 ProblemNotification notification)