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


Java DatabaseDescriptor.getCommitFailurePolicy方法代码示例

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


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

示例1: handleCommitError

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@VisibleForTesting
public static boolean handleCommitError(String message, Throwable t)
{
    JVMStabilityInspector.inspectCommitLogThrowable(t);
    switch (DatabaseDescriptor.getCommitFailurePolicy())
    {
        // Needed here for unit tests to not fail on default assertion
        case die:
        case stop:
            StorageService.instance.stopTransports();
        case stop_commit:
            logger.error(String.format("%s. Commit disk failure policy is %s; terminating thread", message, DatabaseDescriptor.getCommitFailurePolicy()), t);
            return false;
        case ignore:
            logger.error(message, t);
            return true;
        default:
            throw new AssertionError(DatabaseDescriptor.getCommitFailurePolicy());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:CommitLog.java

示例2: testCommitFailurePolicy_stop

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testCommitFailurePolicy_stop() throws ConfigurationException
{
    // Need storage service active so stop policy can shutdown gossip
    StorageService.instance.initServer();
    Assert.assertTrue(Gossiper.instance.isEnabled());

    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.stop);
        CommitLog.handleCommitError("Test stop error", new Throwable());
        Assert.assertFalse(Gossiper.instance.isEnabled());
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:CommitLogTest.java

示例3: testCommitFailurePolicy_die

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testCommitFailurePolicy_die()
{
    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.die);
        CommitLog.handleCommitError("Testing die policy", new Throwable());
        Assert.assertTrue(killerForTests.wasKilled());
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:CommitLogTest.java

示例4: handleCommitError

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@VisibleForTesting
public static boolean handleCommitError(String message, Throwable t)
{
    JVMStabilityInspector.inspectCommitLogThrowable(t);
    switch (DatabaseDescriptor.getCommitFailurePolicy())
    {
        // Needed here for unit tests to not fail on default assertion
        case die:
        case stop:
            StorageService.instance.stopTransports();
            //$FALL-THROUGH$
        case stop_commit:
            logger.error(String.format("%s. Commit disk failure policy is %s; terminating thread", message, DatabaseDescriptor.getCommitFailurePolicy()), t);
            return false;
        case ignore:
            logger.error(message, t);
            return true;
        default:
            throw new AssertionError(DatabaseDescriptor.getCommitFailurePolicy());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:CommitLog.java

示例5: testCommitFailurePolicy_stop

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testCommitFailurePolicy_stop() throws ConfigurationException
{
    CassandraDaemon daemon = new CassandraDaemon();
    daemon.completeSetup(); //startup must be completed, otherwise commit log failure must kill JVM regardless of failure policy
    StorageService.instance.registerDaemon(daemon);

    // Need storage service active so stop policy can shutdown gossip
    StorageService.instance.initServer();
    Assert.assertTrue(Gossiper.instance.isEnabled());

    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.stop);
        CommitLog.handleCommitError("Test stop error", new Throwable());
        Assert.assertFalse(Gossiper.instance.isEnabled());
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:CommitLogFailurePolicyTest.java

示例6: testCommitFailurePolicy_die

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testCommitFailurePolicy_die()
{
    CassandraDaemon daemon = new CassandraDaemon();
    daemon.completeSetup(); //startup must be completed, otherwise commit log failure must kill JVM regardless of failure policy
    StorageService.instance.registerDaemon(daemon);

    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.die);
        CommitLog.handleCommitError("Testing die policy", new Throwable());
        Assert.assertTrue(killerForTests.wasKilled());
        Assert.assertFalse(killerForTests.wasKilledQuietly()); //only killed quietly on startup failure
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:CommitLogFailurePolicyTest.java

示例7: testCommitFailurePolicy_ignore_beforeStartup

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testCommitFailurePolicy_ignore_beforeStartup()
{
    //startup was not completed successfuly (since method completeSetup() was not called)
    CassandraDaemon daemon = new CassandraDaemon();
    StorageService.instance.registerDaemon(daemon);

    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.ignore);
        CommitLog.handleCommitError("Testing ignore policy", new Throwable());
        //even though policy is ignore, JVM must die because Daemon has not finished initializing
        Assert.assertTrue(killerForTests.wasKilled());
        Assert.assertTrue(killerForTests.wasKilledQuietly()); //killed quietly due to startup failure
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:CommitLogFailurePolicyTest.java

示例8: testCommitFailurePolicy_ignore_afterStartup

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testCommitFailurePolicy_ignore_afterStartup() throws Exception
{
    CassandraDaemon daemon = new CassandraDaemon();
    daemon.completeSetup(); //startup must be completed, otherwise commit log failure must kill JVM regardless of failure policy
    StorageService.instance.registerDaemon(daemon);

    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.ignore);
        CommitLog.handleCommitError("Testing ignore policy", new Throwable());
        //error policy is set to IGNORE, so JVM must not be killed if error ocurs after startup
        Assert.assertFalse(killerForTests.wasKilled());
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:CommitLogFailurePolicyTest.java

示例9: inspectCommitLogThrowable

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public static void inspectCommitLogThrowable(Throwable t)
{
    if (DatabaseDescriptor.getCommitFailurePolicy() == Config.CommitFailurePolicy.die)
        killer.killCurrentJVM(t);
    else
        inspectThrowable(t);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:JVMStabilityInspector.java

示例10: 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

示例11: inspectCommitLogThrowable

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public static void inspectCommitLogThrowable(Throwable t)
{
    if (!StorageService.instance.isSetupCompleted())
    {
        logger.error("Exiting due to error while processing commit log during initialization.", t);
        killer.killCurrentJVM(t, true);
    } else if (DatabaseDescriptor.getCommitFailurePolicy() == Config.CommitFailurePolicy.die)
        killer.killCurrentJVM(t);
    else
        inspectThrowable(t);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:12,代码来源:JVMStabilityInspector.java

示例12: 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.getCommitFailurePolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。