Search in sources :

Example 6 with HashStreamRanges

use of org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges in project bookkeeper by apache.

the class RangeRouter method getRanges.

public HashStreamRanges getRanges() {
    HashStreamRanges rs;
    long stamp = lock.tryOptimisticRead();
    rs = ranges;
    if (!lock.validate(stamp)) {
        stamp = lock.readLock();
        try {
            rs = ranges;
        } finally {
            lock.unlockRead(stamp);
        }
    }
    return rs;
}
Also used : HashStreamRanges(org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges)

Example 7 with HashStreamRanges

use of org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges in project bookkeeper by apache.

the class RangeRouter method setRanges.

public HashStreamRanges setRanges(HashStreamRanges ranges) {
    long stamp = lock.writeLock();
    try {
        // we only update the routing only when see new active ranges
        if ((this.ranges == null) || (ranges.getMaxRangeId() > this.ranges.getMaxRangeId())) {
            HashStreamRanges oldRanges = this.ranges;
            this.ranges = ranges;
            return oldRanges;
        } else {
            return null;
        }
    } finally {
        lock.unlockWrite(stamp);
    }
}
Also used : HashStreamRanges(org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges)

Aggregations

HashStreamRanges (org.apache.bookkeeper.clients.impl.internal.api.HashStreamRanges)7 Test (org.junit.Test)3 StreamObserver (io.grpc.stub.StreamObserver)2 Map (java.util.Map)2 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)2 RangeProperties (org.apache.bookkeeper.stream.proto.RangeProperties)2 GetActiveRangesResponse (org.apache.bookkeeper.stream.proto.storage.GetActiveRangesResponse)2 MetaRangeServiceImplBase (org.apache.bookkeeper.stream.proto.storage.MetaRangeServiceGrpc.MetaRangeServiceImplBase)2 StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)2 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ByteBuf (io.netty.buffer.ByteBuf)1 Entry (java.util.Map.Entry)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 PTable (org.apache.bookkeeper.api.kv.PTable)1 StorageContainerResponse (org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)1