use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class AbstractMessageParser method addVendorInformationObjects.
protected static List<VendorInformationObject> addVendorInformationObjects(final List<Object> objects) {
final List<VendorInformationObject> vendorInfo = new ArrayList<>();
while (!objects.isEmpty() && objects.get(0) instanceof VendorInformationObject) {
final VendorInformationObject viObject = (VendorInformationObject) objects.get(0);
vendorInfo.add(viObject);
objects.remove(0);
}
return vendorInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class AbstractMessageParser method parseObjects.
private List<Object> parseObjects(final ByteBuf bytes) throws PCEPDeserializerException {
final List<Object> objs = new ArrayList<>();
while (bytes.isReadable()) {
if (bytes.readableBytes() < COMMON_OBJECT_HEADER_LENGTH) {
throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes() + " Expected: >= " + COMMON_OBJECT_HEADER_LENGTH + ".");
}
final int objClass = bytes.readUnsignedByte();
final byte flagsByte = bytes.readByte();
final BitArray flags = BitArray.valueOf(flagsByte);
final int objType = UnsignedBytes.toInt(ByteArray.copyBitsRange(flagsByte, OT_SF_OFFSET, OT_SF_LENGTH));
final int objLength = bytes.readUnsignedShort();
if (bytes.readableBytes() < objLength - COMMON_OBJECT_HEADER_LENGTH) {
throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes() + " Expected: >= " + objLength + ".");
}
// copy bytes for deeper parsing
final ByteBuf bytesToPass = bytes.readSlice(objLength - COMMON_OBJECT_HEADER_LENGTH);
final ObjectHeader header = new ObjectHeaderImpl(flags.get(PROCESSED), flags.get(IGNORED));
if (VendorInformationUtil.isVendorInformationObject(objClass, objType)) {
final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytesToPass.readUnsignedInt());
final Optional<? extends Object> obj = this.registry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
if (obj.isPresent()) {
objs.add(obj.get());
}
} else {
// parseObject is required to return null for P=0 errored objects
final Object o = this.registry.parseObject(objClass, objType, header, bytesToPass);
if (o != null) {
objs.add(o);
}
}
}
return objs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class PCCEndPointIpv4ObjectParser method parseObject.
@Override
public Object parseObject(ObjectHeader header, ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final EndpointsObjBuilder builder = new EndpointsObjBuilder();
if (bytes.readableBytes() != Ipv4Util.IP4_LENGTH * 2) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
final Ipv4Builder b = new Ipv4Builder();
b.setSourceIpv4Address(Ipv4Util.addressForByteBuf(bytes));
b.setDestinationIpv4Address((Ipv4Util.addressForByteBuf(bytes)));
builder.setAddressFamily(new Ipv4CaseBuilder().setIpv4(b.build()).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project openflowplugin by opendaylight.
the class FlowConvertor method toFlowModInput.
private FlowModInputBuilder toFlowModInput(Flow flow, VersionDatapathIdConvertorData versionConverterData) {
FlowModInputBuilder flowMod = new FlowModInputBuilder();
salToOFFlowCookie(flow, flowMod);
salToOFFlowCookieMask(flow, flowMod);
salToOFFlowTableId(flow, flowMod);
salToOFFlowCommand(flow, flowMod);
salToOFFlowIdleTimeout(flow, flowMod);
salToOFFlowHardTimeout(flow, flowMod);
salToOFFlowPriority(flow, flowMod);
salToOFFlowBufferId(flow, flowMod);
salToOFFlowOutPort(flow, flowMod);
salToOFFlowOutGroup(flow, flowMod);
// convert and inject flowFlags
final Optional<Object> conversion = getConvertorExecutor().convert(flow.getFlags(), versionConverterData);
FlowFlagsInjector.inject(conversion, flowMod, versionConverterData.getVersion());
// convert and inject match
final Optional<Object> conversionMatch = getConvertorExecutor().convert(flow.getMatch(), versionConverterData);
MatchInjector.inject(conversionMatch, flowMod, versionConverterData.getVersion());
if (flow.getInstructions() != null) {
flowMod.setInstruction(toInstructions(flow, versionConverterData.getVersion(), versionConverterData.getDatapathId()));
flowMod.setAction(getActions(versionConverterData.getVersion(), versionConverterData.getDatapathId(), flow));
}
flowMod.setVersion(versionConverterData.getVersion());
return flowMod;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project controller by opendaylight.
the class ClusterAdminRpcService method addReplicasForAllShards.
@Override
public Future<RpcResult<AddReplicasForAllShardsOutput>> addReplicasForAllShards() {
LOG.info("Adding replicas for all shards");
final List<Entry<ListenableFuture<Success>, ShardResultBuilder>> shardResultData = new ArrayList<>();
Function<String, Object> messageSupplier = AddShardReplica::new;
sendMessageToManagerForConfiguredShards(DataStoreType.Config, shardResultData, messageSupplier);
sendMessageToManagerForConfiguredShards(DataStoreType.Operational, shardResultData, messageSupplier);
return waitForShardResults(shardResultData, shardResults -> new AddReplicasForAllShardsOutputBuilder().setShardResult(shardResults).build(), "Failed to add replica");
}
Aggregations