This bumps mdsal to 5.0.2 as part of Magnesium MRI.
Change-Id: Id9ab45edf28477dca8acf8f7538cfd26f237f6f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.benchmark.app;
import static java.util.Objects.requireNonNull;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return this.routesIId;
}
- private long addRoute(final Ipv4Prefix ipv4Prefix, final Ipv4Address nextHop, final long count, final long batch) {
+ private long addRoute(final Ipv4Prefix ipv4Prefix, final Ipv4Address nextHop, final Uint32 count,
+ final Uint32 batch) {
final AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(
new Ipv4NextHopBuilder().setGlobal(new Ipv4Address(nextHop)).build()).build());
return processRoutes(ipv4Prefix, count, batch, attributes);
}
- private long deleteRoute(final Ipv4Prefix ipv4Prefix, final long count, final long batch) {
+ private long deleteRoute(final Ipv4Prefix ipv4Prefix, final Uint32 count, final Uint32 batch) {
return processRoutes(ipv4Prefix, count, batch, null);
}
- private long processRoutes(final Ipv4Prefix ipv4Prefix, final long count, final long batch,
+ private long processRoutes(final Ipv4Prefix ipv4Prefix, final Uint32 count, final Uint32 batch,
final Attributes attributes) {
WriteTransaction wt = this.txChain.newWriteOnlyTransaction();
String address = getAdddressFromPrefix(ipv4Prefix);
+ final long countLong = count.longValue();
+ final long batchLong = batch.longValue();
final Stopwatch stopwatch = Stopwatch.createStarted();
- for (int i = 1; i <= count; i++) {
+ for (int i = 1; i <= countLong; i++) {
final Ipv4RouteKey routeKey = new Ipv4RouteKey(NON_PATH_ID, createKey(address));
final KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> routeIId =
this.routesIId.child(Ipv4Route.class, routeKey);
} else {
wt.delete(LogicalDatastoreType.CONFIGURATION, routeIId);
}
- if (i % batch == 0) {
+ if (i % batchLong == 0) {
wt.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
return stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
}
- private static long countRate(final long durationMillis, final long count) {
+ private static long countRate(final long durationMillis, final Uint32 count) {
final long durationSec = TimeUnit.MILLISECONDS.toSeconds(durationMillis);
if (durationSec != 0) {
- return count / durationSec;
+ return count.toJava() / durationSec;
}
- return count;
+ return count.toJava();
}
private static String increasePrefix(final String prefix) {
return InetAddresses.increment(InetAddresses.forString(prefix)).getHostAddress();
}
- private static Result createResult(final long count, final long duration, final long rate) {
+ private static Result createResult(final Uint32 count, final long duration, final long rate) {
return new ResultBuilder().setCount(count).setDuration(duration).setRate(rate).build();
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.esi.arbitrary._case.ArbitraryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.EvpnChoice;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
throw new UnsupportedOperationException();
}
- static Long extractLD(final ContainerNode cont) {
- return (Long) cont.getChild(LD_NID).get().getValue();
+ static Uint32 extractLD(final ContainerNode cont) {
+ return (Uint32) cont.getChild(LD_NID).get().getValue();
}
static Arbitrary extractArbitrary(final ContainerNode esi) {
return new ArbitraryBuilder().setArbitrary(arbitrary).build();
}
-
static AsNumber extractAS(final ContainerNode asGen) {
- return new AsNumber((Long) asGen.getChild(AS_NID).get().getValue());
+ return new AsNumber((Uint32) asGen.getChild(AS_NID).get().getValue());
}
-
- static Integer extractPK(final ContainerNode t1) {
- return (Integer) t1.getChild(PK_NID).get().getValue();
+ static Uint16 extractPK(final ContainerNode t1) {
+ return (Uint16) t1.getChild(PK_NID).get().getValue();
}
static MacAddress extractLacpMac(final ContainerNode t1) {
return new MacAddress((String) lan.getChild(BRIDGE_MAC_NID).get().getValue());
}
- static Integer extractBP(final ContainerNode lan) {
- return (Integer) lan.getChild(RBP_NID).get().getValue();
+ static Uint16 extractBP(final ContainerNode lan) {
+ return (Uint16) lan.getChild(RBP_NID).get().getValue();
}
static Uint24 extractUint24LD(final ContainerNode esiVal) {
- return new Uint24((Long) esiVal.getChild(LD_NID).get().getValue());
+ return new Uint24((Uint32) esiVal.getChild(LD_NID).get().getValue());
}
static MacAddress extractSystmeMac(final ContainerNode macGEn) {
static Ipv4Address extractRD(final ContainerNode t4) {
return new Ipv4Address((String) t4.getChild(RD_NID).get().getValue());
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisherBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
static EthernetTagId extractETI(final ContainerNode evpn) {
final ContainerNode eti = (ContainerNode) evpn.getChild(ETI_NID).get();
- return new EthernetTagIdBuilder().setVlanId((Long) eti.getChild(VLAN_NID).get().getValue()).build();
+ return new EthernetTagIdBuilder().setVlanId((Uint32) eti.getChild(VLAN_NID).get().getValue()).build();
}
static MacAddress extractMAC(final DataContainerNode<? extends PathArgument> evpn) {
static MplsLabel extractMplsLabel(final DataContainerNode<? extends PathArgument> evpn,
final NodeIdentifier mplsNid) {
if (evpn.getChild(mplsNid).isPresent()) {
- return new MplsLabel((Long) evpn.getChild(mplsNid).get().getValue());
+ return new MplsLabel((Uint32) evpn.getChild(mplsNid).get().getValue());
}
return null;
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisherBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
public final class EvpnTestUtil {
public static final int VALUE_SIZE = 9;
- public static final long LD = 33686018;
+ public static final Uint32 LD = Uint32.valueOf(33686018);
public static final String MAC_MODEL = "f2:0c:dd:80:9f:f7";
public static final MacAddress MAC = new MacAddress(MAC_MODEL);
- public static final long AS_MODEL = 16843009;
+ public static final Uint32 AS_MODEL = Uint32.valueOf(16843009);
public static final AsNumber AS_NUMBER = new AsNumber(AS_MODEL);
- public static final Integer PORT = 514;
- public static final MplsLabel MPLS_LABEL = new MplsLabel(24001L);
+ public static final Uint16 PORT = Uint16.valueOf(514);
+ public static final Uint32 MPLS_LABEL_MODEL = Uint32.valueOf(24001L);
+ public static final MplsLabel MPLS_LABEL = new MplsLabel(MPLS_LABEL_MODEL);
public static final int COMMUNITY_VALUE_SIZE = 6;
- public static final long VLAN = 10L;
+ public static final Uint32 VLAN = Uint32.valueOf(10);
public static final String IP_MODEL = "127.0.0.1";
public static final IpAddress IP = new IpAddress(new Ipv4Address(IP_MODEL));
public static final String IPV6_MODEL = "2001::1";
public static final IpAddress IPV6 = new IpAddress(new Ipv6Address(IPV6_MODEL));
- public static final long MPLS_LABEL_MODEL = 24001L;
- public static final MplsLabel MPLS_LABEL2 = new MplsLabel(24002L);
- public static final long MPLS_LABEL2_MODEL = 24002L;
+ public static final Uint32 MPLS_LABEL2_MODEL = Uint32.valueOf(24002L);
+ public static final MplsLabel MPLS_LABEL2 = new MplsLabel(MPLS_LABEL2_MODEL);
public static final String RD_MODEL = "1.2.3.4:258";
public static final RouteDistinguisher RD = RouteDistinguisherBuilder.getDefaultInstance(RD_MODEL);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.esi.LanAutoGeneratedCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.esi.lan.auto.generated._case.LanAutoGenerated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.esi.lan.auto.generated._case.LanAutoGeneratedBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
public class LanParserTest {
- private static final Integer PRIORITY = 514;
+ private static final Uint16 PRIORITY = Uint16.valueOf(514);
public static final LanAutoGeneratedCase LAN_AUT_GEN_CASE = new LanAutoGeneratedCaseBuilder()
.setLanAutoGenerated(new LanAutoGeneratedBuilder()
.setRootBridgeMacAddress(MAC).setRootBridgePriority(PRIORITY).build()).build();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.esi.MacAutoGeneratedCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.esi.mac.auto.generated._case.MacAutoGenerated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.esi.mac.auto.generated._case.MacAutoGeneratedBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
(byte) 0x02, (byte) 0x02, (byte) 0x00};
private static final byte[] RESULT = {(byte) 0x03, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f,
(byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00};
- private static final long UINT24_LD_MODEL = 131584L;
+ private static final Uint32 UINT24_LD_MODEL = Uint32.valueOf(131584L);
private static final Uint24 UINT24_LD = new Uint24(UINT24_LD_MODEL);
private MacParser parser;
for (final Iterator<Dscps> it = dscps.iterator(); it.hasNext(); ) {
final Dscps dscp = it.next();
NumericOneByteOperandParser.INSTANCE.serialize(dscp.getOp(), 1, !it.hasNext(), nlriByteBuf);
- Util.writeShortest(dscp.getValue().getValue(), nlriByteBuf);
+ Util.writeShortest(dscp.getValue().getValue().toJava(), nlriByteBuf);
}
}
for (final Iterator<TcpFlags> it = flags.iterator(); it.hasNext(); ) {
final TcpFlags flag = it.next();
final ByteBuf flagsBuf = Unpooled.buffer();
- Util.writeShortest(flag.getValue(), flagsBuf);
+ Util.writeShortest(flag.getValue().toJava(), flagsBuf);
BitmaskOperandParser.INSTANCE.serialize(flag.getOp(), flagsBuf.readableBytes(),
!it.hasNext(), nlriByteBuf);
nlriByteBuf.writeBytes(flagsBuf);
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOneByteValue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Parser class for NumericOneByteValues.
*/
-public final class NumericOneByteOperandParser extends AbstractNumericByteOperandParser<NumericOneByteValue, Short> {
+public final class NumericOneByteOperandParser extends AbstractNumericByteOperandParser<NumericOneByteValue, Uint8> {
public static final NumericOneByteOperandParser INSTANCE;
for (final Iterator<T> it = list.iterator(); it.hasNext(); ) {
final T operand = it.next();
super.serialize(operand.getOp(), 1, !it.hasNext(), nlriByteBuf);
- Util.writeShortest(operand.getValue(), nlriByteBuf);
+ Util.writeShortest(operand.getValue().toJava(), nlriByteBuf);
}
}
@Override
- protected <T extends NumericOneByteValue> Short getValue(final T item) {
+ protected <T extends NumericOneByteValue> Uint8 getValue(final T item) {
return item.getValue();
}
import io.netty.buffer.Unpooled;
import java.util.Iterator;
import java.util.List;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericTwoByteValue;
+import org.opendaylight.yangtools.yang.common.Uint16;
/**
* Parser class for NumericTwoByteValues.
*/
-public final class NumericTwoByteOperandParser extends AbstractNumericByteOperandParser<NumericTwoByteValue, Integer> {
+public final class NumericTwoByteOperandParser extends AbstractNumericByteOperandParser<NumericTwoByteValue, Uint16> {
public static final NumericTwoByteOperandParser INSTANCE;
for (final Iterator<T> it = list.iterator(); it.hasNext(); ) {
final T operand = it.next();
final ByteBuf protoBuf = Unpooled.buffer();
- Util.writeShortest(operand.getValue(), protoBuf);
+ Util.writeShortest(operand.getValue().toJava(), protoBuf);
super.serialize(operand.getOp(), protoBuf.readableBytes(), !it.hasNext(), nlriByteBuf);
nlriByteBuf.writeBytes(protoBuf);
}
}
@Override
- protected <T extends NumericTwoByteValue> Integer getValue(final T item) {
+ protected <T extends NumericTwoByteValue> Uint16 getValue(final T item) {
return item.getValue();
}
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
= label.getChild(labelValueNid);
if (labelStack.isPresent()) {
final LabelStackBuilder labelStackbuilder = new LabelStackBuilder();
- labelStackbuilder.setLabelValue(new MplsLabel((Long) labelStack.get().getValue()));
+ labelStackbuilder.setLabelValue(new MplsLabel((Uint32) labelStack.get().getValue()));
labels.add(labelStackbuilder.build());
}
}
Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
serializeUnreservedBw(linkAttributes.getUnreservedBandwidth(), output);
ifPresentApply(linkAttributes.getTeMetric(), value -> TlvUtil.writeTLV(TE_METRIC,
- Unpooled.copyLong(((TeMetric) value).getValue()), output));
+ Unpooled.copyLong(((TeMetric) value).getValue().toJava()), output));
ifPresentApply(linkAttributes.getLinkProtection(), value -> TlvUtil.writeTLV(LINK_PROTECTION_TYPE,
Unpooled.copyShort(((LinkProtectionType) value).getIntValue()), output));
serializeMplsProtocolMask(linkAttributes.getMplsProtocol(), output);
if (topList != null) {
final ByteBuf mpIdBuf = Unpooled.buffer();
for (final TopologyIdentifier topologyIdentifier : topList) {
- mpIdBuf.writeShort(topologyIdentifier.getValue());
+ mpIdBuf.writeShort(topologyIdentifier.getValue().toJava());
}
TlvUtil.writeTLV(TlvUtil.MULTI_TOPOLOGY_ID, mpIdBuf, byteAggregator);
}
public static void serializeBindingSidAttributes(final Weight weight, final Flags flags,
final List<BindingSubTlvs> bindingSubTlvs, final ByteBuf aggregator) {
- aggregator.writeByte(weight.getValue());
+ aggregator.writeByte(weight.getValue().toJava());
final BitArray bitFlags = serializeBindingSidFlags(flags);
bitFlags.toByteBuf(aggregator);
aggregator.writeZero(RESERVED_BINDING_SID);
flags.set(INNER_AREA, srRange.isInterArea());
flags.toByteBuf(aggregator);
aggregator.writeZero(RESERVED);
- aggregator.writeShort(srRange.getRangeSize());
+ aggregator.writeShort(srRange.getRangeSize().toJava());
serializeSubTlvs(aggregator, srRange.getSubTlvs());
}
} else {
value.writeZero(FLAGS_BYTE_SIZE);
}
- value.writeByte(adjSid.getWeight().getValue());
+ value.writeByte(adjSid.getWeight().getValue().toJava());
value.writeZero(RESERVED);
value.writeBytes(SidLabelIndexParser.serializeSidValue(adjSid.getSidLabelIndex()));
return value;
final ByteBuf value = Unpooled.buffer();
final BitArray flags = serializeAdjFlags(srLanAdjId.getFlags(), srLanAdjId.getSidLabelIndex());
flags.toByteBuf(value);
- value.writeByte(srLanAdjId.getWeight().getValue());
+ value.writeByte(srLanAdjId.getWeight().getValue().toJava());
value.writeZero(RESERVED);
if (srLanAdjId.getIsoSystemId() != null) {
value.writeBytes(srLanAdjId.getIsoSystemId().getValue());
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.BindingSubTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.UnnumberedInterfaceIdEroCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.UnnumberedInterfaceIdEroCaseBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public final class UnnumberedEroParser implements BindingSubTlvsParser, BindingSubTlvsSerializer {
private static final int UNNUMBERED_ERO = 1165;
return builder.build();
}
- static ByteBuf serializeUnnumberedIdEro(final Boolean loose, final Long routerId, final Long interfaceId) {
+ static ByteBuf serializeUnnumberedIdEro(final Boolean loose, final Uint32 routerId, final Uint32 interfaceId) {
final ByteBuf buffer = Unpooled.buffer();
Ipv4EroParser.serializeEroFlags(buffer, loose);
buffer.writeInt(routerId.intValue());
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.LocalNodeDescriptors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.RemoteNodeDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
final LinkDescriptorsBuilder linkDescBuilder = new LinkDescriptorsBuilder();
if (descriptors.getChild(LINK_LOCAL_NID).isPresent() && descriptors.getChild(LINK_REMOTE_NID).isPresent()) {
- linkDescBuilder.setLinkLocalIdentifier((Long) descriptors.getChild(LINK_LOCAL_NID).get().getValue());
- linkDescBuilder.setLinkRemoteIdentifier((Long) descriptors.getChild(LINK_REMOTE_NID).get().getValue());
+ linkDescBuilder.setLinkLocalIdentifier((Uint32) descriptors.getChild(LINK_LOCAL_NID).get().getValue());
+ linkDescBuilder.setLinkRemoteIdentifier((Uint32) descriptors.getChild(LINK_REMOTE_NID).get().getValue());
}
ifPresentApply(descriptors, IPV4_IFACE_NID,
value -> linkDescBuilder.setIpv4InterfaceAddress(new Ipv4InterfaceIdentifier((String) value)));
import com.google.common.annotations.VisibleForTesting;
import io.netty.buffer.ByteBuf;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
.forValue(domProtocolIdValue((String) dataContainerChild.getValue()))));
final Optional<DataContainerChild<? extends PathArgument, ?>> identifier = linkstate.getChild(IDENTIFIER_NID);
identifier.ifPresent(dataContainerChild -> builder
- .setIdentifier(new Identifier((BigInteger) dataContainerChild.getValue())));
+ .setIdentifier(new Identifier((Uint64) dataContainerChild.getValue())));
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.node.identifier.c.router.identifier.ospf.pseudonode._case.OspfPseudonodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
nodeBuilder.setIsIsRouterIdentifier(isisRouterId.build());
if (pseudoIsisNode.getChild(PSN_NID).isPresent()) {
- nodeBuilder.setPsn((Short) pseudoIsisNode.getChild(PSN_NID).get().getValue());
+ nodeBuilder.setPsn((Uint8) pseudoIsisNode.getChild(PSN_NID).get().getValue());
} else {
- nodeBuilder.setPsn((short) 0);
+ nodeBuilder.setPsn(Uint8.ZERO);
}
return new IsisPseudonodeCaseBuilder().setIsisPseudonode(nodeBuilder.build()).build();
final OspfNodeCaseBuilder builder = new OspfNodeCaseBuilder();
if (ospf.getChild(OSPF_ROUTER_NID).isPresent()) {
final OspfNodeBuilder nodeBuilder = new OspfNodeBuilder();
- nodeBuilder.setOspfRouterId((Long) ospf.getChild(OSPF_ROUTER_NID).get().getValue());
+ nodeBuilder.setOspfRouterId((Uint32) ospf.getChild(OSPF_ROUTER_NID).get().getValue());
builder.setOspfNode(nodeBuilder.build());
}
return builder.build();
final OspfPseudonodeCaseBuilder builder = new OspfPseudonodeCaseBuilder();
final OspfPseudonodeBuilder nodeBuilder = new OspfPseudonodeBuilder();
if (ospfPseudonode.getChild(LAN_IFACE_NID).isPresent()) {
- nodeBuilder.setLanInterface(new OspfInterfaceIdentifier((Long)ospfPseudonode.getChild(LAN_IFACE_NID)
+ nodeBuilder.setLanInterface(new OspfInterfaceIdentifier((Uint32)ospfPseudonode.getChild(LAN_IFACE_NID)
.get().getValue()));
}
if (ospfPseudonode.getChild(OSPF_ROUTER_NID).isPresent()) {
- nodeBuilder.setOspfRouterId((Long)ospfPseudonode.getChild(OSPF_ROUTER_NID).get().getValue());
+ nodeBuilder.setOspfRouterId((Uint32)ospfPseudonode.getChild(OSPF_ROUTER_NID).get().getValue());
}
builder.setOspfPseudonode(nodeBuilder.build());
return builder.build();
private static AsNumber serializeAsNumber(final ContainerNode descriptorsData) {
return descriptorsData.getChild(AS_NUMBER_NID).map(
- dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
+ dataContainerChild -> new AsNumber((Uint32) dataContainerChild.getValue())).orElse(null);
}
private static DomainIdentifier serializeDomainId(final ContainerNode descriptorsData) {
return descriptorsData.getChild(DOMAIN_NID).map(
- dataContainerChild -> new DomainIdentifier((Long) dataContainerChild.getValue())).orElse(null);
+ dataContainerChild -> new DomainIdentifier((Uint32) dataContainerChild.getValue())).orElse(null);
}
private static AreaIdentifier serializeAreaId(final ContainerNode descriptorsData) {
return descriptorsData.getChild(AREA_NID).map(
- dataContainerChild -> new AreaIdentifier((Long) dataContainerChild.getValue())).orElse(null);
+ dataContainerChild -> new AreaIdentifier((Uint32) dataContainerChild.getValue())).orElse(null);
}
private static Ipv4Address serializeBgpRouterId(final ContainerNode descriptorsData) {
private static AsNumber serializeMemberAsn(final ContainerNode descriptorsData) {
return descriptorsData.getChild(MEMBER_ASN_NID).map(
- dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
+ dataContainerChild -> new AsNumber((Uint32) dataContainerChild.getValue())).orElse(null);
}
static LocalNodeDescriptors serializeLocalNodeDescriptors(final ContainerNode descriptorsData) {
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.LinkLrIdentifiers;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
public final class LinkIdTlvParser implements LinkstateTlvParser.LinkstateTlvSerializer<LinkLrIdentifiers>,
LinkstateTlvParser<LinkLrIdentifiers> {
@Override
public LinkLrIdentifiers parseTlvBody(final ByteBuf value) {
- final long localId = value.readUnsignedInt();
- final long remoteId = value.readUnsignedInt();
+ final Uint32 localId = Uint32.valueOf(value.readUnsignedInt());
+ final Uint32 remoteId = Uint32.valueOf(value.readUnsignedInt());
return new LinkLrIdentifiers() {
@Override
public Class<LinkLrIdentifiers> implementedInterface() {
}
@Override
- public Long getLinkRemoteIdentifier() {
+ public Uint32 getLinkRemoteIdentifier() {
return remoteId;
}
@Override
- public Long getLinkLocalIdentifier() {
+ public Uint32 getLinkLocalIdentifier() {
return localId;
}
};
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AssociationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class LinkstateAttributeParserTest {
assertEquals("42.42.42.42", ls.getLocalIpv4RouterId().getValue());
assertEquals("43.43.43.43", ls.getRemoteIpv4RouterId().getValue());
- assertEquals(Long.valueOf(0L), ls.getAdminGroup().getValue());
+ assertEquals(Uint32.ZERO, ls.getAdminGroup().getValue());
assertArrayEquals(new byte[] { (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80 },
ls.getMaxLinkBandwidth().getValue());
assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 },
assertEquals(LinkProtectionType.Dedicated1to1, ls.getLinkProtection());
assertTrue(ls.getMplsProtocol().isLdp());
assertTrue(ls.getMplsProtocol().isRsvpte());
- assertEquals(new Long(10), ls.getMetric().getValue());
+ assertEquals(Uint32.valueOf(10), ls.getMetric().getValue());
assertEquals(2, ls.getSharedRiskLinkGroups().size());
assertEquals(305419896, ls.getSharedRiskLinkGroups().get(0).getValue().intValue());
assertEquals("12K-2", ls.getLinkName());
.setBackup(Boolean.FALSE).setSet(Boolean.FALSE).build();
assertEquals(flags, ls.getSrAdjIds().get(0).getFlags());
assertEquals(flags, ls.getSrAdjIds().get(1).getFlags());
- assertEquals(new Long(1048575L), ((LocalLabelCase)ls.getSrAdjIds().get(0).getSidLabelIndex()).getLocalLabel()
- .getValue());
- assertEquals(new Long(1048559L), ((LocalLabelCase)ls.getSrAdjIds().get(1).getSidLabelIndex()).getLocalLabel()
- .getValue());
- assertEquals(new Long(168496141L), ((SidCase) ls.getPeerNodeSid().getSidLabelIndex()).getSid());
- assertEquals(new Short("5"), ls.getPeerNodeSid().getWeight().getValue());
- assertEquals(new Long(168496142L), ((SidCase) ls.getPeerSetSids().get(0).getSidLabelIndex()).getSid());
- assertEquals(new Short("5"), ls.getPeerSetSids().get(0).getWeight().getValue());
- assertEquals(new Long(168496143L), ((SidCase) ls.getPeerAdjSid().getSidLabelIndex()).getSid());
- assertEquals(new Short("5"), ls.getPeerAdjSid().getWeight().getValue());
+ assertEquals(Uint32.valueOf(1048575L),
+ ((LocalLabelCase)ls.getSrAdjIds().get(0).getSidLabelIndex()).getLocalLabel().getValue());
+ assertEquals(Uint32.valueOf(1048559L),
+ ((LocalLabelCase)ls.getSrAdjIds().get(1).getSidLabelIndex()).getLocalLabel().getValue());
+ assertEquals(Uint32.valueOf(168496141L), ((SidCase) ls.getPeerNodeSid().getSidLabelIndex()).getSid());
+ assertEquals(Uint8.valueOf(5), ls.getPeerNodeSid().getWeight().getValue());
+ assertEquals(Uint32.valueOf(168496142L), ((SidCase) ls.getPeerSetSids().get(0).getSidLabelIndex()).getSid());
+ assertEquals(Uint8.valueOf(5), ls.getPeerSetSids().get(0).getWeight().getValue());
+ assertEquals(Uint32.valueOf(168496143L), ((SidCase) ls.getPeerAdjSid().getSidLabelIndex()).getSid());
+ assertEquals(Uint8.valueOf(5), ls.getPeerAdjSid().getWeight().getValue());
// Performance Metrics
- assertEquals(new Long(10000L), ls.getLinkDelay().getValue());
- assertEquals(new Long(5000L), ls.getLinkMinMaxDelay().getMinDelay().getValue());
- assertEquals(new Long(20000L), ls.getLinkMinMaxDelay().getMaxDelay().getValue());
- assertEquals(new Long(10000L), ls.getDelayVariation().getValue());
- assertEquals(new Long(0L), ls.getLinkLoss().getValue());
+ assertEquals(Uint32.valueOf(10000L), ls.getLinkDelay().getValue());
+ assertEquals(Uint32.valueOf(5000L), ls.getLinkMinMaxDelay().getMinDelay().getValue());
+ assertEquals(Uint32.valueOf(20000L), ls.getLinkMinMaxDelay().getMaxDelay().getValue());
+ assertEquals(Uint32.valueOf(10000L), ls.getDelayVariation().getValue());
+ assertEquals(Uint32.valueOf(0L), ls.getLinkLoss().getValue());
assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 },
ls.getResidualBandwidth().getValue());
assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 },
teLspAttributes.getTspecObject().getTokenBucketSize());
assertEquals(new Float32(new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03}),
tSpec.getPeakDataRate());
- assertEquals(new Long("4"), tSpec.getMinimumPolicedUnit());
- assertEquals(new Long("5"), tSpec.getMaximumPacketSize());
+ assertEquals(Uint32.valueOf(4), tSpec.getMinimumPolicedUnit());
+ assertEquals(Uint32.valueOf(5), tSpec.getMaximumPacketSize());
final AssociationObject associationObject = teLspAttributes.getAssociationObject();
assertEquals(AssociationType.Recovery, associationObject.getAssociationType());
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.math.BigInteger;
import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
// test BA form
assertNull(this.dest.getRouteDistinguisher());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
- assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
+ assertEquals(Uint64.ONE, this.dest.getIdentifier().getValue());
final NodeCase nCase = (NodeCase) this.dest.getObjectType();
final NodeDescriptors nodeD = nCase.getNodeDescriptors();
protocolId.withValue("isis-level2");
linkstateBI.addChild(protocolId.build());
- final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint64> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
- identifier.withValue(BigInteger.ONE);
+ identifier.withValue(Uint64.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> nodeDescriptors = Builders.containerBuilder();
nodeDescriptors.withNodeIdentifier(LinkstateNlriParser.NODE_DESCRIPTORS_NID);
- final ImmutableLeafNodeBuilder<Long> asNumber = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> asNumber = new ImmutableLeafNodeBuilder<>();
asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
- asNumber.withValue(72L);
+ asNumber.withValue(Uint32.valueOf(72));
nodeDescriptors.addChild(asNumber.build());
- final ImmutableLeafNodeBuilder<Long> areaID = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> areaID = new ImmutableLeafNodeBuilder<>();
areaID.withNodeIdentifier(NodeNlriParser.AREA_NID);
- areaID.withValue(2697513L);
+ areaID.withValue(Uint32.valueOf(2697513L));
nodeDescriptors.addChild(areaID.build());
- final ImmutableLeafNodeBuilder<Long> domainID = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> domainID = new ImmutableLeafNodeBuilder<>();
domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
- domainID.withValue(0x28282828L);
+ domainID.withValue(Uint32.valueOf(0x28282828L));
nodeDescriptors.addChild(domainID.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
isisPseudoRouter.addChild(isoSystemID.build());
isisNode.addChild(isisPseudoRouter.build());
- isisNode.addChild(Builders.leafBuilder().withNodeIdentifier(NodeNlriParser.PSN_NID).withValue((short) 5)
+ isisNode.addChild(Builders.leafBuilder().withNodeIdentifier(NodeNlriParser.PSN_NID).withValue(Uint8.valueOf(5))
.build());
crouterId.addChild(isisNode.build());
// test BA form
assertNull(this.dest.getRouteDistinguisher());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
- assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
+ assertEquals(Uint64.ONE, this.dest.getIdentifier().getValue());
final LinkCase lCase = (LinkCase) this.dest.getObjectType();
protocolId.withValue("isis-level2");
linkstateBI.addChild(protocolId.build());
- final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint64> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
- identifier.withValue(BigInteger.ONE);
+ identifier.withValue(Uint64.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
Builders.containerBuilder();
localNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.LOCAL_NODE_DESCRIPTORS_NID);
- final ImmutableLeafNodeBuilder<Long> asNumber = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> asNumber = new ImmutableLeafNodeBuilder<>();
asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
- asNumber.withValue(72L);
+ asNumber.withValue(Uint32.valueOf(72));
localNodeDescriptors.addChild(asNumber.build());
- final ImmutableLeafNodeBuilder<Long> domainID = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> domainID = new ImmutableLeafNodeBuilder<>();
domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
- domainID.withValue(0x28282828L);
+ domainID.withValue(Uint32.valueOf(0x28282828L));
localNodeDescriptors.addChild(domainID.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
bgpRouterId.withNodeIdentifier(NodeNlriParser.BGP_ROUTER_NID);
bgpRouterId.withValue("1.1.1.1");
- final ImmutableLeafNodeBuilder<Long> memberAsn = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> memberAsn = new ImmutableLeafNodeBuilder<>();
memberAsn.withNodeIdentifier(NodeNlriParser.MEMBER_ASN_NID);
- memberAsn.withValue(258L);
+ memberAsn.withValue(Uint32.valueOf(258L));
localNodeDescriptors.addChild(bgpRouterId.build());
localNodeDescriptors.addChild(memberAsn.build());
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> ospfNode = Builders.containerBuilder();
ospfNode.withNodeIdentifier(NodeNlriParser.OSPF_NODE_NID);
- final ImmutableLeafNodeBuilder<Long> ospfRouterId = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> ospfRouterId = new ImmutableLeafNodeBuilder<>();
ospfRouterId.withNodeIdentifier(NodeNlriParser.OSPF_ROUTER_NID);
- ospfRouterId.withValue(0x00000040L);
+ ospfRouterId.withValue(Uint32.valueOf(0x00000040L));
ospfNode.addChild(ospfRouterId.build());
crouterId2.addChild(ospfNode.build());
remoteNodeDescriptors.addChild(crouterId2.build());
bgpRouterIdRemote.withValue("1.1.1.2");
remoteNodeDescriptors.addChild(bgpRouterIdRemote.build());
- final ImmutableLeafNodeBuilder<Long> memberAsnRemote = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> memberAsnRemote = new ImmutableLeafNodeBuilder<>();
memberAsnRemote.withNodeIdentifier(NodeNlriParser.MEMBER_ASN_NID);
- memberAsnRemote.withValue(259L);
+ memberAsnRemote.withValue(Uint32.valueOf(259));
remoteNodeDescriptors.addChild(memberAsnRemote.build());
// link descritpors
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> linkDescriptors = Builders.containerBuilder();
linkDescriptors.withNodeIdentifier(LinkstateNlriParser.LINK_DESCRIPTORS_NID);
- final ImmutableLeafNodeBuilder<Long> linkLocalIdentifier = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> linkLocalIdentifier = new ImmutableLeafNodeBuilder<>();
linkLocalIdentifier.withNodeIdentifier(LinkNlriParser.LINK_LOCAL_NID);
- linkLocalIdentifier.withValue(16909060L);
+ linkLocalIdentifier.withValue(Uint32.valueOf(16909060L));
- final ImmutableLeafNodeBuilder<Long> linkRemoteIdentifier = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> linkRemoteIdentifier = new ImmutableLeafNodeBuilder<>();
linkRemoteIdentifier.withNodeIdentifier(LinkNlriParser.LINK_REMOTE_NID);
- linkRemoteIdentifier.withValue(168496141L);
+ linkRemoteIdentifier.withValue(Uint32.valueOf(168496141L));
final ImmutableLeafNodeBuilder<String> ipv4InterfaceAddress = new ImmutableLeafNodeBuilder<>();
ipv4InterfaceAddress.withNodeIdentifier(LinkNlriParser.IPV4_IFACE_NID);
// test BA form
assertNull(this.dest.getRouteDistinguisher());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
- assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
+ assertEquals(Uint64.ONE, this.dest.getIdentifier().getValue());
final PrefixCase pCase = (PrefixCase) this.dest.getObjectType();
protocolId.withValue("isis-level2");
linkstateBI.addChild(protocolId.build());
- final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint64> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
- identifier.withValue(BigInteger.ONE);
+ identifier.withValue(Uint64.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
Builders.containerBuilder();
advertisingNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.ADVERTISING_NODE_DESCRIPTORS_NID);
- final ImmutableLeafNodeBuilder<Long> asNumber = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> asNumber = new ImmutableLeafNodeBuilder<>();
asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
- asNumber.withValue(72L);
+ asNumber.withValue(Uint32.valueOf(72));
advertisingNodeDescriptors.addChild(asNumber.build());
- final ImmutableLeafNodeBuilder<Long> domainID = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint32> domainID = new ImmutableLeafNodeBuilder<>();
domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
- domainID.withValue(673720360L);
+ domainID.withValue(Uint32.valueOf(673720360L));
advertisingNodeDescriptors.addChild(domainID.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
// test BA form
assertNull(this.dest.getRouteDistinguisher());
assertEquals(ProtocolId.RsvpTe, this.dest.getProtocolId());
- assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
+ assertEquals(Uint64.ONE, this.dest.getIdentifier().getValue());
final TeLspCase teCase = (TeLspCase) this.dest.getObjectType();
assertEquals(new LspId(1L), teCase.getLspId());
protocolId.withValue("rsvp-te");
linkstateBI.addChild(protocolId.build());
- final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
+ final ImmutableLeafNodeBuilder<Uint64> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
- identifier.withValue(BigInteger.ONE);
+ identifier.withValue(Uint64.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.Opaque;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
public static boolean serializeOpaque(final Opaque opaque, final ByteBuf byteBuf) {
- final Short type = opaque.getOpaqueType();
- switch (type) {
+ final Uint8 type = opaque.getOpaqueType();
+ switch (type.toJava()) {
case GENERIC_LSP_IDENTIFIER:
ByteBufWriteUtil.writeUnsignedByte(type, byteBuf);
writeGeneric(opaque.getOpaque(), byteBuf);
return true;
}
- private static void writeExtended(final HexString opaque, final Integer opaqueExtendedType, final ByteBuf byteBuf) {
+ private static void writeExtended(final HexString opaque, final Uint16 opaqueExtendedType, final ByteBuf byteBuf) {
final byte[] output = writeOpaqueValue(opaque.getValue());
ByteBufWriteUtil.writeUnsignedShort(opaqueExtendedType, byteBuf);
- ByteBufWriteUtil.writeUnsignedShort(output.length, byteBuf);
+ byteBuf.writeShort(output.length);
byteBuf.writeBytes(output);
}
private static void writeGeneric(final HexString opaque, final ByteBuf byteBuf) {
final byte[] output = writeOpaqueValue(opaque.getValue());
- ByteBufWriteUtil.writeUnsignedShort(output.length, byteBuf);
+ byteBuf.writeShort(output.length);
byteBuf.writeBytes(output);
}
private static void parseMpls(final PmsiTunnelBuilder pmsiTunnelBuilder, final ByteBuf buffer) {
final MplsLabel mpls = MplsLabelUtil.mplsLabelForByteBuf(buffer);
- if (mpls.getValue() != 0) {
+ if (mpls.getValue().toJava() != 0) {
pmsiTunnelBuilder.setMplsLabel(mpls);
}
}
import org.opendaylight.yangtools.yang.binding.BindingObject;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
.setRouteTargetConstrainChoice(extractRouteTargetChoice(rtDest));
final Optional<Object> originAs = NormalizedNodes
.findNode(rtDest, this.originAsNid).map(NormalizedNode::getValue);
- originAs.ifPresent(o -> builder.setOriginAs(new AsNumber((Long) o)));
+ originAs.ifPresent(o -> builder.setOriginAs(new AsNumber((Uint32) o)));
return builder.build();
}
import java.util.regex.Pattern;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetMedType.Enumeration;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
try {
- return new BgpSetMedType(Integer.toUnsignedLong(Integer.parseUnsignedInt(defaultValue)));
- } catch (final NumberFormatException e) {
+ return new BgpSetMedType(Uint32.valueOf(defaultValue));
+ } catch (final IllegalArgumentException e) {
LOG.debug("Could not interpret \"{}\" as an unsinged integer", defaultValue, e);
}
*/
package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
/**
* Customized handler for instantiating {@link BgpStdCommunityType} from a String.
*/
}
try {
- return new BgpStdCommunityType(Integer.toUnsignedLong(Integer.parseUnsignedInt(defaultValue)));
- } catch (final NumberFormatException e) {
+ return new BgpStdCommunityType(Uint32.valueOf(defaultValue));
+ } catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Cannot create BgpStdCommunityType from " + defaultValue, e);
}
}
package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yangtools.yang.common.Uint32;
/**
* Customized handler for instantiating {@link RrClusterIdType} from a String.
}
try {
- return new RrClusterIdType(Integer.toUnsignedLong(Integer.parseUnsignedInt(defaultValue)));
- } catch (final NumberFormatException e) {
+ return new RrClusterIdType(Uint32.valueOf(defaultValue));
+ } catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Cannot create RrClusterIdType from " + defaultValue, e);
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009;
-import com.google.common.primitives.UnsignedInts;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString;
+import org.opendaylight.yangtools.yang.common.Uint32;
/**
* The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
public static TagType getDefaultInstance(final java.lang.String defaultValue) {
try {
- final long parseUnsignedInt = UnsignedInts.parseUnsignedInt(defaultValue);
- return new TagType(parseUnsignedInt);
- } catch (final NumberFormatException e) {
+ return new TagType(Uint32.valueOf(defaultValue));
+ } catch (final IllegalArgumentException e) {
return new TagType(new HexString(defaultValue));
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpSetMedType.Enumeration;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class BgpSetMedTypeBuilderTest {
@Test
public void testString() {
final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("+1");
- Assert.assertEquals("+1", medType.getString());
+ assertEquals("+1", medType.getString());
}
@Test
public void testUint32() {
final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("1");
- Assert.assertEquals(Long.valueOf(1L), medType.getUint32());
+ assertEquals(Uint32.ONE, medType.getUint32());
}
@Test
public void testEnumLowerCase() {
final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("igp");
- Assert.assertEquals(Enumeration.IGP, medType.getEnumeration());
+ assertEquals(Enumeration.IGP, medType.getEnumeration());
}
@Test
public void testEnumFirstUpperCase() {
final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("Igp");
- Assert.assertEquals(Enumeration.IGP, medType.getEnumeration());
+ assertEquals(Enumeration.IGP, medType.getEnumeration());
}
@Test
public void testEnumUpperCase() {
final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("IGP");
- Assert.assertEquals(Enumeration.IGP, medType.getEnumeration());
+ assertEquals(Enumeration.IGP, medType.getEnumeration());
}
@Test(expected=IllegalArgumentException.class)
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
import org.opendaylight.yangtools.concepts.AbstractRegistration;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.common.Uint32;
final class ActionsRegistryImpl {
@GuardedBy("this")
final BgpActions bgpAction = augmentation.getBgpActions();
final SetAsPathPrepend asPrependAction = bgpAction.getSetAsPathPrepend();
- final Long localPrefPrependAction = bgpAction.getSetLocalPref();
+ final Uint32 localPrefPrependAction = bgpAction.getSetLocalPref();
final BgpOriginAttrType localOriginAction = bgpAction.getSetRouteOrigin();
final BgpSetMedType medAction = bgpAction.getSetMed();
final BgpNextHopType nhAction = bgpAction.getSetNextHop();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.EmptyNextHopCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCase;
+import org.opendaylight.yangtools.yang.common.Uint32;
/**
* Bgp Attribute Conditions Util per check conditions matches.
return afiSafiIn == null ? true : afiSafiIn.contains(afiSafi);
}
- private static boolean matchMED(final MultiExitDisc multiExitDisc, final Long med) {
+ private static boolean matchMED(final MultiExitDisc multiExitDisc, final Uint32 med) {
return multiExitDisc == null || med == null || med.equals(multiExitDisc.getMed());
}
}
final Class<? extends AttributeComparison> comp = asPathLength.getOperator();
- final long asLength = asPathLength.getValue();
+ final long asLength = asPathLength.getValue().toJava();
if (comp == AttributeEq.class) {
return total == asLength;
} else if (comp == AttributeGe.class) {
return nextHopIn.contains(global);
}
- private static boolean matchLocalPref(final LocalPref localPref, final Long localPrefEq) {
+ private static boolean matchLocalPref(final LocalPref localPref, final Uint32 localPrefEq) {
return localPref == null || localPrefEq == null || localPrefEq.equals(localPref.getPref());
}
}
import com.google.common.collect.Maps;
import java.io.Serializable;
import java.util.Arrays;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Possible errors from implemented RFCs and drafts. Each error consists of error code and error subcode
this.errorId = new BGPErrorIdentifier(code, subcode);
}
- public static BGPError forValue(final int code, final int subcode) {
- final BGPError e = VALUE_MAP.get(new BGPErrorIdentifier((short) code, (short) subcode));
+ public static BGPError forValue(final Uint8 code, final Uint8 subcode) {
+ final BGPError e = VALUE_MAP.get(new BGPErrorIdentifier(code.toJava(), subcode.toJava()));
checkArgument(e != null, "BGP Error code %s and subcode %s not recognized.", code, subcode);
return e;
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapabilityBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class APITest {
@Test
public void testBGPError() {
- assertEquals(BGPError.BAD_MSG_TYPE, BGPError.forValue(1, 3));
+ assertEquals(BGPError.BAD_MSG_TYPE, BGPError.forValue(Uint8.ONE, Uint8.valueOf(3)));
}
@Test
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Notify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.NotifyBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final Notify ntf = (Notify) msg;
final ByteBuf msgBody = Unpooled.buffer()
- .writeByte(ntf.getErrorCode())
- .writeByte(ntf.getErrorSubcode());
+ .writeByte(ntf.getErrorCode().toJava())
+ .writeByte(ntf.getErrorSubcode().toJava());
final byte[] data = ntf.getData();
if (data != null) {
msgBody.writeBytes(data);
if (body.readableBytes() < ERROR_SIZE) {
throw BGPDocumentedException.badMessageLength("Notification message too small.", messageLength);
}
- final int errorCode = body.readUnsignedByte();
- final int errorSubcode = body.readUnsignedByte();
+ final Uint8 errorCode = Uint8.valueOf(body.readUnsignedByte());
+ final Uint8 errorSubcode = Uint8.valueOf(body.readUnsignedByte());
final NotifyBuilder builder = new NotifyBuilder()
- .setErrorCode((short) errorCode).setErrorSubcode((short) errorSubcode);
+ .setErrorCode(errorCode).setErrorSubcode(errorSubcode);
if (body.isReadable()) {
builder.setData(ByteArray.readAllBytes(body));
}
.writeByte(BGP_VERSION);
// When our AS number does not fit into two bytes, we report it as AS_TRANS
- int openAS = open.getMyAsNumber();
+ int openAS = open.getMyAsNumber().toJava();
if (openAS > Values.UNSIGNED_SHORT_MAX_VALUE) {
openAS = AS_TRANS;
}
msgBody
.writeShort(openAS)
- .writeShort(open.getHoldTimer())
+ .writeShort(open.getHoldTimer().toJava())
.writeBytes(Ipv4Util.bytesForAddress(open.getBgpIdentifier()));
serializeParameters(open.getBgpParameters(), msgBody);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final List<Tables> tables = grace.getTables();
final int tablesSize = tables != null ? tables.size() : 0;
final ByteBuf bytes = Unpooled.buffer(HEADER_SIZE + PER_AFI_SAFI_SIZE * tablesSize);
- int timeval = 0;
- Integer time = grace.getRestartTime();
+ Uint16 time = grace.getRestartTime();
if (time == null) {
- time = 0;
+ time = Uint16.ZERO;
}
- Preconditions.checkArgument(time >= 0 && time <= MAX_RESTART_TIME, "Restart time is " + time);
- timeval = time;
+ final int timeval = time.toJava();
+ Preconditions.checkArgument(timeval >= 0 && timeval <= MAX_RESTART_TIME, "Restart time is " + time);
final GracefulRestartCapability.RestartFlags flags = grace.getRestartFlags();
if (flags != null && flags.isRestartState()) {
writeUnsignedShort(RESTART_FLAG_STATE | timeval, bytes);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
} else {
buffer.writeZero(1);
}
- final Long staleTime = table.getLongLivedStaleTime();
+ final Uint32 staleTime = table.getLongLivedStaleTime();
final int timeval = staleTime != null ? staleTime.intValue() : 0;
checkArgument(timeval >= 0 && timeval <= MAX_STALE_TIME, "Restart time is %s", staleTime);
buffer.writeMedium(timeval);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPref;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPrefBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) {
final LocalPref lp = attribute.getLocalPref();
if (lp != null) {
- final Long pref = lp.getPref();
+ final Uint32 pref = lp.getPref();
if (pref != null) {
AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, Unpooled.copyInt(pref.intValue()),
byteAggregator);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDisc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDiscBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public final class MultiExitDiscriminatorAttributeParser extends AbstractAttributeParser
implements AttributeSerializer {
public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) {
final MultiExitDisc multiExitDisc = attribute.getMultiExitDisc();
if (multiExitDisc != null) {
- final Long med = multiExitDisc.getMed();
+ final Uint32 med = multiExitDisc.getMed();
if (med != null) {
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, Unpooled.copyInt(med.intValue()),
byteAggregator);
if (unrecognizedAttr.isTransitive()) {
flags |= AttributeUtil.TRANSITIVE;
}
- AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType(),
+ AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType().toJava(),
Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
import com.google.common.base.Preconditions;
-import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractTwoOctetAsExtendedCommunity;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.AsSpecificExtendedCommunityCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.AsSpecificExtendedCommunityCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as.specific.extended.community._case.AsSpecificExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as.specific.extended.community._case.AsSpecificExtendedCommunityBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class AsTwoOctetSpecificEcHandler extends AbstractTwoOctetAsExtendedCommunity {
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
throws BGPDocumentedException, BGPParsingException {
final AsSpecificExtendedCommunity asSpecific = new AsSpecificExtendedCommunityBuilder()
- .setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()))
+ .setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(buffer.readUnsignedShort())))
.setLocalAdministrator(ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH))
.build();
return new AsSpecificExtendedCommunityCaseBuilder().setAsSpecificExtendedCommunity(asSpecific).build();
extendedCommunity);
final AsSpecificExtendedCommunity asSpecific = ((AsSpecificExtendedCommunityCase) extendedCommunity)
.getAsSpecificExtendedCommunity();
- ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(asSpecific.getGlobalAdministrator().getValue()),
- byteAggregator);
+ byteAggregator.writeShort(asSpecific.getGlobalAdministrator().getValue().intValue());
byteAggregator.writeBytes(asSpecific.getLocalAdministrator());
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
import com.google.common.base.Preconditions;
-import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractTwoOctetAsExtendedCommunity;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteOriginExtendedCommunityCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteOriginExtendedCommunityCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunityBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public final class RouteOriginAsTwoOctetEcHandler extends AbstractTwoOctetAsExtendedCommunity {
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
throws BGPDocumentedException, BGPParsingException {
final RouteOriginExtendedCommunity targetOrigin = new RouteOriginExtendedCommunityBuilder()
- .setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()))
+ .setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(buffer.readUnsignedShort())))
.setLocalAdministrator(ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH))
.build();
return new RouteOriginExtendedCommunityCaseBuilder().setRouteOriginExtendedCommunity(targetOrigin).build();
extendedCommunity);
final RouteOriginExtendedCommunity routeOrigin
= ((RouteOriginExtendedCommunityCase) extendedCommunity).getRouteOriginExtendedCommunity();
- ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeOrigin.getGlobalAdministrator().getValue()),
- byteAggregator);
+ byteAggregator.writeShort(routeOrigin.getGlobalAdministrator().getValue().intValue());
byteAggregator.writeBytes(routeOrigin.getLocalAdministrator());
}
package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
import com.google.common.base.Preconditions;
-import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractTwoOctetAsExtendedCommunity;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.SourceAsExtendedCommunityCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.SourceAsExtendedCommunityCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.source.as.extended.community._case.SourceAsExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.source.as.extended.community._case.SourceAsExtendedCommunityBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public final class SourceASHandler extends AbstractTwoOctetAsExtendedCommunity {
private static final short SUBTYPE = 9;
@Override
public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
final SourceAsExtendedCommunityBuilder builder = new SourceAsExtendedCommunityBuilder();
- builder.setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()));
+ builder.setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(buffer.readUnsignedShort())));
buffer.skipBytes(AS_LOCAL_ADMIN_LENGTH);
return new SourceAsExtendedCommunityCaseBuilder().setSourceAsExtendedCommunity(builder.build()).build();
}
extendedCommunity);
final SourceAsExtendedCommunity excomm = ((SourceAsExtendedCommunityCase) extendedCommunity)
.getSourceAsExtendedCommunity();
- ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(excomm.getGlobalAdministrator().getValue()), body);
- ByteBufWriteUtil.writeInt(LOCAL_ADMIN, body);
+ body.writeShort(excomm.getGlobalAdministrator().getValue().intValue());
+ body.writeInt(LOCAL_ADMIN);
}
@Override
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
import static org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractTwoOctetAsExtendedCommunity.AS_LOCAL_ADMIN_LENGTH;
-import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.extended.community.grouping.RouteTargetExtendedCommunity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.extended.community.grouping.RouteTargetExtendedCommunityBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
/**
* Route Target Extended Community Parser / Serializer.
public static RouteTargetExtendedCommunity parse(final ByteBuf buffer) {
return new RouteTargetExtendedCommunityBuilder()
- .setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()))
+ .setGlobalAdministrator(new ShortAsNumber(Uint32.valueOf(buffer.readUnsignedShort())))
.setLocalAdministrator(ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH))
.build();
}
public static void serialize(final RouteTargetExtendedCommunity routeTarget, final ByteBuf byteAggregator) {
- ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeTarget.getGlobalAdministrator().getValue()),
- byteAggregator);
+ byteAggregator.writeShort(routeTarget.getGlobalAdministrator().getValue().intValue());
byteAggregator.writeBytes(routeTarget.getLocalAdministrator());
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
+import org.opendaylight.yangtools.yang.common.Uint16;
public class GracefulCapabilityHandlerTest {
capaBuilder.setRestartFlags(null);
tablesBuilder.setAfiFlags(null);
- capaBuilder.setRestartTime(null);
+ capaBuilder.setRestartTime((Uint16) null);
capaBuilder.setTables(Lists.newArrayList(tablesBuilder.build()));
buffer.clear();
handler.serializeCapability(new CParametersBuilder().addAugmentation(CParameters1.class,
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
public final class PathIdUtil {
- public static final long NON_PATH_ID_VALUE = 0;
+ public static final Uint32 NON_PATH_ID_VALUE = Uint32.ZERO;
public static final PathId NON_PATH_ID = new PathId(NON_PATH_ID_VALUE);
private PathIdUtil() {
* @param buffer The ByteBuf where path-id value can be written.
*/
public static void writePathId(final PathId pathId, final ByteBuf buffer) {
- if (pathId != null && pathId.getValue() != 0) {
- ByteBufWriteUtil.writeUnsignedInt(pathId.getValue(), buffer);
+ if (pathId != null) {
+ final Uint32 value = pathId.getValue();
+ if (value.toJava() != 0) {
+ ByteBufWriteUtil.writeUnsignedInt(value, buffer);
+ }
}
}
* @param pathNii Path Id NodeIdentifier specific per each Rib support
* @return The path identifier from data change
*/
- public static Long extractPathId(final NormalizedNode<?, ?> data, final NodeIdentifier pathNii) {
- return (Long) NormalizedNodes.findNode(data, pathNii).map(NormalizedNode::getValue).orElse(null);
+ public static Uint32 extractPathId(final NormalizedNode<?, ?> data, final NodeIdentifier pathNii) {
+ return (Uint32) NormalizedNodes.findNode(data, pathNii).map(NormalizedNode::getValue).orElse(null);
}
/**
*/
public static PathId buildPathId(final DataContainerNode<? extends PathArgument> routesCont,
final NodeIdentifier pathIdNii) {
- final Long pathIdVal = PathIdUtil.extractPathId(routesCont, pathIdNii);
+ final Uint32 pathIdVal = PathIdUtil.extractPathId(routesCont, pathIdNii);
return pathIdVal == null ? null : new PathId(pathIdVal);
}
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeSchemaAwareBuilder;
public void testExtractPathId() {
final NodeIdentifier NII = new NodeIdentifier(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
"2015-03-05", "path-id").intern());
- final long pathIdValue = 0;
final ContainerNode cont = ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(NII).addChild(
- new ImmutableLeafNodeBuilder<>().withNodeIdentifier(NII).withValue(pathIdValue).build()).build();
- Assert.assertEquals(pathIdValue, PathIdUtil.extractPathId(cont, NII).longValue());
+ new ImmutableLeafNodeBuilder<>().withNodeIdentifier(NII).withValue(Uint32.ZERO).build()).build();
+ Assert.assertEquals(0L, PathIdUtil.extractPathId(cont, NII).longValue());
}
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>yang-binding</artifactId>
public static long getPeerAs(final List<Segments> segments) {
for (final Segments seg : segments) {
if (seg.getAsSequence() != null && !seg.getAsSequence().isEmpty()) {
- return segments.get(0).getAsSequence().get(0).getValue();
+ return segments.get(0).getAsSequence().get(0).getValue().toJava();
}
}
return 0;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpOrigin;
+import org.opendaylight.yangtools.yang.common.Uint32;
public interface BestPathState {
- @Nullable Long getLocalPref();
+ @Nullable Uint32 getLocalPref();
long getMultiExitDisc();
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
/**
* A single route entry inside a route table. Maintains the attributes of
* @param remotePathId remote path Id received
* @return return true if it was the last route on entry
*/
- boolean removeRoute(@NonNull RouterId routerId, Long remotePathId);
+ boolean removeRoute(@NonNull RouterId routerId, Uint32 remotePathId);
/**
* Indicates whether best has changed.
* @param route route Data change
* @return returns the offset
*/
- int addRoute(@NonNull RouterId routerId, Long remotePathId, @NonNull R route);
+ int addRoute(@NonNull RouterId routerId, Uint32 remotePathId, @NonNull R route);
/**
* Returns collections of present selected best path.
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.Segments;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpOrigin;
+import org.opendaylight.yangtools.yang.common.Uint32;
public final class BestPathStateImpl implements BestPathState {
private final Attributes attributes;
private long peerAs = 0L;
private int asPathLength = 0;
- private Long localPref;
+ private Uint32 localPref;
private long multiExitDisc;
private BgpOrigin origin;
private boolean depreferenced;
final MultiExitDisc attrMed = attributes.getMultiExitDisc();
if (attrMed != null) {
- final Long med = attrMed.getMed();
- multiExitDisc = med == null ? 0L : med;
+ final Uint32 med = attrMed.getMed();
+ multiExitDisc = med == null ? 0L : med.toJava();
} else {
multiExitDisc = 0L;
}
}
@Override
- public Long getLocalPref() {
+ public Uint32 getLocalPref() {
resolveValues();
return this.localPref;
}
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
private static final Logger LOG = LoggerFactory.getLogger(AddPathAbstractRouteEntry.class);
- private static final Long[] EMPTY_PATHS_ID = new Long[0];
+ private static final Uint32[] EMPTY_PATHS_ID = new Uint32[0];
private static final Route[] EMPTY_VALUES = new Route[0];
private RouteKeyOffsets offsets = RouteKeyOffsets.EMPTY;
private R[] values = (R[]) EMPTY_VALUES;
- private Long[] pathsId = EMPTY_PATHS_ID;
+ private Uint32[] pathsId = EMPTY_PATHS_ID;
private List<AddPathBestPath> bestPath;
private List<AddPathBestPath> bestPathRemoved;
private List<AddPathBestPath> newBestPathToBeAdvertised;
- private List<Long> removedPathsId;
+ private List<Uint32> removedPathsId;
private long pathIdCounter = 0L;
private boolean isNonAddPathBestPathNew;
}
@Override
- public final int addRoute(final RouterId routerId, final Long remotePathId, final R route) {
+ public final int addRoute(final RouterId routerId, final Uint32 remotePathId, final R route) {
final RouteKey key = new RouteKey(routerId, remotePathId);
int offset = this.offsets.offsetOf(key);
if (offset < 0) {
final RouteKeyOffsets newOffsets = this.offsets.with(key);
offset = newOffsets.offsetOf(key);
final R[] newRoute = newOffsets.expand(this.offsets, this.values, offset);
- final Long[] newPathsId = newOffsets.expand(this.offsets, this.pathsId, offset);
+ final Uint32[] newPathsId = newOffsets.expand(this.offsets, this.pathsId, offset);
this.values = newRoute;
this.offsets = newOffsets;
this.pathsId = newPathsId;
- this.offsets.setValue(this.pathsId, offset, ++this.pathIdCounter);
+ this.offsets.setValue(this.pathsId, offset, Uint32.valueOf(++this.pathIdCounter));
}
this.offsets.setValue(this.values, offset, route);
LOG.trace("Added route {} from {}", route, routerId);
}
@Override
- public final boolean removeRoute(final RouterId routerId, final Long remotePathId) {
+ public final boolean removeRoute(final RouterId routerId, final Uint32 remotePathId) {
final RouteKey key = new RouteKey(routerId, remotePathId);
final int offset = this.offsets.offsetOf(key);
- final Long pathId = this.offsets.getValue(this.pathsId, offset);
+ final Uint32 pathId = this.offsets.getValue(this.pathsId, offset);
this.values = this.offsets.removeValue(this.values, offset, (R[]) EMPTY_VALUES);
this.pathsId = this.offsets.removeValue(this.pathsId, offset, EMPTY_PATHS_ID);
this.offsets = this.offsets.without(key);
final String routeKey) {
final List<PathId> stalePaths;
if (bestPathRemoved != null && !bestPathRemoved.isEmpty()) {
- stalePaths = bestPathRemoved.stream().map(AddPathBestPath::getPathId)
+ stalePaths = bestPathRemoved.stream().map(AddPathBestPath::getPathIdLong)
.map(AddPathAbstractRouteEntry::pathIdObj).collect(Collectors.toList());
bestPathRemoved = null;
} else {
protected final void processOffset(final AddPathSelector selector, final int offset) {
final RouteKey key = offsets.getKey(offset);
final R route = offsets.getValue(values, offset);
- final Long pathId = offsets.getValue(pathsId, offset);
+ final Uint32 pathId = offsets.getValue(pathsId, offset);
LOG.trace("Processing router key {} route {}", key, route);
selector.processPath(route.getAttributes(), key, offset, pathId);
}
});
}
- private static PathId pathIdObj(final Long pathId) {
- return pathId == NON_PATH_ID_VALUE ? NON_PATH_ID : new PathId(pathId);
+ private static PathId pathIdObj(final Uint32 pathId) {
+ return NON_PATH_ID_VALUE.equals(pathId) ? NON_PATH_ID : new PathId(pathId);
}
}
import org.opendaylight.protocol.bgp.mode.api.BestPathState;
import org.opendaylight.protocol.bgp.mode.spi.AbstractBestPath;
import org.opendaylight.protocol.bgp.rib.spi.RouterId;
+import org.opendaylight.yangtools.yang.common.Uint32;
public final class AddPathBestPath extends AbstractBestPath {
private final @NonNull RouteKey routeKey;
- private final @NonNull Long pathId;
+ private final @NonNull Uint32 pathId;
private final int offset;
- AddPathBestPath(final @NonNull BestPathState state, final @NonNull RouteKey key, final @NonNull Long pathId,
+ AddPathBestPath(final @NonNull BestPathState state, final @NonNull RouteKey key, final @NonNull Uint32 pathId,
final int offset) {
super(state);
this.routeKey = requireNonNull(key);
@Override
public long getPathId() {
- return this.pathId;
+ // FIXME: this should return int bits...
+ return this.pathId.longValue();
}
/**
*
* @return Path Id as a {@link Long}
*/
- @NonNull Long getPathIdLong() {
+ @NonNull Uint32 getPathIdLong() {
return this.pathId;
}
}
import org.opendaylight.protocol.bgp.mode.spi.AbstractBestPathSelector;
import org.opendaylight.protocol.bgp.rib.spi.RouterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(AddPathSelector.class);
private RouteKey bestRouteKey;
- private Long bestPathId;
+ private Uint32 bestPathId;
private int bestOffset;
public AddPathSelector(final long ourAs) {
super(ourAs);
}
- void processPath(final Attributes attrs, final RouteKey key, final int offsetPosition, final Long pathId) {
+ void processPath(final Attributes attrs, final RouteKey key, final int offsetPosition, final Uint32 pathId) {
// Consider only non-null attributes
if (attrs != null) {
final RouterId routerId = key.getRouterId();
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.protocol.bgp.rib.spi.RouterId;
import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.common.Uint32;
@NonNullByDefault
final class RouteKey implements Comparable<RouteKey>, Immutable {
private final RouterId routerId;
+ // FIXME: consider dropping this down to an int (but then note Compare() needs to treat it as unsigned)
private final long remotePathId;
- RouteKey(final RouterId routerId, final Long remotePathId) {
+ RouteKey(final RouterId routerId, final Uint32 remotePathId) {
this.routerId = requireNonNull(routerId);
- this.remotePathId = remotePathId.longValue();
+ this.remotePathId = remotePathId.toJava();
}
RouterId getRouterId() {
package org.opendaylight.protocol.bgp.mode.impl.base;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VALUE;
import com.google.common.base.MoreObjects.ToStringHelper;
import org.eclipse.jdt.annotation.NonNull;
@Override
public long getPathId() {
- return NON_PATH_ID_VALUE;
+ // PathIdUtil.NON_PATH_ID_VALUE
+ return 0;
}
@Override
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
@Override
- public boolean removeRoute(final RouterId routerId, final Long remotePathId) {
+ public boolean removeRoute(final RouterId routerId, final Uint32 remotePathId) {
final int offset = this.offsets.offsetOf(routerId);
this.values = this.offsets.removeValue(this.values, offset, (R[]) EMPTY_VALUES);
this.offsets = this.offsets.without(routerId);
}
@Override
- public int addRoute(final RouterId routerId, final Long remotePathId, final R route) {
+ public int addRoute(final RouterId routerId, final Uint32 remotePathId, final R route) {
int offset = this.offsets.offsetOf(routerId);
if (offset < 0) {
final RouterIdOffsets newOffsets = this.offsets.with(routerId);
import org.opendaylight.protocol.bgp.rib.spi.RouterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.OriginatorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpOrigin;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class AbstractBestPathSelector {
private final long ourAs;
* FIXME: for eBGP cases (when the LOCAL_PREF is missing), we should assign a policy-based preference
* before we ever get here.
*/
- final Long bestLocal = this.bestState.getLocalPref();
- final Long stateLocal = state.getLocalPref();
+ final Uint32 bestLocal = this.bestState.getLocalPref();
+ final Uint32 stateLocal = state.getLocalPref();
if (stateLocal != null) {
if (bestLocal == null) {
return true;
}
- final Boolean bool = firstLower(stateLocal, bestLocal);
- if (bool != null) {
- return bool;
+ final int cmp = stateLocal.compareTo(bestLocal);
+ if (cmp != 0) {
+ return cmp < 0;
}
} else if (bestLocal != null) {
return false;
@Test
public void testGetPathId() {
- assertEquals(NON_PATH_ID_VALUE, this.baseBestPath.getPathId());
+ assertEquals(NON_PATH_ID_VALUE.toJava(), this.baseBestPath.getPathId());
}
@Test
this.bgpDispatcher = requireNonNull(bgpDispatcher);
this.address = getAddress(requireNonNull(bindingAddress), requireNonNull(portNumber));
if (!PlatformDependent.isWindows() && !PlatformDependent.maybeSuperUser()
- && portNumber.getValue() < PRIVILEGED_PORTS) {
+ && portNumber.getValue().toJava() < PRIVILEGED_PORTS) {
throw new AccessControlException("Unable to bind port " + portNumber.getValue()
+ " while running as non-root user.");
}
} catch (final UnknownHostException e) {
throw new IllegalArgumentException("Illegal binding address " + ipAddress, e);
}
- return new InetSocketAddress(inetAddr, portNumber.getValue());
+ return new InetSocketAddress(inetAddr, portNumber.getValue().toJava());
}
/**
final DOMDataTreeWriteTransaction tx, final Builder<TablesKey, TableContext> tb) {
// We will use table keys very often, make sure they are optimized
final InstanceIdentifierBuilder idb = YangInstanceIdentifier.builder(newPeerPath
- .node(EMPTY_ADJRIBIN.getIdentifier()).node(TABLES_NID));
- idb.nodeWithKey(instanceIdentifierKey.getNodeType(), instanceIdentifierKey.getKeyValues());
+ .node(EMPTY_ADJRIBIN.getIdentifier()).node(TABLES_NID)).node(instanceIdentifierKey);
final TableContext ctx = new TableContext(rs, idb.build());
ctx.createEmptyTableStructure(tx);
final NodeIdentifierWithPredicates supTablesKey = RibSupportUtils.toYangKey(SupportedTables.QNAME, tableKey);
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tt =
Builders.mapEntryBuilder().withNodeIdentifier(supTablesKey);
- for (final Entry<QName, Object> e : supTablesKey.getKeyValues().entrySet()) {
+ for (final Entry<QName, Object> e : supTablesKey.entrySet()) {
tt.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
if (sendReceive != null) {
setAdvertizedGracefulRestartTableTypes(advertisedTables.stream()
.map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toList()));
}
- setAfiSafiGracefulRestartState(advertisedGracefulRestartCapability.getRestartTime(), false, restartingLocally);
+ setAfiSafiGracefulRestartState(advertisedGracefulRestartCapability.getRestartTime().toJava(), false,
+ restartingLocally);
final Map<TablesKey, Integer> llTablesReceived;
if (advertisedLLTables != null) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.limiter = new ChannelOutputLimiter(this);
this.channel.pipeline().addLast(this.limiter);
- final int holdTimerValue = remoteOpen.getHoldTimer() < localHoldTimer ? remoteOpen.getHoldTimer()
- : localHoldTimer;
+ final int remoteHoldTimer = remoteOpen.getHoldTimer().toJava();
+ final int holdTimerValue = Math.min(remoteHoldTimer, localHoldTimer);
LOG.info("BGP HoldTimer new value: {}", holdTimerValue);
this.holdTimerNanos = TimeUnit.SECONDS.toNanos(holdTimerValue);
this.keepAliveNanos = TimeUnit.SECONDS.toNanos(holdTimerValue / KA_TO_DEADTIMER_RATIO);
}
@Holding("this")
- private void notifyTerminationReasonAndCloseWithoutMessage(final Short errorCode, final Short errorSubcode) {
+ private void notifyTerminationReasonAndCloseWithoutMessage(final BGPError error) {
+ this.terminationReasonNotified = true;
+ this.closeWithoutMessage();
+ this.listener.onSessionTerminated(this, new BGPTerminationReason(error));
+ }
+
+ @Holding("this")
+ private void notifyTerminationReasonAndCloseWithoutMessage(final Uint8 errorCode, final Uint8 errorSubcode) {
this.terminationReasonNotified = true;
this.closeWithoutMessage();
this.listener.onSessionTerminated(this, new BGPTerminationReason(BGPError.forValue(errorCode, errorSubcode)));
builder.setData(data);
}
writeAndFlush(builder.build());
- notifyTerminationReasonAndCloseWithoutMessage(error.getCode(), error.getSubcode());
+ notifyTerminationReasonAndCloseWithoutMessage(error);
}
private void removePeerSession() {
@Override
public ListenableFuture<RpcResult<RestartGracefullyOutput>> restartGracefully(final RestartGracefullyInput input) {
final SettableFuture<RpcResult<RestartGracefullyOutput>> ret = SettableFuture.create();
- Futures.addCallback(peerRPCs.restartGracefully(input.getSelectionDeferralTime()), new FutureCallback<Object>() {
- @Override
- public void onSuccess(final Object result) {
- ret.set(RpcResultBuilder.success(new RestartGracefullyOutputBuilder().build()).build());
- }
+ Futures.addCallback(peerRPCs.restartGracefully(input.getSelectionDeferralTime().toJava()),
+ new FutureCallback<Object>() {
+ @Override
+ public void onSuccess(final Object result) {
+ ret.set(RpcResultBuilder.success(new RestartGracefullyOutputBuilder().build()).build());
+ }
- @Override
- public void onFailure(final Throwable throwable) {
- LOG.error("Failed to perform graceful restart", throwable);
- ret.set(RpcResultBuilder.<RestartGracefullyOutput>failed()
- .withError(ErrorType.RPC, throwable.getMessage()).build());
- }
- }, MoreExecutors.directExecutor());
+ @Override
+ public void onFailure(final Throwable throwable) {
+ LOG.error("Failed to perform graceful restart", throwable);
+ ret.set(RpcResultBuilder.<RestartGracefullyOutput>failed()
+ .withError(ErrorType.RPC, throwable.getMessage()).build());
+ }
+ }, MoreExecutors.directExecutor());
return ret;
}
import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private LocRibWriter(final RIBSupport<C, S, R, I> ribSupport,
final TransactionChain chain,
final KeyedInstanceIdentifier<Rib, RibKey> ribIId,
- final Long ourAs,
+ final Uint32 ourAs,
final DataBroker dataBroker,
final BGPRibRoutingPolicy ribPolicies,
final BGPPeerTracker peerTracker,
this.ribIId = requireNonNull(ribIId);
this.ribSupport = requireNonNull(ribSupport);
this.locRibTableIID = ribIId.child(LocRib.class).child(Tables.class, ribSupport.getTablesKey());
- this.ourAs = ourAs;
+ this.ourAs = ourAs.toJava();
this.dataBroker = requireNonNull(dataBroker);
this.peerTracker = peerTracker;
this.pathSelectionMode = pathSelectionMode;
}
boolean hasHigherAsNumber(final BGPSessionId other) {
- return this.asNumber.getValue() > other.asNumber.getValue();
+ return this.asNumber.getValue().compareTo(other.asNumber.getValue()) > 0;
}
private static long toLong(final Ipv4Address from) {
this.bgpIid = bgpIid;
final String ribInstanceName = getRibInstanceName(bgpIid);
this.serviceGroupIdentifier = ServiceGroupIdentifier.create(ribInstanceName + "-service-group");
- LOG.info("BGPClusterSingletonService {} registered", this.serviceGroupIdentifier.getValue());
+ LOG.info("BGPClusterSingletonService {} registered", this.serviceGroupIdentifier.getName());
ClusterSingletonServiceRegistrationHelper
.registerSingletonService(provider, this);
}
this.peers.values().forEach(PeerBean::instantiateServiceInstance);
}
this.instantiated.set(true);
- LOG.info("BGPClusterSingletonService {} instantiated", this.serviceGroupIdentifier.getValue());
+ LOG.info("BGPClusterSingletonService {} instantiated", this.serviceGroupIdentifier.getName());
}
@Override
public synchronized ListenableFuture<? extends CommitInfo> closeServiceInstance() {
- LOG.info("BGPClusterSingletonService {} close service instance", this.serviceGroupIdentifier.getValue());
+ LOG.info("BGPClusterSingletonService {} close service instance", this.serviceGroupIdentifier.getName());
this.instantiated.set(false);
final List<ListenableFuture<? extends CommitInfo>> futurePeerCloseList = this.peers.values().stream()
@Override
public void close() {
- LOG.info("BGPClusterSingletonService {} close", this.serviceGroupIdentifier.getValue());
+ LOG.info("BGPClusterSingletonService {} close", this.serviceGroupIdentifier.getName());
this.peers.values().iterator().forEachRemaining(PeerBean::close);
this.ribImpl.close();
this.peers.clear();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.Tables.AfiFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
.rev181112.afi.safi.ll.graceful.restart.ll.graceful.restart.Config config =
llGracefulRestart.getConfig();
if (config != null) {
- final Long staleTime = config.getLongLivedStaleTime();
- if (staleTime != null && staleTime > 0) {
+ final Uint32 staleTime = config.getLongLivedStaleTime();
+ if (staleTime != null && staleTime.toJava() > 0) {
final Optional<TablesKey> key = tableTypeRegistry.getTableKey(afiSafi.getAfiSafiName());
if (key.isPresent()) {
timers.put(key.get(), staleTime.intValue());
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ClusterIdentifier;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint16;
final class OpenConfigMappingUtil {
final boolean anyMatch = afiSafi.stream()
.anyMatch(input -> input.getAfiSafiName().equals(IPV4UNICAST.class));
if (!anyMatch) {
- afiSafi.add(IPV4_AFISAFI);
+ final List<AfiSafi> newAfiSafi = new ArrayList<>(afiSafi.size() + 1);
+ newAfiSafi.addAll(afiSafi);
+ newAfiSafi.add(IPV4_AFISAFI);
+ return newAfiSafi;
}
}
return afiSafi;
if (afiSafi2 != null) {
final Optional<BgpTableType> bgpTableType = tableTypeRegistry.getTableType(afiSafi.getAfiSafiName());
if (bgpTableType.isPresent()) {
- final int sendMax = afiSafi2.getSendMax();
+ final short sendMax = afiSafi2.getSendMax().toJava();
final PathSelectionMode selectionMode;
if (sendMax > 1) {
selectionMode = new AddPathBestNPathSelection(sendMax);
}
static int getGracefulRestartTimer(final Neighbor neighbor, final PeerGroup peerGroup, final int holdTimer) {
- Integer timer = null;
+ Uint16 timer = null;
if (peerGroup != null) {
timer = getGracefulRestartTimer(peerGroup.getGracefulRestart());
}
* RFC4724: "A suggested default for the Restart Time is a value less than or
* equal to the HOLDTIME carried in the OPEN."
*/
- if (timer == null) {
- timer = holdTimer;
- }
-
- return timer;
+ return timer == null ? holdTimer : timer.toJava();
}
- private static @Nullable Integer getGracefulRestartTimer(final GracefulRestart gracefulRestart) {
+ private static @Nullable Uint16 getGracefulRestartTimer(final GracefulRestart gracefulRestart) {
if (gracefulRestart != null) {
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.graceful
.restart.Config config = gracefulRestart.getConfig();
.collect(Collectors.toMap(entry ->
new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue));
- final BGPRibRoutingPolicy ribPolicy = this.policyProvider.buildBGPRibPolicy(this.asNumber.getValue(),
+ final BGPRibRoutingPolicy ribPolicy = this.policyProvider.buildBGPRibPolicy(this.asNumber.getValue().toJava(),
this.routerId, this.clusterId, RoutingPolicyUtil.getApplyPolicy(global.getApplyPolicy()));
final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(codecTreeFactory,
this.extensions.getClassLoadingStrategy());
doReturn(futureChannel).when(this.speakerListener).close();
this.listener = new SimpleSessionListener();
this.bgpSession = new BGPSessionImpl(this.listener, this.speakerListener, this.classicOpen,
- this.classicOpen.getHoldTimer(), null);
+ this.classicOpen.getHoldTimer().toJava(), null);
this.bgpSession.setChannelExtMsgCoder(this.classicOpen);
}
doThrow(mockedEx).when(mockListener).onSessionUp(any());
doNothing().when(mockListener).onSessionTerminated(any(), any());
this.bgpSession = spy(new BGPSessionImpl(mockListener, this.speakerListener, this.classicOpen,
- this.classicOpen.getHoldTimer(), null));
+ this.classicOpen.getHoldTimer().toJava(), null));
this.bgpSession.setChannelExtMsgCoder(this.classicOpen);
verify(this.bgpSession, never()).handleException(any());
ribImpl, null, PeerRole.Ibgp, this.serverRegistry, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
bgpPeer.instantiateServiceInstance();
final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen,
- this.classicOpen.getHoldTimer(), null);
+ this.classicOpen.getHoldTimer().toJava(), null);
bgpSession.setChannelExtMsgCoder(this.classicOpen);
bgpPeer.onSessionUp(bgpSession);
ribImpl, null, PeerRole.Ibgp, this.serverRegistry, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
bgpPeer.instantiateServiceInstance();
final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen,
- this.classicOpen.getHoldTimer(), null);
+ this.classicOpen.getHoldTimer().toJava(), null);
bgpSession.setChannelExtMsgCoder(this.classicOpen);
bgpPeer.onSessionUp(bgpSession);
assertTrue(OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafi, false).isEmpty());
assertEquals(afiSafiIpv6, OpenConfigMappingUtil.getAfiSafiWithDefault(new AfiSafisBuilder()
.setAfiSafi(afiSafiIpv6List).build(), false).get(0));
- assertEquals(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build(),
- OpenConfigMappingUtil.getAfiSafiWithDefault(new AfiSafisBuilder().setAfiSafi(afiSafiIpv6List).build(),
- false).get(1));
assertEquals(AFI_SAFI, OpenConfigMappingUtil.getAfiSafiWithDefault(createAfiSafi(), false));
}
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.IpBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.UnnumberedBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final TerminationPoint tp;
- private TpHolder(final TerminationPoint tp) {
+ TpHolder(final TerminationPoint tp) {
this.tp = requireNonNull(tp);
}
- private synchronized void addLink(final LinkId id, final boolean isRemote) {
+ synchronized void addLink(final LinkId id, final boolean isRemote) {
if (isRemote) {
this.remote.add(id);
} else {
}
}
- private synchronized boolean removeLink(final LinkId id, final boolean isRemote) {
+ synchronized boolean removeLink(final LinkId id, final boolean isRemote) {
final boolean removed;
if (isRemote) {
removed = this.remote.remove(id);
return this.local.isEmpty() && this.remote.isEmpty();
}
- private TerminationPoint getTp() {
+ TerminationPoint getTp() {
return this.tp;
}
}
private IgpNodeAttributesBuilder inab;
private NodeBuilder nb;
- private NodeHolder(final NodeId id) {
+ NodeHolder(final NodeId id) {
this.inab = new IgpNodeAttributesBuilder();
this.nb = new NodeBuilder().withKey(new NodeKey(id)).setNodeId(id);
}
* @param trans data modification transaction which to use
* @return True if the node has been purged, false otherwise.
*/
- private boolean syncState(final WriteTransaction trans) {
+ boolean syncState(final WriteTransaction trans) {
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(this.nb.key());
/*
return false;
}
- private boolean checkForRemoval(final WriteTransaction trans) {
+ boolean checkForRemoval(final WriteTransaction trans) {
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(this.nb.key());
if (!this.advertized) {
return false;
}
- private synchronized void removeTp(final TpId tp, final LinkId link, final boolean isRemote) {
+ synchronized void removeTp(final TpId tp, final LinkId link, final boolean isRemote) {
final TpHolder h = this.tps.get(tp);
if (h != null) {
if (h.removeLink(link, isRemote)) {
}
}
- private void addTp(final TerminationPoint tp, final LinkId link, final boolean isRemote) {
+ void addTp(final TerminationPoint tp, final LinkId link, final boolean isRemote) {
final TpHolder h = this.tps.computeIfAbsent(tp.getTpId(), k -> new TpHolder(tp));
h.addLink(link, isRemote);
}
- private void addPrefix(final Prefix pfx) {
+ void addPrefix(final Prefix pfx) {
this.prefixes.put(pfx.key(), pfx);
}
- private void removePrefix(final PrefixCase prefixCase) {
+ void removePrefix(final PrefixCase prefixCase) {
this.prefixes.remove(new PrefixKey(prefixCase.getPrefixDescriptors().getIpReachabilityInformation()));
}
- private void unadvertized() {
+ void unadvertized() {
this.inab = new IgpNodeAttributesBuilder();
this.nb = new NodeBuilder().withKey(this.nb.key()).setNodeId(this.nb.getNodeId());
this.advertized = false;
LOG.debug("Node {} is unadvertized", this.nb.getNodeId());
}
- private void advertized(final NodeBuilder nodeBuilder, final IgpNodeAttributesBuilder igpNodeAttBuilder) {
+ void advertized(final NodeBuilder nodeBuilder, final IgpNodeAttributesBuilder igpNodeAttBuilder) {
this.nb = requireNonNull(nodeBuilder);
this.inab = requireNonNull(igpNodeAttBuilder);
this.advertized = true;
LOG.debug("Node {} is advertized", nodeBuilder.getNodeId());
}
- private NodeId getNodeId() {
+ NodeId getNodeId() {
return this.nb.getNodeId();
}
}
private static TpId buildTpId(final UriBuilder base, final TopologyIdentifier topologyIdentifier,
final Ipv4InterfaceIdentifier ipv4InterfaceIdentifier,
- final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Long id) {
+ final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Uint32 id) {
final UriBuilder b = new UriBuilder(base, "tp");
if (topologyIdentifier != null) {
b.add("mt", topologyIdentifier.getValue());
}
private static TerminationPointType getTpType(final Ipv4InterfaceIdentifier ipv4InterfaceIdentifier,
- final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Long id) {
+ final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Uint32 id) {
// Order of preference: Unnumbered first, then IP
if (id != null) {
LOG.debug("Unnumbered termination point type: {}", id);
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.router.type.PseudonodeBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.prefix.attributes.OspfPrefixAttributesBuilder;
import org.opendaylight.yangtools.yang.common.Empty;
+import org.opendaylight.yangtools.yang.common.Uint8;
public final class ProtocolUtil {
private ProtocolUtil() {
.collect(Collectors.toList());
}
- private static List<Short> nodeMultiTopology(final List<TopologyIdentifier> list) {
- final List<Short> ret = new ArrayList<>(list.size());
+ private static List<Uint8> nodeMultiTopology(final List<TopologyIdentifier> list) {
+ final List<Uint8> ret = new ArrayList<>(list.size());
for (final TopologyIdentifier id : list) {
- ret.add(id.getValue().shortValue());
+ ret.add(Uint8.valueOf(id.getValue()));
}
return ret;
}
package org.opendaylight.bgpcep.bgp.topology.provider;
import com.google.common.io.BaseEncoding;
-import com.google.common.primitives.UnsignedBytes;
import java.util.Arrays;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.IsisAreaIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.NodeIdentifier;
if (routerIdentifier instanceof IsisPseudonodeCase) {
final IsisPseudonode r = ((IsisPseudonodeCase) routerIdentifier).getIsisPseudonode();
return isoId(r.getIsIsRouterIdentifier().getIsoSystemId().getValue()) + '.'
- + BaseEncoding.base16().encode(new byte[] { UnsignedBytes.checkedCast(r.getPsn()) });
+ + BaseEncoding.base16().encode(new byte[] { r.getPsn().byteValue() });
}
if (routerIdentifier instanceof OspfNodeCase) {
return ((OspfNodeCase) routerIdentifier).getOspfNode().getOspfRouterId().toString();
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>4.0.6</version>
+ <version>5.0.2</version>
<relativePath/>
</parent>
bmpDeployerDependencies.getExtensions(), bmpDeployerDependencies.getTree());
LOG.info("BMP Monitor Singleton Service {} registered, Monitor Id {}",
- getIdentifier().getValue(), this.monitorId.getValue());
+ getIdentifier().getName(), this.monitorId.getValue());
this.singletonServiceRegistration = bmpDeployerDependencies.getClusterSingletonProvider()
.registerClusterSingletonService(this);
}
@Override
public synchronized void instantiateServiceInstance() {
LOG.info("BMP Monitor Singleton Service {} instantiated, Monitor Id {}",
- getIdentifier().getValue(), this.monitorId.getValue());
+ getIdentifier().getName(), this.monitorId.getValue());
final ChannelFuture channelFuture = this.dispatcher.createServer(this.address, this.sessionManager,
constructKeys(this.monitoredRouters));
@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
LOG.info("BMP Monitor Singleton Service {} instance closed, Monitor Id {}",
- getIdentifier().getValue(), this.monitorId.getValue());
+ getIdentifier().getName(), this.monitorId.getValue());
if (this.channel != null) {
this.channel.close().addListener((ChannelFutureListener) future -> {
Preconditions.checkArgument(future.isSuccess(),
}
final InstanceIdentifierBuilder idb = YangInstanceIdentifier.builder(yangTableRootIId);
final NodeIdentifierWithPredicates key = TablesUtil.toYangTablesKey(k);
- idb.nodeWithKey(key.getNodeType(), key.getKeyValues());
+ idb.nodeWithKey(key.getNodeType(), key.asMap());
final TableContext ctx = new TableContext(rs, idb.build(), tree);
ctx.createTable(tx);
// tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
final NodeIdentifierWithPredicates tableKey =
(NodeIdentifierWithPredicates) this.tableId.getLastPathArgument();
- for (final Map.Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
+ for (final Map.Entry<QName, Object> e : tableKey.entrySet()) {
tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
<groupId>${project.groupId}</groupId>
<artifactId>util</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc6991-ietf-inet-types</artifactId>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>4.0.6</version>
+ <version>5.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc6991-ietf-inet-types</artifactId>
@Override
public void addTlv(final ErrorObjectBuilder builder, final Tlv tlv) {
- if (tlv instanceof ReqMissing && builder.getType() == PCEPErrors.SYNC_PATH_COMP_REQ_MISSING.getErrorType()) {
+ if (tlv instanceof ReqMissing
+ && builder.getType().toJava() == PCEPErrors.SYNC_PATH_COMP_REQ_MISSING.getErrorType()) {
builder.setTlvs(new TlvsBuilder().setReqMissing((ReqMissing) tlv).build());
}
}
}
@Override
- protected final void addVendorInformationTlvs(
+ protected void addVendorInformationTlvs(
final ErrorObjectBuilder builder,
final List<VendorInformationTlv> tlvs) {
if (!tlvs.isEmpty()) {
@Override
public void addTlv(final CNotificationBuilder builder, final Tlv tlv) {
- if (tlv instanceof OverloadDuration && builder.getType() == 2 && builder.getValue() == 1) {
+ if (tlv instanceof OverloadDuration && builder.getType().toJava() == 2 && builder.getValue().toJava() == 1) {
builder.setTlvs(new TlvsBuilder().setOverloadDuration((OverloadDuration) tlv).build());
}
}
}
@Override
- protected final void addVendorInformationTlvs(
+ protected void addVendorInformationTlvs(
final CNotificationBuilder builder,
final List<VendorInformationTlv> tlvs) {
if (!tlvs.isEmpty()) {
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
import com.google.common.base.Preconditions;
-import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.List;
flags.set(E_FLAG_OFFSET, rpObj.isEroCompression());
final byte[] res = flags.array();
if (rpObj.getPriority() != null) {
- final byte p = UnsignedBytes.checkedCast(rpObj.getPriority());
+ final byte p = rpObj.getPriority().byteValue();
res[res.length - 1] = (byte) (res[res.length - 1] | p);
}
body.writeBytes(res);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.SrlgCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.SrlgCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Parser for {@link SrlgCase}
Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
writeUnsignedInt(specObj.getSrlgId().getValue(), body);
Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
- writeUnsignedByte(null, body);
+ writeUnsignedByte((Uint8) null, body);
writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class PathSetupTypeTlvParser implements TlvParser, TlvSerializer {
private static final short RSVP_TE_PST = 0;
private static final String UNSUPPORTED_PST = "Unsupported path setup type.";
- private static final Set<Short> PSTS = new HashSet<>();
+ private static final Set<Uint8> PSTS = new HashSet<>();
public PathSetupTypeTlvParser() {
- PSTS.add(RSVP_TE_PST);
+ PSTS.add(Uint8.valueOf(RSVP_TE_PST));
}
public PathSetupTypeTlvParser(final short srTePst) {
this();
- PSTS.add(srTePst);
+ PSTS.add(Uint8.valueOf(srTePst));
}
@Override
if (buffer == null) {
return null;
}
- final short pst = buffer.readerIndex(OFFSET).readUnsignedByte();
+ final Uint8 pst = Uint8.valueOf(buffer.readerIndex(OFFSET).readUnsignedByte());
if (!checkPST(pst)) {
throw new PCEPDeserializerException(UNSUPPORTED_PST);
}
return new PathSetupTypeBuilder().setPst(pst).build();
}
- private static boolean checkPST(final Short pst) {
+ private static boolean checkPST(final Uint8 pst) {
return pst != null && PSTS.contains(pst);
}
}
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Map;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.path.binding.tlv.path.binding.binding.type.value.MplsLabelEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.path.binding.tlv.path.binding.binding.type.value.MplsLabelEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
-import org.opendaylight.yangtools.concepts.Codec;
+import org.opendaylight.yangtools.concepts.IllegalArgumentCodec;
/**
* Parser for {@link PathBinding}.
final MplsLabelEntry mplsEntry = (MplsLabelEntry) bindingValue;
final ByteBuf value = Unpooled.buffer(MPLS_ENTRY_LENGTH);
final long entry = getMplsStackEntry(mplsEntry.getLabel())
- | mplsEntry.getTrafficClass() << TC_SHIFT
+ | mplsEntry.getTrafficClass().toJava() << TC_SHIFT
| (mplsEntry.isBottomOfStack() ? 1 : 0) << S_SHIFT
- | mplsEntry.getTimeToLive();
+ | mplsEntry.getTimeToLive().toJava();
ByteBufWriteUtil.writeUnsignedInt(entry, value);
return value;
}
}
}
- private interface PathBindingTlvCodec extends Codec<ByteBuf, BindingTypeValue> {
+ private interface PathBindingTlvCodec extends IllegalArgumentCodec<ByteBuf, BindingTypeValue> {
int getBindingType();
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel
getMplsLabel(final long mplsStackEntry) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125
.MplsLabel(mplsStackEntry >> LABEL_SHIFT & LABEL_MASK);
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static long getMplsStackEntry(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network
.concepts.rev131125.MplsLabel mplsLabel) {
- return mplsLabel.getValue() << LABEL_SHIFT;
+ return mplsLabel.getValue().toJava() << LABEL_SHIFT;
}
-
}
final Lsp lsp = (Lsp) object;
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp
.object.lsp.Tlvs tlvs = lsp.getTlvs();
- if (!lspViaSR && lsp.getPlspId().getValue() != 0 && (tlvs == null || tlvs.getLspIdentifiers() == null)) {
+ if (!lspViaSR && lsp.getPlspId().getValue().toJava() != 0
+ && (tlvs == null || tlvs.getLspIdentifiers() == null)) {
final Message errorMsg = createErrorMsg(PCEPErrors.LSP_IDENTIFIERS_TLV_MISSING, Optional.empty());
errors.add(errorMsg);
return false;
this.tlsConfiguration = tlsConfiguration;
}
- public DefaultPCEPSessionNegotiatorFactory(final PCEPSessionProposalFactory spf, final PcepDispatcherConfig config) {
- this(spf, config.getMaxUnknownMessages(), config.getTls());
+ public DefaultPCEPSessionNegotiatorFactory(final PCEPSessionProposalFactory spf,
+ final PcepDispatcherConfig config) {
+ this(spf, config.getMaxUnknownMessages().toJava(), config.getTls());
}
@Override
*/
close();
this.listener.onSessionTerminated(this, new PCEPCloseTermination(TerminationReason
- .forValue(((CloseMessage) msg).getCCloseMessage().getCClose().getReason())));
+ .forValue(((CloseMessage) msg).getCCloseMessage().getCClose().getReason().toJava())));
} else {
// This message needs to be handled by the user
if (msg instanceof PcerrMessage) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors;
import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class FiniteStateMachineTest extends AbstractPCEPSessionTest {
for (final Notification m : this.msgsSend) {
if (m instanceof Pcerr) {
final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
- assertEquals(new Short((short) 1), obj.getErrorObject().getType());
- assertEquals(new Short((short) 1), obj.getErrorObject().getValue());
+ assertEquals(Uint8.ONE, obj.getErrorObject().getType());
+ assertEquals(Uint8.ONE, obj.getErrorObject().getValue());
}
}
});
for (final Notification m : this.msgsSend) {
if (m instanceof Pcerr) {
final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
- assertEquals(new Short((short) 1), obj.getErrorObject().getType());
- assertEquals(new Short((short) 7), obj.getErrorObject().getValue());
+ assertEquals(Uint8.ONE, obj.getErrorObject().getType());
+ assertEquals(Uint8.valueOf(7), obj.getErrorObject().getValue());
}
}
});
for (final Notification m : this.msgsSend) {
if (m instanceof Pcerr) {
final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
- assertEquals(new Short((short) 1), obj.getErrorObject().getType());
- assertEquals(new Short((short) 2), obj.getErrorObject().getValue());
+ assertEquals(Uint8.ONE, obj.getErrorObject().getType());
+ assertEquals(Uint8.valueOf(2), obj.getErrorObject().getValue());
}
}
});
Assert.assertTrue(this.msgsSend.get(0) instanceof Pcerr);
final Pcerr pcErr = (Pcerr) this.msgsSend.get(0);
final ErrorObject errorObj = pcErr.getPcerrMessage().getErrors().get(0).getErrorObject();
- Assert.assertEquals(PCEPErrors.CAPABILITY_NOT_SUPPORTED, PCEPErrors.forValue(errorObj.getType(), errorObj.getValue()));
+ Assert.assertEquals(PCEPErrors.CAPABILITY_NOT_SUPPORTED, PCEPErrors.forValue(errorObj.getType(),
+ errorObj.getValue()));
Assert.assertEquals(1, this.session.getMessages().getUnknownMsgReceived().intValue());
// exceeded max. unknown messages count - terminate session
Assert.assertTrue(this.msgsSend.get(1) instanceof CloseMessage);
final CloseMessage closeMsg = (CloseMessage) this.msgsSend.get(1);
- Assert.assertEquals(TerminationReason.TOO_MANY_UNKNOWN_MSGS, TerminationReason.forValue(closeMsg.getCCloseMessage().getCClose().getReason()));
+ Assert.assertEquals(TerminationReason.TOO_MANY_UNKNOWN_MSGS,
+ TerminationReason.forValue(closeMsg.getCCloseMessage().getCClose().getReason().toJava()));
Mockito.verify(this.channel, Mockito.times(1)).close();
}
Assert.assertEquals(1, this.msgsSend.size());
Assert.assertTrue(this.msgsSend.get(0) instanceof CloseMessage);
final CloseMessage closeMsg = (CloseMessage) this.msgsSend.get(0);
- Assert.assertEquals(TerminationReason.UNKNOWN, TerminationReason.forValue(closeMsg.getCCloseMessage().getCClose().getReason()));
+ Assert.assertEquals(TerminationReason.UNKNOWN,
+ TerminationReason.forValue(closeMsg.getCCloseMessage().getCClose().getReason().toJava()));
Mockito.verify(this.channel, Mockito.times(1)).close();
}
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc6991-ietf-inet-types</artifactId>
import ch.qos.logback.classic.LoggerContext;
import com.google.common.base.Preconditions;
import com.google.common.net.InetAddresses;
-import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Collections;
import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static boolean includeDbv = Boolean.FALSE;
private static boolean incrementalSync = Boolean.FALSE;
private static boolean triggeredResync = Boolean.FALSE;
- private static BigInteger syncOptDBVersion;
+ private static Uint64 syncOptDBVersion;
private static int reconnectAfterXSeconds;
private static int disonnectAfterXSeconds;
final Long dbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
disonnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
reconnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
- syncOptDBVersion = BigInteger.valueOf(dbVersionAfterReconnect);
+ syncOptDBVersion = Uint64.valueOf(dbVersionAfterReconnect);
break;
case "--incremental-sync-procedure":
//TODO Check that DBv > Lsp always ??
final Long initialDbVersionAfterReconnect = Long.valueOf(args[++argIdx]);
disonnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
reconnectAfterXSeconds = Integer.parseInt(args[++argIdx]);
- syncOptDBVersion = BigInteger.valueOf(initialDbVersionAfterReconnect);
+ syncOptDBVersion = Uint64.valueOf(initialDbVersionAfterReconnect);
break;
case "--triggered-initial-sync":
triggeredInitSync = Boolean.TRUE;
+ "reconnectes requires to be higher than lsps");
}
- final Optional<BigInteger> dBVersion = Optional.ofNullable(syncOptDBVersion);
+ final Optional<Uint64> dBVersion = Optional.ofNullable(syncOptDBVersion);
final PCCsBuilder pccs = new PCCsBuilder(lsps, pcError, pccCount, localAddress, remoteAddress, ka, dt,
password, reconnectTime, redelegationTimeout,
stateTimeout, getCapabilities());
final TimerHandler timerHandler = new TimerHandler(pccs, dBVersion, disonnectAfterXSeconds,
reconnectAfterXSeconds);
- pccs.createPCCs(BigInteger.valueOf(lsps), Optional.ofNullable(timerHandler));
+ pccs.createPCCs(Uint64.valueOf(lsps), Optional.ofNullable(timerHandler));
if (!triggeredInitSync) {
timerHandler.createDisconnectTask();
}
}
private static ch.qos.logback.classic.Logger getRootLogger(final LoggerContext lc) {
- return lc.getLoggerList().stream().filter(input -> (input != null) && input.getName()
+ return lc.getLoggerList().stream().filter(input -> input != null && input.getName()
.equals(Logger.ROOT_LOGGER_NAME)).findFirst().get();
}
}
import static java.util.Objects.requireNonNull;
-import java.math.BigInteger;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.protocol.pcep.pcc.mock.api.PCCSession;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.lsp.db.version.tlv.LspDbVersion;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.Tlvs1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs;
+import org.opendaylight.yangtools.yang.common.Uint64;
final class PCCSyncOptimization {
private final boolean dbVersionMatch;
private final boolean isTriggeredReSyncEnable;
private final LspDbVersion localLspDbVersion;
private final LspDbVersion remoteLspDbVersion;
- private BigInteger lspDBVersion = BigInteger.ONE;
+ private Uint64 lspDBVersion = Uint64.ONE;
private Boolean resynchronizing = Boolean.FALSE;
PCCSyncOptimization(final @NonNull PCCSession session) {
return this.isTriggeredReSyncEnable;
}
- public BigInteger getLocalLspDbVersionValue() {
+ public Uint64 getLocalLspDbVersionValue() {
if (this.localLspDbVersion == null) {
return null;
}
return this.localLspDbVersion.getLspDbVersionValue();
}
- public BigInteger getRemoteLspDbVersionValue() {
+ public Uint64 getRemoteLspDbVersionValue() {
if (this.remoteLspDbVersion == null) {
- return BigInteger.ONE;
+ return Uint64.ONE;
}
return this.remoteLspDbVersion.getLspDbVersionValue();
}
return false;
}
- public Optional<BigInteger> incrementLspDBVersion() {
+ public Optional<Uint64> incrementLspDBVersion() {
if (!isSyncAvoidanceEnabled()) {
return Optional.empty();
} else if (isSyncNeedIt() && getLocalLspDbVersionValue() != null && !this.resynchronizing) {
return Optional.of(this.lspDBVersion);
}
- this.lspDBVersion = this.lspDBVersion.add(BigInteger.ONE);
+ this.lspDBVersion = Uint64.fromLongBits(lspDBVersion.longValue() + 1);
return Optional.of(this.lspDBVersion);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
final class PCCTunnelBuilder {
static final int PCC_DELEGATION = -1;
static Map<PlspId, PCCTunnel> createTunnels(final String address, final int lsps) {
final Map<PlspId, PCCTunnel> tunnels = new HashMap<>();
for (int i = 1; i <= lsps; i++) {
- final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, i),
+ final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, Uint32.valueOf(i)),
PCC_DELEGATION, LspType.PCC_LSP, createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
tunnels.put(new PlspId((long) i), tunnel);
}
import com.google.common.net.InetAddresses;
import io.netty.util.Timeout;
import io.netty.util.Timer;
-import java.math.BigInteger;
import java.net.InetAddress;
import java.util.Collections;
import java.util.HashMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.SrpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public final class PCCTunnelManagerImpl implements PCCTunnelManager {
protected void reportToAll(final Updates update, final PCCSession session) {
final PlspId plspId = update.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
- final long srpId = update.getSrp().getOperationId().getValue();
+ final Uint32 srpId = update.getSrp().getOperationId().getValue();
if (tunnel != null) {
if (hasDelegation(tunnel, session)) {
- final Srp srp = createSrp(update.getSrp().getOperationId().getValue());
+ final Srp srp = createSrp(srpId);
final Path path = updToRptPath(update.getPath());
final List<Subobject> subobjects = update.getPath().getEro().getSubobject();
final Lsp lsp = update.getLsp();
private void returnDelegation(final Updates update, final PCCSession session) {
final PlspId plspId = update.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
- final long srpId = update.getSrp().getOperationId().getValue();
+ final Uint32 srpId = update.getSrp().getOperationId().getValue();
if (tunnel != null) {
//check if session really has a delegation
if (hasDelegation(tunnel, session)) {
protected void takeDelegation(final Requests request, final PCCSession session) {
final PlspId plspId = request.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
- final long srpId = request.getSrp().getOperationId().getValue();
+ final Uint32 srpId = request.getSrp().getOperationId().getValue();
if (tunnel != null) {
//check if tunnel has no delegation
if (tunnel.getType() == LspType.PCE_LSP && (tunnel.getDelegationHolder() == -1
protected void removeTunnel(final Requests request, final PCCSession session) {
final PlspId plspId = request.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
- final long srpId = request.getSrp().getOperationId().getValue();
+ final Uint32 srpId = request.getSrp().getOperationId().getValue();
if (tunnel != null) {
if (tunnel.getType() == LspType.PCE_LSP) {
if (hasDelegation(tunnel, session)) {
}
}
- private Tlvs buildTlvs(final PCCTunnel tunnel, final Long plspId, final Optional<List<Subobject>> subobjectsList) {
+ private Tlvs buildTlvs(final PCCTunnel tunnel, final Uint32 plspId,
+ final Optional<List<Subobject>> subobjectsList) {
final List<Subobject> subObject = subobjectsList.isPresent() ? subobjectsList.get() :
tunnel.getLspState().getEro().getSubobject();
final String destinationAddress = getDestinationAddress(subObject, this.address);
private synchronized void lazyTunnelInicialization() {
if (this.tunnels.isEmpty()) {
- final BigInteger dbV = this.syncOptimization.getLocalLspDbVersionValue();
- if (dbV != null && this.syncOptimization.isSyncAvoidanceEnabled() && !dbV.equals(BigInteger.ONE)) {
+ final Uint64 dbV = this.syncOptimization.getLocalLspDbVersionValue();
+ if (dbV != null && this.syncOptimization.isSyncAvoidanceEnabled() && !dbV.equals(Uint64.ONE)) {
this.tunnels.putAll(PCCTunnelBuilder.createTunnels(this.address, dbV.intValue()));
} else {
this.tunnels.putAll(PCCTunnelBuilder.createTunnels(this.address, this.lspsCount));
}
private boolean isInitialSyncTriggered(final Lsp lsp) {
- return lsp.getPlspId().getValue() == 0 && lsp.isSync() && this.syncOptimization.isTriggeredInitSyncEnabled();
+ return lsp.getPlspId().getValue().toJava() == 0 && lsp.isSync()
+ && this.syncOptimization.isTriggeredInitSyncEnabled();
}
private void handledDbTriggeredResync(final Updates update, final PCCSession session) {
this.syncOptimization.setResynchronizingState(Boolean.TRUE);
final SrpIdNumber operationId = update.getSrp().getOperationId();
- if (update.getLsp().getPlspId().getValue() == 0) {
+ if (update.getLsp().getPlspId().getValue().toJava() == 0) {
reportAllKnownLsp(Optional.of(operationId), session);
} else {
reportLsp(update.getLsp().getPlspId(), operationId, session);
private void reportMissedLsp(final PCCSession session) {
for (long missedLsp = this.syncOptimization.getRemoteLspDbVersionValue().longValue() + 1;
missedLsp <= this.syncOptimization.getLocalLspDbVersionValue().longValue(); missedLsp++) {
- final PlspId plspId = new PlspId(missedLsp);
+ final Uint32 missed = Uint32.valueOf(missedLsp);
+ final PlspId plspId = new PlspId(missed);
final PCCTunnel tunnel = this.tunnels.get(plspId);
- createLspAndSendReport(missedLsp, tunnel, session, Optional.empty(), NO_SRP);
+ createLspAndSendReport(missed, tunnel, session, Optional.empty(), NO_SRP);
}
}
- private void createLspAndSendReport(final long plspId, final PCCTunnel tunnel, final PCCSession session,
+ private void createLspAndSendReport(final Uint32 plspId, final PCCTunnel tunnel, final PCCSession session,
final Optional<Boolean> isSync, final Optional<Srp> srp) {
final boolean delegation = hasDelegation(tunnel, session);
if (delegation) {
if (this.syncOptimization.isSyncAvoidanceEnabled()) {
tlv = createLspTlvsEndofSync(this.syncOptimization.incrementLspDBVersion().get());
}
- final Pcrpt pcrtp = createPcRtpMessage(createLsp(0, false, tlv, true, false),
+ final Pcrpt pcrtp = createPcRtpMessage(createLsp(Uint32.ZERO, false, tlv, true, false),
Optional.ofNullable(srp), createPath(Collections.emptyList()));
session.sendReport(pcrtp);
}
for (final Entry<PlspId, PCCTunnel> entry : this.tunnels.entrySet()) {
final PCCTunnel tunnel = entry.getValue();
- final long plspId = entry.getKey().getValue();
+ final Uint32 plspId = entry.getKey().getValue();
createLspAndSendReport(plspId, tunnel, session, Optional.empty(), Optional.ofNullable(srp));
}
}
if (tunnel.getType() == LspType.PCE_LSP) {
PCCTunnelManagerImpl.this.tunnels.remove(plspId);
//report tunnel removal to all
- sendToAll(tunnel, plspId, Collections.emptyList(), createSrp(0), new PathBuilder().build(),
- createLsp(plspId.getValue(), false, Optional.empty(), false, true));
+ sendToAll(tunnel, plspId, Collections.emptyList(), createSrp(Uint32.ZERO),
+ new PathBuilder().build(), createLsp(plspId.getValue(), false, Optional.empty(), false, true));
}
}, this.stateTimeout, TimeUnit.SECONDS);
tunnel.setStateTimeout(newStateTimeout);
import com.google.common.net.InetAddresses;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
-import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.List;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator;
+import org.opendaylight.yangtools.yang.common.Uint64;
final class PCCsBuilder {
private final int lsps;
startActivators();
}
- void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler) {
+ void createPCCs(final Uint64 initialDBVersion, final Optional<TimerHandler> timerHandler) {
InetAddress currentAddress = this.localAddress.getAddress();
this.pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance()
.getMessageHandlerRegistry());
}
private void createPCC(final @NonNull InetSocketAddress plocalAddress,
- final PCCTunnelManager tunnelManager, final BigInteger initialDBVersion) {
+ final PCCTunnelManager tunnelManager, final Uint64 initialDBVersion) {
final PCEPSessionNegotiatorFactory<PCEPSessionImpl> snf = getSessionNegotiatorFactory();
for (final InetSocketAddress pceAddress : this.remoteAddress) {
this.pccDispatcher.createClient(pceAddress, this.reconnectTime, () -> new PCCSessionListener(
import io.netty.util.Timeout;
import io.netty.util.Timer;
import io.netty.util.TimerTask;
-import java.math.BigInteger;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final Timer timer = new HashedWheelTimer();
private PCCDispatcherImpl pccDispatcher;
private final int reconnectAfter;
- private final Optional<BigInteger> syncOptDBVersion;
+ private final Optional<Uint64> syncOptDBVersion;
private final PCCsBuilder pcCsBuilder;
private boolean reconnectActive = false;
- public TimerHandler(final PCCsBuilder pcCsBuilder, final Optional<BigInteger> syncOptDBVersion,
+ public TimerHandler(final PCCsBuilder pcCsBuilder, final Optional<Uint64> syncOptDBVersion,
final int disconnectAfter, final int reconnectAfter) {
this.pcCsBuilder = pcCsBuilder;
this.syncOptDBVersion = syncOptDBVersion;
@Override
public void run(final Timeout timeout) {
LOG.debug("Reconnecting PCCs}");
- TimerHandler.this.pcCsBuilder.createPCCs(TimerHandler.this.syncOptDBVersion.isPresent()
- ? TimerHandler.this.syncOptDBVersion.get() : BigInteger.ONE, Optional.empty());
+ TimerHandler.this.pcCsBuilder.createPCCs(TimerHandler.this.syncOptDBVersion.orElse(Uint64.ONE),
+ Optional.empty());
}
}
package org.opendaylight.protocol.pcep.pcc.mock.api;
import io.netty.util.concurrent.Future;
-import java.math.BigInteger;
import java.net.InetSocketAddress;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
+import org.opendaylight.yangtools.yang.common.Uint64;
public interface PCCDispatcher {
@NonNull Future<PCEPSession> createClient(@NonNull InetSocketAddress remoteAddress,
long reconnectTime, @NonNull PCEPSessionListenerFactory listenerFactory,
@NonNull PCEPSessionNegotiatorFactory<? extends PCEPSession> negotiatorFactory, @NonNull KeyMapping keys,
- @NonNull InetSocketAddress localAddress, @NonNull BigInteger dbVersion);
+ @NonNull InetSocketAddress localAddress, @NonNull Uint64 dbVersion);
@NonNull Future<PCEPSession> createClient(@NonNull InetSocketAddress remoteAddress,
long reconnectTime, @NonNull PCEPSessionListenerFactory listenerFactory,
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.concurrent.Future;
-import java.math.BigInteger;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutionException;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.protocol.pcep.impl.PCEPHandlerFactory;
import org.opendaylight.protocol.pcep.pcc.mock.api.PCCDispatcher;
import org.opendaylight.protocol.pcep.spi.MessageRegistry;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final PCEPSessionNegotiatorFactory<? extends PCEPSession> negotiatorFactory, final KeyMapping keys,
final InetSocketAddress localAddress) {
return createClient(remoteAddress, reconnectTime, listenerFactory, negotiatorFactory, keys, localAddress,
- BigInteger.ONE);
+ Uint64.ONE);
}
@Override
@SuppressWarnings("unchecked")
public Future<PCEPSession> createClient(final InetSocketAddress remoteAddress, final long reconnectTime,
final PCEPSessionListenerFactory listenerFactory, final PCEPSessionNegotiatorFactory negotiatorFactory,
- final KeyMapping keys, final InetSocketAddress localAddress, final BigInteger dbVersion) {
+ final KeyMapping keys, final InetSocketAddress localAddress, final Uint64 dbVersion) {
final Bootstrap b = new Bootstrap();
b.group(this.workerGroup);
b.localAddress(localAddress);
final long retryTimer = reconnectTime == -1 ? 0 : reconnectTime;
final PCCReconnectPromise promise =
new PCCReconnectPromise(remoteAddress, (int) retryTimer, CONNECT_TIMEOUT, b);
- final ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<SocketChannel>() {
+ final ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<>() {
@Override
protected void initChannel(final SocketChannel ch) {
ch.pipeline().addLast(PCCDispatcherImpl.this.factory.getDecoders());
import static java.util.Objects.requireNonNull;
-import java.math.BigInteger;
import java.net.InetSocketAddress;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.protocol.pcep.PCEPPeerProposal;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.lsp.db.version.tlv.LspDbVersion;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.lsp.db.version.tlv.LspDbVersionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
+import org.opendaylight.yangtools.yang.common.Uint64;
public final class PCCPeerProposal implements PCEPPeerProposal {
- private final BigInteger dbVersion;
+ private final Uint64 dbVersion;
- public PCCPeerProposal(final @NonNull BigInteger dbVersion) {
+ public PCCPeerProposal(final @NonNull Uint64 dbVersion) {
this.dbVersion = dbVersion;
}
import static java.util.Objects.requireNonNull;
-import java.math.BigInteger;
import java.net.InetSocketAddress;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.protocol.pcep.PCEPPeerProposal;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs3Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.lsp.db.version.tlv.LspDbVersionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCCServerPeerProposal implements PCEPPeerProposal {
private boolean isAfterReconnection;
- private final BigInteger dbVersion;
+ private final Uint64 dbVersion;
- public PCCServerPeerProposal(final @NonNull BigInteger dbVersion) {
+ public PCCServerPeerProposal(final @NonNull Uint64 dbVersion) {
this.dbVersion = dbVersion;
}
package org.opendaylight.protocol.pcep.pcc.mock.spi;
import com.google.common.collect.Lists;
-import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv4ExtendedTunnelId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public final class MsgBuilderUtil {
return rptBuilder.build();
}
- public static Lsp createLsp(final long plspId, final boolean sync, final Optional<Tlvs> tlvs,
+ public static Lsp createLsp(final Uint32 plspId, final boolean sync, final Optional<Tlvs> tlvs,
final boolean isDelegatedLsp, final boolean remove) {
final LspBuilder lspBuilder = new LspBuilder();
lspBuilder.setAdministrative(true);
return lspBuilder.build();
}
- public static Lsp createLsp(final long plspId, final boolean sync, final Optional<Tlvs> tlvs,
+ public static Lsp createLsp(final Uint32 plspId, final boolean sync, final Optional<Tlvs> tlvs,
final boolean isDelegatedLspe) {
return createLsp(plspId, sync, tlvs, isDelegatedLspe, false);
}
return pathBuilder.build();
}
- public static Srp createSrp(final long srpId) {
+ public static Srp createSrp(final Uint32 srpId) {
final SrpBuilder srpBuilder = new SrpBuilder();
srpBuilder.setProcessingRule(false);
srpBuilder.setIgnore(false);
return pathBuilder.build();
}
- public static Tlvs createLspTlvs(final long lspId, final boolean symbolicPathName, final String tunnelEndpoint,
+ public static Tlvs createLspTlvs(final Uint32 lspId, final boolean symbolicPathName, final String tunnelEndpoint,
final String tunnelSender, final String extendedTunnelAddress, final Optional<byte[]> symbolicName) {
return createLspTlvs(lspId, symbolicPathName, tunnelEndpoint, tunnelSender, extendedTunnelAddress, symbolicName,
Optional.empty());
}
- public static Tlvs createLspTlvs(final long lspId, final boolean symbolicPathName, final String tunnelEndpoint,
+ public static Tlvs createLspTlvs(final Uint32 lspId, final boolean symbolicPathName, final String tunnelEndpoint,
final String tunnelSender, final String extendedTunnelAddress, final Optional<byte[]> symbolicName,
- final Optional<BigInteger> lspDBVersion) {
+ final Optional<Uint64> lspDBVersion) {
final TlvsBuilder tlvs = new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder()
.setLspId(new LspId(lspId))
.setAddressFamily(
.setIpv4TunnelSenderAddress(new Ipv4AddressNoZone(tunnelSender))
.setIpv4ExtendedTunnelId(
new Ipv4ExtendedTunnelId(extendedTunnelAddress))
- .build()).build()).setTunnelId(new TunnelId((int) lspId)).build());
+ .build()).build()).setTunnelId(new TunnelId(lspId.intValue())).build());
if (symbolicPathName) {
if (symbolicName.isPresent()) {
tlvs.setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(
return tlvs.build();
}
- public static Optional<Tlvs> createLspTlvsEndofSync(final @NonNull BigInteger bigInteger) {
+ public static Optional<Tlvs> createLspTlvsEndofSync(final @NonNull Uint64 dbVersion) {
final Tlvs tlvs = new TlvsBuilder().addAugmentation(Tlvs1.class, new Tlvs1Builder().setLspDbVersion(
- new LspDbVersionBuilder().setLspDbVersionValue(bigInteger).build()).build()).build();
+ new LspDbVersionBuilder().setLspDbVersionValue(dbVersion).build()).build()).build();
return Optional.of(tlvs);
}
+ public static Pcerr createErrorMsg(final @NonNull PCEPErrors pcepErrors, final Uint32 srpId) {
+ return new PcerrBuilder()
+ .setPcerrMessage(new PcerrMessageBuilder()
+ .setErrorType(new StatefulCaseBuilder()
+ .setStateful(new StatefulBuilder()
+ .setSrps(Collections.singletonList(new SrpsBuilder()
+ .setSrp(new SrpBuilder()
+ .setProcessingRule(false)
+ .setIgnore(false)
+ .setOperationId(new SrpIdNumber(srpId))
+ .build())
+ .build()))
+ .build())
+ .build())
+ .setErrors(Collections.singletonList(new ErrorsBuilder()
+ .setErrorObject(new ErrorObjectBuilder()
+ .setType(pcepErrors.getErrorType())
+ .setValue(pcepErrors.getErrorValue())
+ .build())
+ .build()))
+ .build())
+ .build();
+ }
+
public static Pcerr createErrorMsg(final @NonNull PCEPErrors pcepErrors, final long srpId) {
- final PcerrMessageBuilder msgBuilder = new PcerrMessageBuilder();
- return new PcerrBuilder().setPcerrMessage(
- msgBuilder
- .setErrorType(
- new StatefulCaseBuilder().setStateful(
- new StatefulBuilder().setSrps(
- Lists.newArrayList(new SrpsBuilder().setSrp(
- new SrpBuilder().setProcessingRule(false).setIgnore(false)
- .setOperationId(new SrpIdNumber(srpId)).build())
- .build())).build()).build())
- .setErrors(
- Collections.singletonList(new ErrorsBuilder().setErrorObject(
- new ErrorObjectBuilder().setType(pcepErrors.getErrorType()).setValue(pcepErrors.getErrorValue())
- .build()).build())).build()).build();
+ return createErrorMsg(pcepErrors, Uint32.valueOf(srpId));
}
- public static byte[] getDefaultPathName(final String address, final long lspId) {
+ public static byte[] getDefaultPathName(final String address, final Uint32 lspId) {
return ("pcc_" + address + "_tunnel_" + lspId).getBytes(StandardCharsets.UTF_8);
}
import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCServerPeerProposal;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCCIncrementalSyncTest extends PCCMockCommon {
@Test
public void testSessionIncrementalSyncEstablishment() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
- final BigInteger numberOflspAndDBv = BigInteger.valueOf(8);
+ final Uint64 numberOflspAndDBv = Uint64.valueOf(8);
final Channel channel = createServer(factory, this.remoteAddress, new PCCServerPeerProposal(numberOflspAndDBv));
Main.main(this.mainInputIncrementalSync);
final TestingSessionListener pceSessionListener = getListener(factory);
checkSynchronizedSession(8, pceSessionListener, numberOflspAndDBv);
Thread.sleep(6000);
final int expetecdNumberOfLspAndEndOfSync = 3;
- final BigInteger expectedFinalDBVersion = BigInteger.valueOf(10);
+ final Uint64 expectedFinalDBVersion = Uint64.valueOf(10);
final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
checkResyncSession(Optional.empty(), expetecdNumberOfLspAndEndOfSync, 3, numberOflspAndDBv,
expectedFinalDBVersion, sessionListenerAfterReconnect);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.pcep.pcc.mock;
import static org.junit.Assert.assertEquals;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
import io.netty.util.concurrent.Future;
-import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp.object.Lsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.pcrpt.message.pcrpt.message.Reports;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
+import org.opendaylight.yangtools.yang.common.Uint64;
public abstract class PCCMockCommon {
private static final short KEEP_ALIVE = 30;
}
static void checkSynchronizedSession(final int numberOfLsp,
- final TestingSessionListener pceSessionListener, final BigInteger expectedeInitialDb) throws Exception {
+ final TestingSessionListener pceSessionListener, final Uint64 expectedeInitialDb) throws Exception {
assertTrue(pceSessionListener.isUp());
//Send Open with LspDBV = 1
final int numberOfSyncMessage = 1;
int numberOfLspExpected = numberOfLsp;
- if (!expectedeInitialDb.equals(BigInteger.ZERO)) {
+ if (!expectedeInitialDb.equals(Uint64.ZERO)) {
checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedeInitialDb));
numberOfLspExpected += numberOfSyncMessage;
}
}
static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp,
- final int expectedTotalMessages, final BigInteger startingDBVersion, final BigInteger expectedDBVersion,
+ final int expectedTotalMessages, final Uint64 startingDBVersion, final Uint64 expectedDBVersion,
final TestingSessionListener pceSessionListener) throws Exception {
assertNotNull(pceSessionListener.getSession());
assertTrue(pceSessionListener.isUp());
assertTrue(session.getRemoteTlvs().augmentation(Tlvs1.class).getStateful()
.augmentation(Stateful1.class).isInitiation());
- final BigInteger pceDBVersion = session.getLocalTlvs().augmentation(Tlvs3.class)
+ final Uint64 pceDBVersion = session.getLocalTlvs().augmentation(Tlvs3.class)
.getLspDbVersion().getLspDbVersionValue();
assertEquals(startingDBVersion, pceDBVersion);
}
}
protected static void checkSequequenceDBVersionSync(final TestingSessionListener pceSessionListener,
- final BigInteger expectedDbVersion) {
+ final Uint64 expectedDbVersion) {
for (final Message msg : pceSessionListener.messages()) {
final List<Reports> pcrt = ((Pcrpt) msg).getPcrptMessage().getReports();
for (final Reports report : pcrt) {
final Lsp lsp = report.getLsp();
- if (lsp.getPlspId().getValue() == 0) {
+ if (lsp.getPlspId().getValue().toJava() == 0) {
assertEquals(false, lsp.isSync());
} else {
assertEquals(true, lsp.isSync());
}
- final BigInteger actuaLspDBVersion = lsp.getTlvs().augmentation(org.opendaylight.yang.gen
- .v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1.class)
- .getLspDbVersion().getLspDbVersionValue();
+ final Uint64 actuaLspDBVersion = lsp.getTlvs()
+ .augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep
+ .sync.optimizations.rev181109.Tlvs1.class)
+ .getLspDbVersion().getLspDbVersionValue();
assertEquals(expectedDbVersion, actuaLspDBVersion);
}
}
}
- Future<PCEPSession> createPCCSession(final BigInteger dbVersion) {
+ Future<PCEPSession> createPCCSession(final Uint64 dbVersion) {
final PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(this.messageRegistry);
final PCEPSessionNegotiatorFactory<PCEPSessionImpl> snf = getSessionNegotiatorFactory();
final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(3, this.localAddress.getAddress(),
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class PCCSessionListenerTest {
public void testSendError() {
final PCCSessionListener listener = new PCCSessionListener(1, this.tunnelManager, false);
listener.onSessionUp(this.mockedSession);
- listener.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.ATTEMPT_2ND_SESSION, 0));
+ listener.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.ATTEMPT_2ND_SESSION, Uint32.ZERO));
verify(this.mockedSession).sendMessage(Mockito.any());
}
final List<Requests> requests = Lists.newArrayList();
final RequestsBuilder reqBuilder = new RequestsBuilder()
.setLsp(lspBuilder.build())
- .setSrp(new SrpBuilder(MsgBuilderUtil.createSrp(123)).addAugmentation(Srp1.class,
+ .setSrp(new SrpBuilder(MsgBuilderUtil.createSrp(Uint32.valueOf(123))).addAugmentation(Srp1.class,
new Srp1Builder().setRemove(remove).build()).build());
if (endpoint) {
reqBuilder.setEndpointsObj(new EndpointsObjBuilder().build());
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.pcep.pcc.mock;
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCPeerProposal;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCCSyncAvoidanceProcedureTest extends PCCMockCommon {
@Test
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
- final PCEPSession session = createPCCSession(BigInteger.TEN).get();
+ final PCEPSession session = createPCCSession(Uint64.valueOf(10)).get();
assertNotNull(session);
final TestingSessionListener pceSessionListener = getListener(factory);
assertNotNull(pceSessionListener);
assertNotNull(pceSessionListener.getSession());
- checkResyncSession(Optional.empty(), 11, 11, null,
- BigInteger.valueOf(10), pceSessionListener);
+ checkResyncSession(Optional.empty(), 11, 11, null, Uint64.valueOf(10), pceSessionListener);
channel.close().get();
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.pcep.pcc.mock;
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.Srp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.SrpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCCTriggeredFullDBResyncTest extends PCCMockCommon {
public void testSessionTriggeredFullDBReSync() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
final int lspQuantity = 3;
- final BigInteger numberOflspAndDBv = BigInteger.valueOf(lspQuantity);
+ final Uint64 numberOflspAndDBv = Uint64.valueOf(lspQuantity);
final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
assertNotNull(session);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.pcep.pcc.mock;
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.Srp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.SrpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCCTriggeredLspResyncTest extends PCCMockCommon {
@Test
public void testSessionTriggeredLspReSync() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
final int lspQuantity = 3;
- final BigInteger numberOflspAndDBv = BigInteger.valueOf(lspQuantity);
+ final Uint64 numberOflspAndDBv = Uint64.valueOf(lspQuantity);
final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.pcep.pcc.mock;
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.Srp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.SrpBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCCTriggeredSyncTest extends PCCMockCommon {
@Test
public void testSessionTriggeredSync() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
- final BigInteger numberOflspAndDBv = BigInteger.valueOf(3);
+ final Uint64 numberOflspAndDBv = Uint64.valueOf(3);
final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
assertNotNull(session);
final TestingSessionListener pceSessionListener = getListener(factory);
assertNotNull(pceSessionListener);
- checkSynchronizedSession(0, pceSessionListener, BigInteger.ZERO);
+ checkSynchronizedSession(0, pceSessionListener, Uint64.ZERO);
this.pccSessionListener.onMessage(session, createTriggerMsg());
checkSynchronizedSession(3, pceSessionListener, numberOflspAndDBv);
channel.close().get();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.subobject.nai.IpNodeIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.subobject.nai.UnnumberedAdjacency;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.subobject.nai.UnnumberedAdjacencyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
-public abstract class AbstractSrSubobjectParser {
+public abstract class AbstractSrSubobjectParser {
protected static final int MINIMAL_LENGTH = 4;
protected static final int BITSET_LENGTH = 8;
private final boolean mflag;
private final boolean cflag;
private final SidType sidType;
- private final Long sid;
+ private final Uint32 sid;
private final Nai nai;
- SrSubobjectImpl(final boolean mflag, final boolean cflag, final SidType sidType, final Long sid,
+ SrSubobjectImpl(final boolean mflag, final boolean cflag, final SidType sidType, final Uint32 sid,
final Nai nai) {
this.mflag = mflag;
this.cflag = cflag;
}
@Override
- public Long getSid() {
+ public Uint32 getSid() {
return this.sid;
}
"Both SID and NAI are absent in SR subobject.");
if (srSubobject.getSid() != null) {
if (srSubobject.isMFlag()) {
- writeUnsignedInt(srSubobject.getSid() << MPLS_LABEL_OFFSET, buffer);
+ writeUnsignedInt(srSubobject.getSid().toJava() << MPLS_LABEL_OFFSET, buffer);
} else {
writeUnsignedInt(srSubobject.getSid(), buffer);
}
if (f && s) {
throw new PCEPDeserializerException("Both SID and NAI are absent in SR subobject.");
}
- Long tmp = null;
+
+ final Uint32 sid;
if (!s) {
- if (m) {
- tmp = buffer.readUnsignedInt() >>> MPLS_LABEL_OFFSET;
- } else {
- tmp = buffer.readUnsignedInt();
- }
+ final long tmp = buffer.readUnsignedInt();
+ sid = Uint32.valueOf(m ? tmp >> MPLS_LABEL_OFFSET : tmp);
+ } else {
+ sid = null;
}
- final Long sid = tmp;
final Nai nai;
if (sidType != null && !f) {
nai = parseNai(sidType, buffer);
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>yang-binding</artifactId>
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.Arrays;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Possible errors listed in RFC5440, RFC 5455 and stateful draft.
private PCEPErrorIdentifier errorId;
- public static PCEPErrors forValue(final short errorType, final short errorValue) {
- return VALUE_MAP.get(new PCEPErrorIdentifier(errorType, errorValue));
+ public static PCEPErrors forValue(final Uint8 errorType, final Uint8 errorValue) {
+ return VALUE_MAP.get(new PCEPErrorIdentifier(errorType.toJava(), errorValue.toJava()));
}
PCEPErrors(final int type, final int value) {
package org.opendaylight.protocol.pcep.spi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType;
+import org.opendaylight.yangtools.yang.common.Uint8;
public final class PSTUtil {
private PSTUtil() {
* @return true if setup is via RSVP-TE signaling protocol
*/
public static boolean isDefaultPST(final PathSetupType pst) {
- if (pst != null && pst.getPst() != null && pst.getPst() != 0) {
- return false;
+ if (pst != null) {
+ final Uint8 value = pst.getPst();
+ if (value != null && value.toJava() != 0) {
+ return false;
+ }
}
return true;
}
*/
package org.opendaylight.protocol.pcep.spi.pojo;
-import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import java.util.Optional;
import org.opendaylight.protocol.concepts.HandlerRegistry;
public Registration registerVendorInformationObjectParser(final EnterpriseNumber enterpriseNumber,
final ObjectParser parser) {
- return this.handlers.registerParser(Ints.checkedCast(enterpriseNumber.getValue()), parser);
+ return this.handlers.registerParser(enterpriseNumber.getValue().intValue(), parser);
}
public Registration registerVendorInformationObjectSerializer(
public Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber,
final ObjectHeader header, final ByteBuf buffer)
throws PCEPDeserializerException {
- final ObjectParser parser = this.handlers.getParser(Ints.checkedCast(enterpriseNumber.getValue()));
+ final ObjectParser parser = this.handlers.getParser(enterpriseNumber.getValue().intValue());
if (parser == null) {
if (!header.isProcessingRule()) {
return Optional.empty();
*/
package org.opendaylight.protocol.pcep.spi.pojo;
-import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import java.util.Optional;
import org.opendaylight.protocol.concepts.HandlerRegistry;
public Registration registerVendorInformationTlvParser(final EnterpriseNumber enterpriseNumber,
final TlvParser parser) {
- return this.handlers.registerParser(Ints.checkedCast(enterpriseNumber.getValue()), parser);
+ return this.handlers.registerParser(enterpriseNumber.getValue().intValue(), parser);
}
public Registration registerVendorInformationTlvSerializer(
@Override
public Optional<VendorInformationTlv> parseVendorInformationTlv(final EnterpriseNumber enterpriseNumber,
final ByteBuf buffer) throws PCEPDeserializerException {
- final TlvParser parser = this.handlers.getParser(Ints.checkedCast(enterpriseNumber.getValue()));
+ final TlvParser parser = this.handlers.getParser(enterpriseNumber.getValue().intValue());
if (parser == null) {
return Optional.empty();
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.RepliesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
@RunWith(MockitoJUnitRunner.class)
public class AbstractMessageParserTest {
new PcrepMessageBuilder().setReplies(Arrays.asList(repsBuilder.build())).build())
.build();
} else if (objects.get(0) instanceof ErrorObject) {
- final short errorType = ((ErrorObject) objects.get(0)).getType();
- final short errorValue = ((ErrorObject) objects.get(0)).getValue();
+ final Uint8 errorType = ((ErrorObject) objects.get(0)).getType();
+ final Uint8 errorValue = ((ErrorObject) objects.get(0)).getValue();
return createErrorMsg(PCEPErrors.forValue(errorType, errorValue), Optional.empty());
}
return null;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.util.concurrent.FutureListener;
import java.net.InetAddress;
import java.util.ArrayList;
final List<Path> updatedPaths;
//lspId = 0 and remove = false -> tunnel is down, still exists but no path is signaled
//remove existing tunnel's paths now, as explicit path remove will not come
- if (!remove && reportedLspId.getValue() == 0) {
+ if (!remove && reportedLspId.getValue().toJava() == 0) {
updatedPaths = new ArrayList<>();
LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
} else {
LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
for (final Path path : previous.getPath()) {
//we found reported path in previous reports
- if (path.getLspId().getValue() == 0 || path.getLspId().equals(reportedLspId)) {
+ if (path.getLspId().getValue().toJava() == 0 || path.getLspId().equals(reportedLspId)) {
LOG.debug("Match on lsp-id {}", path.getLspId().getValue());
// path that was reported previously and does have the same lsp-id, path will be updated
final boolean r = updatedPaths.remove(path);
LOG.trace("Adding new path {} to {}", rlb.getPath(), updatedPaths);
updatedPaths.addAll(rlb.getPath());
if (remove) {
- if (reportedLspId.getValue() == 0) {
+ if (reportedLspId.getValue().toJava() == 0) {
// if lsp-id also 0, remove all paths
LOG.debug("Removing all paths.");
updatedPaths.clear();
this.requests.add(req);
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void notifyRequests() {
for (final PCEPRequest r : this.requests) {
r.done(OperationResults.SUCCESS);
final StatefulCase stat = (StatefulCase) errMsg.getErrorType();
for (final Srps srps : stat.getStateful().getSrps()) {
final SrpIdNumber id = srps.getSrp().getOperationId();
- if (id.getValue() != 0) {
+ if (id.getValue().toJava() != 0) {
final PCEPRequest req = removeRequest(id);
if (req != null) {
req.done(OperationResults.createFailed(errMsg.getErrors()));
return false;
}
final SrpIdNumber id = srp.getOperationId();
- if (id.getValue() == 0) {
+ if (id.getValue().toJava() == 0) {
return false;
}
switch (lsp.getOperational()) {
final PlspId plspid = lsp.getPlspId();
final Srp srp = report.getSrp();
- if (!lsp.isSync() && (plspid == null || plspid.getValue() == 0)) {
+ if (!lsp.isSync() && (plspid == null || plspid.getValue().toJava() == 0)) {
purgeStaleLsps(ctx);
if (isTriggeredSyncInProcess()) {
if (srp == null) {
return false;
}
final SrpIdNumber id = srp.getOperationId();
- if (id.getValue() == 0) {
+ if (id.getValue().toJava() == 0) {
return false;
}
final PCEPRequest req = removeRequest(id);
return rb.build();
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private ListenableFuture<OperationResult> redelegate(final Lsp reportedLsp, final Srp srp, final Lsp lsp,
final UpdateLspArgs input) {
// the D bit that was reported decides the type of PCE message sent
properties.put(PCEPTopologyProvider.class.getName(), configDependencies.getTopologyId().getValue());
this.serviceRegistration = bean.bundleContext
.registerService(DefaultTopologyReference.class.getName(), this.pcepTopoProvider, properties);
- LOG.info("PCEP Topology Provider service {} registered", getIdentifier().getValue());
+ LOG.info("PCEP Topology Provider service {} registered", getIdentifier().getName());
this.cssRegistration = bean.cssp.registerClusterSingletonService(this);
}
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public synchronized void instantiateServiceInstance() {
- LOG.info("PCEP Topology Provider Singleton Service {} instantiated", getIdentifier().getValue());
+ LOG.info("PCEP Topology Provider Singleton Service {} instantiated", getIdentifier().getName());
try {
this.pcepTopoProvider.instantiateServiceInstance();
} catch (final Exception e) {
@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
- LOG.info("Close PCEP Topology Provider Singleton Service {}", getIdentifier().getValue());
+ LOG.info("Close PCEP Topology Provider Singleton Service {}", getIdentifier().getName());
if (this.serviceInstantiated) {
this.serviceInstantiated = false;
return this.pcepTopoProvider.closeServiceInstance();
}
static InetSocketAddress getInetSocketAddress(final @NonNull IpAddress address, final @NonNull PortNumber port) {
- return new InetSocketAddress(IetfInetUtil.INSTANCE.inetAddressFor(address), port.getValue());
+ return new InetSocketAddress(IetfInetUtil.INSTANCE.inetAddressFor(address), port.getValue().toJava());
}
static boolean filterPcepTopologies(final @Nullable TopologyTypes topologyTypes) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTimeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
+import org.opendaylight.yangtools.yang.common.Uint16;
public final class SessionStateImpl implements PcepSessionState {
private final LongAdder lastReceivedRptMsgTimestamp = new LongAdder();
}
}
+ @Override
public synchronized String getSessionDuration() {
return StatisticsUtil.formatElapsedTime(this.sessionUpDuration.elapsed(TimeUnit.SECONDS));
}
}
@Override
- public Integer getDelegatedLspsCount() {
- return this.topologySessionStats.getDelegatedLspsCount();
+ public Uint16 getDelegatedLspsCount() {
+ return Uint16.valueOf(this.topologySessionStats.getDelegatedLspsCount());
}
@Override
import static org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createPath;
import static org.opendaylight.protocol.util.CheckTestUtil.readDataOperational;
-import java.math.BigInteger;
import java.util.Collections;
import java.util.Optional;
import org.junit.Before;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.PccSyncState;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class IncrementalSynchronizationProcedureTest
extends AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
this.listener.onSessionUp(session);
//report LSP + LSP-DB version number
- final Pcrpt pcRpt = getPcrpt(1L, "test");
+ final Pcrpt pcRpt = getPcrpt(Uint32.ONE, "test");
this.listener.onMessage(session, pcRpt);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertFalse(pcc.getReportedLsp().isEmpty());
//session up - expect sync (LSP-DBs do not match)
final LspDbVersion localDbVersion = new LspDbVersionBuilder()
- .setLspDbVersionValue(BigInteger.valueOf(2L)).build();
+ .setLspDbVersionValue(Uint64.valueOf(2L)).build();
session = getPCEPSession(getOpen(localDbVersion), getOpen(null));
this.listener.onSessionUp(session);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
});
//report LSP2 + LSP-DB version number 2
- final Pcrpt pcRpt2 = getPcrpt(2L,"testsecond");
+ final Pcrpt pcRpt2 = getPcrpt(Uint32.valueOf(2), "testsecond");
this.listener.onMessage(session, pcRpt2);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
//check node - synchronized
});
//report LSP3 + LSP-DB version number 4
- final Pcrpt pcRpt3 = getPcrpt(3L,"testthird");
+ final Pcrpt pcRpt3 = getPcrpt(Uint32.valueOf(3), "testthird");
this.listener.onMessage(session, pcRpt3);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
//check node - synchronized
.build()).build();
}
- private Pcrpt getPcrpt(final Long val, final String pathname) {
+ private static Pcrpt getPcrpt(final Uint32 val, final String pathname) {
return MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(val)).setTlvs(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp
.object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder()
pathname.getBytes())).build()).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params
.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1.class, new org.opendaylight.yang.gen.v1
.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1Builder()
- .setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(val)).build())
+ .setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(Uint64.valueOf(val)).build())
.build()).build()).setPlspId(new PlspId(val)
).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.empty(),
createPath(Collections.emptyList()));
}
- private Pcrpt getSyncPcrt() {
- return MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(
+ private static Pcrpt getSyncPcrt() {
+ return MsgBuilderUtil.createPcRtpMessage(createLsp(Uint32.ZERO, false, Optional.of(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109
.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight
.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1.class,
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync
.optimizations.rev181109.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder()
- .setLspDbVersionValue(BigInteger.valueOf(3L)).build()).build()).build()),
+ .setLspDbVersionValue(Uint64.valueOf(3L)).build()).build()).build()),
true, false), Optional.empty(),
createPath(Collections.emptyList()));
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.PccSyncState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.TriggerSyncInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client.attributes.path.computation.client.ReportedLsp;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCEPTriggeredReSynchronizationProcedureTest
extends AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
.setLspDbVersion(this.lspDbVersion).build()).build()).build();
}
- private Pcrpt getSyncMsg() {
+ private static Pcrpt getSyncMsg() {
final SrpBuilder srpBuilder = new SrpBuilder();
// not sue whether use 0 instead of nextRequest() or do not insert srp == SRP-ID-number = 0
- srpBuilder.setOperationId(new SrpIdNumber(1L));
- return MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(
+ srpBuilder.setOperationId(new SrpIdNumber(Uint32.ONE));
+ return MsgBuilderUtil.createPcRtpMessage(createLsp(Uint32.ZERO, false, Optional.of(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp
.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params
.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1.class,
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync
.optimizations.rev181109.Tlvs1Builder()
- .setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(3L))
+ .setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(Uint64.valueOf(3L))
.build()).build()).build()), true, false),
Optional.of(srpBuilder.build()), createPath(Collections.emptyList()));
}
- private Pcrpt getPcrt() {
- return MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(1L)).setTlvs(
+ private static Pcrpt getPcrt() {
+ return MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(Uint32.ONE)).setTlvs(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp
.object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder()
- .setLspId(new LspId(1L)).build()).setSymbolicPathName(
+ .setLspId(new LspId(Uint32.ONE)).build()).setSymbolicPathName(
new SymbolicPathNameBuilder().setPathName(new SymbolicPathName("test".getBytes())).build())
.addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep
.sync.optimizations.rev181109.Tlvs1.class,
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync
.optimizations.rev181109.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder()
- .setLspDbVersionValue(BigInteger.ONE).build()).build()).build())
- .setPlspId(new PlspId(1L)).setSync(true).setRemove(false)
+ .setLspDbVersionValue(Uint64.ONE).build()).build()).build())
+ .setPlspId(new PlspId(Uint32.ONE)).setSync(true).setRemove(false)
.setOperational(OperationalStatus.Active).build(), Optional.empty(),
createPath(Collections.emptyList()));
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.PccSyncState;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class PCETriggeredInitialSyncProcedureTest
extends AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
.build()).build();
}
- private Pcrpt getsyncMsg() {
- return MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(
+ private static Pcrpt getsyncMsg() {
+ return MsgBuilderUtil.createPcRtpMessage(createLsp(Uint32.ZERO, false, Optional.of(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp
.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params
.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1.class, new org.opendaylight
.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109
- .Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger
+ .Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(Uint64
.valueOf(2L)).build()).build()).build()), true, false), Optional.empty(),
createPath(Collections.emptyList()));
}
- private Pcrpt getPcrpt() {
- return MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(1L)).setTlvs(
+ private static Pcrpt getPcrpt() {
+ return MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(Uint32.ONE)).setTlvs(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp
.object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder()
- .setLspId(new LspId(1L)).build()).setSymbolicPathName(new SymbolicPathNameBuilder()
+ .setLspId(new LspId(Uint32.ONE)).build()).setSymbolicPathName(new SymbolicPathNameBuilder()
.setPathName(new SymbolicPathName("test".getBytes())).build()).addAugmentation(org.opendaylight
.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109
.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller
.pcep.sync.optimizations.rev181109.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder()
- .setLspDbVersionValue(BigInteger.valueOf(3L)).build())
- .build()).build()).setPlspId(new PlspId(1L)).setSync(true).setRemove(false)
+ .setLspDbVersionValue(Uint64.valueOf(3L)).build())
+ .build()).build()).setPlspId(new PlspId(Uint32.ONE)).setSync(true).setRemove(false)
.setOperational(OperationalStatus.Active).build(), Optional.empty(),
createPath(Collections.emptyList()));
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.PccSyncState;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class StateSynchronizationAvoidanceProcedureTest extends
AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1.class,
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync
.optimizations.rev181109.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder()
- .setLspDbVersionValue(BigInteger.ONE).build()).build()).build())
- .setPlspId(new PlspId(1L)).setSync(false).setRemove(false)
+ .setLspDbVersionValue(Uint64.ONE).build()).build()).build())
+ .setPlspId(new PlspId(Uint32.ONE)).setSync(false).setRemove(false)
.setOperational(OperationalStatus.Active).build(),
- Optional.of(MsgBuilderUtil.createSrp(1L)), null);
+ Optional.of(MsgBuilderUtil.createSrp(Uint32.ONE)), null);
this.listener.onMessage(session, pcRpt);
//check topology
readDataOperational(getDataBroker(), this.pathComputationClientIId.builder()
});
//sync rpt + LSP-DB
- final Pcrpt syncMsg = MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(
+ final Pcrpt syncMsg = MsgBuilderUtil.createPcRtpMessage(createLsp(Uint32.ZERO, false, Optional.of(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109
.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight
.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.Tlvs1.class,
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync
.optimizations.rev181109.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder()
- .setLspDbVersionValue(BigInteger.valueOf(2L)).build()).build()).build()),
+ .setLspDbVersionValue(Uint64.valueOf(2L)).build()).build()).build()),
true, false), Optional.empty(),
createPath(Collections.emptyList()));
this.listener.onMessage(session, syncMsg);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client.attributes.path.computation.client.ReportedLsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client.attributes.path.computation.client.reported.lsp.Path;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class Stateful07TopologySessionListenerTest
extends AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
- final long srpId = req.getSrp().getOperationId().getValue();
+ final Uint32 srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp())
.setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)),
MsgBuilderUtil.createPath(req.getEro().getSubobject()));
final Pcrpt esm = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setSync(false).build(),
- Optional.of(MsgBuilderUtil.createSrp(0L)), null);
+ Optional.of(MsgBuilderUtil.createSrp(Uint32.ZERO)), null);
this.listener.onMessage(this.session, esm);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertEquals(this.testAddress, pcc.getIpAddress().getIpv4Address().getValue());
checkEquals(() -> assertEquals(1, listenerState.getDelegatedLspsCount().intValue()));
checkEquals(() -> assertTrue(this.listener.isSessionSynchronized()));
checkEquals(() -> assertTrue(listenerState.getMessages()
- .augmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
+ .augmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp().toJava() > 0));
checkEquals(() -> assertEquals(2, listenerState.getMessages()
.augmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
checkEquals(() -> assertEquals(1, listenerState.getMessages()
assertTrue(this.receivedMsgs.get(1) instanceof Pcupd);
final Pcupd updateMsg = (Pcupd) this.receivedMsgs.get(1);
final Updates upd = updateMsg.getPcupdMessage().getUpdates().get(0);
- final long srpId2 = upd.getSrp().getOperationId().getValue();
+ final Uint32 srpId2 = upd.getSrp().getOperationId().getValue();
final Tlvs tlvs2 = createLspTlvs(upd.getLsp().getPlspId().getValue(), false,
this.newDestinationAddress, this.testAddress, this.testAddress, Optional.empty());
final Pcrpt pcRpt2 = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(upd.getLsp()).setTlvs(tlvs2)
assertTrue(this.listener.isSessionSynchronized());
final StatefulMessagesStatsAug statefulstate = listenerState.getMessages()
.augmentation(StatefulMessagesStatsAug.class);
- assertTrue(statefulstate.getLastReceivedRptMsgTimestamp() > 0);
+ assertTrue(statefulstate.getLastReceivedRptMsgTimestamp().toJava() > 0);
assertEquals(3, statefulstate.getReceivedRptMsgCount().intValue());
assertEquals(1, statefulstate.getSentInitMsgCount().intValue());
assertEquals(1, statefulstate.getSentUpdMsgCount().intValue());
final ReplyTime replyTime = listenerState.getMessages().getReplyTime();
- assertTrue(replyTime.getAverageTime() > 0);
- assertTrue(replyTime.getMaxTime() > 0);
+ assertTrue(replyTime.getAverageTime().toJava() > 0);
+ assertTrue(replyTime.getMaxTime().toJava() > 0);
final StatefulCapabilitiesStatsAug statefulCapabilities = listenerState
.getPeerCapabilities().augmentation(StatefulCapabilitiesStatsAug.class);
assertFalse(statefulCapabilities.isActive());
assertTrue(this.receivedMsgs.get(2) instanceof Pcinitiate);
final Pcinitiate pcinitiate2 = (Pcinitiate) this.receivedMsgs.get(2);
final Requests req2 = pcinitiate2.getPcinitiateMessage().getRequests().get(0);
- final long srpId3 = req2.getSrp().getOperationId().getValue();
+ final Uint32 srpId3 = req2.getSrp().getOperationId().getValue();
final Tlvs tlvs3 = createLspTlvs(req2.getLsp().getPlspId().getValue(), false,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
final Pcrpt pcRpt3 = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req2.getLsp()).setTlvs(tlvs3)
checkEquals(() -> assertEquals(0, listenerState.getDelegatedLspsCount().intValue()));
checkEquals(() -> assertTrue(this.listener.isSessionSynchronized()));
checkEquals(() -> assertTrue(listenerState.getMessages()
- .augmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
+ .augmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp().toJava() > 0));
checkEquals(() -> assertEquals(4, listenerState.getMessages()
.augmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
checkEquals(() -> assertEquals(2, listenerState.getMessages()
@Test
public void testOnErrorMessage() throws InterruptedException, ExecutionException {
- final Message errorMsg = MsgBuilderUtil.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, 1L);
+ final Message errorMsg = MsgBuilderUtil.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, Uint32.ONE);
this.listener.onSessionUp(this.session);
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
this.listener.onMessage(this.session, errorMsg);
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
- final long srpId = req.getSrp().getOperationId().getValue();
+ final Uint32 srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true)
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
- final long srpId = req.getSrp().getOperationId().getValue();
+ final Uint32 srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true)
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
- final long srpId = req.getSrp().getOperationId().getValue();
+ final Uint32 srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true)
assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
- final long srpId = req.getSrp().getOperationId().getValue();
+ final Uint32 srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs)
- .setPlspId(new PlspId(1L))
+ .setPlspId(new PlspId(Uint32.ONE))
.setSync(false)
.setRemove(false)
.setOperational(OperationalStatus.Active)
assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
- final long srpId = req.getSrp().getOperationId().getValue();
+ final Uint32 srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
//delegate set to true
assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
- final long srpId = req.getSrp().getOperationId().getValue();
+ final Uint32 srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true,
this.testAddress, this.testAddress, this.testAddress, Optional.empty());
//delegate set to false
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs)
- .setPlspId(
- new PlspId(1L))
+ .setPlspId(new PlspId(Uint32.ONE))
.setSync(false)
.setRemove(false)
.setOperational(OperationalStatus.Active)
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.HashMap;
import java.util.Map;
import java.util.TimerTask;
}
@SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized void updatePcepStats() {
final WriteTransaction tx = TopologyStatsProviderImpl.this.transactionChain.newWriteOnlyTransaction();
}
}
- private Node getNode() {
+ Node getNode() {
return (Node) read(this.nii);
}
- private TerminationPoint getTp() {
+ TerminationPoint getTp() {
return (TerminationPoint) read(this.tii);
}
}
this.serviceRegistration = dependencies.getBundleContext()
.registerService(DefaultTopologyReference.class.getName(), this.ttp, properties);
- LOG.info("PCEP Tunnel Cluster Singleton service {} registered", getIdentifier().getValue());
+ LOG.info("PCEP Tunnel Cluster Singleton service {} registered", getIdentifier().getName());
this.pcepTunnelCssReg = dependencies.getCssp().registerClusterSingletonService(this);
}
@Override
public synchronized void instantiateServiceInstance() {
- LOG.info("Instantiate PCEP Tunnel Topology Provider Singleton Service {}", getIdentifier().getValue());
+ LOG.info("Instantiate PCEP Tunnel Topology Provider Singleton Service {}", getIdentifier().getName());
final InstanceIdentifier<Topology> topology = InstanceIdentifier
.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(this.tunnelTopologyId)).build();
@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
LOG.info("Close Service Instance PCEP Tunnel Topology Provider Singleton Service {}",
- getIdentifier().getValue());
+ getIdentifier().getName());
this.reg.close();
this.tp.close();
this.ttp.close();
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public synchronized void close() {
- LOG.info("Close PCEP Tunnel Topology Provider Singleton Service {}", getIdentifier().getValue());
+ LOG.info("Close PCEP Tunnel Topology Provider Singleton Service {}", getIdentifier().getName());
if (this.pcepTunnelCssReg != null) {
try {
this.pcepTunnelCssReg.close();
} catch (final Exception e) {
- LOG.debug("Failed to close PCEP Tunnel Topology service {}", this.sgi.getValue(), e);
+ LOG.debug("Failed to close PCEP Tunnel Topology service {}", this.sgi.getName(), e);
}
this.pcepTunnelCssReg = null;
}
@Test
public void testCurrentTime() {
- assertTrue(NanotimeUtil.currentTime().getValue().divide(BigInteger.valueOf(1000000)).subtract(
+ assertTrue(NanotimeUtil.currentTime().getValue().toJava().divide(BigInteger.valueOf(1000000)).subtract(
BigInteger.valueOf(System.currentTimeMillis())).shortValue() <= 0);
}
this.qid = KeyedInstanceIdentifier.builder(InstructionsQueue.class,
new InstructionsQueueKey(this.instructionId)).build();
this.sgi = ServiceGroupIdentifier.create(this.instructionId + "-service-group");
- LOG.info("Creating Programming Service {}.", this.sgi.getValue());
+ LOG.info("Creating Programming Service {}.", this.sgi.getName());
this.csspReg = cssp.registerClusterSingletonService(this);
}
@Override
public synchronized void instantiateServiceInstance() {
- LOG.info("Instruction Queue service {} instantiated", this.sgi.getValue());
+ LOG.info("Instruction Queue service {} instantiated", this.sgi.getName());
this.reg = this.rpcProviderRegistry.registerRpcImplementation(ProgrammingService.class, this);
final WriteTransaction wt = this.dataProvider.newWriteOnlyTransaction();
// First things first: check the deadline
final Nanotime now = NanotimeUtil.currentTime();
- final BigInteger left = input.getDeadline().getValue().subtract(now.getValue());
+ final BigInteger left = input.getDeadline().getValue().toJava().subtract(now.getValue().toJava());
if (left.compareTo(BigInteger.ZERO) <= 0) {
LOG.debug("Instruction {} deadline has already passed by {}ns", id, left);
@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
- LOG.info("Closing Instruction Queue service {}", this.sgi.getValue());
+ LOG.info("Closing Instruction Queue service {}", this.sgi.getName());
if (this.reg != null) {
this.reg.close();
final BigInteger deadlineOffset = BigInteger.valueOf(
1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
final Nanotime current = NanotimeUtil.currentTime();
- final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
+ final Nanotime deadlineNano = new Nanotime(current.getValue().toJava().add(deadlineOffset));
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
final BigInteger deadlineOffset = BigInteger.valueOf(
1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
final Nanotime current = NanotimeUtil.currentTime();
- final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
+ final Nanotime deadlineNano = new Nanotime(current.getValue().toJava().add(deadlineOffset));
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
final BigInteger deadlineOffset = BigInteger.valueOf(
1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
final Nanotime current = NanotimeUtil.currentTime();
- final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
+ final Nanotime deadlineNano = new Nanotime(current.getValue().toJava().add(deadlineOffset));
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.submit.instruction.output.result.failure._case.Failure;
public class SchedulerException extends Exception {
+ private static final long serialVersionUID = 1L;
+
private final Failure failure;
public SchedulerException(final String message, final Failure failure) {
*/
package org.opendaylight.bgpcep.programming.spi;
-import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
}
@Override
- public Collection<RpcError> getErrors() {
+ public List<RpcError> getErrors() {
return Collections.emptyList();
}
}
\ No newline at end of file
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc6991-ietf-inet-types</artifactId>
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.srlg._case.SrlgBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Parser for {@link SrlgCase}.
Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
writeUnsignedInt(specObj.getSrlgId().getValue(), body);
Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
- writeUnsignedByte(null, body);
+ writeUnsignedByte((Uint8) null, body);
writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
if (assObject.getIpAddress().getIpv4AddressNoZone() != null) {
serializeAttributeHeader(BODY_SIZE_IPV4, CLASS_NUM, CTYPE_IPV4, output);
output.writeShort(assObject.getAssociationType().getIntValue());
- output.writeShort(assObject.getAssociationId());
+ output.writeShort(assObject.getAssociationId().toJava());
output.writeBytes(Ipv4Util.byteBufForAddress(assObject.getIpAddress().getIpv4AddressNoZone()));
} else {
serializeAttributeHeader(BODY_SIZE_IPV6, CLASS_NUM, CTYPE_IPV6, output);
output.writeShort(assObject.getAssociationType().getIntValue());
- output.writeShort(assObject.getAssociationId());
+ output.writeShort(assObject.getAssociationId().toJava());
output.writeBytes(Ipv6Util.byteBufForAddress(assObject.getIpAddress().getIpv6AddressNoZone()));
}
}
final BasicFastRerouteObject fastRerouteObject = (BasicFastRerouteObject) teLspObject;
serializeAttributeHeader(BODY_SIZE_C1, CLASS_NUM, CTYPE, byteAggregator);
- byteAggregator.writeByte(fastRerouteObject.getSetupPriority());
- byteAggregator.writeByte(fastRerouteObject.getHoldPriority());
- byteAggregator.writeByte(fastRerouteObject.getHopLimit());
+ byteAggregator.writeByte(fastRerouteObject.getSetupPriority().toJava());
+ byteAggregator.writeByte(fastRerouteObject.getHoldPriority().toJava());
+ byteAggregator.writeByte(fastRerouteObject.getHopLimit().toJava());
byteAggregator.writeByte(fastRerouteObject.getFlags().getIntValue());
byteAggregator.writeBytes(Unpooled.wrappedBuffer(fastRerouteObject.getBandwidth().getValue()));
writeAttributeFilter(fastRerouteObject.getIncludeAny(), byteAggregator);
final LegacyFastRerouteObject fastRerouteObject = (LegacyFastRerouteObject) teLspObject;
serializeAttributeHeader(BODY_SIZE_C7, CLASS_NUM, CTYPE, byteAggregator);
- byteAggregator.writeByte(fastRerouteObject.getSetupPriority());
- byteAggregator.writeByte(fastRerouteObject.getHoldPriority());
- byteAggregator.writeByte(fastRerouteObject.getHopLimit());
+ byteAggregator.writeByte(fastRerouteObject.getSetupPriority().toJava());
+ byteAggregator.writeByte(fastRerouteObject.getHoldPriority().toJava());
+ byteAggregator.writeByte(fastRerouteObject.getHopLimit().toJava());
byteAggregator.writeZero(ByteBufWriteUtil.ONE_BYTE_LENGTH);
byteAggregator.writeBytes(Unpooled.wrappedBuffer(fastRerouteObject.getBandwidth().getValue()));
writeAttributeFilter(fastRerouteObject.getIncludeAny(), byteAggregator);
reflect.set(BOUND, metric.isBound());
reflect.set(COMPUTED, metric.isComputed());
reflect.toByteBuf(output);
- output.writeByte(metric.getMetricType());
+ output.writeByte(metric.getMetricType().toJava());
writeFloat32(metric.getValue(), output);
}
}
private static final int PADDING = 4;
static int getPadding(final int length) {
- return (PADDING - (length % PADDING)) % PADDING;
+ return (PADDING - length % PADDING) % PADDING;
}
@Override
.getSessionName()));
final int pad = getPadding(sessionName.readableBytes());
serializeAttributeHeader(BODY_SIZE_C7 + pad + sessionName.readableBytes(), CLASS_NUM, CTYPE, output);
- output.writeByte(sessionObject.getSetupPriority());
- output.writeByte(sessionObject.getHoldPriority());
+ output.writeByte(sessionObject.getSetupPriority().toJava());
+ output.writeByte(sessionObject.getHoldPriority().toJava());
final BitArray bs = new BitArray(FLAGS_SIZE);
bs.set(LOCAL_PROTECTION, sessionObject.isLocalProtectionDesired());
bs.set(LABEL_RECORDING, sessionObject.isLabelRecordingDesired());
writeAttributeFilter(sessionObject.getIncludeAny(), output);
writeAttributeFilter(sessionObject.getExcludeAny(), output);
writeAttributeFilter(sessionObject.getIncludeAll(), output);
- output.writeByte(sessionObject.getSetupPriority());
- output.writeByte(sessionObject.getHoldPriority());
+ output.writeByte(sessionObject.getSetupPriority().toJava());
+ output.writeByte(sessionObject.getHoldPriority().toJava());
final BitArray bs = new BitArray(FLAGS_SIZE);
bs.set(SessionAttributeLspObjectParser.LOCAL_PROTECTION, sessionObject.isLocalProtectionDesired());
bs.set(SessionAttributeLspObjectParser.LABEL_RECORDING, sessionObject.isLabelRecordingDesired());
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>yang-binding</artifactId>
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.Unnumbered;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class CUISubobjectParserTest {
- private final Long routerId = 3735928559L;
- private final Long interfaceId = 3736059631L;
- private final Unnumbered unnumbered1 = new UnnumberedBuilder().setRouterId(null).build();
- private final Unnumbered unnumbered2 = new UnnumberedBuilder().setRouterId(1L).setInterfaceId(null).build();
+ private final Uint32 routerId = Uint32.valueOf(3735928559L);
+ private final Uint32 interfaceId = Uint32.valueOf(3736059631L);
+ private final Unnumbered unnumbered1 = new UnnumberedBuilder().setRouterId((Uint32) null).build();
+ private final Unnumbered unnumbered2 = new UnnumberedBuilder().setRouterId(Uint32.ONE).setInterfaceId((Uint32) null)
+ .build();
@Test
public void testProcessing() {
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Utility class for ByteBuf's write methods.
* Short value to be write to the output.
* @param output
* ByteBuf, where value or zeros are written.
+ * @deprecated Use {@link #writeUnsignedByte(Uint8, ByteBuf)} instead.
*/
+ @Deprecated(forRemoval = true)
public static void writeUnsignedByte(final Short value, final ByteBuf output) {
if (value != null) {
output.writeByte(value);
}
}
+ /**
+ * Writes unsigned byte <code>value</code> if not null, otherwise writes
+ * zero to the <code>output</code> ByteBuf. ByteBuf's writerIndex is
+ * increased by 1.
+ *
+ * @param value
+ * Short value to be write to the output.
+ * @param output
+ * ByteBuf, where value or zeros are written.
+ */
+ public static void writeUnsignedByte(final Uint8 value, final ByteBuf output) {
+ if (value != null) {
+ output.writeByte(value.byteValue());
+ } else {
+ output.writeZero(ONE_BYTE_LENGTH);
+ }
+ }
+
/**
* Writes unsigned 16-bit short integer <code>value</code> if not null,
* otherwise writes zeros to the <code>output</code> ByteBuf. ByteBuf's
* Integer value to be written to the output.
* @param output
* ByteBuf, where value or zeros are written.
+ * @deprecated Use {@link #writeUnsignedShort(Uint16, ByteBuf)} instead.
*/
+ @Deprecated(forRemoval = true)
public static void writeUnsignedShort(final Integer value, final ByteBuf output) {
if (value != null) {
output.writeShort(value.shortValue());
}
}
+ /**
+ * Writes unsigned 16-bit short integer <code>value</code> if not null,
+ * otherwise writes zeros to the <code>output</code> ByteBuf. ByteBuf's
+ * writerIndex is increased by 2.
+ *
+ * @param value
+ * Integer value to be written to the output.
+ * @param output
+ * ByteBuf, where value or zeros are written.
+ */
+ public static void writeUnsignedShort(final Uint16 value, final ByteBuf output) {
+ if (value != null) {
+ output.writeShort(value.shortValue());
+ } else {
+ output.writeZero(SHORT_BYTES_LENGTH);
+ }
+ }
+
/**
* Writes unsigned 32-bit integer <code>value</code> if not null, otherwise
* writes zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is
* Long value to be written to the output.
* @param output
* ByteBuf, where value or zeros are written.
+ * @deprecated Use {@link #writeUnsignedInt(Uint32, ByteBuf)} instead.
*/
+ @Deprecated(forRemoval = true)
public static void writeUnsignedInt(final Long value, final ByteBuf output) {
if (value != null) {
output.writeInt(value.intValue());
}
}
+ /**
+ * Writes unsigned 32-bit integer <code>value</code> if not null, otherwise
+ * writes zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is
+ * increased by 4.
+ *
+ * @param value
+ * Long value to be written to the output.
+ * @param output
+ * ByteBuf, where value or zeros are written.
+ */
+ public static void writeUnsignedInt(final Uint32 value, final ByteBuf output) {
+ if (value != null) {
+ output.writeInt(value.intValue());
+ } else {
+ output.writeZero(INT_BYTES_LENGTH);
+ }
+ }
+
/**
* Writes unsigned 64-bit integer <code>value</code> if not null, otherwise
* writes zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is
* BigInteger value to be written to the output.
* @param output
* ByteBuf, where value or zeros are written.
+ * @deprecated Use {@link #writeUnsignedLong(Uint64, ByteBuf)} instead.
*/
+ @Deprecated(forRemoval = true)
public static void writeUnsignedLong(final BigInteger value, final ByteBuf output) {
if (value != null) {
output.writeLong(value.longValue());
}
}
+ /**
+ * Writes unsigned 64-bit integer <code>value</code> if not null, otherwise
+ * writes zeros to the <code>output</code> ByteBuf. ByteBuf's writerIndex is
+ * increased by 8.
+ *
+ * @param value
+ * BigInteger value to be written to the output.
+ * @param output
+ * ByteBuf, where value or zeros are written.
+ */
+ public static void writeUnsignedLong(final Uint64 value, final ByteBuf output) {
+ if (value != null) {
+ output.writeLong(value.longValue());
+ } else {
+ output.writeZero(LONG_BYTES_LENGTH);
+ }
+ }
+
/**
* Writes IPv4 address if not null, otherwise writes zeros to the
* <code>output</code> ByteBuf. ByteBuf's writerIndex is increased by 4.
*/
public static InetSocketAddress toInetSocketAddress(final IpAddress ipAddress, final PortNumber port) {
final String ipString = toStringIP(ipAddress);
- return new InetSocketAddress(InetAddresses.forString(ipString), port.getValue());
+ return new InetSocketAddress(InetAddresses.forString(ipString), port.getValue().toJava());
}
/**
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.math.BigInteger;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class ByteBufWriteUtilTest {
public void testWriteUnsignedByteValue() {
final byte[] result = { 5 };
final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.ONE_BYTE_LENGTH);
- writeUnsignedByte((short) 5, output);
+ writeUnsignedByte(Uint8.valueOf(5), output);
assertArrayEquals(result, output.array());
output.clear();
- writeUnsignedByte(null, output);
+ writeUnsignedByte((Uint8) null, output);
assertArrayEquals(ONE_BYTE_ZERO, output.array());
}
public void testWriteUnsignedShortValue() {
final byte[] result = { 0, 5 };
final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
- writeUnsignedShort(5, output);
+ writeUnsignedShort(Uint16.valueOf(5), output);
assertArrayEquals(result, output.array());
output.clear();
- writeUnsignedShort(null, output);
+ writeUnsignedShort((Uint16) null, output);
assertArrayEquals(TWO_BYTE_ZEROS, output.array());
}
public void testWriteUnsignedIntValue() {
final byte[] result = { 0, 0, 0, 5 };
final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.INT_BYTES_LENGTH);
- ByteBufWriteUtil.writeUnsignedInt((long) 5, output);
+ ByteBufWriteUtil.writeUnsignedInt(Uint32.valueOf(5), output);
assertArrayEquals(result, output.array());
output.clear();
- writeUnsignedInt(null, output);
+ writeUnsignedInt((Uint32) null, output);
assertArrayEquals(FOUR_BYTE_ZEROS, output.array());
}
public void testWriteUnsignedLongValue() {
final byte[] result = { 0, 0, 0, 0, 0, 0, 0, 5 };
final ByteBuf output = Unpooled.buffer(ByteBufWriteUtil.LONG_BYTES_LENGTH);
- writeUnsignedLong(new BigInteger("5"), output);
+ writeUnsignedLong(Uint64.valueOf(5), output);
assertArrayEquals(result, output.array());
output.clear();
- writeUnsignedLong(null, output);
+ writeUnsignedLong((Uint64) null, output);
assertArrayEquals(EIGHT_BYTE_ZEROS, output.array());
}