Search in sources :

Example 16 with Group

use of io.fabric8.groups.Group in project netvirt by opendaylight.

the class ElanInterfaceManager method setBCGrouponOtherDpns.

@SuppressWarnings("checkstyle:IllegalCatch")
private void setBCGrouponOtherDpns(ElanInstance elanInfo, BigInteger dpId, int elanTag, long groupId) {
    int bucketId = 0;
    ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
    if (elanDpns != null) {
        List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
        for (DpnInterfaces dpnInterface : dpnInterfaces) {
            List<Bucket> remoteListBucketInfo = new ArrayList<>();
            if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpId) && dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
                List<Action> listAction = new ArrayList<>();
                int actionKey = 0;
                listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
                remoteListBucketInfo.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
                bucketId++;
                for (DpnInterfaces otherFes : dpnInterfaces) {
                    if (elanUtils.isDpnPresent(otherFes.getDpId()) && !Objects.equals(otherFes.getDpId(), dpnInterface.getDpId()) && otherFes.getInterfaces() != null && !otherFes.getInterfaces().isEmpty()) {
                        try {
                            List<Action> remoteListActionInfo = elanItmUtils.getInternalTunnelItmEgressAction(dpnInterface.getDpId(), otherFes.getDpId(), elanUtils.isOpenstackVniSemanticsEnforced() ? elanUtils.getVxlanSegmentationId(elanInfo) : elanTag);
                            if (!remoteListActionInfo.isEmpty()) {
                                remoteListBucketInfo.add(MDSALUtil.buildBucket(remoteListActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
                                bucketId++;
                            }
                        } catch (Exception ex) {
                            LOG.error("setElanBCGrouponOtherDpns failed due to Exception caught; " + "Logical Group Interface not found between source Dpn - {}, " + "destination Dpn - {} ", dpnInterface.getDpId(), otherFes.getDpId(), ex);
                            return;
                        }
                    }
                }
                List<Bucket> elanL2GwDevicesBuckets = elanL2GatewayMulticastUtils.getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpnInterface.getDpId(), bucketId);
                remoteListBucketInfo.addAll(elanL2GwDevicesBuckets);
                if (remoteListBucketInfo.isEmpty()) {
                    LOG.debug("No ITM is present on Dpn - {} ", dpnInterface.getDpId());
                    continue;
                }
                Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(remoteListBucketInfo));
                LOG.trace("Installing remote bc group {} on dpnId {}", group, dpnInterface.getDpId());
                mdsalManager.syncInstallGroup(dpnInterface.getDpId(), group);
            }
        }
        try {
            Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
        } catch (InterruptedException e1) {
            LOG.warn("Error while waiting for remote BC group on other DPNs for ELAN {} to install", elanInfo);
        }
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) ArrayList(java.util.ArrayList) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup)

Example 17 with Group

use of io.fabric8.groups.Group in project netvirt by opendaylight.

the class NexthopManager method removeOrUpdateDcGwLoadBalancingGroup.

/**
 * This method is invoked when the tunnel state is removed from DS.
 * If the there is just one DC-GW left in configuration then the LB groups can be deleted.
 * Otherwise, the groups are just updated.
 */
public void removeOrUpdateDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp) {
    Preconditions.checkNotNull(availableDcGws, "There are no dc-gws present");
    WriteTransaction configTx = dataBroker.newWriteOnlyTransaction();
    WriteTransaction operationalTx = dataBroker.newWriteOnlyTransaction();
    int noOfDcGws = availableDcGws.size();
    // If availableDcGws does not contain the destination Ip it means this is a configuration delete.
    if (!availableDcGws.contains(destinationIp)) {
        availableDcGws.add(destinationIp);
        Collections.sort(availableDcGws);
    }
    // TODO : Place the logic to construct all possible DC-GW combination here.
    int bucketId = availableDcGws.indexOf(destinationIp);
    Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
    if (!dpnLbNextHops.isPresent()) {
        return;
    }
    List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
    nextHopKeys.forEach(nextHopKey -> {
        Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
        if (!optionalNextHops.isPresent()) {
            return;
        }
        Nexthops nexthops = optionalNextHops.get();
        final String groupId = nexthops.getGroupId();
        final long groupIdValue = Long.parseLong(groupId);
        if (noOfDcGws > 1) {
            mdsalApiManager.removeBucketToTx(dpnId, groupIdValue, bucketId, configTx);
        } else {
            Group group = MDSALUtil.buildGroup(groupIdValue, nextHopKey, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(Collections.emptyList()));
            LOG.trace("Removed LB group {} on dpn {}", group, dpnId);
            mdsalApiManager.removeGroupToTx(dpnId, group, configTx);
            removeNextHopPointer(nextHopKey);
        }
        // When the DC-GW is removed from configuration.
        if (noOfDcGws != availableDcGws.size()) {
            FibUtil.removeOrUpdateNextHopInfo(dpnId, nextHopKey, groupId, nexthops, operationalTx);
        }
    });
    FibUtil.removeDpnIdToNextHopInfo(destinationIp, dpnId, operationalTx);
    configTx.submit();
    operationalTx.submit();
    return;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) VpnNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops) Nexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.l3vpn.lb.nexthops.Nexthops) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops)

