Search in sources :

Example 1 with CassandraDaemon

use of org.apache.cassandra.service.CassandraDaemon in project cassandra-indexing by hmsonline.

the class AbstractIndexingTest method setUp.

@Before
public void setUp() throws Exception {
    if (cassandraService == null) {
        // Start cassandra server
        cassandraService = new CassandraDaemon();
        cassandraService.activate();
        //Thread.sleep(4000);
        cluster = HFactory.getOrCreateCluster(CLUSTER_NAME, CASSANDRA_HOST + ":" + CASSANDRA_PORT);
        // Create indexing schema
        indexKeyspace = createSchema(INDEX_KS, Arrays.asList(CONF_CF, INDEX_CF), cluster);
        // Create data schema
        dataKeyspace = createSchema(DATA_KS, Arrays.asList(DATA_CF, DATA_CF2), cluster);
        cluster.describeKeyspaces();
        configureIndexes();
    // Thread.sleep(10000000);
    }
}
Also used : CassandraDaemon(org.apache.cassandra.service.CassandraDaemon) Before(org.junit.Before)

Example 2 with CassandraDaemon

use of org.apache.cassandra.service.CassandraDaemon in project scale7-pelops by s7.

the class EmbeddedCassandraServer method start.

/**
	 * starts embedded Cassandra server.
	 * 
	 * @throws Exception
	 *             if an error occurs
	 */
public void start() throws Exception {
    try {
        cleanupDirectoriesFailover();
        FileUtils.createDirectory(baseDirectory);
        System.setProperty("log4j.configuration", "file:target/test-classes/log4j.properties");
        System.setProperty("cassandra.config", "file:target/test-classes/cassandra.yaml");
        cassandraDaemon = new CassandraDaemon();
        cassandraDaemon.init(null);
        cassandraThread = new Thread(new Runnable() {

            public void run() {
                try {
                    cassandraDaemon.start();
                } catch (Exception e) {
                    logger.error("Embedded casandra server run failed", e);
                }
            }
        });
        cassandraThread.setDaemon(true);
        cassandraThread.start();
    } catch (Exception e) {
        logger.error("Embedded casandra server start failed", e);
        // cleanup
        stop();
    }
}
Also used : CassandraDaemon(org.apache.cassandra.service.CassandraDaemon)

Example 3 with CassandraDaemon

use of org.apache.cassandra.service.CassandraDaemon in project cassandra by apache.

the class CommitLogFailurePolicyTest method testCommitFailurePolicy_ignore_beforeStartup.

@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());
        //killed quietly due to startup failure
        Assert.assertTrue(killerForTests.wasKilledQuietly());
    } finally {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
Also used : JVMStabilityInspector(org.apache.cassandra.utils.JVMStabilityInspector) KillerForTests(org.apache.cassandra.utils.KillerForTests) Config(org.apache.cassandra.config.Config) CassandraDaemon(org.apache.cassandra.service.CassandraDaemon) Test(org.junit.Test)

Example 4 with CassandraDaemon

use of org.apache.cassandra.service.CassandraDaemon in project gora by apache.

the class GoraCassandraTestDriver method setUpClass.

/**
   * Starts embedded Cassandra server.
   *
   * @throws Exception
   * 	if an error occurs
   */
@Override
public void setUpClass() {
    log.info("Starting embedded Cassandra Server...");
    try {
        cleanupDirectoriesFailover();
        FileUtils.createDirectory(baseDirectory);
        System.setProperty("log4j.configuration", "log4j-server.properties");
        System.setProperty("cassandra.config", "cassandra.yaml");
        cassandraDaemon = new CassandraDaemon();
        cassandraDaemon.init(null);
        cassandraThread = new Thread(new Runnable() {

            public void run() {
                try {
                    cassandraDaemon.start();
                } catch (Exception e) {
                    log.error("Embedded casandra server run failed!", e);
                }
            }
        });
        cassandraThread.setDaemon(true);
        cassandraThread.start();
    } catch (Exception e) {
        log.error("Embedded casandra server start failed!", e);
        // cleanup
        tearDownClass();
    }
}
Also used : CassandraDaemon(org.apache.cassandra.service.CassandraDaemon)

Example 5 with CassandraDaemon

use of org.apache.cassandra.service.CassandraDaemon in project ignite by apache.

the class CassandraLifeCycleBean method startEmbeddedCassandra.

/**
     * Starts embedded Cassandra instance
     */
private void startEmbeddedCassandra() {
    if (log != null) {
        log.info("-------------------------------");
        log.info("| Starting embedded Cassandra |");
        log.info("-------------------------------");
    }
    try {
        if (jmxPort != null)
            System.setProperty(CASSANDRA_JMX_PORT_PROP, jmxPort);
        if (cassandraCfgFile != null)
            System.setProperty(CASSANDRA_CONFIG_PROP, FILE_PREFIX + cassandraCfgFile);
        embeddedCassandraDaemon = new CassandraDaemon(true);
        embeddedCassandraDaemon.init(null);
        embeddedCassandraDaemon.start();
    } catch (Exception e) {
        throw new RuntimeException("Failed to start embedded Cassandra", e);
    }
    if (log != null) {
        log.info("------------------------------");
        log.info("| Embedded Cassandra started |");
        log.info("------------------------------");
    }
}
Also used : CassandraDaemon(org.apache.cassandra.service.CassandraDaemon)

Aggregations

CassandraDaemon (org.apache.cassandra.service.CassandraDaemon)9 Config (org.apache.cassandra.config.Config)4 Test (org.junit.Test)4 JVMStabilityInspector (org.apache.cassandra.utils.JVMStabilityInspector)3 KillerForTests (org.apache.cassandra.utils.KillerForTests)3 Cluster (com.datastax.driver.core.Cluster)1 Duration (io.airlift.units.Duration)1 InetSocketAddress (java.net.InetSocketAddress)1 Before (org.junit.Before)1