mirror of https://github.com/apache/cassandra
Fix nomenclature of deny and allow lists
Patch by Sam Tunnicliffe; reviewed by Jordan West for CASSANDRA-15862
This commit is contained in:
parent
334024751c
commit
c8c3c269bf
|
|
@ -1,4 +1,5 @@
|
|||
2.2.18
|
||||
* Fix nomenclature of allow and deny lists (CASSANDRA-15862)
|
||||
* Remove generated files from source artifact (CASSANDRA-15849)
|
||||
* Remove duplicated tools binaries from tarballs (CASSANDRA-15768)
|
||||
* Duplicate results with DISTINCT queries in mixed mode (CASSANDRA-15501)
|
||||
|
|
|
|||
|
|
@ -292,10 +292,10 @@ public class Directories
|
|||
|
||||
/**
|
||||
* Basically the same as calling {@link #getWriteableLocationAsFile(long)} with an unknown size ({@code -1L}),
|
||||
* which may return any non-blacklisted directory - even a data directory that has no usable space.
|
||||
* which may return any allowed directory - even a data directory that has no usable space.
|
||||
* Do not use this method in production code.
|
||||
*
|
||||
* @throws IOError if all directories are blacklisted.
|
||||
* @throws IOError if all directories are blocked.
|
||||
*/
|
||||
public File getDirectoryForNewSSTables()
|
||||
{
|
||||
|
|
@ -303,9 +303,9 @@ public class Directories
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a non-blacklisted data directory that _currently_ has {@code writeSize} bytes as usable space.
|
||||
* Returns an allowed directory that _currently_ has {@code writeSize} bytes as usable space.
|
||||
*
|
||||
* @throws IOError if all directories are blacklisted.
|
||||
* @throws IOError if all directories are disallowed.
|
||||
*/
|
||||
public File getWriteableLocationAsFile(long writeSize)
|
||||
{
|
||||
|
|
@ -313,9 +313,9 @@ public class Directories
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a non-blacklisted data directory that _currently_ has {@code writeSize} bytes as usable space.
|
||||
* Returns an allowed data directory that _currently_ has {@code writeSize} bytes as usable space.
|
||||
*
|
||||
* @throws IOError if all directories are blacklisted.
|
||||
* @throws IOError if all directories are disallowed.
|
||||
*/
|
||||
public DataDirectory getWriteableLocation(long writeSize)
|
||||
{
|
||||
|
|
@ -323,13 +323,13 @@ public class Directories
|
|||
|
||||
long totalAvailable = 0L;
|
||||
|
||||
// pick directories with enough space and so that resulting sstable dirs aren't blacklisted for writes.
|
||||
// pick directories with enough space and so that resulting sstable dirs aren't disallowed for writes.
|
||||
boolean tooBig = false;
|
||||
for (DataDirectory dataDir : dataDirectories)
|
||||
{
|
||||
if (BlacklistedDirectories.isUnwritable(getLocationForDisk(dataDir)))
|
||||
if (DisallowedDirectories.isUnwritable(getLocationForDisk(dataDir)))
|
||||
{
|
||||
logger.trace("removing blacklisted candidate {}", dataDir.location);
|
||||
logger.trace("removing disallowed candidate {}", dataDir.location);
|
||||
continue;
|
||||
}
|
||||
DataDirectoryCandidate candidate = new DataDirectoryCandidate(dataDir);
|
||||
|
|
@ -348,7 +348,7 @@ public class Directories
|
|||
if (tooBig)
|
||||
throw new RuntimeException("Insufficient disk space to write " + writeSize + " bytes");
|
||||
else
|
||||
throw new FSWriteError(new IOException("All configured data directories have been blacklisted as unwritable for erroring out"), "");
|
||||
throw new FSWriteError(new IOException("All configured data directories have been disallowed as unwritable for erroring out"), "");
|
||||
|
||||
// shortcut for single data directory systems
|
||||
if (candidates.size() == 1)
|
||||
|
|
@ -393,7 +393,7 @@ public class Directories
|
|||
|
||||
for (DataDirectory dataDir : dataDirectories)
|
||||
{
|
||||
if (BlacklistedDirectories.isUnwritable(getLocationForDisk(dataDir)))
|
||||
if (DisallowedDirectories.isUnwritable(getLocationForDisk(dataDir)))
|
||||
continue;
|
||||
DataDirectoryCandidate candidate = new DataDirectoryCandidate(dataDir);
|
||||
// exclude directory if its total writeSize does not fit to data directory
|
||||
|
|
@ -588,7 +588,7 @@ public class Directories
|
|||
|
||||
for (File location : dataPaths)
|
||||
{
|
||||
if (BlacklistedDirectories.isUnreadable(location))
|
||||
if (DisallowedDirectories.isUnreadable(location))
|
||||
continue;
|
||||
|
||||
if (snapshotName != null)
|
||||
|
|
|
|||
|
|
@ -25,21 +25,22 @@ import java.util.Collections;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import org.apache.cassandra.utils.JVMStabilityInspector;
|
||||
import org.apache.cassandra.utils.MBeanWrapper;
|
||||
|
||||
public class BlacklistedDirectories implements BlacklistedDirectoriesMBean
|
||||
public class DisallowedDirectories implements DisallowedDirectoriesMBean
|
||||
{
|
||||
public static final String MBEAN_NAME = "org.apache.cassandra.db:type=BlacklistedDirectories";
|
||||
private static final Logger logger = LoggerFactory.getLogger(BlacklistedDirectories.class);
|
||||
private static final BlacklistedDirectories instance = new BlacklistedDirectories();
|
||||
public static final String DEPRECATED_MBEAN_NAME = "org.apache.cassandra.db:type=BlacklistedDirectories";
|
||||
public static final String MBEAN_NAME = "org.apache.cassandra.db:type=DisallowedDirectories";
|
||||
private static final Logger logger = LoggerFactory.getLogger(DisallowedDirectories.class);
|
||||
private static final DisallowedDirectories instance = new DisallowedDirectories();
|
||||
|
||||
private final Set<File> unreadableDirectories = new CopyOnWriteArraySet<File>();
|
||||
private final Set<File> unwritableDirectories = new CopyOnWriteArraySet<File>();
|
||||
|
||||
private BlacklistedDirectories()
|
||||
private DisallowedDirectories()
|
||||
{
|
||||
// Register this instance with JMX
|
||||
MBeanWrapper.instance.registerMBean(this, DEPRECATED_MBEAN_NAME, MBeanWrapper.OnException.LOG);
|
||||
MBeanWrapper.instance.registerMBean(this, MBEAN_NAME, MBeanWrapper.OnException.LOG);
|
||||
}
|
||||
|
||||
|
|
@ -57,14 +58,14 @@ public class BlacklistedDirectories implements BlacklistedDirectoriesMBean
|
|||
* Adds parent directory of the file (or the file itself, if it is a directory)
|
||||
* to the set of unreadable directories.
|
||||
*
|
||||
* @return the blacklisted directory or null if nothing has been added to the list.
|
||||
* @return the disallowed directory or null if nothing has been added to the list.
|
||||
*/
|
||||
public static File maybeMarkUnreadable(File path)
|
||||
{
|
||||
File directory = getDirectory(path);
|
||||
if (instance.unreadableDirectories.add(directory))
|
||||
{
|
||||
logger.warn("Blacklisting {} for reads", directory);
|
||||
logger.warn("Disallowing {} for reads", directory);
|
||||
return directory;
|
||||
}
|
||||
return null;
|
||||
|
|
@ -74,22 +75,22 @@ public class BlacklistedDirectories implements BlacklistedDirectoriesMBean
|
|||
* Adds parent directory of the file (or the file itself, if it is a directory)
|
||||
* to the set of unwritable directories.
|
||||
*
|
||||
* @return the blacklisted directory or null if nothing has been added to the list.
|
||||
* @return the disallowed directory or null if nothing has been added to the list.
|
||||
*/
|
||||
public static File maybeMarkUnwritable(File path)
|
||||
{
|
||||
File directory = getDirectory(path);
|
||||
if (instance.unwritableDirectories.add(directory))
|
||||
{
|
||||
logger.warn("Blacklisting {} for writes", directory);
|
||||
logger.warn("Disallowing {} for writes", directory);
|
||||
return directory;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not the directory is blacklisted for reads.
|
||||
* @return whether or not the directory is blacklisted for reads.
|
||||
* Tells whether or not the directory is disallowed for reads.
|
||||
* @return whether or not the directory is disallowed for reads.
|
||||
*/
|
||||
public static boolean isUnreadable(File directory)
|
||||
{
|
||||
|
|
@ -97,8 +98,8 @@ public class BlacklistedDirectories implements BlacklistedDirectoriesMBean
|
|||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not the directory is blacklisted for writes.
|
||||
* @return whether or not the directory is blacklisted for reads.
|
||||
* Tells whether or not the directory is disallowed for writes.
|
||||
* @return whether or not the directory is disallowed for reads.
|
||||
*/
|
||||
public static boolean isUnwritable(File directory)
|
||||
{
|
||||
|
|
@ -20,7 +20,8 @@ package org.apache.cassandra.db;
|
|||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
public interface BlacklistedDirectoriesMBean {
|
||||
public interface DisallowedDirectoriesMBean
|
||||
{
|
||||
|
||||
public Set<File> getUnreadableDirectories();
|
||||
|
||||
|
|
@ -243,10 +243,10 @@ public abstract class AbstractCompactionStrategy
|
|||
}
|
||||
|
||||
/**
|
||||
* Filters SSTables that are to be blacklisted from the given collection
|
||||
* Filters SSTables that are to be excluded from the given collection
|
||||
*
|
||||
* @param originalCandidates The collection to check for blacklisted SSTables
|
||||
* @return list of the SSTables with blacklisted ones filtered out
|
||||
* @param originalCandidates The collection to check for excluded SSTables
|
||||
* @return list of the SSTables with excluded ones filtered out
|
||||
*/
|
||||
public static Iterable<SSTableReader> filterSuspectSSTables(Iterable<SSTableReader> originalCandidates)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -546,7 +546,7 @@ public class LeveledManifest
|
|||
|
||||
/**
|
||||
* @return highest-priority sstables to compact for the given level.
|
||||
* If no compactions are possible (because of concurrent compactions or because some sstables are blacklisted
|
||||
* If no compactions are possible (because of concurrent compactions or because some sstables are excluded
|
||||
* for prior failure), will return an empty list. Never returns null.
|
||||
*/
|
||||
private Collection<SSTableReader> getCandidatesFor(int level)
|
||||
|
|
|
|||
|
|
@ -1687,7 +1687,7 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
|
|||
public void markSuspect()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
logger.trace("Marking {} as a suspect for blacklisting.", getFilename());
|
||||
logger.trace("Marking {} as a suspect to be excluded from reads.", getFilename());
|
||||
|
||||
isSuspect.getAndSet(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.BlacklistedDirectories;
|
||||
import org.apache.cassandra.db.DisallowedDirectories;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.io.FSError;
|
||||
import org.apache.cassandra.io.FSErrorHandler;
|
||||
|
|
@ -66,10 +66,10 @@ public class DefaultFSErrorHandler implements FSErrorHandler
|
|||
break;
|
||||
case best_effort:
|
||||
// for both read and write errors mark the path as unwritable.
|
||||
BlacklistedDirectories.maybeMarkUnwritable(e.path);
|
||||
DisallowedDirectories.maybeMarkUnwritable(e.path);
|
||||
if (e instanceof FSReadError)
|
||||
{
|
||||
File directory = BlacklistedDirectories.maybeMarkUnreadable(e.path);
|
||||
File directory = DisallowedDirectories.maybeMarkUnreadable(e.path);
|
||||
if (directory != null)
|
||||
Keyspace.removeUnreadableSSTables(directory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import java.util.concurrent.ExecutionException;
|
|||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.cassandra.db.BlacklistedDirectories;
|
||||
import org.apache.cassandra.db.DisallowedDirectories;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Directories.DataDirectory;
|
||||
import org.apache.cassandra.db.commitlog.CommitLog;
|
||||
|
|
@ -56,7 +56,7 @@ public class OutOfSpaceBase extends CQLTester
|
|||
for ( ; ; )
|
||||
{
|
||||
DataDirectory dir = cfs.directories.getWriteableLocation(1);
|
||||
BlacklistedDirectories.maybeMarkUnwritable(cfs.directories.getLocationForDisk(dir));
|
||||
DisallowedDirectories.maybeMarkUnwritable(cfs.directories.getLocationForDisk(dir));
|
||||
}
|
||||
}
|
||||
catch (IOError e)
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ public class DirectoriesTest
|
|||
for (DataDirectory dd : Directories.dataDirectories)
|
||||
{
|
||||
File file = new File(dd.location, new File(KS, "bad").getPath());
|
||||
assertTrue(BlacklistedDirectories.isUnwritable(file));
|
||||
assertTrue(DisallowedDirectories.isUnwritable(file));
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.*;
|
|||
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -44,9 +43,9 @@ import static org.junit.Assert.assertNotNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.apache.cassandra.Util.cellname;
|
||||
|
||||
public class BlacklistingCompactionsTest
|
||||
public class CorruptedSSTablesCompactionsTest
|
||||
{
|
||||
private static final String KEYSPACE1 = "BlacklistingCompactionsTest";
|
||||
private static final String KEYSPACE1 = "CorruptedSSTablesCompactionsTest";
|
||||
private static final String CF_STANDARD1 = "Standard1";
|
||||
// seed hardcoded to one we know works:
|
||||
private static final Random random = new Random(1);
|
||||
|
|
@ -82,18 +81,18 @@ public class BlacklistingCompactionsTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBlacklistingWithSizeTieredCompactionStrategy() throws Exception
|
||||
public void testCorruptedSSTablesWithSizeTieredCompactionStrategy() throws Exception
|
||||
{
|
||||
testBlacklisting(SizeTieredCompactionStrategy.class.getCanonicalName());
|
||||
testCorruptedSSTables(SizeTieredCompactionStrategy.class.getCanonicalName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlacklistingWithLeveledCompactionStrategy() throws Exception
|
||||
public void testCorruptedSSTablesWithLeveledCompactionStrategy() throws Exception
|
||||
{
|
||||
testBlacklisting(LeveledCompactionStrategy.class.getCanonicalName());
|
||||
testCorruptedSSTables(LeveledCompactionStrategy.class.getCanonicalName());
|
||||
}
|
||||
|
||||
public void testBlacklisting(String compactionStrategy) throws Exception
|
||||
public void testCorruptedSSTables(String compactionStrategy) throws Exception
|
||||
{
|
||||
// this test does enough rows to force multiple block indexes to be used
|
||||
Keyspace keyspace = Keyspace.open(KEYSPACE1);
|
||||
Loading…
Reference in New Issue