Search in sources :

Example 46 with Group

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

the class FlowCapableNodeLookups method wrapGroupsToMap.

@Nonnull
public static Map<Long, Group> wrapGroupsToMap(@Nullable final List<Group> groups) {
    final Map<Long, Group> groupMap;
    if (groups == null) {
        groupMap = Collections.emptyMap();
    } else {
        LOG.trace("groups found: {}", groups.size());
        groupMap = new HashMap<>();
        for (Group group : groups) {
            groupMap.put(group.getGroupId().getValue(), group);
        }
    }
    return groupMap;
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Nonnull(javax.annotation.Nonnull)

Example 47 with Group

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

the class ReconcileUtil method resolveAndDivideGroupDiffs.

/**
 * Returns a list of safe synchronization steps.
 *
 * @param nodeId             target node
 * @param installedGroupsArg groups resent on device
 * @param pendingGroups      groups configured for device
 * @param gatherUpdates      check content of pending item if present on device (and create update task eventually)
 * @return list of safe synchronization steps
 */
public static List<ItemSyncBox<Group>> resolveAndDivideGroupDiffs(final NodeId nodeId, final Map<Long, Group> installedGroupsArg, final Collection<Group> pendingGroups, final boolean gatherUpdates) {
    final Map<Long, Group> installedGroups = new HashMap<>(installedGroupsArg);
    final List<ItemSyncBox<Group>> plan = new ArrayList<>();
    while (!Iterables.isEmpty(pendingGroups)) {
        final ItemSyncBox<Group> stepPlan = new ItemSyncBox<>();
        final Iterator<Group> iterator = pendingGroups.iterator();
        final Map<Long, Group> installIncrement = new HashMap<>();
        while (iterator.hasNext()) {
            final Group group = iterator.next();
            final Group existingGroup = installedGroups.get(group.getGroupId().getValue());
            if (existingGroup != null) {
                if (!gatherUpdates) {
                    iterator.remove();
                } else {
                    // check buckets and eventually update
                    if (group.equals(existingGroup)) {
                        iterator.remove();
                    } else {
                        if (checkGroupPrecondition(installedGroups.keySet(), group)) {
                            iterator.remove();
                            LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(), nodeId);
                            stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup, group));
                        }
                    }
                }
            } else if (checkGroupPrecondition(installedGroups.keySet(), group)) {
                iterator.remove();
                installIncrement.put(group.getGroupId().getValue(), group);
                stepPlan.getItemsToPush().add(group);
            }
        }
        if (!stepPlan.isEmpty()) {
            // atomic update of installed flows in order to keep plan portions clean of local group dependencies
            installedGroups.putAll(installIncrement);
            plan.add(stepPlan);
        } else if (!pendingGroups.isEmpty()) {
            LOG.warn("Failed to resolve and divide groups into preconditions-match based ordered plan: {}, " + "resolving stuck at level {}", nodeId.getValue(), plan.size());
            throw new IllegalStateException("Failed to resolve and divide groups when matching preconditions");
        }
    }
    return plan;
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 48 with Group

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

the class MQCreateAction method createDTO.

private MQBrokerConfigDTO createDTO() {
    if (Strings.isNullOrBlank(username)) {
        username = ShellUtils.retrieveFabricUser(session);
    }
    if (Strings.isNullOrBlank(password)) {
        password = ShellUtils.retrieveFabricUserPassword(session);
    }
    MQBrokerConfigDTO dto = new MQBrokerConfigDTO();
    if (config != null) {
        dto.setConfigUrl(config);
    } else {
        if (nossl) {
            dto.setConfigUrl("broker.xml");
        } else {
            dto.setConfigUrl("ssl-broker.xml");
        }
    }
    dto.setData(data);
    if (ports != null && ports.length > 0) {
        for (String port : ports) {
            addConfig(port, dto.getPorts());
        }
    }
    dto.setGroup(group);
    dto.setJvmOpts(jvmOpts);
    dto.setBrokerName(name);
    dto.setProfile(profile);
    dto.setClientProfile(clientProfile);
    dto.setClientParentProfile(clientParentProfile);
    dto.setNetworks(networks);
    dto.setNetworksPassword(networksPassword);
    dto.setNetworksUserName(networksUserName);
    dto.setParentProfile(parentProfile);
    dto.setProperties(properties);
    if (version == null) {
        version = fabricService.getDefaultVersionId();
    }
    dto.setVersion(version);
    dto.setMinimumInstances(minimumInstances);
    dto.setReplicas(replicas);
    dto.setSsl(!nossl);
    dto.setKind(kind);
    return dto;
}
Also used : MQBrokerConfigDTO(io.fabric8.api.jmx.MQBrokerConfigDTO)

Example 49 with Group

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

the class GitMasterListener method updateMasterUrl.

/**
 * Updates the git master url, if needed.
 */
private void updateMasterUrl(Group<GitNode> group) {
    GitNode master = group.master();
    String masterUrl = master != null ? master.getUrl() : null;
    try {
        if (masterUrl != null) {
            GitService gitservice = gitService.get();
            String substitutedUrl = getSubstitutedData(curator.get(), masterUrl);
            if (!Strings.isNotBlank(substitutedUrl)) {
                LOGGER.warn("Could not render git master URL {}.", masterUrl);
            }
            // Catch any possible issue indicating that the URL is invalid.
            if (!FabricValidations.isURIValid(substitutedUrl)) {
                LOGGER.warn("Not changing master Git URL to \"" + substitutedUrl + "\". There may be pending ZK connection shutdown.");
            } else {
                gitservice.notifyRemoteChanged(substitutedUrl);
            }
        }
    } catch (Exception e) {
        LOGGER.error("Failed to point origin to the new master.", e);
    }
}
Also used : GitService(io.fabric8.git.GitService) GitNode(io.fabric8.git.GitNode) IOException(java.io.IOException)

Example 50 with Group

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

the class GitHttpServerRegistrationHandler method activate.

@Activate
void activate(Map<String, ?> configuration) throws Exception {
    RuntimeProperties sysprops = runtimeProperties.get();
    realm = getConfiguredRealm(sysprops, configuration);
    roles = getConfiguredRoles(sysprops, configuration);
    dataPath = sysprops.getDataPath();
    activateComponent();
    group = new ZooKeeperGroup<GitNode>(curator.get(), ZkPath.GIT.getPath(), GitNode.class, new NamedThreadFactory("zkgroup-git-httpreg"));
    // if anything went wrong in a previous deactivation we still have to clean up the registry
    zkCleanUp(group);
    group.add(this);
    group.update(createState());
    group.start();
}
Also used : NamedThreadFactory(io.fabric8.utils.NamedThreadFactory) GitNode(io.fabric8.git.GitNode) RuntimeProperties(io.fabric8.api.RuntimeProperties) Activate(org.apache.felix.scr.annotations.Activate)

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