use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method addTunnel.
protected void addTunnel(final Requests request, final PCCSession session) {
final PlspId plspId = new PlspId(Uint32.valueOf(this.plspIDsCounter.incrementAndGet()));
final PCCTunnel tunnel = new PCCTunnel(request.getLsp().getTlvs().getSymbolicPathName().getPathName().getValue(), session.getId(), LspType.PCE_LSP, reqToRptPath(request));
sendToAll(tunnel, plspId, request.getEro().getSubobject(), createSrp(request.getSrp().getOperationId().getValue()), tunnel.getLspState(), new LspBuilder(request.getLsp()).addAugmentation(new Lsp1Builder().setCreate(true).build()).build());
this.tunnels.put(plspId, tunnel);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method takeDelegation.
protected void takeDelegation(final Requests request, final PCCSession session) {
final PlspId plspId = request.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
final Uint32 srpId = request.getSrp().getOperationId().getValue();
if (tunnel != null) {
// check if tunnel has no delegation
if (tunnel.getType() == LspType.PCE_LSP && (tunnel.getDelegationHolder() == -1 || tunnel.getDelegationHolder() == session.getId())) {
// set delegation
tunnel.cancelTimeouts();
setDelegation(plspId, session);
// send report
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.empty());
session.sendReport(createPcRtpMessage(new LspBuilder(request.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(true).setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState()));
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.LSP_NOT_PCE_INITIATED, srpId));
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method startStateTimeout.
private void startStateTimeout(final PCCTunnel tunnel, final PlspId plspId) {
if (this.stateTimeout > -1) {
final Timeout newStateTimeout = this.timer.newTimeout(timeout -> {
if (tunnel.getType() == LspType.PCE_LSP) {
PCCTunnelManagerImpl.this.tunnels.remove(plspId);
// report tunnel removal to all
sendToAll(tunnel, plspId, Collections.emptyList(), createSrp(Uint32.ZERO), new PathBuilder().build(), createLsp(plspId.getValue(), false, Optional.empty(), false, true));
}
}, this.stateTimeout, TimeUnit.SECONDS);
tunnel.setStateTimeout(newStateTimeout);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method onSessionDown.
@Override
public synchronized void onSessionDown(final PCCSession session) {
for (final Entry<PlspId, PCCTunnel> entry : this.tunnels.entrySet()) {
final PCCTunnel tunnel = entry.getValue();
final PlspId plspId = entry.getKey();
// deal with delegations
if (hasDelegation(tunnel, session)) {
startStateTimeout(tunnel, entry.getKey());
startRedelegationTimer(tunnel, plspId, session);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method reportAllKnownLsp.
private void reportAllKnownLsp(final Optional<SrpIdNumber> operationId, final PCCSession session) {
Srp srp = null;
if (operationId.isPresent()) {
srp = new SrpBuilder().setOperationId(operationId.get()).build();
}
for (final Entry<PlspId, PCCTunnel> entry : this.tunnels.entrySet()) {
final PCCTunnel tunnel = entry.getValue();
final Uint32 plspId = entry.getKey().getValue();
createLspAndSendReport(plspId, tunnel, session, Optional.empty(), Optional.ofNullable(srp));
}
}
Aggregations