/** * 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(); } }
/** * 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(); } }
/** * 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 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; }
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; }
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; }
/** * 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(); }
/** * 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(); }
/** * 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(); }