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;
}
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("-", "."));
}
}
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;
}
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);
}
use of org.apache.karaf.features.Feature in project ddf by codice.
the class ApplicationServiceBean method getInstallationProfiles.
@Override
public List<Map<String, Object>> getInstallationProfiles() {
try {
List<Feature> installationProfiles = appService.getInstallationProfiles();
List<Map<String, Object>> profiles = new ArrayList<>();
for (Feature profile : installationProfiles) {
Map<String, Object> profileMap = new HashMap<>();
profileMap.put(INSTALL_PROFILE_NAME, profile.getName());
profileMap.put(INSTALL_PROFILE_DESCRIPTION, profile.getDescription());
List<String> includedFeatures = new ArrayList<>();
profile.getDependencies().forEach(dep -> includedFeatures.add(dep.getName()));
profileMap.put(INSTALL_PROFILE_DEFAULT_APPLICATIONS, includedFeatures);
profiles.add(profileMap);
}
return profiles;
} catch (VirtualMachineError e) {
throw e;
} catch (Throwable e) {
LOGGER.info("Could not retrieve installation profiles", e);
throw new ApplicationServiceBeanException("Could not retrieve installation profiles");
}
}
Aggregations