Search in sources :

Example 1 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class ClusterIdAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
    final ClusterId cid = ((Attributes) attribute).getClusterId();
    if (cid == null) {
        return;
    }
    final List<ClusterIdentifier> cluster = cid.getCluster();
    if (cluster == null || cluster.isEmpty()) {
        return;
    }
    final ByteBuf clusterIdBuffer = Unpooled.buffer();
    for (final ClusterIdentifier clusterIdentifier : cid.getCluster()) {
        clusterIdBuffer.writeBytes(Ipv4Util.bytesForAddress(clusterIdentifier));
    }
    AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, clusterIdBuffer, byteAggregator);
}
Also used : ClusterId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterId) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class MatchClusterIdSetHandler method matchClusterIdCondition.

private boolean matchClusterIdCondition(final ClusterIdentifier localClusterId, final ClusterId clusterId, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev200120.match.cluster.id.set.condition.grouping.MatchClusterIdSetCondition matchClusterIdSetCondition) {
    final ClusterIdSet clusterIdSet = this.sets.getUnchecked(StringUtils.substringBetween(matchClusterIdSetCondition.getClusterIdSet(), "=\"", "\""));
    if (clusterIdSet == null) {
        return false;
    }
    final MatchSetOptionsType matchOption = matchClusterIdSetCondition.getMatchSetOptions();
    if (clusterId != null) {
        List<ClusterIdentifier> newList = new ArrayList<>();
        if (clusterIdSet.getClusterId() != null) {
            newList.addAll(clusterIdSet.getClusterId());
        }
        if (clusterIdSet.getLocal() != null) {
            newList.add(localClusterId);
        }
        final List<ClusterIdentifier> matchClusterList = clusterId.getCluster();
        if (matchOption.equals(MatchSetOptionsType.ALL)) {
            return matchClusterList.containsAll(newList) && newList.containsAll(matchClusterList);
        }
        final boolean noneInCommon = Collections.disjoint(matchClusterList, newList);
        if (matchOption.equals(MatchSetOptionsType.ANY)) {
            return !noneInCommon;
        } else if (matchOption.equals(MatchSetOptionsType.INVERT)) {
            return noneInCommon;
        }
    } else if (matchOption.equals(MatchSetOptionsType.INVERT)) {
        return true;
    }
    return false;
}
Also used : MatchSetOptionsType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsType) ArrayList(java.util.ArrayList) ClusterIdSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev200120.cluster.id.set.ClusterIdSet) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier)

Example 3 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class ExportAttributeTestUtil method createClusterId.

private static ClusterId createClusterId() {
    final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.1"));
    final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4AddressNoZone("1.1.1.2"));
    return new ClusterIdBuilder().setCluster(Arrays.asList(CLUSTER, cluster1, cluster2)).build();
}
Also used : Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder)

Example 4 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class ClusterIdAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
    final ClusterId cid = pathAttributes.getClusterId();
    if (cid != null) {
        final List<ClusterIdentifier> cluster = cid.getCluster();
        if (cluster != null && !cluster.isEmpty()) {
            final ByteBuf clusterIdBuffer = Unpooled.buffer();
            for (final ClusterIdentifier clusterIdentifier : cluster) {
                clusterIdBuffer.writeBytes(Ipv4Util.bytesForAddress(clusterIdentifier));
            }
            AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, clusterIdBuffer, byteAggregator);
        }
    }
}
Also used : ClusterId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) ByteBuf(io.netty.buffer.ByteBuf)

Example 5 with ClusterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterId in project bgpcep by opendaylight.

the class ClusterIdAttributeParserTest method testParseEmptyListAttribute.

@Test
public void testParseEmptyListAttribute() {
    final List<ClusterIdentifier> list = new ArrayList<>();
    final Attributes clusterId = new AttributesBuilder().setClusterId(new ClusterIdBuilder().setCluster(list).build()).build();
    final ByteBuf output = Unpooled.buffer();
    this.parser.serializeAttribute(clusterId, output);
    assertEquals(Unpooled.buffer(), output);
}
Also used : ArrayList(java.util.ArrayList) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

ClusterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier)8 ClusterIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ClusterIdBuilder)7 ByteBuf (io.netty.buffer.ByteBuf)5 ArrayList (java.util.ArrayList)5 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)5 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)5 Test (org.junit.Test)3 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 FluentFuture (com.google.common.util.concurrent.FluentFuture)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 GuardedBy (org.checkerframework.checker.lock.qual.GuardedBy)1 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)1 DOMDataBroker (org.opendaylight.mdsal.dom.api.DOMDataBroker)1