Search in sources :

Example 16 with Monitoring

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring in project genius by opendaylight.

the class InterfaceManagerCommonUtils method updateOpState.

/*
     * update operational state of interface based on events like tunnel
     * monitoring
     */
public static void updateOpState(WriteTransaction transaction, String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus) {
    InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
    LOG.debug("updating tep interface state as {} for {}", operStatus.name(), interfaceName);
    InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setOperStatus(operStatus);
    ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
    transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), false);
}
Also used : InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)

Example 17 with Monitoring

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring in project bgpcep by opendaylight.

the class BmpMonitoringStationImpl method closeServiceInstance.

@Override
public synchronized ListenableFuture<Void> closeServiceInstance() {
    LOG.info("BMP Monitor Singleton Service {} instance closed, Monitor Id {}", getIdentifier().getValue(), this.monitorId.getValue());
    if (this.channel != null) {
        this.channel.close().addListener((ChannelFutureListener) future -> {
            Preconditions.checkArgument(future.isSuccess(), "Channel failed to close: %s", future.cause());
            BmpMonitoringStationImpl.this.sessionManager.close();
        });
    }
    final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, this.yangMonitorId);
    LOG.info("BMP monitoring station {} closed.", this.monitorId.getValue());
    return wTx.submit();
}
Also used : Router(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) MonitorId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.MonitorId) LoggerFactory(org.slf4j.LoggerFactory) KeyConstructorUtil.constructKeys(org.opendaylight.protocol.bmp.impl.app.KeyConstructorUtil.constructKeys) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) MonitoredRouter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev171207.odl.bmp.monitors.bmp.monitor.config.MonitoredRouter) Monitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.bmp.monitor.Monitor) Rfc2385Key(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key) InetAddress(java.net.InetAddress) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) BmpMonitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.BmpMonitor) Objects.requireNonNull(java.util.Objects.requireNonNull) ChannelFutureListener(io.netty.channel.ChannelFutureListener) BmpDeployerDependencies(org.opendaylight.protocol.bmp.impl.config.BmpDeployerDependencies) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Nonnull(javax.annotation.Nonnull) Logger(org.slf4j.Logger) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) InetSocketAddress(java.net.InetSocketAddress) QName(org.opendaylight.yangtools.yang.common.QName) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) Ipv4Util(org.opendaylight.protocol.util.Ipv4Util) List(java.util.List) BmpMonitoringStation(org.opendaylight.protocol.bmp.impl.spi.BmpMonitoringStation) BmpDispatcher(org.opendaylight.protocol.bmp.api.BmpDispatcher) DOMDataBroker(org.opendaylight.controller.md.sal.dom.api.DOMDataBroker) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction) Preconditions(com.google.common.base.Preconditions) InetAddresses(com.google.common.net.InetAddresses) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 18 with Monitoring

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring in project bgpcep by opendaylight.

the class PCEPValidatorTest method testMonRepMsg.

@Test
public void testMonRepMsg() throws PCEPDeserializerException, IOException {
    final PCEPMonitoringReplyMessageParser parser = new PCEPMonitoringReplyMessageParser(this.objectRegistry);
    final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder();
    builder.setMonitoring(this.monitoring);
    builder.setMonitoringMetricsList(new GeneralMetricsListBuilder().setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build())).build());
    final byte[] msgBytes = { 0x20, 0x09, 0x00, 0x18, /* monitoring object */
    0x13, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, /* pce-id object */
    0x19, 0x10, 0x00, 0x08, 0x7f, 0x00, 0x00, 0x02 };
    ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
    assertEquals(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
    ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
    builder.setMonitoring(this.monitoring);
    builder.setPccIdReq(this.pccIdReq);
    final SpecificMetricsBuilder smBuilder = new SpecificMetricsBuilder();
    smBuilder.setRp(this.rpTrue);
    final List<MetricPce> metricPces = Lists.newArrayList();
    metricPces.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId).setProcTime(this.procTime).build());
    metricPces.add(new MetricPceBuilder().setPceId(this.pceId).setProcTime(this.procTime).build());
    smBuilder.setMetricPce(metricPces);
    final SpecificMetricsBuilder smBuilder2 = new SpecificMetricsBuilder();
    final List<MetricPce> metricPces2 = Lists.newArrayList();
    smBuilder2.setRp(this.rpTrue);
    metricPces2.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId).build());
    smBuilder2.setMetricPce(metricPces2);
    builder.setMonitoringMetricsList(new SpecificMetricsListBuilder().setSpecificMetrics(Lists.newArrayList(smBuilder.build(), smBuilder2.build())).build());
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCMonRep.bin"));
    assertEquals(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
    buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
}
Also used : PcmonrepMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcmonrep.message.PcmonrepMessageBuilder) SpecificMetricsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.SpecificMetricsListBuilder) GeneralMetricsListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.GeneralMetricsListBuilder) SpecificMetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetricsBuilder) PcmonrepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonrepBuilder) PCEPMonitoringReplyMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringReplyMessageParser) ByteBuf(io.netty.buffer.ByteBuf) MetricPceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPceBuilder) MetricPce(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce) Test(org.junit.Test)

