Search in sources :

Example 86 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class AdminConfig method setLogLevels.

public void setLogLevels() throws IOException {
    String logLevel = System.getProperty(TEST_LOGLEVEL_PROPERTY);
    String securityLogLevel = System.getProperty(TEST_SECURITYLOGLEVEL_PROPERTY);
    Configuration logConfig = configAdmin.getConfiguration(LOG_CONFIG_PID, null);
    Dictionary<String, Object> properties = logConfig.getProperties();
    properties.put(LOGGER_PREFIX + "*", DEFAULT_LOG_LEVEL);
    if (!StringUtils.isEmpty(logLevel)) {
        properties.put(LOGGER_PREFIX + "ddf", logLevel);
        properties.put(LOGGER_PREFIX + "org.codice", logLevel);
        if (StringUtils.isEmpty(securityLogLevel)) {
            properties.put(LOGGER_PREFIX + "ddf.security.expansion.impl.RegexExpansion", logLevel);
            properties.put(LOGGER_PREFIX + "ddf.security.service.impl.AbstractAuthorizingRealm", logLevel);
        }
    }
    logConfig.update(properties);
}
Also used : Configuration(org.osgi.service.cm.Configuration)

Example 87 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class ServiceManagerImpl method createManagedService.

@Override
public Configuration createManagedService(String factoryPid, Map<String, Object> properties) throws IOException {
    Configuration sourceConfig = adminConfig.createFactoryConfiguration(factoryPid, null);
    startManagedService(sourceConfig, properties);
    return sourceConfig;
}
Also used : Configuration(org.osgi.service.cm.Configuration)

Example 88 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class SynchronizedConfiguration method updateConfig.

public final void updateConfig() throws Exception {
    Configuration config = configAdmin.getConfiguration(pid, location);
    config.update(new Hashtable<>(configProps));
    long timeoutLimit = System.currentTimeMillis() + CONFIG_UPDATE_MAX_WAIT_MILLIS;
    boolean retried = false;
    while (true) {
        if (configCallable.call()) {
            break;
        } else {
            //if it still keeps failing then we should remove this
            if (!retried && System.currentTimeMillis() > timeoutLimit - CONFIG_UPDATE_MAX_WAIT_MILLIS / 2) {
                config.update(new Hashtable<>(configProps));
                retried = true;
            }
            if (System.currentTimeMillis() > timeoutLimit) {
                fail(String.format("Timed out waiting for configuration change for %s", pid));
            } else {
                Thread.sleep(LOOP_SLEEP_MILLIS);
            }
        }
    }
}
Also used : Configuration(org.osgi.service.cm.Configuration)

Example 89 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class SystemStateManager method captureSystemState.

private void captureSystemState() {
    LOGGER.info("Capturing system state");
    try {
        baseFeatures = Arrays.stream(features.listInstalledFeatures()).map(e -> e.getName()).collect(Collectors.toList());
        Configuration[] configs = adminConfig.listConfigurations(CONFIGURATION_FILTER);
        for (Configuration config : configs) {
            baseConfigurations.put(config.getPid(), config);
        }
        console.runCommand("catalog:export --provider --force --skip-signature-verification --delete=false --output \"./itest-catalog-entries.zip\" --cql \"\\\"metacard-tags\\\" like '*'\"");
        LOGGER.info("Feature Count: {}", baseFeatures.size());
        LOGGER.info("Configuration Count: {}", baseConfigurations.size());
    } catch (Exception e) {
        LOGGER.error("Error capturing system configuration.", e);
    }
}
Also used : Configuration(org.osgi.service.cm.Configuration)

Example 90 with Configuration

use of org.osgi.service.cm.Configuration in project ddf by codice.

the class ServiceManagerImpl method stopManagedService.

@Override
public void stopManagedService(String servicePid) throws IOException {
    Configuration sourceConfig = adminConfig.getConfiguration(servicePid, null);
    ServiceManagerImpl.ServiceConfigurationListener listener = new ServiceManagerImpl.ServiceConfigurationListener(sourceConfig.getPid());
    adminConfig.getDdfConfigAdmin().delete(sourceConfig.getPid());
}
Also used : Configuration(org.osgi.service.cm.Configuration)

Aggregations

Configuration (org.osgi.service.cm.Configuration)226 Test (org.junit.Test)85 Hashtable (java.util.Hashtable)75 IOException (java.io.IOException)55 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)49 Dictionary (java.util.Dictionary)36 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)19 ServiceReference (org.osgi.framework.ServiceReference)19 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)18 Matchers.anyString (org.mockito.Matchers.anyString)16 BundleContext (org.osgi.framework.BundleContext)15 RegistrySourceConfiguration (org.codice.ddf.registry.federationadmin.service.internal.RegistrySourceConfiguration)11 Map (java.util.Map)10 Bundle (org.osgi.framework.Bundle)10 File (java.io.File)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)9 Mockito.anyString (org.mockito.Mockito.anyString)9 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)8 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)7