Java Code Examples for org.apache.atlas.ApplicationProperties#getSubsetConfiguration()

The following examples show how to use org.apache.atlas.ApplicationProperties#getSubsetConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Titan1GraphDatabase.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public static Configuration getConfiguration() throws AtlasException {
    Configuration configProperties = ApplicationProperties.get();

    Configuration titanConfig = ApplicationProperties.getSubsetConfiguration(configProperties, GRAPH_PREFIX);

    //add serializers for non-standard property value types that Atlas uses

    titanConfig.addProperty("attributes.custom.attribute1.attribute-class", TypeCategory.class.getName());
    titanConfig.addProperty("attributes.custom.attribute1.serializer-class",
            TypeCategorySerializer.class.getName());

    //not ideal, but avoids making large changes to Atlas
    titanConfig.addProperty("attributes.custom.attribute2.attribute-class", ArrayList.class.getName());
    titanConfig.addProperty("attributes.custom.attribute2.serializer-class", StringListSerializer.class.getName());

    titanConfig.addProperty("attributes.custom.attribute3.attribute-class", BigInteger.class.getName());
    titanConfig.addProperty("attributes.custom.attribute3.serializer-class", BigIntegerSerializer.class.getName());

    titanConfig.addProperty("attributes.custom.attribute4.attribute-class", BigDecimal.class.getName());
    titanConfig.addProperty("attributes.custom.attribute4.serializer-class", BigDecimalSerializer.class.getName());

    return titanConfig;
}
 
Example 2
Source File: AtlasJanusGraphDatabase.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static Configuration getConfiguration() throws AtlasException {
    startLocalSolr();

    Configuration configProperties = ApplicationProperties.get();

    if (isEmbeddedSolr()) { // AtlasJanusGraphIndexClient.performRequestHandlerAction() fails for embedded-solr; disable freetext until this issue is resolved
        configProperties.setProperty(ApplicationProperties.ENABLE_FREETEXT_SEARCH_CONF, false);
    }

    configProperties.setProperty(SOLR_ZOOKEEPER_URLS, configProperties.getStringArray(SOLR_ZOOKEEPER_URL));

    Configuration janusConfig = ApplicationProperties.getSubsetConfiguration(configProperties, GRAPH_PREFIX);

    //add serializers for non-standard property value types that Atlas uses
    janusConfig.addProperty("attributes.custom.attribute1.attribute-class", TypeCategory.class.getName());
    janusConfig.addProperty("attributes.custom.attribute1.serializer-class", TypeCategorySerializer.class.getName());

    //not ideal, but avoids making large changes to Atlas
    janusConfig.addProperty("attributes.custom.attribute2.attribute-class", ArrayList.class.getName());
    janusConfig.addProperty("attributes.custom.attribute2.serializer-class", SerializableSerializer.class.getName());

    janusConfig.addProperty("attributes.custom.attribute3.attribute-class", BigInteger.class.getName());
    janusConfig.addProperty("attributes.custom.attribute3.serializer-class", BigIntegerSerializer.class.getName());

    janusConfig.addProperty("attributes.custom.attribute4.attribute-class", BigDecimal.class.getName());
    janusConfig.addProperty("attributes.custom.attribute4.serializer-class", BigDecimalSerializer.class.getName());

    return janusConfig;
}
 
Example 3
Source File: JanusGraphProviderTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@BeforeTest
public void setUp() throws Exception {
    GraphSandboxUtil.create();

    //First get Instance
    graph         = new AtlasJanusGraph();
    configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), AtlasJanusGraphDatabase.GRAPH_PREFIX);
}
 
Example 4
Source File: EmbeddedKafkaServer.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Inject
public EmbeddedKafkaServer(Configuration applicationProperties) throws AtlasException {
    Configuration kafkaConf = ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX);

    this.isEmbedded = applicationProperties.getBoolean(PROPERTY_EMBEDDED, false);
    this.properties = ConfigurationConverter.getProperties(kafkaConf);
}
 
Example 5
Source File: HBaseBasedAuditRepository.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Converts atlas' application properties to hadoop conf
 * @return
 * @throws AtlasException
 * @param atlasConf
 */
