import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.util.concurrent.FutureListener;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.annotation.concurrent.GuardedBy;
+import java.util.stream.Stream;
+import org.checkerframework.checker.lock.qual.GuardedBy;
+import org.checkerframework.checker.lock.qual.Holding;
import org.opendaylight.bgpcep.pcep.topology.provider.session.stats.SessionStateImpl;
import org.opendaylight.bgpcep.pcep.topology.provider.session.stats.TopologySessionStats;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client.attributes.path.computation.client.ReportedLspKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client.attributes.path.computation.client.reported.lsp.Path;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
public abstract class AbstractTopologySessionListener<S, L> implements TopologySessionListener, TopologySessionStats {
static final MessageHeader MESSAGE_HEADER = new MessageHeader() {
- private final ProtocolVersion version = new ProtocolVersion((short) 1);
+ private final ProtocolVersion version = new ProtocolVersion(Uint8.ONE);
@Override
- public Class<? extends DataContainer> getImplementedInterface() {
+ public Class<MessageHeader> implementedInterface() {
return MessageHeader.class;
}
}
this.session = psession;
this.nodeState = state;
- this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
state.storeNode(topologyAugment,
new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), this.session);
this.listenerState.init(psession);
+ this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
LOG.info("Session with {} attached to topology node {}", psession.getRemoteAddress(), state.getNodeId());
}
* Tear down the given PCEP session. It's OK to call this method even after the session
* is already down. It always clear up the current session status.
*/
- @GuardedBy("this")
+ @Holding("this")
@SuppressWarnings("checkstyle:IllegalCatch")
private synchronized void tearDown(final PCEPSession psession) {
this.lspData.put(name, rl);
}
- private List<Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name,
- final boolean remove) {
+ private static List<Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous,
+ final String name, final boolean remove) {
// just one path should be reported
Preconditions.checkState(rlb.getPath().size() == 1);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId =
final List<Path> updatedPaths;
//lspId = 0 and remove = false -> tunnel is down, still exists but no path is signaled
//remove existing tunnel's paths now, as explicit path remove will not come
- if (!remove && reportedLspId.getValue() == 0) {
+ if (!remove && reportedLspId.getValue().toJava() == 0) {
updatedPaths = new ArrayList<>();
LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
} else {
LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
for (final Path path : previous.getPath()) {
//we found reported path in previous reports
- if (path.getLspId().getValue() == 0 || path.getLspId().equals(reportedLspId)) {
+ if (path.getLspId().getValue().toJava() == 0 || path.getLspId().equals(reportedLspId)) {
LOG.debug("Match on lsp-id {}", path.getLspId().getValue());
// path that was reported previously and does have the same lsp-id, path will be updated
final boolean r = updatedPaths.remove(path);
LOG.trace("Adding new path {} to {}", rlb.getPath(), updatedPaths);
updatedPaths.addAll(rlb.getPath());
if (remove) {
- if (reportedLspId.getValue() == 0) {
+ if (reportedLspId.getValue().toJava() == 0) {
// if lsp-id also 0, remove all paths
LOG.debug("Removing all paths.");
updatedPaths.clear();
@Override
public int getDelegatedLspsCount() {
- return Math.toIntExact(ImmutableList.copyOf(this.lspData.values()).stream()
- .map(ReportedLsp::getPath).filter(Objects::nonNull).filter(pathList -> !pathList.isEmpty())
- // pick the first path, as delegate status should be same in each path
- .map(pathList -> pathList.get(0))
- .map(path -> path.augmentation(Path1.class)).filter(Objects::nonNull)
- .map(LspObject::getLsp).filter(Objects::nonNull)
- .filter(Lsp::isDelegate)
- .count());
+ final Stream<ReportedLsp> stream;
+ synchronized (this) {
+ stream = ImmutableList.copyOf(this.lspData.values()).stream();
+ }
+
+ return Math.toIntExact(stream
+ .map(ReportedLsp::getPath).filter(pathList -> pathList != null && !pathList.isEmpty())
+ // pick the first path, as delegate status should be same in each path
+ .map(pathList -> pathList.get(0))
+ .map(path -> path.augmentation(Path1.class)).filter(Objects::nonNull)
+ .map(LspObject::getLsp).filter(Objects::nonNull)
+ .filter(Lsp::isDelegate)
+ .count());
}
@Override
this.requests.add(req);
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void notifyRequests() {
for (final PCEPRequest r : this.requests) {
r.done(OperationResults.SUCCESS);