Search in sources :

Example 1 with ConfigEntry

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;
}
Also used : ConfigEntry(co.cask.cdap.proto.ConfigEntry) Map(java.util.Map)

Example 2 with ConfigEntry

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.");
}
Also used : ConfigEntry(co.cask.cdap.proto.ConfigEntry)

Example 3 with ConfigEntry

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());
}
Also used : ConfigEntry(co.cask.cdap.proto.ConfigEntry) Version(co.cask.cdap.proto.Version) Test(org.junit.Test)

Example 4 with ConfigEntry

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));
}
Also used : ReaderInputStream(org.apache.commons.io.input.ReaderInputStream) ConfigEntry(co.cask.cdap.proto.ConfigEntry) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) StringReader(java.io.StringReader) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Test(org.junit.Test)

Example 5 with ConfigEntry

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;
}
Also used : ConfigEntry(co.cask.cdap.proto.ConfigEntry) TypeToken(com.google.common.reflect.TypeToken) HttpResponse(co.cask.common.http.HttpResponse)

Aggregations

ConfigEntry (co.cask.cdap.proto.ConfigEntry)6 Map (java.util.Map)2 Test (org.junit.Test)2 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 Version (co.cask.cdap.proto.Version)1 HttpResponse (co.cask.common.http.HttpResponse)1 TypeToken (com.google.common.reflect.TypeToken)1 StringReader (java.io.StringReader)1 ReaderInputStream (org.apache.commons.io.input.ReaderInputStream)1 Configuration (org.apache.hadoop.conf.Configuration)1