You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sa...@apache.org on 2020/06/12 10:38:22 UTC

[cassandra] branch cassandra-2.2 updated: Fix nomenclature of deny and allow lists

This is an automated email from the ASF dual-hosted git repository.

samt pushed a commit to branch cassandra-2.2
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-2.2 by this push:
     new c8c3c26  Fix nomenclature of deny and allow lists
c8c3c26 is described below

commit c8c3c269bf1df944b73e2d4bf0008a6f412bf121
Author: Sam Tunnicliffe <sa...@beobal.com>
AuthorDate: Thu Jun 11 18:40:18 2020 +0100

    Fix nomenclature of deny and allow lists
    
    Patch by Sam Tunnicliffe; reviewed by Jordan West for CASSANDRA-15862
---
 CHANGES.txt                                        |  1 +
 src/java/org/apache/cassandra/db/Directories.java  | 24 +++++++++---------
 ...Directories.java => DisallowedDirectories.java} | 29 +++++++++++-----------
 ...sMBean.java => DisallowedDirectoriesMBean.java} |  3 ++-
 .../db/compaction/AbstractCompactionStrategy.java  |  6 ++---
 .../cassandra/db/compaction/LeveledManifest.java   |  2 +-
 .../cassandra/io/sstable/format/SSTableReader.java |  2 +-
 .../cassandra/service/DefaultFSErrorHandler.java   |  6 ++---
 .../org/apache/cassandra/cql3/OutOfSpaceBase.java  |  4 +--
 .../org/apache/cassandra/db/DirectoriesTest.java   |  2 +-
 ....java => CorruptedSSTablesCompactionsTest.java} | 15 ++++++-----
 11 files changed, 48 insertions(+), 46 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 788b2bf..b10a057 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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)
diff --git a/src/java/org/apache/cassandra/db/Directories.java b/src/java/org/apache/cassandra/db/Directories.java
index fa76b61..d1aa650 100644
--- a/src/java/org/apache/cassandra/db/Directories.java
+++ b/src/java/org/apache/cassandra/db/Directories.java
@@ -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)
diff --git a/src/java/org/apache/cassandra/db/BlacklistedDirectories.java b/src/java/org/apache/cassandra/db/DisallowedDirectories.java
similarity index 76%
rename from src/java/org/apache/cassandra/db/BlacklistedDirectories.java
rename to src/java/org/apache/cassandra/db/DisallowedDirectories.java
index a14e013..c0518e2 100644
--- a/src/java/org/apache/cassandra/db/BlacklistedDirectories.java
+++ b/src/java/org/apache/cassandra/db/DisallowedDirectories.java
@@ -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)
     {
diff --git a/src/java/org/apache/cassandra/db/BlacklistedDirectoriesMBean.java b/src/java/org/apache/cassandra/db/DisallowedDirectoriesMBean.java
similarity index 95%
rename from src/java/org/apache/cassandra/db/BlacklistedDirectoriesMBean.java
rename to src/java/org/apache/cassandra/db/DisallowedDirectoriesMBean.java
index 3163b9a..8e825dd 100644
--- a/src/java/org/apache/cassandra/db/BlacklistedDirectoriesMBean.java
+++ b/src/java/org/apache/cassandra/db/DisallowedDirectoriesMBean.java
@@ -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();
     
diff --git a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
index 5170375..f9ed780 100644
--- a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
@@ -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)
     {
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
index 3b207da..fba6798 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
@@ -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)
diff --git a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
index 16fa6c9..96bf01d 100644
--- a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
@@ -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);
     }
diff --git a/src/java/org/apache/cassandra/service/DefaultFSErrorHandler.java b/src/java/org/apache/cassandra/service/DefaultFSErrorHandler.java
index 88a1fce..0413e0d 100644
--- a/src/java/org/apache/cassandra/service/DefaultFSErrorHandler.java
+++ b/src/java/org/apache/cassandra/service/DefaultFSErrorHandler.java
@@ -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);
                 }
diff --git a/test/unit/org/apache/cassandra/cql3/OutOfSpaceBase.java b/test/unit/org/apache/cassandra/cql3/OutOfSpaceBase.java
index 826d6e6..eda2413 100644
--- a/test/unit/org/apache/cassandra/cql3/OutOfSpaceBase.java
+++ b/test/unit/org/apache/cassandra/cql3/OutOfSpaceBase.java
@@ -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)
diff --git a/test/unit/org/apache/cassandra/db/DirectoriesTest.java b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
index bc5b7bf..11adef2 100644
--- a/test/unit/org/apache/cassandra/db/DirectoriesTest.java
+++ b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
@@ -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 
diff --git a/test/unit/org/apache/cassandra/db/compaction/BlacklistingCompactionsTest.java b/test/unit/org/apache/cassandra/db/compaction/CorruptedSSTablesCompactionsTest.java
similarity index 92%
rename from test/unit/org/apache/cassandra/db/compaction/BlacklistingCompactionsTest.java
rename to test/unit/org/apache/cassandra/db/compaction/CorruptedSSTablesCompactionsTest.java
index c482116..5208401 100644
--- a/test/unit/org/apache/cassandra/db/compaction/BlacklistingCompactionsTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CorruptedSSTablesCompactionsTest.java
@@ -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);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org