Search in sources :

Example 1 with Broadcaster

use of org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.Broadcaster in project jackrabbit-oak by apache.

the class PersistentCache method broadcast.

void broadcast(CacheType type, Function<WriteBuffer, Void> writer) {
    Broadcaster b = broadcaster;
    if (b == null) {
        return;
    }
    WriteBuffer buff = writeBuffer.get();
    if (buff == null) {
        buff = new WriteBuffer();
        writeBuffer.set(buff);
    }
    buff.clear();
    // space for the length
    buff.putInt(0);
    buff.put(broadcastId);
    buff.put((byte) type.ordinal());
    writer.apply(buff);
    ByteBuffer byteBuff = buff.getBuffer();
    int length = byteBuff.position();
    byteBuff.limit(length);
    // write length
    byteBuff.putInt(0, length);
    byteBuff.position(0);
    b.send(byteBuff);
}
Also used : WriteBuffer(org.h2.mvstore.WriteBuffer) Broadcaster(org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.Broadcaster) UDPBroadcaster(org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.UDPBroadcaster) InMemoryBroadcaster(org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.InMemoryBroadcaster) TCPBroadcaster(org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.TCPBroadcaster) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 Broadcaster (org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.Broadcaster)1 InMemoryBroadcaster (org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.InMemoryBroadcaster)1 TCPBroadcaster (org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.TCPBroadcaster)1 UDPBroadcaster (org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.UDPBroadcaster)1 WriteBuffer (org.h2.mvstore.WriteBuffer)1