use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCase in project bgpcep by opendaylight.
the class PCEPErrorMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
Preconditions.checkArgument(message instanceof PcerrMessage, "Wrong instance of Message. Passed instance of %s. Need PcerrMessage.", message.getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.PcerrMessage err = ((PcerrMessage) message).getPcerrMessage();
Preconditions.checkArgument(err.getErrors() != null && !err.nonnullErrors().isEmpty(), "Errors should not be empty.");
final ByteBuf buffer = Unpooled.buffer();
serializeCases(err, buffer);
for (final Errors e : err.nonnullErrors()) {
serializeObject(e.getErrorObject(), buffer);
}
if (err.getErrorType() instanceof SessionCase) {
serializeObject(((SessionCase) err.getErrorType()).getSession().getOpen(), buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCase in project bgpcep by opendaylight.
the class UtilTest method testCreateErrorMessageWithOpen.
@Test
public void testCreateErrorMessageWithOpen() {
final Pcerr errMsg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, OPEN);
assertThat(errMsg.getPcerrMessage().getErrorType(), isA(SessionCase.class));
final SessionCase sessionCase = (SessionCase) errMsg.getPcerrMessage().getErrorType();
assertEquals(OPEN, sessionCase.getSession().getOpen());
final ErrorObject errorObject = errMsg.getPcerrMessage().getErrors().get(0).getErrorObject();
assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType());
assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCase in project bgpcep by opendaylight.
the class AbstractPCEPSessionNegotiator method handleMessagePcerr.
private boolean handleMessagePcerr(final Message msg) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.PcerrMessage err = ((Pcerr) msg).getPcerrMessage();
if (err.getErrorType() == null) {
final ErrorObject obj = err.getErrors().get(0).getErrorObject();
LOG.warn("Unexpected error received from PCC: type {} value {}", obj.getType(), obj.getValue());
negotiationFailed(new IllegalStateException("Unexpected error received from PCC."));
this.state = State.IDLE;
return true;
}
this.localPrefs = getRevisedProposal(((SessionCase) err.getErrorType()).getSession().getOpen());
if (this.localPrefs == null) {
sendErrorMessage(PCEPErrors.PCERR_NON_ACC_SESSION_CHAR);
negotiationFailed(new IllegalStateException("Peer suggested unacceptable retry proposal"));
this.state = State.FINISHED;
return true;
}
this.sendMessage(new OpenBuilder().setOpenMessage(new OpenMessageBuilder().setOpen(this.localPrefs).build()).build());
if (!this.remoteOK) {
this.state = State.OPEN_WAIT;
}
scheduleFailTimer();
return true;
}
Aggregations