use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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.rev131005.pcerr.message.PcerrMessage err = ((PcerrMessage) message).getPcerrMessage();
Preconditions.checkArgument(err.getErrors() != null && !err.getErrors().isEmpty(), "Errors should not be empty.");
final ByteBuf buffer = Unpooled.buffer();
serializeCases(err, buffer);
for (final Errors e : err.getErrors()) {
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.rev131005.pcerr.message.pcerr.message.error.type.SessionCase in project bgpcep by opendaylight.
the class UtilTest method testCreateErrorMessageWithOpen.
@Test
public void testCreateErrorMessageWithOpen() {
final Message msg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, OPEN);
Assert.assertTrue(msg instanceof Pcerr);
final Pcerr errMsg = (Pcerr) msg;
Assert.assertTrue(errMsg.getPcerrMessage().getErrorType() instanceof SessionCase);
final SessionCase sessionCase = (SessionCase) errMsg.getPcerrMessage().getErrorType();
Assert.assertEquals(OPEN, sessionCase.getSession().getOpen());
final ErrorObject errorObject = errMsg.getPcerrMessage().getErrors().get(0).getErrorObject();
Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType().shortValue());
Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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.rev131005.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