Search in sources :

Example 11 with Holding

use of org.checkerframework.checker.lock.qual.Holding in project controller by opendaylight.

the class ProxyHistory method doSkipTransactions.

@Holding("lock")
private void doSkipTransactions(final List<TransactionIdentifier> toSkip) {
    final var txIds = toSkip.stream().mapToLong(TransactionIdentifier::getTransactionId).distinct().sorted().mapToObj(UnsignedLong::fromLongBits).collect(ImmutableList.toImmutableList());
    LOG.debug("Proxy {} skipping transactions {}", this, txIds);
    connection.enqueueRequest(new SkipTransactionsRequest(new TransactionIdentifier(identifier, txIds.get(0).longValue()), 0, localActor(), txIds.subList(1, txIds.size())), resp -> {
        LOG.debug("Proxy {} confirmed transaction skip", this);
    }, connection.currentTime());
}
Also used : TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier) SkipTransactionsRequest(org.opendaylight.controller.cluster.access.commands.SkipTransactionsRequest) Holding(org.checkerframework.checker.lock.qual.Holding)

Example 12 with Holding

use of org.checkerframework.checker.lock.qual.Holding in project bgpcep by opendaylight.

the class BmpRouterImpl method tearDown.

@Holding("this")
@SuppressWarnings("checkstyle:IllegalCatch")
private synchronized void tearDown() {
    // the session has been teared down before
    if (this.session == null) {
        return;
    }
    // we want to display remote router's IP here, as sometimes this.session.close() is already
    // invoked before tearDown(), and session channel is null in this case, which leads to unuseful
    // log information
    LOG.info("BMP Session with remote router {} ({}) went down.", this.routerIp, this.session);
    this.session = null;
    final Iterator<BmpRouterPeer> it = this.peers.values().iterator();
    try {
        while (it.hasNext()) {
            it.next().close();
            it.remove();
        }
        this.domTxChain.close();
    } catch (final Exception e) {
        LOG.error("Failed to properly close BMP application.", e);
    } finally {
        // as the routerId is the same for both connection
        if (isDatastoreWritable()) {
            try {
                // it means the session was closed before it was written to datastore
                final DOMDataTreeWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
                wTx.delete(LogicalDatastoreType.OPERATIONAL, this.routerYangIId);
                wTx.commit().get();
            } catch (final InterruptedException | ExecutionException e) {
                LOG.error("Failed to remove BMP router data from DS.", e);
            }
            this.sessionManager.removeSessionListener(this);
        }
    }
}
Also used : DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) ExecutionException(java.util.concurrent.ExecutionException) BmpRouterPeer(org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer) ExecutionException(java.util.concurrent.ExecutionException) Holding(org.checkerframework.checker.lock.qual.Holding)

Example 13 with Holding

use of org.checkerframework.checker.lock.qual.Holding in project bgpcep by opendaylight.

the class BGPPeer method handleGracefulEndOfRib.

@Holding("this")
private void handleGracefulEndOfRib() {
    if (isLocalRestarting()) {
        if (this.missingEOT.isEmpty()) {
            createEffRibInWriter();
            this.effRibInWriter.init();
            registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
            for (final TablesKey key : getAfiSafisAdvertized()) {
                createAdjRibOutListener(key, true);
            }
            setLocalRestartingState(false);
            setGracefulPreferences(false, Collections.emptySet());
        }
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) Holding(org.checkerframework.checker.lock.qual.Holding)

Example 14 with Holding

use of org.checkerframework.checker.lock.qual.Holding in project bgpcep by opendaylight.

the class BGPSessionImpl method notifyTerminationReasonAndCloseWithoutMessage.

@Holding({ "this.listener", "this" })
private void notifyTerminationReasonAndCloseWithoutMessage(final Uint8 errorCode, final Uint8 errorSubcode) {
    this.terminationReasonNotified = true;
    this.closeWithoutMessage();
    this.listener.onSessionTerminated(this, new BGPTerminationReason(BGPError.forValue(errorCode, errorSubcode)));
}
Also used : BGPTerminationReason(org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason) Holding(org.checkerframework.checker.lock.qual.Holding)

Example 15 with Holding

use of org.checkerframework.checker.lock.qual.Holding 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 cause BGPDocumentedException
 */
@VisibleForTesting
@Holding({ "this.listener", "this" })
void terminate(final BGPDocumentedException cause) {
    final BGPError error = cause.getError();
    final byte[] data = cause.getData();
    final NotifyBuilder builder = new NotifyBuilder().setErrorCode(error.getCode()).setErrorSubcode(error.getSubcode());
    if (data != null && data.length != 0) {
        builder.setData(data);
    }
    writeAndFlush(builder.build());
    notifyTerminationReasonAndCloseWithoutMessage(error);
}
Also used : BGPError(org.opendaylight.protocol.bgp.parser.BGPError) NotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.NotifyBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Holding(org.checkerframework.checker.lock.qual.Holding)

Aggregations

Holding (org.checkerframework.checker.lock.qual.Holding)16 IOException (java.io.IOException)3 ActorSelection (akka.actor.ActorSelection)2 File (java.io.File)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 BGPTerminationReason (org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason)2 ActorRef (akka.actor.ActorRef)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Stopwatch (com.google.common.base.Stopwatch)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 Cleaner (java.lang.ref.Cleaner)1 Cleanable (java.lang.ref.Cleaner.Cleanable)1 URISyntaxException (java.net.URISyntaxException)1 FileChannel (java.nio.channels.FileChannel)1 FileLock (java.nio.channels.FileLock)1 ExecutionException (java.util.concurrent.ExecutionException)1