Search in sources :

Example 1 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPMonitoringRequestMessageParser method validate.

@Override
protected Message validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    Preconditions.checkArgument(objects != null, "Passed list can't be null.");
    if (objects.isEmpty()) {
        throw new PCEPDeserializerException("Pcmonreq message cannot be empty.");
    }
    final MonitoringRequest monReq = getMonitoring(objects);
    if (monReq == null) {
        errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.empty()));
    }
    final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder().setMonitoringRequest(monReq);
    final List<Svec> svecs = getSvecs(objects);
    if (!svecs.isEmpty()) {
        mBuilder.setSvec(svecs);
    }
    final List<Requests> requests = getRequests(objects, errors);
    if (requests != null && !requests.isEmpty()) {
        mBuilder.setRequests(requests);
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcmonreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
Also used : Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec) PcmonreqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcmonreqBuilder) PcreqMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessageBuilder) MonitoringRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequest) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 2 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getMonitoring.

protected MonitoringRequest getMonitoring(final Queue<Object> objects) {
    final MonitoringRequestBuilder builder = new MonitoringRequestBuilder();
    Object obj = objects.peek();
    if (obj instanceof Monitoring) {
        builder.setMonitoring((Monitoring) obj);
        objects.remove();
    } else {
        return null;
    }
    obj = objects.peek();
    if (obj instanceof PccIdReq) {
        builder.setPccIdReq((PccIdReq) obj);
        objects.remove();
        obj = objects.peek();
    }
    final List<PceIdList> pceIdList = new ArrayList<>();
    while (obj instanceof PceId) {
        pceIdList.add(new PceIdListBuilder().setPceId((PceId) obj).build());
        objects.remove();
        obj = objects.peek();
    }
    if (!pceIdList.isEmpty()) {
        builder.setPceIdList(pceIdList);
    }
    return builder.build();
}
Also used : MonitoringRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequestBuilder) PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList) ArrayList(java.util.ArrayList) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceId) PceIdListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring)

Example 3 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPMonitoringRequestMessageParser method validate.

@Override
protected Message 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("Pcmonreq message cannot be empty.");
    }
    final MonitoringRequest monReq = getMonitoring(objects);
    if (monReq == null) {
        errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
    }
    final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
    mBuilder.setMonitoringRequest(monReq);
    final List<Svec> svecs = getSvecs(objects);
    if (!svecs.isEmpty()) {
        mBuilder.setSvec(svecs);
    }
    final List<Requests> requests = getRequests(objects, errors);
    if (requests != null && !requests.isEmpty()) {
        mBuilder.setRequests(requests);
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcmonreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
Also used : Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Svec) PcmonreqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonreqBuilder) PcreqMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.PcreqMessageBuilder) MonitoringRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 4 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getMonitoring.

protected MonitoringRequest getMonitoring(final List<Object> objects) {
    final MonitoringRequestBuilder builder = new MonitoringRequestBuilder();
    if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
        builder.setMonitoring((Monitoring) objects.get(0));
        objects.remove(0);
    } else {
        return null;
    }
    if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
        builder.setPccIdReq((PccIdReq) objects.get(0));
        objects.remove(0);
    }
    final List<PceIdList> pceIdList = new ArrayList<>();
    while (!objects.isEmpty() && objects.get(0) instanceof PceId) {
        pceIdList.add(new PceIdListBuilder().setPceId((PceId) objects.get(0)).build());
        objects.remove(0);
    }
    if (!pceIdList.isEmpty()) {
        builder.setPceIdList(pceIdList);
    }
    return builder.build();
}
Also used : MonitoringRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequestBuilder) PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdList) ArrayList(java.util.ArrayList) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) PceIdListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)

Example 5 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method serializeMonitoringRequest.

protected void serializeMonitoringRequest(final MonitoringRequest monReq, final ByteBuf out) {
    serializeObject(monReq.getMonitoring(), out);
    serializeObject(monReq.getPccIdReq(), out);
    for (final PceIdList pceId : monReq.nonnullPceIdList()) {
        serializeObject(pceId.getPceId(), out);
    }
}
Also used : PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList)

Aggregations

ArrayList (java.util.ArrayList)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 PceIdList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList)2 PcmonreqBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonreqBuilder)1 PcmonreqBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcmonreqBuilder)1 Monitoring (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)1 PccIdReq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq)1 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId)1 PcreqMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.PcreqMessageBuilder)1 MonitoringRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest)1 MonitoringRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequestBuilder)1 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests)1 Svec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Svec)1 PceIdList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdList)1 PceIdListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder)1 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)1 Monitoring (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring)1 PccIdReq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq)1 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceId)1 PcreqMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessageBuilder)1