public int getDiskIndex(SSTableReader sstable) { if (positions == null) { return getBoundariesFromSSTableDirectory(sstable); } int pos = Collections.binarySearch(positions, sstable.first); assert pos < 0; // boundaries are .minkeybound and .maxkeybound so they should never be equal return -pos - 1; }
public Directories.DataDirectory getCorrectDiskForSSTable(SSTableReader sstable) { return directories.get(getDiskIndex(sstable)); } }
public void invalidate() { if (diskBoundaries != null) diskBoundaries.invalidate(); }
public DiskBoundaries getDiskBoundaries(ColumnFamilyStore cfs) { if (!cfs.getPartitioner().splitter().isPresent()) return new DiskBoundaries(cfs.getDirectories().getWriteableLocations(), BlacklistedDirectories.getDirectoriesVersion()); if (diskBoundaries == null || diskBoundaries.isOutOfDate()) { synchronized (this) { if (diskBoundaries == null || diskBoundaries.isOutOfDate()) { logger.debug("Refreshing disk boundary cache for {}.{}", cfs.keyspace.getName(), cfs.getTableName()); DiskBoundaries oldBoundaries = diskBoundaries; diskBoundaries = getDiskBoundaryValue(cfs); logger.debug("Updating boundaries from {} to {} for {}.{}", oldBoundaries, diskBoundaries, cfs.keyspace.getName(), cfs.getTableName()); } } } return diskBoundaries; }
/** * Checks if the disk boundaries changed and reloads the compaction strategies * to reflect the most up-to-date disk boundaries. * * This is typically called before acquiring the {@link this#readLock} to ensure the most up-to-date * disk locations and boundaries are used. * * This should *never* be called inside by a thread holding the {@link this#readLock}, since it * will potentially acquire the {@link this#writeLock} to update the compaction strategies * what can cause a deadlock. */ //TODO improve this to reload after receiving a notification rather than trying to reload on every operation @VisibleForTesting protected boolean maybeReloadDiskBoundaries() { if (!currentBoundaries.isOutOfDate()) return false; writeLock.lock(); try { if (!currentBoundaries.isOutOfDate()) return false; reload(params); return true; } finally { writeLock.unlock(); } }
return new DiskBoundaries(dirs, null, ringVersion, directoriesVersion); return new DiskBoundaries(dirs, positions, ringVersion, directoriesVersion);
this.destination = cfs.getDirectories().getLocationForDisk(cfs.getDiskBoundaries().getCorrectDiskForSSTable(sstable)); this.isCommutative = cfs.metadata.isCounter();
public DiskBoundaries getDiskBoundaries(ColumnFamilyStore cfs) { if (!cfs.getPartitioner().splitter().isPresent()) return new DiskBoundaries(cfs.getDirectories().getWriteableLocations(), BlacklistedDirectories.getDirectoriesVersion()); if (diskBoundaries == null || diskBoundaries.isOutOfDate()) { synchronized (this) { if (diskBoundaries == null || diskBoundaries.isOutOfDate()) { logger.debug("Refreshing disk boundary cache for {}.{}", cfs.keyspace.getName(), cfs.getTableName()); DiskBoundaries oldBoundaries = diskBoundaries; diskBoundaries = getDiskBoundaryValue(cfs); logger.debug("Updating boundaries from {} to {} for {}.{}", oldBoundaries, diskBoundaries, cfs.keyspace.getName(), cfs.getTableName()); } } } return diskBoundaries; }
/** * Checks if the disk boundaries changed and reloads the compaction strategies * to reflect the most up-to-date disk boundaries. * * This is typically called before acquiring the {@link this#readLock} to ensure the most up-to-date * disk locations and boundaries are used. * * This should *never* be called inside by a thread holding the {@link this#readLock}, since it * will potentially acquire the {@link this#writeLock} to update the compaction strategies * what can cause a deadlock. */ //TODO improve this to reload after receiving a notification rather than trying to reload on every operation @VisibleForTesting protected boolean maybeReloadDiskBoundaries() { if (!currentBoundaries.isOutOfDate()) return false; writeLock.lock(); try { if (!currentBoundaries.isOutOfDate()) return false; reload(params); return true; } finally { writeLock.unlock(); } }
return new DiskBoundaries(dirs, null, ringVersion, directoriesVersion); return new DiskBoundaries(dirs, positions, ringVersion, directoriesVersion);
this.destination = cfs.getDirectories().getLocationForDisk(cfs.getDiskBoundaries().getCorrectDiskForSSTable(sstable)); this.isCommutative = cfs.metadata.isCounter();
public Directories.DataDirectory getCorrectDiskForSSTable(SSTableReader sstable) { return directories.get(getDiskIndex(sstable)); } }
public DiskBoundaries getDiskBoundaries(ColumnFamilyStore cfs) { if (!cfs.getPartitioner().splitter().isPresent()) return new DiskBoundaries(cfs.getDirectories().getWriteableLocations(), BlacklistedDirectories.getDirectoriesVersion()); if (diskBoundaries == null || diskBoundaries.isOutOfDate()) { synchronized (this) { if (diskBoundaries == null || diskBoundaries.isOutOfDate()) { logger.debug("Refreshing disk boundary cache for {}.{}", cfs.keyspace.getName(), cfs.getTableName()); DiskBoundaries oldBoundaries = diskBoundaries; diskBoundaries = getDiskBoundaryValue(cfs); logger.debug("Updating boundaries from {} to {} for {}.{}", oldBoundaries, diskBoundaries, cfs.keyspace.getName(), cfs.getTableName()); } } } return diskBoundaries; }
/** * Checks if the disk boundaries changed and reloads the compaction strategies * to reflect the most up-to-date disk boundaries. * * This is typically called before acquiring the {@link this#readLock} to ensure the most up-to-date * disk locations and boundaries are used. * * This should *never* be called inside by a thread holding the {@link this#readLock}, since it * will potentially acquire the {@link this#writeLock} to update the compaction strategies * what can cause a deadlock. */ //TODO improve this to reload after receiving a notification rather than trying to reload on every operation @VisibleForTesting protected boolean maybeReloadDiskBoundaries() { if (!currentBoundaries.isOutOfDate()) return false; writeLock.lock(); try { if (!currentBoundaries.isOutOfDate()) return false; reload(params); return true; } finally { writeLock.unlock(); } }
public void invalidate() { if (diskBoundaries != null) diskBoundaries.invalidate(); }
public int getDiskIndex(SSTableReader sstable) { if (positions == null) { return getBoundariesFromSSTableDirectory(sstable); } int pos = Collections.binarySearch(positions, sstable.first); assert pos < 0; // boundaries are .minkeybound and .maxkeybound so they should never be equal return -pos - 1; }
return new DiskBoundaries(dirs, null, ringVersion, directoriesVersion); return new DiskBoundaries(dirs, positions, ringVersion, directoriesVersion);
this.destination = cfs.getDirectories().getLocationForDisk(cfs.getDiskBoundaries().getCorrectDiskForSSTable(sstable)); this.isCommutative = cfs.metadata.isCounter();
public Directories.DataDirectory getCorrectDiskForSSTable(SSTableReader sstable) { return directories.get(getDiskIndex(sstable)); } }
/** * Reload the compaction strategies * * Called after changing configuration and at startup. * @param newCompactionParams */ private void reload(CompactionParams newCompactionParams) { boolean enabledWithJMX = enabled && !shouldBeEnabled(); boolean disabledWithJMX = !enabled && shouldBeEnabled(); if (currentBoundaries != null) { if (!newCompactionParams.equals(schemaCompactionParams)) logger.debug("Recreating compaction strategy - compaction parameters changed for {}.{}", cfs.keyspace.getName(), cfs.getTableName()); else if (currentBoundaries.isOutOfDate()) logger.debug("Recreating compaction strategy - disk boundaries are out of date for {}.{}.", cfs.keyspace.getName(), cfs.getTableName()); } if (currentBoundaries == null || currentBoundaries.isOutOfDate()) currentBoundaries = boundariesSupplier.get(); setStrategy(newCompactionParams); schemaCompactionParams = cfs.metadata.params.compaction; if (disabledWithJMX || !shouldBeEnabled() && !enabledWithJMX) disable(); else enable(); startup(); }