Search in sources :

Example 51 with Object

use of com.google.storage.v2.Object in project bgpcep by opendaylight.

the class PcRptMessageCodec method getValidReports.

@Override
protected Reports getValidReports(final List<Object> objects, final List<Message> errors) {
    final Optional<Object> find = Iterables.tryFind(objects, Predicates.instanceOf(BandwidthUsage.class));
    final Object object;
    if (find.isPresent()) {
        object = find.get();
        objects.remove(object);
    } else {
        object = null;
    }
    final Reports validReports = super.getValidReports(objects, errors);
    if (object != null && validReports != null) {
        final Path path = validReports.getPath();
        if (path != null) {
            return new ReportsBuilder(validReports).setPath(new PathBuilder(path).setBandwidth(setBandwidthUsage(path.getBandwidth(), (BandwidthUsage) object)).build()).build();
        }
    }
    return validReports;
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.Path) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder) ReportsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.ReportsBuilder) BandwidthUsage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev171025.bandwidth.usage.object.BandwidthUsage) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)

Example 52 with Object

use of com.google.storage.v2.Object in project bgpcep by opendaylight.

the class StatefulPCUpdateRequestMessageParser method getValidUpdates.

protected Updates getValidUpdates(final Queue<Object> objects, final List<Message> errors) {
    final UpdatesBuilder builder = new UpdatesBuilder();
    Object object = objects.remove();
    if (object instanceof Srp) {
        builder.setSrp((Srp) object);
        object = objects.poll();
    } else {
        errors.add(createErrorMsg(PCEPErrors.SRP_MISSING, Optional.empty()));
    }
    if (validateLsp(object, errors, builder)) {
        if (!objects.isEmpty()) {
            if (!validatePath(objects, errors, builder)) {
                return null;
            }
        }
        return builder.build();
    }
    return null;
}
Also used : Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder)

Example 53 with Object

use of com.google.storage.v2.Object in project bgpcep by opendaylight.

the class StatefulPCUpdateRequestMessageParser method validatePath.

private static boolean validatePath(final Queue<Object> objects, final List<Message> errors, final UpdatesBuilder builder) {
    final PathBuilder pBuilder = new PathBuilder();
    Object object = objects.remove();
    if (object instanceof Ero) {
        pBuilder.setEro((Ero) object);
    } else {
        errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.empty()));
        return false;
    }
    parsePath(objects, pBuilder);
    builder.setPath(pBuilder.build());
    return true;
}
Also used : PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)

Example 54 with Object

use of com.google.storage.v2.Object in project bgpcep by opendaylight.

the class StatefulPCUpdateRequestMessageParser method parsePath.

private static void parsePath(final Queue<Object> objects, final PathBuilder pathBuilder) {
    final List<Metrics> pathMetrics = new ArrayList<>();
    State state = State.INIT;
    for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
        state = insertObject(state, obj, pathBuilder, pathMetrics);
        if (state == State.END) {
            break;
        }
        objects.remove();
    }
    if (!pathMetrics.isEmpty()) {
        pathBuilder.setMetrics(pathMetrics);
    }
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) ArrayList(java.util.ArrayList) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)

Example 55 with Object

use of com.google.storage.v2.Object in project bgpcep by opendaylight.

the class PCEPMonitoringReplyMessageParser method validate.

@Override
protected Message validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    checkArgument(objects != null, "Passed list can't be null.");
    final Object monitoring = objects.poll();
    if (monitoring == null) {
        throw new PCEPDeserializerException("Pcmonrep message cannot be empty.");
    }
    if (!(monitoring instanceof Monitoring)) {
        errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.empty()));
        return null;
    }
    final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder().setMonitoring((Monitoring) monitoring);
    final Object obj = objects.peek();
    if (obj instanceof PccIdReq) {
        builder.setPccIdReq((PccIdReq) obj);
        objects.remove();
    }
    validateSpecificMetrics(objects, builder);
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build();
}
Also used : PcmonrepMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcmonrep.message.PcmonrepMessageBuilder) PcmonrepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcmonrepBuilder) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring)

Aggregations

Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 ArrayList (java.util.ArrayList)25 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 StorageClient (com.google.storage.v2.StorageClient)16 Object (com.google.storage.v2.Object)12 Test (org.junit.Test)12 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)12 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)12 Object (no.mnemonic.act.platform.api.model.v1.Object)8 Preconditions (com.google.common.base.Preconditions)6 ObjectRecord (no.mnemonic.act.platform.dao.api.record.ObjectRecord)6 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)6 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics)5 Ero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero)5 AbstractMessage (com.google.protobuf.AbstractMessage)4 ByteString (com.google.protobuf.ByteString)4 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)4 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)4 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)4 ListObjectsPagedResponse (com.google.storage.v2.StorageClient.ListObjectsPagedResponse)3