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

io.nosqlbench.driver.pulsar.ops.PulsarBatchProducerStartOp Maven / Gradle / Ivy

Go to download

A Pulsar driver for nosqlbench. This provides the ability to inject synthetic data into a pulsar system.

There is a newer version: 4.15.102
Show newest version
package io.nosqlbench.driver.pulsar.ops;

import io.nosqlbench.nb.api.errors.BasicError;
import org.apache.commons.compress.utils.Lists;
import org.apache.pulsar.client.api.*;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public class PulsarBatchProducerStartOp extends SyncPulsarOp {

    // TODO: ensure sane container lifecycle management
    public final static ThreadLocal>> threadLocalBatchMsgContainer = new ThreadLocal<>();
    public final static ThreadLocal> threadLocalProducer = new ThreadLocal<>();

    public PulsarBatchProducerStartOp(Producer batchProducer) {
        threadLocalProducer.set(batchProducer);
    }

    @Override
    public void run() {
        List> container = threadLocalBatchMsgContainer.get();

        if (container == null) {
            container = Lists.newArrayList();
            threadLocalBatchMsgContainer.set(container);
        } else {
            throw new BasicError("You tried to create a batch message container where one was already" +
                " defined. This means you did not flush and unset the last container, or there is an error in your" +
                " pulsar op sequencing and ratios.");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy