use of com.amazon.dataprepper.plugins.sink.opensearch.index.IndexManager in project data-prepper by opensearch-project.
the class OpenSearchSink method initialize.
public void initialize() throws IOException {
LOG.info("Initializing OpenSearch sink");
restHighLevelClient = openSearchSinkConfig.getConnectionConfiguration().createClient();
indexManager = indexManagerFactory.getIndexManager(indexType, restHighLevelClient, openSearchSinkConfig);
final String dlqFile = openSearchSinkConfig.getRetryConfiguration().getDlqFile();
if (dlqFile != null) {
dlqWriter = Files.newBufferedWriter(Paths.get(dlqFile), StandardOpenOption.CREATE, StandardOpenOption.APPEND);
}
indexManager.setupIndex();
OpenSearchTransport transport = new RestClientTransport(restHighLevelClient.getLowLevelClient(), new PreSerializedJsonpMapper());
openSearchClient = new OpenSearchClient(transport);
bulkRequestSupplier = () -> new JavaClientAccumulatingBulkRequest(new BulkRequest.Builder().index(indexManager.getIndexAlias()));
bulkRetryStrategy = new BulkRetryStrategy(bulkRequest -> openSearchClient.bulk(bulkRequest.getRequest()), this::logFailure, pluginMetrics, bulkRequestSupplier);
LOG.info("Initialized OpenSearch sink");
objectMapper = new ObjectMapper();
}
Aggregations