当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.handleFSError方法代码示例

本文整理汇总了Java中org.apache.cassandra.io.util.FileUtils.handleFSError方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.handleFSError方法的具体用法?Java FileUtils.handleFSError怎么用?Java FileUtils.handleFSError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.io.util.FileUtils的用法示例。


在下文中一共展示了FileUtils.handleFSError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Directories

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private Directories(String keyspacename, String cfname, String directoryName)
{
    this.keyspacename = keyspacename;
    this.cfname = cfname;
    this.sstableDirectories = new File[dataFileLocations.length];
    for (int i = 0; i < dataFileLocations.length; ++i)
        sstableDirectories[i] = new File(dataFileLocations[i].location, join(keyspacename, directoryName));

    if (!StorageService.instance.isClientMode())
    {
        for (File dir : sstableDirectories)
        {
            try
            {
                FileUtils.createDirectory(dir);
            }
            catch (FSError e)
            {
                // don't just let the default exception handler do this, we need the create loop to continue
                logger.error("Failed to create {} directory", dir);
                FileUtils.handleFSError(e);
            }
        }
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:26,代码来源:Directories.java

示例2: testDiskFailurePolicy_best_effort

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testDiskFailurePolicy_best_effort()
{
    DiskFailurePolicy origPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    
    try 
    {
        DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.best_effort);
        // Fake a Directory creation failure
        if (Directories.dataDirectories.length > 0)
        {
            String[] path = new String[] {KS, "bad"};
            File dir = new File(Directories.dataDirectories[0].location, StringUtils.join(path, File.separator));
            FileUtils.handleFSError(new FSWriteError(new IOException("Unable to create directory " + dir), dir));
        }

        for (DataDirectory dd : Directories.dataDirectories)
        {
            File file = new File(dd.location, new File(KS, "bad").getPath());
            assertTrue(BlacklistedDirectories.isUnwritable(file));
        }
    } 
    finally 
    {
        DatabaseDescriptor.setDiskFailurePolicy(origPolicy);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:DirectoriesTest.java

示例3: testDiskFailurePolicy_best_effort

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testDiskFailurePolicy_best_effort()
{
    DiskFailurePolicy origPolicy = DatabaseDescriptor.getDiskFailurePolicy();

    try
    {
        DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.best_effort);
        // Fake a Directory creation failure
        if (Directories.dataDirectories.length > 0)
        {
            String[] path = new String[] {KS, "bad"};
            File dir = new File(Directories.dataDirectories[0].location, StringUtils.join(path, File.separator));
            FileUtils.handleFSError(new FSWriteError(new IOException("Unable to create directory " + dir), dir));
        }

        for (DataDirectory dd : Directories.dataDirectories)
        {
            File file = new File(dd.location, new File(KS, "bad").getPath());
            assertTrue(BlacklistedDirectories.isUnwritable(file));
        }
    } 
    finally 
    {
        DatabaseDescriptor.setDiskFailurePolicy(origPolicy);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:28,代码来源:DirectoriesTest.java

示例4: Directories

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
/**
 * Create Directories of given ColumnFamily.
 * SSTable directories are created under data_directories defined in cassandra.yaml if not exist at this time.
 *
 * @param metadata metadata of ColumnFamily
 */
public Directories(CFMetaData metadata)
{
    this.metadata = metadata;
    if (StorageService.instance.isClientMode())
    {
        dataPaths = null;
        return;
    }

    String cfId = ByteBufferUtil.bytesToHex(ByteBufferUtil.bytes(metadata.cfId));
    int idx = metadata.cfName.indexOf(SECONDARY_INDEX_NAME_SEPARATOR);
    // secondary indicies go in the same directory as the base cf
    String directoryName = idx > 0 ? metadata.cfName.substring(0, idx) + "-" + cfId : metadata.cfName + "-" + cfId;

    this.dataPaths = new File[dataDirectories.length];
    // If upgraded from version less than 2.1, use existing directories
    for (int i = 0; i < dataDirectories.length; ++i)
    {
        // check if old SSTable directory exists
        dataPaths[i] = new File(dataDirectories[i].location,
                                join(metadata.ksName,
                                     idx > 0 ? metadata.cfName.substring(0, idx) : metadata.cfName));
    }
    boolean olderDirectoryExists = Iterables.any(Arrays.asList(dataPaths), new Predicate<File>()
    {
        public boolean apply(File file)
        {
            return file.exists();
        }
    });
    if (!olderDirectoryExists)
    {
        // use 2.1-style path names
        for (int i = 0; i < dataDirectories.length; ++i)
            dataPaths[i] = new File(dataDirectories[i].location, join(metadata.ksName, directoryName));
    }

    for (File dir : dataPaths)
    {
        try
        {
            FileUtils.createDirectory(dir);
        }
        catch (FSError e)
        {
            // don't just let the default exception handler do this, we need the create loop to continue
            logger.error("Failed to create {} directory", dir);
            FileUtils.handleFSError(e);
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:58,代码来源:Directories.java


注:本文中的org.apache.cassandra.io.util.FileUtils.handleFSError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。