Search in sources :

Example 1 with AtomicIntegerFieldUpdater

use of java.util.concurrent.atomic.AtomicIntegerFieldUpdater in project pulsar by yahoo.

the class PersistentDispatcherFailoverConsumerTest method getNextConsumer.

private Consumer getNextConsumer(PersistentDispatcherMultipleConsumers dispatcher) throws Exception {
    Consumer consumer = dispatcher.getNextConsumer();
    Field field = Consumer.class.getDeclaredField("MESSAGE_PERMITS_UPDATER");
    field.setAccessible(true);
    AtomicIntegerFieldUpdater<Consumer> messagePermits = (AtomicIntegerFieldUpdater) field.get(consumer);
    messagePermits.decrementAndGet(consumer);
    return consumer;
}
Also used : Field(java.lang.reflect.Field) Consumer(com.yahoo.pulsar.broker.service.Consumer) PersistentDispatcherSingleActiveConsumer(com.yahoo.pulsar.broker.service.persistent.PersistentDispatcherSingleActiveConsumer) AtomicIntegerFieldUpdater(java.util.concurrent.atomic.AtomicIntegerFieldUpdater)

Aggregations

Consumer (com.yahoo.pulsar.broker.service.Consumer)1 PersistentDispatcherSingleActiveConsumer (com.yahoo.pulsar.broker.service.persistent.PersistentDispatcherSingleActiveConsumer)1 Field (java.lang.reflect.Field)1 AtomicIntegerFieldUpdater (java.util.concurrent.atomic.AtomicIntegerFieldUpdater)1