Search in sources :

Example 61 with Feature

use of org.apache.karaf.features.Feature in project controller by opendaylight.

the class ConfigPushingRunnable method run.

@Override
@SuppressWarnings("IllegalCatch")
public void run() {
    List<Feature> toInstall = new ArrayList<>();
    FeatureEvent event = null;
    boolean interrupted = false;
    while (true) {
        try {
            if (!interrupted) {
                if (toInstall.isEmpty()) {
                    event = queue.take();
                } else {
                    event = queue.poll(POLL_TIME, TimeUnit.MILLISECONDS);
                }
                if (event != null && event.getFeature() != null) {
                    processFeatureEvent(event, toInstall);
                }
            } else if (toInstall.isEmpty()) {
                LOG.error("ConfigPushingRunnable - exiting");
                return;
            }
        } catch (final InterruptedException e) {
            LOG.error("ConfigPushingRunnable - interrupted");
            interrupted = true;
        } catch (final Exception e) {
            LOG.error("Exception while processing features {} event {}", toInstall, event, e);
        }
    }
}
Also used : FeatureEvent(org.apache.karaf.features.FeatureEvent) ArrayList(java.util.ArrayList) Feature(org.apache.karaf.features.Feature)

Example 62 with Feature

use of org.apache.karaf.features.Feature in project admin-console-beta by connexta.

the class CreateFeatureDependencyGraph method createFeatureDependenciesGraph.

private DirectedGraph<Field, DependencyEdge> createFeatureDependenciesGraph(List<FeatureField> features) {
    DirectedGraph<Field, DependencyEdge> graph = new DirectedPseudograph<>(DependencyEdge.class);
    FEATURE_BUNDLE_VERTEX_PROV.getAttributes().forEach(attri -> exporter.registerAttribute(attri.getAttriName(), attri.getCategory(), attri.getType()));
    features.forEach(graph::addVertex);
    Map<String, FeatureField> featuresById = features.stream().collect(Collectors.toMap(FeatureField::id, f -> f));
    for (FeatureField feature : features) {
        for (String featId : feature.featDeps()) {
            try {
                Feature feat = featureUtils.getFeature(featId);
                if (feat != null && featuresById.containsKey(feat.getId())) {
                    graph.addEdge(feature, featuresById.get(feat.getId()), DependencyEdge.create(null));
                } else {
                    LOGGER.error("Failed to find feature {} while creating feature dependency graph.", featId);
                }
            } catch (Exception e) {
                LOGGER.error("Failed to find feature {} while creating feature dependency graph.", featId, e);
            }
        }
        feature.bundleDeps().forEach(dep -> {
            graph.addVertex(dep);
            graph.addEdge(feature, dep, DependencyEdge.create(null));
        });
    }
    return graph;
}
Also used : DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph) LoggerFactory(org.slf4j.LoggerFactory) DIRECTORY_DOES_NOT_EXIST(org.codice.ddf.admin.common.report.message.DefaultMessages.DIRECTORY_DOES_NOT_EXIST) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) DefaultMessages.failedPersistError(org.codice.ddf.admin.common.report.message.DefaultMessages.failedPersistError) ImmutableList(com.google.common.collect.ImmutableList) FAILED_PERSIST(org.codice.ddf.admin.common.report.message.DefaultMessages.FAILED_PERSIST) Map(java.util.Map) BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) FunctionField(org.codice.ddf.admin.api.fields.FunctionField) Field(org.codice.ddf.admin.api.Field) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) BaseFunctionField(org.codice.ddf.admin.common.fields.base.BaseFunctionField) Feature(org.apache.karaf.features.Feature) Set(java.util.Set) GraphMLExporter(org.jgrapht.ext.GraphMLExporter) Collectors(java.util.stream.Collectors) FeatureUtils(org.codice.ddf.admin.query.dev.system.dependency.FeatureUtils) List(java.util.List) Paths(java.nio.file.Paths) DependencyEdge(org.codice.ddf.admin.query.dev.system.graph.DependencyEdge) DirectedGraph(org.jgrapht.DirectedGraph) FeatureGraphProvider(org.codice.ddf.admin.query.dev.system.graph.FeatureGraphProvider) DirectoryField(org.codice.ddf.admin.common.fields.common.DirectoryField) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) FunctionField(org.codice.ddf.admin.api.fields.FunctionField) Field(org.codice.ddf.admin.api.Field) BaseFunctionField(org.codice.ddf.admin.common.fields.base.BaseFunctionField) DirectoryField(org.codice.ddf.admin.common.fields.common.DirectoryField) DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) DependencyEdge(org.codice.ddf.admin.query.dev.system.graph.DependencyEdge) Feature(org.apache.karaf.features.Feature) DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph)

