Search in sources :

Example 1 with Configurations

use of org.apache.metron.common.configuration.Configurations in project metron by apache.

the class SolrIndexingIntegrationTest method getSearchComponent.

@Override
public InMemoryComponent getSearchComponent(final Properties topologyProperties) throws Exception {
    SolrComponent solrComponent = new SolrComponent.Builder().addCollection(collection, "../metron-solr/src/test/resources/solr/conf").withPostStartCallback(new Function<SolrComponent, Void>() {

        @Nullable
        @Override
        public Void apply(@Nullable SolrComponent solrComponent) {
            topologyProperties.setProperty("solr.zk", solrComponent.getZookeeperUrl());
            try {
                String testZookeeperUrl = topologyProperties.getProperty(ZKServerComponent.ZOOKEEPER_PROPERTY);
                Configurations configurations = SampleUtil.getSampleConfigs();
                Map<String, Object> globalConfig = configurations.getGlobalConfig();
                globalConfig.put("solr.zookeeper", solrComponent.getZookeeperUrl());
                ConfigurationsUtils.writeGlobalConfigToZookeeper(JSONUtils.INSTANCE.toJSONPretty(globalConfig), testZookeeperUrl);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    }).build();
    return solrComponent;
}
Also used : Function(com.google.common.base.Function) SolrComponent(org.apache.metron.solr.integration.components.SolrComponent) Configurations(org.apache.metron.common.configuration.Configurations) Nullable(javax.annotation.Nullable) IOException(java.io.IOException)

Example 2 with Configurations

use of org.apache.metron.common.configuration.Configurations in project metron by apache.

the class BaseValidationTest method getConfiguration.

public Configurations getConfiguration(String config) throws IOException {
    Configurations configurations = new Configurations();
    configurations.updateGlobalConfig(Bytes.toBytes(config));
    return configurations;
}
Also used : Configurations(org.apache.metron.common.configuration.Configurations)

Example 3 with Configurations

use of org.apache.metron.common.configuration.Configurations in project metron by apache.

the class BaseValidationTest method execute.

public boolean execute(String config, Map<String, Object> input) throws IOException {
    Configurations configurations = getConfiguration(config);
    FieldValidator validator = getValidator(configurations);
    return validator.isValid(new JSONObject(input), configurations.getGlobalConfig(), Context.EMPTY_CONTEXT());
}
Also used : JSONObject(org.json.simple.JSONObject) FieldValidator(org.apache.metron.common.configuration.FieldValidator) Configurations(org.apache.metron.common.configuration.Configurations)

Example 4 with Configurations

use of org.apache.metron.common.configuration.Configurations in project metron by apache.

the class SolrIndexingIntegrationTest method getSearchComponent.

@Override
public InMemoryComponent getSearchComponent(final Properties topologyProperties) throws Exception {
    SolrComponent solrComponent = new SolrComponent.Builder().addInitialCollection(collection, "../metron-solr-common/src/main/config/schema/yaf").withPostStartCallback(new Function<SolrComponent, Void>() {

        @Nullable
        @Override
        public Void apply(@Nullable SolrComponent solrComponent) {
            topologyProperties.setProperty("solr.zk", solrComponent.getZookeeperUrl());
            try {
                String testZookeeperUrl = topologyProperties.getProperty(ZKServerComponent.ZOOKEEPER_PROPERTY);
                Configurations configurations = SampleUtil.getSampleConfigs();
                Map<String, Object> globalConfig = configurations.getGlobalConfig();
                globalConfig.put(SolrConstants.SOLR_ZOOKEEPER, solrComponent.getZookeeperUrl());
                ConfigurationsUtils.writeGlobalConfigToZookeeper(JSONUtils.INSTANCE.toJSONPretty(globalConfig), testZookeeperUrl);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    }).build();
    return solrComponent;
}
Also used : Function(com.google.common.base.Function) SolrComponent(org.apache.metron.solr.integration.components.SolrComponent) Configurations(org.apache.metron.common.configuration.Configurations) Nullable(javax.annotation.Nullable)

Aggregations

Configurations (org.apache.metron.common.configuration.Configurations)4 Function (com.google.common.base.Function)2 Nullable (javax.annotation.Nullable)2 SolrComponent (org.apache.metron.solr.integration.components.SolrComponent)2 IOException (java.io.IOException)1 FieldValidator (org.apache.metron.common.configuration.FieldValidator)1 JSONObject (org.json.simple.JSONObject)1