Search in sources :

Example 1 with TranslogDeletionPolicyFactory

use of org.opensearch.index.translog.TranslogDeletionPolicyFactory in project OpenSearch by opensearch-project.

the class InternalEngineTests method testEngineCreationWithCustomTranslogDeletePolicy.

public void testEngineCreationWithCustomTranslogDeletePolicy() throws IOException {
    class CustomTranslogDeletionPolicy extends DefaultTranslogDeletionPolicy {

        public CustomTranslogDeletionPolicy(IndexSettings indexSettings, Supplier<RetentionLeases> retentionLeasesSupplier) {
            super(indexSettings.getTranslogRetentionSize().getBytes(), indexSettings.getTranslogRetentionAge().getMillis(), indexSettings.getTranslogRetentionTotalFiles());
        }
    }
    TranslogDeletionPolicyFactory translogDeletionPolicyFactory = CustomTranslogDeletionPolicy::new;
    EngineConfig config = engine.config();
    EngineConfig configWithCustomTranslogDeletionPolicyFactory = new EngineConfig(config.getShardId(), config.getThreadPool(), config.getIndexSettings(), config.getWarmer(), config.getStore(), config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(), config.getTranslogConfig(), translogDeletionPolicyFactory, config.getFlushMergesAfter(), config.getExternalRefreshListener(), config.getInternalRefreshListener(), config.getIndexSort(), config.getCircuitBreakerService(), config.getGlobalCheckpointSupplier(), config.retentionLeasesSupplier(), config.getPrimaryTermSupplier(), config.getTombstoneDocSupplier());
    engine.close();
    engine = createEngine(configWithCustomTranslogDeletionPolicyFactory);
    assertTrue(engine.getTranslog().getDeletionPolicy() instanceof CustomTranslogDeletionPolicy);
}
Also used : DefaultTranslogDeletionPolicy(org.opensearch.index.translog.DefaultTranslogDeletionPolicy) IndexSettings(org.opensearch.index.IndexSettings) CodecService(org.opensearch.index.codec.CodecService) Supplier(java.util.function.Supplier) IntSupplier(java.util.function.IntSupplier) LongSupplier(java.util.function.LongSupplier) TranslogDeletionPolicyFactory(org.opensearch.index.translog.TranslogDeletionPolicyFactory)

Aggregations

IntSupplier (java.util.function.IntSupplier)1 LongSupplier (java.util.function.LongSupplier)1 Supplier (java.util.function.Supplier)1 IndexSettings (org.opensearch.index.IndexSettings)1 CodecService (org.opensearch.index.codec.CodecService)1 DefaultTranslogDeletionPolicy (org.opensearch.index.translog.DefaultTranslogDeletionPolicy)1 TranslogDeletionPolicyFactory (org.opensearch.index.translog.TranslogDeletionPolicyFactory)1