All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opensearch.migrations.replay.traffic.source.ITrafficCaptureSource Maven / Gradle / Ivy

There is a newer version: 0.2.0.4
Show newest version
package org.opensearch.migrations.replay.traffic.source;

import java.io.IOException;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;

import org.opensearch.migrations.replay.datatypes.ITrafficStreamKey;
import org.opensearch.migrations.replay.tracing.ITrafficSourceContexts;

public interface ITrafficCaptureSource extends AutoCloseable {

    enum CommitResult {
        IMMEDIATE,
        AFTER_NEXT_READ,
        BLOCKED_BY_OTHER_COMMITS,
        IGNORED
    }

    CompletableFuture> readNextTrafficStreamChunk(
        Supplier contextSupplier
    );

    CommitResult commitTrafficStream(ITrafficStreamKey trafficStreamKey) throws IOException;

    default void close() throws Exception {}

    /**
     * Keep-alive call to be used by the BlockingTrafficSource to keep this connection alive if
     * this is required.
     */
    default void touch(ITrafficSourceContexts.IBackPressureBlockContext context) {}

    /**
     * @return The time that the next call to touch() must be completed for this source to stay
     * active.  Empty indicates that touch() does not need to be called to keep the
     * source active.
     */
    default Optional getNextRequiredTouch() {
        return Optional.empty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy