Search in sources :

Example 1 with MicroserviceConfigLoader

use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.

the class TestConfigUtil method testCreateDynamicConfigNoConfigCenterSPI.

@Test
public void testCreateDynamicConfigNoConfigCenterSPI() {
    new Expectations(SPIServiceUtils.class) {

        {
            SPIServiceUtils.getTargetService(ConfigCenterConfigurationSource.class);
            result = null;
        }
    };
    AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
    MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader(dynamicConfig);
    List<ConfigModel> list = loader.getConfigModels();
    Assert.assertEquals(loader, ConfigUtil.getMicroserviceConfigLoader(dynamicConfig));
    Assert.assertEquals(1, list.size());
    Assert.assertNotEquals(DynamicWatchedConfiguration.class, ((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
Also used : Expectations(mockit.Expectations) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigModel(org.apache.servicecomb.config.archaius.sources.ConfigModel) MicroserviceConfigLoader(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) Test(org.junit.Test)

Example 2 with MicroserviceConfigLoader

use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.

the class RegistryUtils method init.

public static void init() {
    MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
    MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
    serviceRegistry = ServiceRegistryFactory.getOrCreate(EventManager.eventBus, ServiceRegistryConfig.INSTANCE, microserviceDefinition);
    serviceRegistry.init();
}
Also used : MicroserviceConfigLoader(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader) MicroserviceDefinition(org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition)

Example 3 with MicroserviceConfigLoader

use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.

the class TestMicroserviceFactory method testInit.

@Test
public void testInit() {
    MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
    loader.loadAndSort();
    MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
    MicroserviceFactory factory = new MicroserviceFactory();
    Microservice microservice = factory.create(microserviceDefinition);
    String microserviceName = "default";
    Assert.assertEquals(microserviceName, microservice.getServiceName());
}
Also used : MicroserviceConfigLoader(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader) MicroserviceDefinition(org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition) Test(org.junit.Test)

Example 4 with MicroserviceConfigLoader

use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project java-chassis by ServiceComb.

the class ConfigUtil method createLocalConfig.

public static ConcurrentCompositeConfiguration createLocalConfig() {
    MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
    loader.loadAndSort();
    if (localConfig.size() > 0) {
        ConfigModel model = new ConfigModel();
        model.setConfig(localConfig);
        loader.getConfigModels().add(model);
    }
    boolean isPrintUrl = DynamicPropertyFactory.getInstance().getBooleanProperty(IS_PRINT_URL, true).get();
    if (isPrintUrl) {
        LOGGER.info("create local config from paths=[{}]", StringUtils.join(loader.getConfigModels(), ","));
    }
    ConcurrentCompositeConfiguration config = ConfigUtil.createLocalConfig(loader.getConfigModels());
    return config;
}
Also used : ConfigModel(org.apache.servicecomb.config.archaius.sources.ConfigModel) MicroserviceConfigLoader(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration)

Example 5 with MicroserviceConfigLoader

use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.

the class ServiceRegistryFactory method createLocal.

public static ServiceRegistry createLocal() {
    EventBus eventBus = new EventBus();
    ServiceRegistryConfig serviceRegistryConfig = ServiceRegistryConfig.INSTANCE;
    MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
    loader.loadAndSort();
    MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
    return new LocalServiceRegistry(eventBus, serviceRegistryConfig, microserviceDefinition);
}
Also used : ServiceRegistryConfig(org.apache.servicecomb.serviceregistry.config.ServiceRegistryConfig) MicroserviceConfigLoader(org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader) MicroserviceDefinition(org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition) EventBus(com.google.common.eventbus.EventBus)

Aggregations

MicroserviceConfigLoader (org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader)8 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)3 ConfigModel (org.apache.servicecomb.config.archaius.sources.ConfigModel)3 MicroserviceDefinition (org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition)3 Test (org.junit.Test)3 List (java.util.List)2 Map (java.util.Map)2 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)2 EventBus (com.google.common.eventbus.EventBus)1 Subscribe (com.google.common.eventbus.Subscribe)1 ConfigurationManager (com.netflix.config.ConfigurationManager)1 DynamicPropertyFactory (com.netflix.config.DynamicPropertyFactory)1 WatchedUpdateResult (com.netflix.config.WatchedUpdateResult)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Properties (java.util.Properties)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 Expectations (mockit.Expectations)1