Search in sources :

Example 1 with BGPError

use of org.opendaylight.protocol.bgp.parser.BGPError in project bgpcep by opendaylight.

the class BGPSessionImpl method terminate.

/**
 * Closes BGP session from the parent with given reason. A message needs to be sent, but parent doesn't have to be
 * modified, because he initiated the closing. (To prevent concurrent modification exception).
 *
 * @param e BGPDocumentedException
 */
@VisibleForTesting
synchronized void terminate(final BGPDocumentedException e) {
    final BGPError error = e.getError();
    final byte[] data = e.getData();
    final NotifyBuilder builder = new NotifyBuilder().setErrorCode(error.getCode()).setErrorSubcode(error.getSubcode());
    if (data != null && data.length != 0) {
        builder.setData(data);
    }
    this.writeAndFlush(builder.build());
    notifyTerminationReasonAndCloseWithoutMessage(error.getCode(), error.getSubcode());
}
Also used : BGPError(org.opendaylight.protocol.bgp.parser.BGPError) NotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.NotifyBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BGPError (org.opendaylight.protocol.bgp.parser.BGPError)1 NotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.NotifyBuilder)1