Search in sources :

Example 46 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project bgpcep by opendaylight.

the class PCEPSessionImpl method sendMessage.

/**
 * Sends message to serialization.
 *
 * @param msg to be sent
 */
@Override
public Future<Void> sendMessage(final Message msg) {
    final ChannelFuture f = this.channel.writeAndFlush(msg);
    this.lastMessageSentAt = TICKER.read();
    this.sessionState.updateLastSentMsg();
    if (!(msg instanceof KeepaliveMessage)) {
        LOG.debug("PCEP Message enqueued: {}", msg);
    }
    if (msg instanceof PcerrMessage) {
        this.sessionState.setLastSentError(msg);
    }
    f.addListener((ChannelFutureListener) arg -> {
        if (arg.isSuccess()) {
            LOG.trace("Message sent to socket: {}", msg);
        } else {
            LOG.debug("Message not sent: {}", msg, arg.cause());
        }
    });
    return f;
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) KeepaliveMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.keepalive.message.KeepaliveMessageBuilder) CCloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CCloseBuilder) Date(java.util.Date) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Keepalive) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OpenMessage) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) KeepaliveMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.KeepaliveMessage) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage) ToStringHelper(com.google.common.base.MoreObjects.ToStringHelper) InetAddress(java.net.InetAddress) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) PCEPErrors(org.opendaylight.protocol.pcep.spi.PCEPErrors) Objects.requireNonNull(java.util.Objects.requireNonNull) ChannelFutureListener(io.netty.channel.ChannelFutureListener) LinkedList(java.util.LinkedList) PCEPCloseTermination(org.opendaylight.protocol.pcep.PCEPCloseTermination) PCEPSessionListener(org.opendaylight.protocol.pcep.PCEPSessionListener) CCloseMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.message.CCloseMessageBuilder) TerminationReason(org.opendaylight.protocol.pcep.TerminationReason) Messages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages) CloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.CloseMessage) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs) Logger(org.slf4j.Logger) MoreObjects(com.google.common.base.MoreObjects) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref) IOException(java.io.IOException) Ticker(com.google.common.base.Ticker) InetSocketAddress(java.net.InetSocketAddress) CloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.CloseBuilder) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) TimeUnit(java.util.concurrent.TimeUnit) Util(org.opendaylight.protocol.pcep.impl.spi.Util) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) GuardedBy(org.checkerframework.checker.lock.qual.GuardedBy) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.KeepaliveBuilder) SimpleChannelInboundHandler(io.netty.channel.SimpleChannelInboundHandler) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Queue(java.util.Queue) Future(io.netty.util.concurrent.Future) PeerPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPref) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage) KeepaliveMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.KeepaliveMessage)

Example 47 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project bgpcep by opendaylight.

the class AbstractPCEPSessionNegotiator method handleMessageOpenWait.

private boolean handleMessageOpenWait(final Message msg) {
    if (!(msg instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open)) {
        return false;
    }
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.message.OpenMessage o = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open) msg).getOpenMessage();
    final Open open = o.getOpen();
    if (isProposalAcceptable(open)) {
        this.sendMessage(KEEPALIVE);
        this.remotePrefs = open;
        this.remoteOK = true;
        if (this.localOK) {
            negotiationSuccessful(createSession(this.channel, this.localPrefs, this.remotePrefs));
            LOG.info("PCEP peer {} completed negotiation", this.channel);
            this.state = State.FINISHED;
        } else {
            scheduleFailTimer();
            this.state = State.KEEP_WAIT;
            LOG.debug("Channel {} moved to KeepWait state with remoteOK=1", this.channel);
        }
        return true;
    }
    if (this.openRetry) {
        sendErrorMessage(PCEPErrors.SECOND_OPEN_MSG);
        negotiationFailed(new IllegalStateException("OPEN renegotiation failed"));
        this.state = State.FINISHED;
        return true;
    }
    final Open newPrefs = getCounterProposal(open);
    if (newPrefs == null) {
        sendErrorMessage(PCEPErrors.NON_ACC_NON_NEG_SESSION_CHAR);
        negotiationFailed(new IllegalStateException("Peer sent unacceptable session parameters"));
        this.state = State.FINISHED;
        return true;
    }
    this.sendMessage(Util.createErrorMessage(PCEPErrors.NON_ACC_NEG_SESSION_CHAR, newPrefs));
    this.openRetry = true;
    this.state = this.localOK ? State.OPEN_WAIT : State.KEEP_WAIT;
    scheduleFailTimer();
    return true;
}
Also used : Preconditions(com.google.common.base.Preconditions) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open)

