@Override protected SizeAndModCount refresh() { // It is ok for the size of the directory to be more recent than // the mod count, we would just recompute the size of the // directory on the next call as well. However the opposite // would be bad as we would potentially have a stale cache // entry for a long time. So we fetch the values of modCount and // numOpenOutputs BEFORE computing the size of the directory. final long modCount; final boolean pendingWrite; synchronized(ByteSizeCachingDirectory.this) { modCount = ByteSizeCachingDirectory.this.modCount; pendingWrite = ByteSizeCachingDirectory.this.numOpenOutputs != 0; } final long size; try { // Compute this OUTSIDE of the lock size = estimateSizeInBytes(getDelegate()); } catch (IOException e) { throw new UncheckedIOException(e); } return new SizeAndModCount(size, modCount, pendingWrite); }
ByteSizeCachingDirectory(Directory in, TimeValue refreshInterval) { super(in); size = new SingleObjectCache<SizeAndModCount>(refreshInterval, new SizeAndModCount(0L, -1L, true)) { @Override protected SizeAndModCount refresh() { throw new UncheckedIOException(e); return new SizeAndModCount(size, modCount, pendingWrite);
ByteSizeCachingDirectory(Directory in, TimeValue refreshInterval) { super(in); size = new SingleObjectCache<SizeAndModCount>(refreshInterval, new SizeAndModCount(0L, -1L, true)) { @Override protected SizeAndModCount refresh() { throw new UncheckedIOException(e); return new SizeAndModCount(size, modCount, pendingWrite);
@Override protected SizeAndModCount refresh() { // It is ok for the size of the directory to be more recent than // the mod count, we would just recompute the size of the // directory on the next call as well. However the opposite // would be bad as we would potentially have a stale cache // entry for a long time. So we fetch the values of modCount and // numOpenOutputs BEFORE computing the size of the directory. final long modCount; final boolean pendingWrite; synchronized(ByteSizeCachingDirectory.this) { modCount = ByteSizeCachingDirectory.this.modCount; pendingWrite = ByteSizeCachingDirectory.this.numOpenOutputs != 0; } final long size; try { // Compute this OUTSIDE of the lock size = estimateSizeInBytes(getDelegate()); } catch (IOException e) { throw new UncheckedIOException(e); } return new SizeAndModCount(size, modCount, pendingWrite); }
@Override protected SizeAndModCount refresh() { // It is ok for the size of the directory to be more recent than // the mod count, we would just recompute the size of the // directory on the next call as well. However the opposite // would be bad as we would potentially have a stale cache // entry for a long time. So we fetch the values of modCount and // numOpenOutputs BEFORE computing the size of the directory. final long modCount; final boolean pendingWrite; synchronized(ByteSizeCachingDirectory.this) { modCount = ByteSizeCachingDirectory.this.modCount; pendingWrite = ByteSizeCachingDirectory.this.numOpenOutputs != 0; } final long size; try { // Compute this OUTSIDE of the lock size = estimateSizeInBytes(getDelegate()); } catch (IOException e) { throw new UncheckedIOException(e); } return new SizeAndModCount(size, modCount, pendingWrite); }
ByteSizeCachingDirectory(Directory in, TimeValue refreshInterval) { super(in); size = new SingleObjectCache<SizeAndModCount>(refreshInterval, new SizeAndModCount(0L, -1L, true)) { @Override protected SizeAndModCount refresh() { throw new UncheckedIOException(e); return new SizeAndModCount(size, modCount, pendingWrite);