Example 19 with Monitoring

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring in project bgpcep by opendaylight.

the class PCEPMonitoringReplyMessageParser method validate.

@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    Preconditions.checkArgument(objects != null, "Passed list can't be null.");
    if (objects.isEmpty()) {
        throw new PCEPDeserializerException("Pcmonrep message cannot be empty.");
    }
    if (!(objects.get(0) instanceof Monitoring)) {
        errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
        return null;
    }
    final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder();
    builder.setMonitoring((Monitoring) objects.get(0));
    objects.remove(0);
    if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
        builder.setPccIdReq((PccIdReq) objects.get(0));
        objects.remove(0);
    }
    validateSpecificMetrics(objects, builder);
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build();
}
Also used : PcmonrepMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcmonrep.message.PcmonrepMessageBuilder) PcmonrepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonrepBuilder) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)

Example 20 with Monitoring

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring in project bgpcep by opendaylight.

the class PCEPMonitoringReplyMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
    Preconditions.checkArgument(message instanceof Pcmonrep, "Wrong instance of Message. Passed instance of %s. Need Pcmonrep.", message.getClass());
    final PcmonrepMessage monRepMsg = ((Pcmonrep) message).getPcmonrepMessage();
    Preconditions.checkArgument(monRepMsg.getMonitoring() != null, "MONITORING object is mandatory.");
    final ByteBuf body = Unpooled.buffer();
    serializeObject(monRepMsg.getMonitoring(), body);
    serializeObject(monRepMsg.getPccIdReq(), body);
    if (monRepMsg.getMonitoringMetricsList() instanceof GeneralMetricsList) {
        final GeneralMetricsList gml = (GeneralMetricsList) monRepMsg.getMonitoringMetricsList();
        if (gml.getMetricPce() != null) {
            for (final MetricPce metricPce : gml.getMetricPce()) {
                serializeMetricPce(metricPce, body);
            }
        }
    } else if (monRepMsg.getMonitoringMetricsList() instanceof SpecificMetricsList) {
        final SpecificMetricsList sml = (SpecificMetricsList) monRepMsg.getMonitoringMetricsList();
        if (sml.getSpecificMetrics() != null) {
            for (final SpecificMetrics specificMetrics : sml.getSpecificMetrics()) {
                serializeObject(specificMetrics.getRp(), body);
                if (specificMetrics.getMetricPce() != null) {
                    for (final MetricPce metricPce : specificMetrics.getMetricPce()) {
                        serializeMetricPce(metricPce, body);
                    }
                }
            }
        }
    }
    MessageUtil.formatMessage(TYPE, body, buffer);
}
Also used : SpecificMetricsList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.SpecificMetricsList) Pcmonrep(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonrep) PcmonrepMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcmonrep.message.PcmonrepMessage) SpecificMetrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetrics) ByteBuf(io.netty.buffer.ByteBuf) GeneralMetricsList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.response.monitoring.metrics.list.GeneralMetricsList) MetricPce(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)

Aggregations

ListenableFuture (com.google.common.util.concurrent.ListenableFuture)12 ArrayList (java.util.ArrayList)12 Optional (com.google.common.base.Optional)11 List (java.util.List)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)9 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)9 Collections (java.util.Collections)8 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)8 MonitorProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile)8 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)8 FutureCallback (com.google.common.util.concurrent.FutureCallback)7 Nonnull (javax.annotation.Nonnull)7 Inject (javax.inject.Inject)7 Singleton (javax.inject.Singleton)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)7 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)7 EtherTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7