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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations