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


Java DatabaseDescriptor.getDiskFailurePolicy方法代码示例

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


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

示例1: inspectThrowable

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * Certain Throwables and Exceptions represent "Die" conditions for the server.
 * This recursively checks the input Throwable's cause hierarchy until null.
 * @param t
 *      The Throwable to check for server-stop conditions
 */
public static void inspectThrowable(Throwable t)
{
    boolean isUnstable = false;
    if (t instanceof OutOfMemoryError)
    {
        isUnstable = true;
        HeapUtils.generateHeapDump();
    }

    if (DatabaseDescriptor.getDiskFailurePolicy() == Config.DiskFailurePolicy.die)
        if (t instanceof FSError || t instanceof CorruptSSTableException)
        isUnstable = true;

    // Check for file handle exhaustion
    if (t instanceof FileNotFoundException || t instanceof SocketException)
        if (t.getMessage().contains("Too many open files"))
            isUnstable = true;

    if (isUnstable)
        killer.killCurrentJVM(t);

    if (t.getCause() != null)
        inspectThrowable(t.getCause());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:31,代码来源:JVMStabilityInspector.java

示例2: inspectThrowable

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 * Certain Throwables and Exceptions represent "Die" conditions for the server.
 * @param t
 *      The Throwable to check for server-stop conditions
 */
public static void inspectThrowable(Throwable t)
{
    boolean isUnstable = false;
    if (t instanceof OutOfMemoryError)
        isUnstable = true;

    if (DatabaseDescriptor.getDiskFailurePolicy() == Config.DiskFailurePolicy.die)
        if (t instanceof FSError || t instanceof CorruptSSTableException)
        isUnstable = true;

    // Check for file handle exhaustion
    if (t instanceof FileNotFoundException || t instanceof SocketException)
        if (t.getMessage().contains("Too many open files"))
            isUnstable = true;

    if (isUnstable)
        killer.killCurrentJVM(t);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:JVMStabilityInspector.java

示例3: handleFSError

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public static void handleFSError(FSError e)
{
    JVMStabilityInspector.inspectThrowable(e);
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
        case stop:
            StorageService.instance.stopTransports();
            break;
        case best_effort:
            // for both read and write errors mark the path as unwritable.
            BlacklistedDirectories.maybeMarkUnwritable(e.path);
            if (e instanceof FSReadError)
            {
                File directory = BlacklistedDirectories.maybeMarkUnreadable(e.path);
                if (directory != null)
                    Keyspace.removeUnreadableSSTables(directory);
            }
            break;
        case ignore:
            // already logged, so left nothing to do
            break;
        default:
            throw new IllegalStateException();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:FileUtils.java

示例4: handleStartupFSError

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
private static void handleStartupFSError(Throwable t)
{
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
        case stop:
        case die:
            logger.error("Exiting forcefully due to file system exception on startup, disk failure policy \"{}\"",
                         DatabaseDescriptor.getDiskFailurePolicy(),
                         t);
            JVMStabilityInspector.killCurrentJVM(t, true);
            break;
        default:
            break;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:DefaultFSErrorHandler.java

示例5: testFlushUnwriteableDie

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testFlushUnwriteableDie() throws Throwable
{
    makeTable();

    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
    DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore()))
    {
        DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.die);
        flushAndExpectError();
        Assert.assertTrue(killerForTests.wasKilled());
        Assert.assertFalse(killerForTests.wasKilledQuietly()); //only killed quietly on startup failure
    }
    finally
    {
        DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:OutOfSpaceTest.java

示例6: testFlushUnwriteableStop

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testFlushUnwriteableStop() throws Throwable
{
    makeTable();

    DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore()))
    {
        DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.stop);
        flushAndExpectError();
        Assert.assertFalse(Gossiper.instance.isEnabled());
    }
    finally
    {
        DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:OutOfSpaceTest.java

示例7: testFlushUnwriteableIgnore

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testFlushUnwriteableIgnore() throws Throwable
{
    makeTable();

    DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore()))
    {
        DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.ignore);
        flushAndExpectError();
    }
    finally
    {
        DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
    }

    // Next flush should succeed.
    flush();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:OutOfSpaceTest.java

