Search in sources :

Example 11 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project controller by opendaylight.

the class MdsalLowLevelTestProvider method unsubscribeDdtl.

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<UnsubscribeDdtlOutput>> unsubscribeDdtl() {
    LOG.debug("Received unsubscribe-ddtl.");
    if (idIntsDdtl == null || ddtlReg == null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Ddtl missing.", "No DOMDataTreeListener registered.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed().withRpcError(error).build());
    }
    try {
        idIntsDdtl.tryFinishProcessing().get(120, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "resource-denied-transport", "Unable to finish notification processing in 120 seconds.", "clustering-it", "clustering-it", e);
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed().withRpcError(error).build());
    }
    ddtlReg.close();
    ddtlReg = null;
    if (!idIntsDdtl.hasTriggered()) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received" + "any notifications.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed().withRpcError(error).build());
    }
    final String shardName = ClusterUtils.getCleanShardName(ProduceTransactionsHandler.ID_INTS_YID);
    LOG.debug("Creating distributed datastore client for shard {}", shardName);
    final ActorContext actorContext = configDataStore.getActorContext();
    final Props distributedDataStoreClientProps = SimpleDataStoreClientActor.props(actorContext.getCurrentMemberName(), "Shard-" + shardName, actorContext, shardName);
    final ActorRef clientActor = actorSystem.actorOf(distributedDataStoreClientProps);
    final DataStoreClient distributedDataStoreClient;
    try {
        distributedDataStoreClient = SimpleDataStoreClientActor.getDistributedDataStoreClient(clientActor, 30, TimeUnit.SECONDS);
    } catch (RuntimeException e) {
        LOG.error("Failed to get actor for {}", distributedDataStoreClientProps, e);
        clientActor.tell(PoisonPill.getInstance(), noSender());
        final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Unable to create ds client for read.", "Unable to create ds client for read.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed().withRpcError(error).build());
    }
    final ClientLocalHistory localHistory = distributedDataStoreClient.createLocalHistory();
    final ClientTransaction tx = localHistory.createTransaction();
    final CheckedFuture<Optional<NormalizedNode<?, ?>>, org.opendaylight.mdsal.common.api.ReadFailedException> read = tx.read(YangInstanceIdentifier.of(ProduceTransactionsHandler.ID_INT));
    tx.abort();
    localHistory.close();
    try {
        final Optional<NormalizedNode<?, ?>> optional = read.checkedGet();
        if (!optional.isPresent()) {
            LOG.warn("Final read from client is empty.");
            final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Read failed.", "Final read from id-ints is empty.");
            return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed().withRpcError(error).build());
        }
        return Futures.immediateFuture(RpcResultBuilder.success(new UnsubscribeDdtlOutputBuilder().setCopyMatches(idIntsDdtl.checkEqual(optional.get()))).build());
    } catch (org.opendaylight.mdsal.common.api.ReadFailedException e) {
        LOG.error("Unable to read data to verify ddtl data.", e);
        final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Read failed.", "Final read from id-ints failed.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDdtlOutput>failed().withRpcError(error).build());
    } finally {
        distributedDataStoreClient.close();
        clientActor.tell(PoisonPill.getInstance(), noSender());
    }
}
Also used : UnsubscribeDdtlOutputBuilder(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDdtlOutputBuilder) ActorRef(akka.actor.ActorRef) RpcError(org.opendaylight.yangtools.yang.common.RpcError) Props(akka.actor.Props) DataStoreClient(org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient) ExecutionException(java.util.concurrent.ExecutionException) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) TimeoutException(java.util.concurrent.TimeoutException) UnsubscribeDdtlOutput(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDdtlOutput) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) ClientTransaction(org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction) ActorContext(org.opendaylight.controller.cluster.datastore.utils.ActorContext) ClientLocalHistory(org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHistory)

Example 12 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project bgpcep by opendaylight.

the class PCEPValidatorTest method testNotificationMsg.

@Test
public void testNotificationMsg() throws IOException, PCEPDeserializerException {
    final CNotification cn1 = new CNotificationBuilder().setIgnore(false).setProcessingRule(false).setType((short) 1).setValue((short) 1).build();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> innerNot = Lists.newArrayList();
    innerNot.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
    final List<Rps> rps = Lists.newArrayList();
    rps.add(new RpsBuilder().setRp(this.rpFalse).build());
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCNtf.5.bin"));
    final PCEPNotificationMessageParser parser = new PCEPNotificationMessageParser(this.objectRegistry);
    final PcntfMessageBuilder builder = new PcntfMessageBuilder();
    final List<Notifications> nots = Lists.newArrayList();
    final NotificationsBuilder b = new NotificationsBuilder();
    b.setNotifications(innerNot);
    b.setRps(rps);
    nots.add(b.build());
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> innerNot1 = Lists.newArrayList();
    innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
    innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
    final List<Rps> rps1 = Lists.newArrayList();
    rps1.add(new RpsBuilder().setRp(this.rpFalse).build());
    rps1.add(new RpsBuilder().setRp(this.rpFalse).build());
    b.setNotifications(innerNot1);
    b.setRps(rps1);
    nots.add(b.build());
    builder.setNotifications(nots);
    assertEquals(new PcntfBuilder().setPcntfMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
    final ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcntfBuilder().setPcntfMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
}
Also used : Notifications(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications) Collections(java.util.Collections) ByteBuf(io.netty.buffer.ByteBuf) Rps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Rps) PcntfBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder) PCEPNotificationMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPNotificationMessageParser) RpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.RpsBuilder) CNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification) NotificationsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.NotificationsBuilder) PcntfMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessageBuilder) CNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotificationBuilder) Notifications(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications) Test(org.junit.Test)