public static org.apache.hadoop.conf.Configuration getHBaseConfiguration(Configuration atlasConf) throws AtlasException {
    Configuration subsetAtlasConf =
            ApplicationProperties.getSubsetConfiguration(atlasConf, CONFIG_PREFIX);
    org.apache.hadoop.conf.Configuration hbaseConf = HBaseConfiguration.create();
    Iterator<String> keys = subsetAtlasConf.getKeys();
    while (keys.hasNext()) {
        String key = keys.next();
        hbaseConf.set(key, subsetAtlasConf.getString(key));
    }
    return hbaseConf;
}
 
Example 6
Source File: TitanGraphProviderTest.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@BeforeTest
public void setUp() throws AtlasException {
    GraphSandboxUtil.create();

    //First get Instance
    graph = new Titan1Graph();
    configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(),
            Titan1GraphDatabase.GRAPH_PREFIX);
}
 
Example 7
Source File: Titan0DatabaseValidationTest.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@BeforeTest
public void setUp() throws AtlasException {
    GraphSandboxUtil.create();

    // First get Instance
    graph = new Titan0Graph();
    configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(),
            Titan0GraphDatabase.GRAPH_PREFIX);
}
 
Example 8
Source File: KafkaNotification.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a KafkaNotification.
 *
 * @param applicationProperties  the application properties used to configure Kafka
 *
 * @throws AtlasException if the notification interface can not be created
 */
@Inject
public KafkaNotification(Configuration applicationProperties) throws AtlasException {
    super(applicationProperties);
    Configuration subsetConfiguration =
            ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX);
    properties = ConfigurationConverter.getProperties(subsetConfiguration);
    //override to store offset in kafka
    //todo do we need ability to replay?

    //Override default configs
    properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    pollTimeOutMs = subsetConfiguration.getLong("poll.timeout.ms", 1000);
    boolean oldApiCommitEnbleFlag = subsetConfiguration.getBoolean("auto.commit.enable",false);
    //set old autocommit value if new autoCommit property is not set.
    properties.put("enable.auto.commit", subsetConfiguration.getBoolean("enable.auto.commit", oldApiCommitEnbleFlag));
    properties.put("session.timeout.ms", subsetConfiguration.getString("session.timeout.ms", "30000"));

}
 
Example 9
Source File: KafkaNotification.java    From atlas with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a KafkaNotification.
 *
 * @param applicationProperties  the application properties used to configure Kafka
 *
 * @throws AtlasException if the notification interface can not be created
 */
@Inject
public KafkaNotification(Configuration applicationProperties) throws AtlasException {
    super(applicationProperties);

    LOG.info("==> KafkaNotification()");

    Configuration kafkaConf = ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX);

    properties             = ConfigurationConverter.getProperties(kafkaConf);
    pollTimeOutMs          = kafkaConf.getLong("poll.timeout.ms", 1000);
    consumerClosedErrorMsg = kafkaConf.getString("error.message.consumer_closed", DEFAULT_CONSUMER_CLOSED_ERROR_MESSAGE);

    //Override default configs
    properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    boolean oldApiCommitEnableFlag = kafkaConf.getBoolean("auto.commit.enable", false);

    //set old autocommit value if new autoCommit property is not set.
    properties.put("enable.auto.commit", kafkaConf.getBoolean("enable.auto.commit", oldApiCommitEnableFlag));
    properties.put("session.timeout.ms", kafkaConf.getString("session.timeout.ms", "30000"));

    if(applicationProperties.getBoolean(TLS_ENABLED, false)) {
        try {
            properties.put("ssl.truststore.password", getPassword(applicationProperties, TRUSTSTORE_PASSWORD_KEY));
        } catch (Exception e) {
            LOG.error("Exception while getpassword truststore.password ", e);
        }
    }

    // if no value is specified for max.poll.records, set to 1
    properties.put("max.poll.records", kafkaConf.getInt("max.poll.records", 1));

    setKafkaJAASProperties(applicationProperties, properties);

    LOG.info("<== KafkaNotification()");
}
 
Example 10
Source File: Titan0GraphDatabase.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
public static Configuration getConfiguration() throws AtlasException {
    Configuration configProperties = ApplicationProperties.get();
    return ApplicationProperties.getSubsetConfiguration(configProperties, GRAPH_PREFIX);
}