import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+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;
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 =
@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