Search in sources :

Example 1 with ConfigTable

use of org.apache.skywalking.oap.server.configuration.api.ConfigTable in project incubator-skywalking by apache.

the class ConfigmapConfigurationWatcherRegister method readConfig.

@Override
public Optional<ConfigTable> readConfig(Set<String> keys) {
    final ConfigTable configTable = new ConfigTable();
    Map<String, String> configMapData = informer.configMapData();
    for (final String name : keys) {
        final String value = configMapData.get(name);
        if (log.isDebugEnabled()) {
            log.debug("read config: name:{} ,value:{}", name, value);
        }
        configTable.add(new ConfigTable.ConfigItem(name, value));
    }
    return Optional.of(configTable);
}
Also used : ConfigTable(org.apache.skywalking.oap.server.configuration.api.ConfigTable) GroupConfigTable(org.apache.skywalking.oap.server.configuration.api.GroupConfigTable)

Example 2 with ConfigTable

use of org.apache.skywalking.oap.server.configuration.api.ConfigTable in project incubator-skywalking by apache.

the class ConfigmapConfigWatcherRegisterTest method readConfigWhenInformerWork.

@Test
public void readConfigWhenInformerWork() throws Exception {
    Map<String, String> configMapData = this.readMockConfigMapData();
    PowerMockito.doReturn(configMapData).when(informer).configMapData();
    Optional<ConfigTable> optionalConfigTable = register.readConfig(new HashSet<String>() {

        {
            add("agent-analyzer.default.slowDBAccessThreshold");
            add("alarm.default.alarm-settings");
            add("core.default.apdexThreshold");
            add("agent-analyzer.default.uninstrumentedGateways");
        }
    });
    Assert.assertTrue(optionalConfigTable.isPresent());
    ConfigTable configTable = optionalConfigTable.get();
    List<String> list = configTable.getItems().stream().map(ConfigTable.ConfigItem::getValue).filter(Objects::nonNull).collect(Collectors.toList());
    Assert.assertEquals(list.size(), 4);
}
Also used : GroupConfigTable(org.apache.skywalking.oap.server.configuration.api.GroupConfigTable) ConfigTable(org.apache.skywalking.oap.server.configuration.api.ConfigTable) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with ConfigTable

use of org.apache.skywalking.oap.server.configuration.api.ConfigTable in project incubator-skywalking by apache.

the class ApolloConfigWatcherRegister method readConfig.

@Override
public Optional<ConfigTable> readConfig(Set<String> keys) {
    final ConfigTable configTable = new ConfigTable();
    for (final String name : keys) {
        final String value = configReader.getProperty(name, null);
        configTable.add(new ConfigTable.ConfigItem(name, value));
    }
    return Optional.of(configTable);
}
Also used : ConfigTable(org.apache.skywalking.oap.server.configuration.api.ConfigTable) GroupConfigTable(org.apache.skywalking.oap.server.configuration.api.GroupConfigTable)

Example 4 with ConfigTable

use of org.apache.skywalking.oap.server.configuration.api.ConfigTable in project incubator-skywalking by apache.

the class ConsulConfigurationWatcherRegister method readConfig.

@Override
public Optional<ConfigTable> readConfig(Set<String> keys) {
    removeUninterestedKeys(keys);
    registerKeyListeners(keys);
    final ConfigTable table = new ConfigTable();
    configItemKeyedByName.forEach((key, value) -> {
        if (value.isPresent()) {
            table.add(new ConfigTable.ConfigItem(key, value.get()));
        } else {
            table.add(new ConfigTable.ConfigItem(key, null));
        }
    });
    return Optional.of(table);
}
Also used : GroupConfigTable(org.apache.skywalking.oap.server.configuration.api.GroupConfigTable) ConfigTable(org.apache.skywalking.oap.server.configuration.api.ConfigTable)

Example 5 with ConfigTable

use of org.apache.skywalking.oap.server.configuration.api.ConfigTable in project incubator-skywalking by apache.

the class NacosConfigWatcherRegisterTest method shouldReadConfigs.

@Test
public void shouldReadConfigs() throws NacosException {
    final String group = "skywalking";
    final String testKey1 = "agent-analyzer.default.slowDBAccessThreshold";
    final String testVal1 = "test";
    final String testKey2 = "testKey";
    final String testVal2 = "testVal";
    final NacosServerSettings mockSettings = mock(NacosServerSettings.class);
    when(mockSettings.getGroup()).thenReturn(group);
    when(mockSettings.getNamespace()).thenReturn("");
    final NacosConfigWatcherRegister mockRegister = spy(new NacosConfigWatcherRegister(mockSettings));
    final ConfigService mockConfigService = mock(ConfigService.class);
    when(mockConfigService.getConfig(testKey1, group, 1000)).thenReturn(testVal1);
    when(mockConfigService.getConfig(testKey2, group, 1000)).thenReturn(testVal2);
    Whitebox.setInternalState(mockRegister, "configService", mockConfigService);
    final ConfigTable configTable = mockRegister.readConfig(Sets.newHashSet(testKey1, testKey2)).get();
    assertEquals(2, configTable.getItems().size());
    Map<String, String> kvs = new HashMap<>();
    for (ConfigTable.ConfigItem item : configTable.getItems()) {
        kvs.put(item.getName(), item.getValue());
    }
    assertEquals(testVal1, kvs.get(testKey1));
    assertEquals(testVal2, kvs.get(testKey2));
}
Also used : ConfigService(com.alibaba.nacos.api.config.ConfigService) HashMap(java.util.HashMap) ConfigTable(org.apache.skywalking.oap.server.configuration.api.ConfigTable) Test(org.junit.Test)

Aggregations

ConfigTable (org.apache.skywalking.oap.server.configuration.api.ConfigTable)26 GroupConfigTable (org.apache.skywalking.oap.server.configuration.api.GroupConfigTable)22 Test (org.junit.Test)10 ChildData (org.apache.curator.framework.recipes.cache.ChildData)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 HashMap (java.util.HashMap)4 ConfigService (com.alibaba.nacos.api.config.ConfigService)2 GetResponse (io.etcd.jetcd.kv.GetResponse)2 Map (java.util.Map)2 Optional (java.util.Optional)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 PathChildrenCache (org.apache.curator.framework.recipes.cache.PathChildrenCache)2 ConfigurationRequest (org.apache.skywalking.oap.server.configuration.service.ConfigurationRequest)2 ConfigurationResponse (org.apache.skywalking.oap.server.configuration.service.ConfigurationResponse)2 GroupConfigurationResponse (org.apache.skywalking.oap.server.configuration.service.GroupConfigurationResponse)2 ZookeeperServerSettings (org.apache.skywalking.oap.server.configuration.zookeeper.ZookeeperServerSettings)2