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));
}
}
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);
}
}
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());
}
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");
}
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);
}
Aggregations