Example usage for org.apache.cassandra.service EmbeddedCassandraService EmbeddedCassandraService

List of usage examples for org.apache.cassandra.service EmbeddedCassandraService EmbeddedCassandraService

Introduction

In this page you can find the example usage for org.apache.cassandra.service EmbeddedCassandraService EmbeddedCassandraService.

Prototype

EmbeddedCassandraService

Source Link

Usage

From source file:com.impetus.client.persistence.CassandraCli.java

License:Apache License

/**
 * Cassandra set up.//from   w  ww. j  a  va 2  s .com
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws TException
 *             the t exception
 * @throws InvalidRequestException
 *             the invalid request exception
 * @throws UnavailableException
 *             the unavailable exception
 * @throws TimedOutException
 *             the timed out exception
 * @throws SchemaDisagreementException
 *             the schema disagreement exception
 */
public static void cassandraSetUp() throws IOException, TException, InvalidRequestException,
        UnavailableException, TimedOutException, SchemaDisagreementException {

    if (!checkIfServerRunning()) {
        cassandra = new EmbeddedCassandraService();
        cassandra.start();
        initClient();
    }
}

From source file:com.impetus.client.spark.cassandra.utils.CassandraCli.java

License:Apache License

/**
 * Cassandra set up./*w  w  w . jav  a 2  s .com*/
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws TException
 *             the t exception
 * @throws InvalidRequestException
 *             the invalid request exception
 * @throws UnavailableException
 *             the unavailable exception
 * @throws TimedOutException
 *             the timed out exception
 * @throws SchemaDisagreementException
 *             the schema disagreement exception
 */
public static void cassandraSetUp(String ip, int port) throws IOException, TException, InvalidRequestException,
        UnavailableException, TimedOutException, SchemaDisagreementException {
    if (!checkIfServerRunning(ip, port)) {
        cassandra = new EmbeddedCassandraService();
        cassandra.start();
    }
    initClient(ip, port);
}

From source file:com.impetus.kundera.client.cassandra.persistence.CassandraCli.java

License:Apache License

/**
 * Cassandra set up./* w  ww .  j  a va  2  s  . com*/
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws TException
 *             the t exception
 * @throws InvalidRequestException
 *             the invalid request exception
 * @throws UnavailableException
 *             the unavailable exception
 * @throws TimedOutException
 *             the timed out exception
 * @throws SchemaDisagreementException
 *             the schema disagreement exception
 */
public static void cassandraSetUp() throws IOException, TException, InvalidRequestException,
        UnavailableException, TimedOutException, SchemaDisagreementException {
    if (!checkIfServerRunning()) {
        cassandra = new EmbeddedCassandraService();
        cassandra.start();
    }
    initClient();
}

From source file:com.impetus.kundera.examples.twitter.TwissandraTest.java

License:Apache License

/**
 * Start cassandra server.//from w ww .java  2s  .  c  o m
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws ConfigurationException
 *             the configuration exception
 */
private static void startCassandraServer() throws IOException, ConfigurationException {

    if (!checkIfServerRunning()) {
        EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
        cassandra.start();
    }
}

From source file:com.impetus.kundera.junit.TestCassandra.java

License:Apache License

public void startCassandraServer() throws Exception {
    URL configURL = TestCassandra.class.getClassLoader().getResource("storage-conf.xml");
    try {//from   w w  w .  j  a v  a 2  s .  c o m
        String storageConfigPath = configURL.getFile().substring(1).substring(0,
                configURL.getFile().lastIndexOf("/"));
        System.setProperty("storage-config", storageConfigPath);
    } catch (Exception e) {
        fail("Could not find storage-config.xml sfile");
    }
    cassandra = new EmbeddedCassandraService();
    cassandra.init();
    Thread t = new Thread(cassandra);
    t.setDaemon(true);
    t.start();
}

From source file:com.isthari.spring.cloud.config.cassandra.CassandraEnvironmentRepositoryTest.java

License:Apache License