示例8: handleCorruptSSTable

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public static void handleCorruptSSTable(CorruptSSTableException e)
{
    JVMStabilityInspector.inspectThrowable(e);
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
            StorageService.instance.stopTransports();
            break;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:FileUtils.java

示例9: testKill

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testKill() throws Exception
{
    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);

    Config.DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    Config.CommitFailurePolicy oldCommitPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new IOException());
        assertFalse(killerForTests.wasKilled());

        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new OutOfMemoryError());
        assertTrue(killerForTests.wasKilled());

        DatabaseDescriptor.setDiskFailurePolicy(Config.DiskFailurePolicy.die);
        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new FSReadError(new IOException(), "blah"));
        assertTrue(killerForTests.wasKilled());

        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.die);
        killerForTests.reset();
        JVMStabilityInspector.inspectCommitLogThrowable(new Throwable());
        assertTrue(killerForTests.wasKilled());
    }
    finally
    {
        JVMStabilityInspector.replaceKiller(originalKiller);
        DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
        DatabaseDescriptor.setCommitFailurePolicy(oldCommitPolicy);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:36,代码来源:JVMStabilityInspectorTest.java

示例10: testDiskFailurePolicy_best_effort

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的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

示例11: handleFSError

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public static void handleFSError(FSError e)
{
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop:
            if (StorageService.instance.isInitialized())
            {
                logger.error("Stopping gossiper");
                StorageService.instance.stopGossiping();
            }

            if (StorageService.instance.isRPCServerRunning())
            {
                logger.error("Stopping RPC server");
                StorageService.instance.stopRPCServer();
            }

            if (StorageService.instance.isNativeTransportRunning())
            {
                logger.error("Stopping native transport");
                StorageService.instance.stopNativeTransport();
            }
            break;
        case best_effort:
            // for both read and write errors mark the path as unwritable.
            BlacklistedDirectories.maybeMarkUnwritable(e.path);
            if (e instanceof FSReadError)
            {
                File directory = BlacklistedDirectories.maybeMarkUnreadable(e.path);
                if (directory != null)
                    Keyspace.removeUnreadableSSTables(directory);
            }
            break;
        case ignore:
            // already logged, so left nothing to do
            break;
        default:
            throw new IllegalStateException();
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:41,代码来源:FileUtils.java

示例12: handleCorruptSSTable

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Override
public void handleCorruptSSTable(CorruptSSTableException e)
{
    if (!StorageService.instance.isSetupCompleted())
        handleStartupFSError(e);

    JVMStabilityInspector.inspectThrowable(e);
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
            StorageService.instance.stopTransports();
            break;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:DefaultFSErrorHandler.java

示例13: handleFSError

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Override
public void handleFSError(FSError e)
{
    if (!StorageService.instance.isSetupCompleted())
        handleStartupFSError(e);

    JVMStabilityInspector.inspectThrowable(e);
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
        case stop:
            StorageService.instance.stopTransports();
            break;
        case best_effort:
            // for both read and write errors mark the path as unwritable.
            BlacklistedDirectories.maybeMarkUnwritable(e.path);
            if (e instanceof FSReadError)
            {
                File directory = BlacklistedDirectories.maybeMarkUnreadable(e.path);
                if (directory != null)
                    Keyspace.removeUnreadableSSTables(directory);
            }
            break;
        case ignore:
            // already logged, so left nothing to do
            break;
        default:
            throw new IllegalStateException();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:31,代码来源:DefaultFSErrorHandler.java

示例14: testDiskFailurePolicy_best_effort

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的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

示例15: testKill

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testKill() throws Exception
{
    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);

    Config.DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    Config.CommitFailurePolicy oldCommitPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new IOException());
        assertFalse(killerForTests.wasKilled());

        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new OutOfMemoryError());
        assertTrue(killerForTests.wasKilled());

        DatabaseDescriptor.setDiskFailurePolicy(Config.DiskFailurePolicy.die);
        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new FSReadError(new IOException(), "blah"));
        assertTrue(killerForTests.wasKilled());

        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.die);
        killerForTests.reset();
        JVMStabilityInspector.inspectCommitLogThrowable(new Throwable());
        assertTrue(killerForTests.wasKilled());

        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new Exception(new IOException()));
        assertFalse(killerForTests.wasKilled());

        killerForTests.reset();
        JVMStabilityInspector.inspectThrowable(new Exception(new OutOfMemoryError()));
        assertTrue(killerForTests.wasKilled());

    }
    finally
    {
        JVMStabilityInspector.replaceKiller(originalKiller);
        DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
        DatabaseDescriptor.setCommitFailurePolicy(oldCommitPolicy);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:45,代码来源:JVMStabilityInspectorTest.java


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