本文整理汇总了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);
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}