@BeforeClass
public static void startCassandra() throws Exception {
    String embedded = System.getProperty("isthari.cassandra.test.embedded");
    useEmbeddedCassandra = embedded == null || "true".equals(useEmbeddedCassandra);

    if (useEmbeddedCassandra) {
        cleanUp();/* w  w w.  j ava2  s.co m*/
        EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
        cassandra.start();
    }

    repository = new CassandraEnvironmentRepository(null, "127.0.0.1", null, null, true);

    // LOAD TEST DATASET
    Class<?> clazz = repository.getClass();
    Field sessionField = clazz.getDeclaredField("session");
    sessionField.setAccessible(true);
    session = (Session) sessionField.get(repository);

    stmtApplicationLabelProfile = session.prepare(
            "insert into application_label_version (application, label , profile, version  ) VALUES (?,?,?,?)");
    stmtApplicationSnapshot = session
            .prepare("insert into configuration_snapshot (application, version, parameters) values (?,?,?)");

    createSnapshot("application", "master", "", new String[] { "param4" }, new String[] { "value4" });
}

From source file:com.jeklsoft.cassandraclient.EmbeddedCassandra.java

License:Apache License

private void init() throws IOException {

    setupStorageConfigPath();//from w w  w.j a  va  2s  .  c o  m

    if (cleanCassandra) {
        clean();
    }

    EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
    cassandra.start();

    if (cassandraStartupCommands != null) {
        executeCommands();
    }
}

From source file:com.jointhegrid.hivecasudfs.UDFCasMapJoinTest.java

License:Apache License

public void setUp() throws Exception {
    super.setUp();
    CassandraServiceDataCleaner cleaner = new CassandraServiceDataCleaner();
    cleaner.prepare();//  w w w  .  j  av a  2  s  . c  om

    ecs = new EmbeddedCassandraService();
    ecs.start();
    cluster = HFactory.getOrCreateCluster("Test Cluster", "localhost:9154");

    KeyspaceDefinition ksDef = HFactory.createKeyspaceDefinition("udfmj");
    ColumnFamilyDefinition cfBak = HFactory.createColumnFamilyDefinition("udfmj", "udfmj",
            ComparatorType.BYTESTYPE);

    cluster.addKeyspace(ksDef);
    cluster.addColumnFamily(cfBak);

    ksp = HFactory.createKeyspace("udfmj", cluster);
    data = new ThriftColumnFamilyTemplate<ByteBuffer, ByteBuffer>(ksp, "udfmj", ByteBufferSerializer.get(),
            ByteBufferSerializer.get());

}

From source file:com.jointhegrid.hivecasudfs.UDFDeleteTest.java

License:Apache License

public void setUp() throws Exception {
    super.setUp();
    CassandraServiceDataCleaner cleaner = new CassandraServiceDataCleaner();
    cleaner.prepare();/*from   w w w.java 2s.c  o m*/

    ecs = new EmbeddedCassandraService();
    ecs.start();
    cluster = HFactory.getOrCreateCluster("Test Cluster", "localhost:9154");

    KeyspaceDefinition ksDef = HFactory.createKeyspaceDefinition("udfdelete");
    ColumnFamilyDefinition cfBak = HFactory.createColumnFamilyDefinition("udfdelete", "udfdelete",
            ComparatorType.UTF8TYPE);

    cluster.addKeyspace(ksDef);
    cluster.addColumnFamily(cfBak);

    ksp = HFactory.createKeyspace("udfdelete", cluster);
    data = new ThriftColumnFamilyTemplate<String, String>(ksp, "udfdelete", StringSerializer.get(),
            StringSerializer.get());

}

From source file:com.navercorp.pinpoint.plugin.cassandra.CassandraTestHelper.java

License:Apache License

public static void init(final String cassandraVersion) throws IOException, ConfigurationException {
    final String cassandraStorageDir = String.format("%s/data_%s", CASSANDRA_HOME, cassandraVersion);
    final String cassandraConfigFile = String.format("cassandra/cassandra_%s.yaml", cassandraVersion);
    System.setProperty("cassandra.storagedir", cassandraStorageDir);
    System.setProperty("cassandra.config", cassandraConfigFile);
    prepareEnvironment();//from  w  ww  .  j a v  a  2  s.co  m
    EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
    cassandra.start();
}