@@ -0,0 +1,3387 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.cassandra.db;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.File;%0Aimport java.util.Set;%0Aimport java.util.concurrent.CopyOnWriteArraySet;%0A%0Apublic class BlacklistedDirectories%0A%7B%0A    private static final Logger logger = LoggerFactory.getLogger(BlacklistedDirectories.class);%0A%0A    private static Set%3CFile%3E unreadableDirectories = new CopyOnWriteArraySet%3CFile%3E();%0A    private static Set%3CFile%3E unwritableDirectories = new CopyOnWriteArraySet%3CFile%3E();%0A%0A    /**%0A     * Adds parent directory of the file (or the file itself, if it is a directory)%0A     * to the set of unreadable directories.%0A     *%0A     * @return the blacklisted directory or null if nothing has been added to the list.%0A     */%0A    public static File maybeMarkUnreadable(File path)%0A    %7B%0A        File directory = getDirectory(path);%0A        if (unreadableDirectories.add(directory))%0A        %7B%0A            logger.warn(%22Blacklisting %7B%7D for reads%22, directory);%0A            return directory;%0A        %7D%0A        return null;%0A    %7D%0A%0A    /**%0A     * Adds parent directory of the file (or the file itself, if it is a directory)%0A     * to the set of unwritable directories.%0A     *%0A     * @return the blacklisted directory or null if nothing has been added to the list.%0A     */%0A    public static File maybeMarkUnwritable(File path)%0A    %7B%0A        File directory = getDirectory(path);%0A        if (unwritableDirectories.add(directory))%0A        %7B%0A            logger.warn(%22Blacklisting %7B%7D for writes%22, directory);%0A            return directory;%0A        %7D%0A        return null;%0A    %7D%0A%0A    /**%0A     * Tells whether or not the directory is blacklisted for reads.%0A     * @return whether or not the directory is blacklisted for reads.%0A     */%0A    public static boolean isUnreadable(File directory)%0A    %7B%0A        return unreadableDirectories.contains(directory);%0A    %7D%0A%0A    /**%0A     * Tells whether or not the directory is blacklisted for writes.%0A     * @return whether or not the directory is blacklisted for reads.%0A     */%0A    public static boolean isUnwritable(File directory)%0A    %7B%0A        return unwritableDirectories.contains(directory);%0A    %7D%0A%0A    private static File getDirectory(File file)%0A    %7B%0A        if (file.isDirectory())%0A            return file;%0A%0A        if (file.isFile())%0A            return file.getParentFile();%0A%0A        // the file with path cannot be read - try determining the directory manually.%0A        if (file.getPath().endsWith(%22.db%22))%0A            return file.getParentFile();%0A%0A        throw new IllegalStateException(%22Unable to parse directory from path %22 + file);%0A    %7D%0A%7D%0A

add src/java/org/apache/cassandra/db/BlacklistedDirectories.java