Example 18 with Group

use of io.fabric8.groups.Group in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method setupLeavesEtreeBroadcastGroups.

public void setupLeavesEtreeBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
    EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
    if (etreeInstance != null) {
        long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
        List<Bucket> listBucket = new ArrayList<>();
        int bucketId = 0;
        int actionKey = 0;
        List<Action> listAction = new ArrayList<>();
        listAction.add(new ActionGroup(ElanUtils.getEtreeLeafLocalBCGId(etreeLeafTag)).buildAction(++actionKey));
        listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
        bucketId++;
        List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId, etreeLeafTag);
        listBucket.addAll(listBucketInfoRemote);
        long groupId = ElanUtils.getEtreeLeafRemoteBCGId(etreeLeafTag);
        Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
        LOG.trace("Installing the remote BroadCast Group:{}", group);
        mdsalManager.syncInstallGroup(dpnId, group);
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ArrayList(java.util.ArrayList) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 19 with Group

use of io.fabric8.groups.Group in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method setupStandardElanBroadcastGroups.

public void setupStandardElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
    List<Bucket> listBucket = new ArrayList<>();
    int bucketId = 0;
    int actionKey = 0;
    Long elanTag = elanInfo.getElanTag();
    List<Action> listAction = new ArrayList<>();
    listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
    listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
    bucketId++;
    List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId, elanTag);
    listBucket.addAll(listBucketInfoRemote);
    long groupId = ElanUtils.getElanRemoteBCGId(elanTag);
    Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
    LOG.trace("Installing the remote BroadCast Group:{}", group);
    mdsalManager.syncInstallGroup(dpnId, group);
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ArrayList(java.util.ArrayList) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 20 with Group

use of io.fabric8.groups.Group in project fabric8 by jboss-fuse.

the class FabricDiscovery method addingService.

@Override
public CuratorFramework addingService(ServiceReference<CuratorFramework> reference) {
    CuratorFramework curator = context.getService(reference);
    try {
        logger.debug("CuratorFramework found, starting group");
        GroupFactory factory = new ZooKeeperGroupFactory(curator);
        singleton = factory.createGroup("/fabric/registry/clusters/elasticsearch/" + clusterName.value(), ESNode.class);
        singleton.add(this);
        singleton.update(new ESNode(clusterName.value(), localNode, false));
        singleton.start();
    } catch (Exception e) {
        LOG.error("Error starting group", e);
    }
    return curator;
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) GroupFactory(io.fabric8.groups.GroupFactory) ZooKeeperGroupFactory(io.fabric8.groups.internal.ZooKeeperGroupFactory) ZooKeeperGroupFactory(io.fabric8.groups.internal.ZooKeeperGroupFactory) ElasticsearchException(org.elasticsearch.ElasticsearchException) ElasticsearchIllegalStateException(org.elasticsearch.ElasticsearchIllegalStateException) IOException(java.io.IOException)

Aggregations

Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)50 Test (org.junit.Test)28 ArrayList (java.util.ArrayList)27 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)18 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)15 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)15 CuratorFramework (org.apache.curator.framework.CuratorFramework)12 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)11 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)11 IOException (java.io.IOException)9 StaleGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup)9 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)9 ZooKeeperGroup (io.fabric8.groups.internal.ZooKeeperGroup)8 RetryNTimes (org.apache.curator.retry.RetryNTimes)8 NodeState (io.fabric8.groups.NodeState)7 Map (java.util.Map)7 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)7 BigInteger (java.math.BigInteger)6 HashMap (java.util.HashMap)6 NIOServerCnxnFactory (org.apache.zookeeper.server.NIOServerCnxnFactory)6