use of co.cask.cdap.proto.ConfigEntry in project cdap by caskdata.
the class ConfigService method toConfigEntries.
private List<ConfigEntry> toConfigEntries(Configuration configuration) {
List<ConfigEntry> result = Lists.newArrayList();
for (Map.Entry<String, String> entry : configuration) {
String source = getFirstElement(configuration.getPropertySources(entry.getKey()));
result.add(new ConfigEntry(entry.getKey(), entry.getValue(), source));
}
return result;
}
use of co.cask.cdap.proto.ConfigEntry in project cdap by caskdata.
the class IntegrationTestBase method assertUnrecoverableResetEnabled.
private void assertUnrecoverableResetEnabled() throws IOException, UnauthenticatedException, UnauthorizedException {
ConfigEntry configEntry = getMetaClient().getCDAPConfig().get(Constants.Dangerous.UNRECOVERABLE_RESET);
Preconditions.checkNotNull(configEntry, "Missing key from CDAP Configuration: %s", Constants.Dangerous.UNRECOVERABLE_RESET);
Preconditions.checkState(Boolean.parseBoolean(configEntry.getValue()), "UnrecoverableReset not enabled.");
}
use of co.cask.cdap.proto.ConfigEntry in project cdap by caskdata.
the class MetaClientTestRun method testAll.
@Test
public void testAll() throws IOException, UnauthenticatedException, UnauthorizedException {
MetaClient metaClient = new MetaClient(clientConfig);
metaClient.ping();
Version version = metaClient.getVersion();
String expectedVersion = Resources.toString(Resources.getResource("VERSION"), Charsets.UTF_8).trim();
Assert.assertEquals(expectedVersion, version.getVersion());
// check a key that we know exists, to ensure that we retrieved the configurations
Map<String, ConfigEntry> cdapConfig = metaClient.getCDAPConfig();
ConfigEntry configEntry = cdapConfig.get(Constants.Dangerous.UNRECOVERABLE_RESET);
Assert.assertNotNull(configEntry);
Assert.assertEquals(Constants.Dangerous.UNRECOVERABLE_RESET, configEntry.getName());
Assert.assertNotNull(configEntry.getValue());
Map<String, ConfigEntry> hadoopConfig = metaClient.getHadoopConfig();
configEntry = hadoopConfig.get("hadoop.tmp.dir");
Assert.assertNotNull(configEntry);
Assert.assertEquals("hadoop.tmp.dir", configEntry.getName());
Assert.assertNotNull(configEntry.getValue());
}
use of co.cask.cdap.proto.ConfigEntry in project cdap by caskdata.
the class ConfigServiceTest method testConfig.
@Test
public void testConfig() {
String cConfResourceString = "<configuration>\n" + "\n" + " <property>\n" + " <name>stream.zz.threshold</name>\n" + " <value>1</value>\n" + " <description>Some description</description>\n" + " </property>\n" + "\n" + "</configuration>";
ReaderInputStream cConfResource = new ReaderInputStream(new StringReader(cConfResourceString));
CConfiguration cConf = CConfiguration.create(cConfResource);
ConfigEntry cConfEntry = new ConfigEntry("stream.zz.threshold", "1", cConfResource.toString());
// hConf
Configuration hConf = new Configuration();
String hConfResourceString = "<configuration>\n" + "\n" + " <property>\n" + " <name>stream.notification.threshold</name>\n" + " <value>3</value>\n" + " <description>Some description</description>\n" + " </property>\n" + "\n" + "</configuration>";
ReaderInputStream hConfResource = new ReaderInputStream(new StringReader(hConfResourceString));
hConf.addResource(hConfResource);
ConfigEntry hConfEntry = new ConfigEntry("stream.notification.threshold", "3", hConfResource.toString());
// test
ConfigService configService = new ConfigService(cConf, hConf);
List<ConfigEntry> cConfEntries = configService.getCConf();
Assert.assertTrue(cConfEntries.contains(cConfEntry));
List<ConfigEntry> hConfEntries = configService.getHConf();
Assert.assertTrue(hConfEntries.contains(hConfEntry));
}
use of co.cask.cdap.proto.ConfigEntry in project cdap by caskdata.
the class MetaClient method getConfig.
private Map<String, ConfigEntry> getConfig(String url) throws IOException, UnauthenticatedException, UnauthorizedException {
HttpResponse response = restClient.execute(HttpMethod.GET, config.resolveURL(url), config.getAccessToken());
List<ConfigEntry> responseObject = ObjectResponse.fromJsonBody(response, new TypeToken<List<ConfigEntry>>() {
}).getResponseObject();
Map<String, ConfigEntry> config = Maps.newHashMap();
for (ConfigEntry configEntry : responseObject) {
config.put(configEntry.getName(), configEntry);
}
return config;
}
Aggregations