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;
}
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);
}
}
Aggregations