@Override public void takeDelegation(final Requests request, final PccSession session) { final PlspId plspId = request.getLsp().getPlspId(); final Tunnel tunnel = this.tunnels.get(plspId); final long srpId = request.getSrp().getOperationId().getValue(); if (tunnel != null) { // check if tunnel has no delegation if (tunnel.type == LspType.PCE_LSP && (tunnel.getDelegationHolder() == -1 || tunnel.getDelegationHolder() == session.getId())) { // set delegation tunnel.cancelTimeouts(); setDelegation(plspId, session); // send report final Tlvs tlvs = createLspTlvs( plspId.getValue(), true, getDestinationAddress(tunnel.getLspState().getEro().getSubobject(), this.address), this.address, this.address, Optional.of(tunnel.getPathName())); 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)); } }
private static boolean hasDelegation(final Tunnel tunnel, final PccSession session) { return tunnel.getDelegationHolder() == session.getId(); }