Search in sources :

Example 86 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class PipelineConfigurationValidator method validateSourceMapping.

/**
 * This method validates if pipeline's source is correctly configured to reflect the sink of its parent i.e.
 * if p2 is defined as sink for p1, source of p2 should be defined as p1.
 *
 * @param sourcePipeline           name of the expected source pipeline
 * @param currentPipeline          name of the current pipeline that is being validated
 * @param pipelineConfigurationMap pipeline name to pipeline configuration map
 */
private static void validateSourceMapping(final String sourcePipeline, final String currentPipeline, final Map<String, PipelineConfiguration> pipelineConfigurationMap) {
    if (!pipelineConfigurationMap.containsKey(currentPipeline)) {
        throw new RuntimeException(format("Invalid configuration, no pipeline is defined with name %s", currentPipeline));
    }
    final PipelineConfiguration pipelineConfiguration = pipelineConfigurationMap.get(currentPipeline);
    final PluginSetting sourcePluginSettings = pipelineConfiguration.getSourcePluginSetting();
    if (!isPipelineAttributeExists(sourcePluginSettings, sourcePipeline)) {
        LOG.error("Invalid configuration, expected source {} for pipeline {} is missing", sourcePipeline, currentPipeline);
        throw new RuntimeException(format("Invalid configuration, expected source %s for pipeline %s is missing", sourcePipeline, currentPipeline));
    }
}
Also used : PipelineConfiguration(com.amazon.dataprepper.parser.model.PipelineConfiguration) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 87 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class PipelineConfigurationValidator method visitAndValidate.

private static void visitAndValidate(final String pipeline, final Map<String, PipelineConfiguration> pipelineConfigurationMap, final Set<String> touchedPipelineSet, final Set<String> visitedAndProcessedPipelineSet, final List<String> sortedPipelineNames) {
    // if it is already marked, it means it results in a cycle
    if (touchedPipelineSet.contains(pipeline)) {
        LOG.error("Configuration results in a cycle - check pipeline: {}", pipeline);
        throw new RuntimeException(format("Provided configuration results in a loop, check pipeline: %s", pipeline));
    }
    // if its not already visited, recursively check
    if (!visitedAndProcessedPipelineSet.contains(pipeline)) {
        final PipelineConfiguration pipelineConfiguration = pipelineConfigurationMap.get(pipeline);
        touchedPipelineSet.add(pipeline);
        // if validation is successful, then there is definitely sink
        final List<PluginSetting> connectedPipelinesSettings = pipelineConfiguration.getSinkPluginSettings();
        // Recursively check connected pipelines
        for (PluginSetting pluginSetting : connectedPipelinesSettings) {
            // Further process only if the sink is of pipeline type
            if (pluginSetting.getName().equals(PIPELINE_TYPE)) {
                final String connectedPipelineName = (String) pluginSetting.getAttributeFromSettings(PIPELINE_ATTRIBUTE_NAME);
                validatePipelineAttributeName(connectedPipelineName, pipeline);
                validateSourceMapping(pipeline, connectedPipelineName, pipelineConfigurationMap);
                visitAndValidate(connectedPipelineName, pipelineConfigurationMap, touchedPipelineSet, visitedAndProcessedPipelineSet, sortedPipelineNames);
            }
        }
        visitedAndProcessedPipelineSet.add(pipeline);
        touchedPipelineSet.remove(pipeline);
        sortedPipelineNames.add(pipeline);
    }
}
Also used : PipelineConfiguration(com.amazon.dataprepper.parser.model.PipelineConfiguration) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 88 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class PeerForwarderConfigTest method testBuildConfigNoSSL.

@Test
public void testBuildConfigNoSSL() {
    final int testNumSpansPerRequest = 2;
    final int testTimeout = 300;
    final HashMap<String, Object> settings = new HashMap<>();
    settings.put(PeerForwarderConfig.DISCOVERY_MODE, DiscoveryMode.STATIC.toString());
    settings.put(PeerForwarderConfig.STATIC_ENDPOINTS, TEST_ENDPOINTS);
    settings.put(PeerForwarderConfig.MAX_NUM_SPANS_PER_REQUEST, testNumSpansPerRequest);
    settings.put(PeerForwarderConfig.TIME_OUT, testTimeout);
    settings.put(PeerForwarderConfig.SSL, false);
    final PeerForwarderConfig peerForwarderConfig = PeerForwarderConfig.buildConfig(new PluginSetting("peer_forwarder", settings) {

        {
            setPipelineName(PIPELINE_NAME);
        }
    });
    Assert.assertEquals(testNumSpansPerRequest, peerForwarderConfig.getMaxNumSpansPerRequest());
    Assert.assertEquals(testTimeout, peerForwarderConfig.getTimeOut());
}
Also used : HashMap(java.util.HashMap) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.Test)

Example 89 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class AwsCloudMapPeerListProvider_CreateTest method setUp.

@BeforeEach
void setUp() {
    pluginSetting = new PluginSetting(PLUGIN_NAME, new HashMap<>()) {

        {
            setPipelineName(PIPELINE_NAME);
        }
    };
    pluginMetrics = mock(PluginMetrics.class);
    pluginSetting.getSettings().put(PeerForwarderConfig.DOMAIN_NAME, ENDPOINT);
    pluginSetting.getSettings().put(PeerForwarderConfig.AWS_CLOUD_MAP_NAMESPACE_NAME, UUID.randomUUID().toString());
    pluginSetting.getSettings().put(PeerForwarderConfig.AWS_CLOUD_MAP_SERVICE_NAME, UUID.randomUUID().toString());
    pluginSetting.getSettings().put(PeerForwarderConfig.AWS_REGION, "us-east-1");
}
Also used : HashMap(java.util.HashMap) PluginMetrics(com.amazon.dataprepper.metrics.PluginMetrics) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 90 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class StaticPeerListProvider_CreateTest method setup.

@BeforeEach
void setup() {
    pluginSetting = new PluginSetting(PLUGIN_NAME, new HashMap<>());
    pluginSetting.setPipelineName(PIPELINE_NAME);
    pluginMetrics = mock(PluginMetrics.class);
}
Also used : HashMap(java.util.HashMap) PluginMetrics(com.amazon.dataprepper.metrics.PluginMetrics) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)150 Test (org.junit.jupiter.api.Test)58 HashMap (java.util.HashMap)55 Test (org.junit.Test)43 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 Record (com.amazon.dataprepper.model.record.Record)22 AsciiString (io.netty.util.AsciiString)16 Measurement (io.micrometer.core.instrument.Measurement)12 StringJoiner (java.util.StringJoiner)12 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 Map (java.util.Map)11 Path (java.nio.file.Path)9 Server (com.linecorp.armeria.server.Server)8 Before (org.junit.Before)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 BlockingBuffer (com.amazon.dataprepper.plugins.buffer.blockingbuffer.BlockingBuffer)7 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)7 PluginMetrics (com.amazon.dataprepper.metrics.PluginMetrics)6 CertificateProvider (com.amazon.dataprepper.plugins.certificate.CertificateProvider)6 ACMCertificateProvider (com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider)6