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


Java DatabaseDescriptor.setCommitFailurePolicy方法代码示例

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


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

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

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

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

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

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

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

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

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