Search in sources :

Example 46 with MessageBatch

use of org.jgroups.util.MessageBatch in project JGroups by belaban.

the class SEQUENCER2 method removeAndDeliver.

protected void removeAndDeliver(Table<Message> win, Address sender) {
    AtomicInteger adders = win.getAdders();
    if (adders.getAndIncrement() != 0)
        return;
    final MessageBatch batch = new MessageBatch(win.size()).dest(local_addr).sender(sender).multicast(false);
    Supplier<MessageBatch> batch_creator = () -> batch;
    do {
        try {
            batch.reset();
            win.removeMany(true, 0, null, batch_creator, BATCH_ACCUMULATOR);
        } catch (Throwable t) {
            log.error("failed removing messages from table for " + sender, t);
        }
        if (!batch.isEmpty()) {
            // batch is guaranteed to NOT contain any OOB messages as the drop_oob_msgs_filter removed them
            deliverBatch(batch);
        }
    } while (adders.decrementAndGet() != 0);
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

MessageBatch (org.jgroups.util.MessageBatch)46 Message (org.jgroups.Message)37 Util (org.jgroups.util.Util)6 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)5 ClassConfigurator (org.jgroups.conf.ClassConfigurator)5 Test (org.testng.annotations.Test)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 DataInputStream (java.io.DataInputStream)4 DataOutputStream (java.io.DataOutputStream)4 java.util (java.util)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 BiFunction (java.util.function.BiFunction)4 Predicate (java.util.function.Predicate)4 Collectors (java.util.stream.Collectors)4 Address (org.jgroups.Address)4 Global (org.jgroups.Global)4 org.jgroups.protocols (org.jgroups.protocols)4 Collection (java.util.Collection)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2