import java.util.concurrent.atomic.AtomicBoolean;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.checkerframework.checker.lock.qual.Holding;
+import org.eclipse.jdt.annotation.Nullable;
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.pcep.types.rev181109.MessageHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1Builder;
}
if (this.session != null || this.nodeState != null) {
- LOG.error("PCEP session is already up with {}. Closing session {}", psession.getRemoteAddress(),
- psession);
+ LOG.error("PCEP session is already up with {}. Closing session {}", peerAddress, psession);
psession.close(TerminationReason.UNKNOWN);
this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
return;
LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
// Our augmentation in the topology node
- final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder();
+ final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder()
+ .setIpAddress(IetfInetUtil.INSTANCE.ipAddressNoZoneFor(peerAddress));
+
+ // Let subclass fill the details
+ onSessionUp(pccBuilder, peerAddress, psession.getRemoteTlvs());
- onSessionUp(psession, pccBuilder);
this.synced.set(isSynchronized());
- pccBuilder.setIpAddress(IetfInetUtil.INSTANCE.ipAddressNoZoneFor(peerAddress));
final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
this.listenerState = new SessionStateImpl(this, psession);
this.serverSessionManager.bind(state.getNodeId(), this.listenerState);
- LOG.info("Session with {} attached to topology node {}", psession.getRemoteAddress(),
- state.getNodeId());
+ LOG.info("Session with {} attached to topology node {}", peerAddress, state.getNodeId());
}
}
}
- protected abstract void onSessionUp(PCEPSession session, PathComputationClientBuilder pccBuilder);
+ protected abstract void onSessionUp(PathComputationClientBuilder pccBuilder, InetAddress peerAddress,
+ @Nullable Tlvs remoteTlvs);
synchronized void updatePccState(final PccSyncState pccSyncState) {
if (this.nodeState == null) {
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.bgpcep.pcep.server.PathComputation;
import org.opendaylight.bgpcep.pcep.server.PceServerProvider;
-import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.PSTUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.PathComputationClient1Builder;
}
@Override
- protected void onSessionUp(final PCEPSession session, final PathComputationClientBuilder pccBuilder) {
- final InetAddress peerAddress = session.getRemoteAddress();
-
- final Tlvs tlvs = session.getRemoteTlvs();
- if (tlvs != null && tlvs.augmentation(Tlvs1.class) != null) {
- final Stateful stateful = tlvs.augmentation(Tlvs1.class).getStateful();
- if (stateful != null) {
- setStatefulCapabilities(stateful);
- pccBuilder.setReportedLsp(Collections.emptyMap());
- if (isSynchronized()) {
- pccBuilder.setStateSync(PccSyncState.Synchronized);
- } else if (isTriggeredInitialSynchro()) {
- pccBuilder.setStateSync(PccSyncState.TriggeredInitialSync);
- } else if (isIncrementalSynchro()) {
- pccBuilder.setStateSync(PccSyncState.IncrementalSync);
- } else {
- pccBuilder.setStateSync(PccSyncState.InitialResync);
+ protected void onSessionUp(final PathComputationClientBuilder pccBuilder, final InetAddress peerAddress,
+ final Tlvs remoteTlvs) {
+ if (remoteTlvs != null) {
+ final Tlvs1 statefulTlvs = remoteTlvs.augmentation(Tlvs1.class);
+ if (statefulTlvs != null) {
+ final Stateful stateful = statefulTlvs.getStateful();
+ if (stateful != null) {
+ setStatefulCapabilities(stateful);
+ pccBuilder.setReportedLsp(Map.of());
+ if (isSynchronized()) {
+ pccBuilder.setStateSync(PccSyncState.Synchronized);
+ } else if (isTriggeredInitialSynchro()) {
+ pccBuilder.setStateSync(PccSyncState.TriggeredInitialSync);
+ } else if (isIncrementalSynchro()) {
+ pccBuilder.setStateSync(PccSyncState.IncrementalSync);
+ } else {
+ pccBuilder.setStateSync(PccSyncState.InitialResync);
+ }
+ pccBuilder.setStatefulTlv(new StatefulTlvBuilder()
+ .addAugmentation(new StatefulTlv1Builder(statefulTlvs).build())
+ .build());
+ return;
}
- pccBuilder.setStatefulTlv(new StatefulTlvBuilder().addAugmentation(
- new StatefulTlv1Builder(tlvs.augmentation(Tlvs1.class)).build()).build());
- } else {
- LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
- } else {
- LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
+ LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
@Override
updBuilder.setPath(pb.build());
updBuilder.setLsp(lsp).setSrp(srp).setPath(pb.build());
- pcupdMessageBuilder.setUpdates(Collections.singletonList(updBuilder.build()));
+ pcupdMessageBuilder.setUpdates(List.of(updBuilder.build()));
return srp.getOperationId();
}
}
final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
final Requests rb = buildRequest(rep, reportedLsp);
- ib.setRequests(Collections.singletonList(rb));
+ ib.setRequests(List.of(rb));
return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(),
rb.getSrp().getOperationId(), null);
}, MoreExecutors.directExecutor());
pb.fieldsFrom(input.getArguments());
rb.setPath(pb.build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
- ub.setUpdates(Collections.singletonList(rb.build()));
+ ub.setUpdates(List.of(rb.build()));
msg = new PcupdBuilder().setPcupdMessage(ub.build()).build();
} else {
final Lsp1 lspCreateFlag = reportedLsp.augmentation(Lsp1.class);
final PathBuilder pb = new PathBuilder();
rb.setPath(pb.build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
- ub.setUpdates(Collections.singletonList(rb.build()));
+ ub.setUpdates(List.of(rb.build()));
return new PcupdBuilder().setPcupdMessage(ub.build()).build();
}
}
// Send the message
return sendMessage(new PcinitiateBuilder()
.setPcinitiateMessage(new PcinitiateMessageBuilder(MESSAGE_HEADER)
- .setRequests(Collections.singletonList(rb.build()))
+ .setRequests(List.of(rb.build()))
.build())
.build(),
rb.getSrp().getOperationId(), input.getArguments().getMetadata());
.setPcerrMessage(new PcerrMessageBuilder()
.setErrorType(new RequestCaseBuilder()
.setRequest(new RequestBuilder()
- .setRps(Collections.singletonList(new RpsBuilder()
+ .setRps(List.of(new RpsBuilder()
.setRp(new RpBuilder()
.setProcessingRule(false)
.setIgnore(false)
.build()))
.build())
.build())
- .setErrors(Collections.singletonList(new ErrorsBuilder()
+ .setErrors(List.of(new ErrorsBuilder()
.setErrorObject(new ErrorObjectBuilder()
.setType(pcepErrors.getErrorType())
.setValue(pcepErrors.getErrorValue())