Example 13 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project bgpcep by opendaylight.

the class PCEPNotificationMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf out) {
    Preconditions.checkArgument(message instanceof PcntfMessage, "Wrong instance of Message. Passed instance of %s. Need PcntfMessage.", message.getClass());
    final ByteBuf buffer = Unpooled.buffer();
    for (final Notifications n : ((PcntfMessage) message).getPcntfMessage().getNotifications()) {
        if (n.getRps() != null) {
            for (final Rps rps : n.getRps()) {
                serializeObject(rps.getRp(), buffer);
            }
        }
        Preconditions.checkArgument(n.getNotifications() != null && !n.getNotifications().isEmpty(), "Message must contain at least one notification object");
        for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications not : n.getNotifications()) {
            serializeObject(not.getCNotification(), buffer);
        }
    }
    MessageUtil.formatMessage(TYPE, buffer, out);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Rps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Rps) PcntfMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcntfMessage) Notifications(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications)

Example 14 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project bgpcep by opendaylight.

the class PCEPNotificationMessageParser method insertObject.

private static State insertObject(final State state, final Object obj, final List<Message> errors, final List<Rps> requestParameters, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> notifications) {
    switch(state) {
        case INIT:
            if (obj instanceof Rp) {
                final Rp rp = (Rp) obj;
                if (rp.isProcessingRule()) {
                    errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
                    return null;
                }
                requestParameters.add(new RpsBuilder().setRp(rp).build());
                return State.INIT;
            }
        case RP_IN:
            if (obj instanceof CNotification) {
                final CNotification n = (CNotification) obj;
                notifications.add(new NotificationsBuilder().setCNotification(n).build());
                return State.RP_IN;
            }
        case NOTIFICATION_IN:
        case END:
            return State.END;
        default:
            return state;
    }
}
Also used : RpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.RpsBuilder) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) CNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification) NotificationsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder)

Example 15 with Notifications

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications in project netvirt by opendaylight.

the class Ipv6ServiceInterfaceEventListener method add.

@Override
protected void add(InstanceIdentifier<Interface> key, Interface add) {
    List<String> ofportIds = add.getLowerLayerIf();
    if (!L2vlan.class.equals(add.getType())) {
        return;
    }
    // In ipv6service, we are only interested in the notification for NeutronPort, so we skip other notifications
    if (ofportIds == null || ofportIds.isEmpty() || !isNeutronPort(add.getName())) {
        return;
    }
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface;
    iface = ipv6ServiceUtils.getInterface(add.getName());
    if (null != iface) {
        LOG.debug("Port {} is a Neutron port", iface.getName());
        NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
        BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
        if (!dpId.equals(Ipv6Constants.INVALID_DPID)) {
            Uuid portId = new Uuid(iface.getName());
            VirtualPort port = ifMgr.obtainV6Interface(portId);
            if (port == null) {
                LOG.info("Port {} does not include IPv6Address, skipping.", portId);
                return;
            }
            Long ofPort = MDSALUtil.getOfPortNumberFromPortName(nodeConnectorId);
            ifMgr.updateDpnInfo(portId, dpId, ofPort);
            VirtualPort routerPort = ifMgr.getRouterV6InterfaceForNetwork(port.getNetworkID());
            if (routerPort == null) {
                LOG.info("Port {} is not associated to a Router, skipping.", portId);
                return;
            }
            // Check and program icmpv6 punt flows on the dpnID if its the first VM on the host.
            ifMgr.programIcmpv6PuntFlowsIfNecessary(portId, dpId, routerPort);
            if (!port.getServiceBindingStatus()) {
                jobCoordinator.enqueueJob("IPv6-" + String.valueOf(portId), () -> {
                    // Bind Service
                    Long elanTag = ifMgr.getNetworkElanTag(routerPort.getNetworkID());
                    ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
                    port.setServiceBindingStatus(true);
                    return Collections.emptyList();
                }, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
            }
        }
    }
}
Also used : L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger)

Aggregations

Notifications (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications)4 Optional (com.google.common.base.Optional)3 ArrayList (java.util.ArrayList)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 Test (org.junit.Test)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ByteBuf (io.netty.buffer.ByteBuf)2 Semaphore (java.util.concurrent.Semaphore)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 NotificationService (org.opendaylight.controller.sal.binding.api.NotificationService)2 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 MonitoringState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringState)2 MonitoringStateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder)2 CNotification (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification)2 Rps (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Rps)2 RpsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.RpsBuilder)2