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;
}
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;
}
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);
}
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);
}
Aggregations