Example 63 with Feature

use of org.apache.karaf.features.Feature in project ignite by apache.

the class IgniteKarafFeaturesInstallationTest method testAllBundlesActiveAndFeaturesInstalled.

/**
 * @throws Exception
 */
@Test
public void testAllBundlesActiveAndFeaturesInstalled() throws Exception {
    // Asssert all bundles except fragments are ACTIVE.
    for (Bundle b : bundleCtx.getBundles()) {
        System.out.println(String.format("Checking state of bundle [symbolicName=%s, state=%s]", b.getSymbolicName(), b.getState()));
        if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null)
            assertTrue(b.getState() == Bundle.ACTIVE);
    }
    // Check that according to the FeaturesService, all Ignite features except ignite-log4j are installed.
    Feature[] features = featuresSvc.getFeatures(IGNITE_FEATURES_NAME_REGEX);
    assertNotNull(features);
    assertEquals(EXPECTED_FEATURES, features.length);
    for (Feature f : features) {
        if (IGNORED_FEATURES.contains(f.getName()))
            continue;
        boolean installed = featuresSvc.isInstalled(f);
        System.out.println(String.format("Checking if feature is installed [featureName=%s, installed=%s]", f.getName(), installed));
        assertTrue(installed);
        assertEquals(PROJECT_VERSION.replaceAll("-", "."), f.getVersion().replaceAll("-", "."));
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Example 64 with Feature

use of org.apache.karaf.features.Feature in project ddf by codice.

the class ProfileInstallCommandTest method createMockFeature.

private Feature createMockFeature(String name) {
    Feature feature = mock(Feature.class);
    when(feature.getName()).thenReturn(name);
    when(feature.getVersion()).thenReturn("0.0.0");
    return feature;
}
Also used : Feature(org.apache.karaf.features.Feature)

Example 65 with Feature

use of org.apache.karaf.features.Feature in project ddf by codice.

the class ProfileInstallCommandTest method testUninstallInstallerFailure.

@Test(expected = Exception.class)
public void testUninstallInstallerFailure() throws Exception {
    Feature installerFeature = createMockFeature("admin-modules-installer");
    this.featuresService = mock(FeaturesService.class);
    when(featuresService.getFeature(anyString())).thenReturn(installerFeature);
    when(featuresService.isInstalled(installerFeature)).thenReturn(true);
    doThrow(Exception.class).when(featuresService).uninstallFeature("admin-modules-installer", "0.0.0", NO_AUTO_REFRESH);
    profileInstallCommand.profileName = "invalidStopBundles";
    profileInstallCommand.doExecute(applicationService, featuresService, bundleService);
}
Also used : FeaturesService(org.apache.karaf.features.FeaturesService) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Aggregations

Feature (org.apache.karaf.features.Feature)127 Test (org.junit.Test)56 FeaturesService (org.apache.karaf.features.FeaturesService)43 HashSet (java.util.HashSet)41 Repository (org.apache.karaf.features.Repository)39 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)18 Bundle (org.osgi.framework.Bundle)18 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 Map (java.util.Map)16 Dependency (org.apache.karaf.features.Dependency)15 BundleInfo (org.apache.karaf.features.BundleInfo)14 Application (org.codice.ddf.admin.application.service.Application)14 URI (java.net.URI)13 IOException (java.io.IOException)12 VersionRange (org.apache.felix.utils.version.VersionRange)12 LinkedHashSet (java.util.LinkedHashSet)11 Version (org.osgi.framework.Version)11 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)10 EnumSet (java.util.EnumSet)9