Example 48 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project bgpcep by opendaylight.

the class GracefulRestartTest method verifySendEORafterRestartTest.

/**
 * After graceful restart is performed from peer side we have to re-advertise routes followed by
 * End-of-RIB marker.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void verifySendEORafterRestartTest() throws Exception {
    final SimpleSessionListener listener2 = new SimpleSessionListener();
    configurePeer(this.tableRegistry, PEER2, this.ribImpl, this.parameters, PeerRole.Ebgp, this.serverRegistry, afiSafiAdvertised, gracefulAfiSafiAdvertised);
    final BGPSessionImpl session2 = createPeerSession(PEER2, this.parameters, listener2);
    final List<Ipv4Prefix> ipv4Prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
    final List<Ipv4Prefix> ipv4Prefixes2 = Arrays.asList(new Ipv4Prefix(PREFIX2));
    final List<Ipv6Prefix> ipv6Prefixes = Collections.singletonList(new Ipv6Prefix(PREFIX3));
    insertRoutes(ipv4Prefixes, ipv6Prefixes);
    insertRoutes(ipv4Prefixes2, PEER2, null, null, session2, BgpOrigin.Egp);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(1);
    org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 3);
    // verify sending of Ipv4 EOT, Ipv6 EOT and Ipv4 update with route
    checkReceivedMessages(this.listener, 3);
    assertTrue(this.listener.getListMsg().get(0) instanceof Update);
    assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(0)));
    assertTrue(this.listener.getListMsg().get(1) instanceof Update);
    assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(1)));
    assertTrue(this.listener.getListMsg().get(2) instanceof Update);
    assertFalse(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(2)));
    this.session.close();
    checkIdleState(this.peer);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(0);
    // verify nothing new was sent
    checkReceivedMessages(this.listener, 3);
    this.session = createPeerSession(PEER1, createParameter(false, true, Collections.singletonMap(TABLES_KEY, true)), this.listener);
    checkUpState(listener);
    checkUpState(this.peer);
    org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 6);
    // verify sending of Ipv4 update with route, Ipv4 EOT and Ipv6 EOT; order can vary based on ODTC order
    final List<Notification> subList = this.listener.getListMsg().subList(3, 6);
    int eotCount = 0;
    int routeUpdateCount = 0;
    for (Notification message : subList) {
        if (BgpPeerUtil.isEndOfRib((Update) message)) {
            eotCount++;
        } else {
            routeUpdateCount++;
        }
    }
    assertEquals(2, eotCount);
    assertEquals(1, routeUpdateCount);
}
Also used : Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Notification(org.opendaylight.yangtools.yang.binding.Notification) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 49 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project bgpcep by opendaylight.

the class GracefulRestartTest method resetConnectionOnOpenTest.

/**
 * Test correct behavior when connection restart is unnoticed.
 * "Correct" means that the previous TCP session MUST be closed, and the new one retained.
 * Since the previous connection is considered to be terminated, no NOTIFICATION message should be sent.
 */
@Test
public void resetConnectionOnOpenTest() {
    checkReceivedMessages(this.listener, 2);
    final Open open = createClassicOpen(true);
    this.session.writeAndFlush(open);
    checkIdleState(this.peer);
    checkReceivedMessages(this.listener, 2);
}
Also used : Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)14 ExecutionException (java.util.concurrent.ExecutionException)13 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)11 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)4 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)4 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)4 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 UnknownHostException (java.net.UnknownHostException)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)3 VpnToDpnListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder)3 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces)3 VpnInterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 BigInteger (java.math.BigInteger)2 InetSocketAddress (java.net.InetSocketAddress)2