use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage in project bgpcep by opendaylight.
the class PCEPErrorMessageParser method validate.
@Override
protected PcerrMessage validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Error message is empty.");
}
final List<Rps> requestParameters = new ArrayList<>();
final List<Errors> errorObjects = new ArrayList<>();
final PcerrMessageBuilder b = new PcerrMessageBuilder();
Object obj = objects.get(0);
State state = State.INIT;
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
state = State.ERROR_IN;
} else if (obj instanceof Rp) {
final Rp o = (Rp) obj;
if (o.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
return null;
}
requestParameters.add(new RpsBuilder().setRp(o).build());
state = State.RP_IN;
}
if (state.equals(State.INIT)) {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
objects.remove(0);
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
if (obj instanceof UnknownObject) {
return new PcerrBuilder().setPcerrMessage(b.setErrors(((UnknownObject) obj).getErrors()).build()).build();
}
state = insertObject(state, errorObjects, obj, requestParameters, b);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
if (errorObjects.isEmpty()) {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
if (!requestParameters.isEmpty()) {
b.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(requestParameters).build()).build());
}
return new PcerrBuilder().setPcerrMessage(b.setErrors(errorObjects).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method onMessage.
@Override
protected synchronized boolean onMessage(final MessageContext ctx, final Message message) {
if (message instanceof PcerrMessage) {
return handleErrorMessage((PcerrMessage) message);
}
if (!(message instanceof PcrptMessage)) {
return true;
}
this.listenerState.updateLastReceivedRptMsg();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.PcrptMessage rpt = ((PcrptMessage) message).getPcrptMessage();
for (final Reports report : rpt.getReports()) {
if (!manageNextReport(report, ctx)) {
return false;
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage in project bgpcep by opendaylight.
the class PCEPSessionImpl method sendMessage.
/**
* Sends message to serialization.
*
* @param msg to be sent
*/
@Override
public Future<Void> sendMessage(final Message msg) {
final ChannelFuture f = this.channel.writeAndFlush(msg);
this.lastMessageSentAt = TICKER.read();
this.sessionState.updateLastSentMsg();
if (!(msg instanceof KeepaliveMessage)) {
LOG.debug("PCEP Message enqueued: {}", msg);
}
if (msg instanceof PcerrMessage) {
this.sessionState.setLastSentError(msg);
}
f.addListener((ChannelFutureListener) arg -> {
if (arg.isSuccess()) {
LOG.trace("Message sent to socket: {}", msg);
} else {
LOG.debug("Message not sent: {}", msg, arg.cause());
}
});
return f;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage in project bgpcep by opendaylight.
the class PCEPTopologySessionListener method onMessage.
@Override
protected synchronized boolean onMessage(final MessageContext ctx, final Message message) {
if (message instanceof PcerrMessage) {
return handleErrorMessage((PcerrMessage) message);
}
if (message instanceof Pcreq) {
LOG.info("PcReq detected. Start Request Message handler");
return handlePcreqMessage(((Pcreq) message).getPcreqMessage());
}
if (!(message instanceof PcrptMessage)) {
return true;
}
listenerState.updateLastReceivedRptMsg();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.PcrptMessage rpt = ((PcrptMessage) message).getPcrptMessage();
for (final Reports report : rpt.getReports()) {
if (!manageNextReport(report, ctx)) {
return false;
}
}
return false;
}
Aggregations