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


Java EmbeddedCassandraServerHelper类代码示例

本文整理汇总了Java中org.cassandraunit.utils.EmbeddedCassandraServerHelper的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedCassandraServerHelper类的具体用法?Java EmbeddedCassandraServerHelper怎么用?Java EmbeddedCassandraServerHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: before

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@Override
protected void before() throws Throwable {

	if (runtimeMode == RuntimeMode.REQUIRE_RUNNING_INSTANCE) {
		if (!CassandraSocket.isConnectable(getHost(), getPort())) {
			throw new AssumptionViolatedException(
					String.format("Cassandra is not reachable at %s:%s.", getHost(), getPort()));
		}
	}

	if (runtimeMode == RuntimeMode.EMBEDDED_IF_NOT_RUNNING) {
		if (CassandraSocket.isConnectable(getHost(), getPort())) {
			return;
		}
	}

	EmbeddedCassandraServerHelper.startEmbeddedCassandra("embedded-cassandra.yaml");
	super.before();
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:20,代码来源:Cassandra.java

示例2: startServer

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeClass
public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException, URISyntaxException  {
    if (! started) {
        EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_UNIT_RANDOM_PORT_YAML, CASSANDRA_TIMEOUT);
        Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(getNativeTransportPort()).build();
        Session session = cluster.connect();
        String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}";
        session.execute(createQuery);
        String useKeyspaceQuery = "USE " + CASSANDRA_UNIT_KEYSPACE;
        session.execute(useKeyspaceQuery);
        CQLDataLoader dataLoader = new CQLDataLoader(session);
        applyScripts(dataLoader, "config/cql/changelog/", "*.cql");
        started = true;
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:16,代码来源:AbstractCassandraTest.java

示例3: stop

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
/**
 * Stops the server
 */
public static void stop() {

    LOG.info("Checking if the Cassandra server can be stopped");

    // stop the server only if there is a server running
    if (serverRunning.compareAndSet(true, false)) {

        LOG.info("Stopping the Cassandra server");

        // clear all data from the cluster
        EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();

        // close the cluster and all sessions, and shutdown the embedded server
        session.getCluster().close();

        LOG.info("Cassandra server stopped");
    } else
        LOG.info("Cassandra server not running");
}
 
开发者ID:mbeiter,项目名称:eaudit4j,代码行数:23,代码来源:CassandraServer.java

示例4: startServer

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeClass
public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException {
    EmbeddedCassandraServerHelper.startEmbeddedCassandra();
    Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(9142).build();
    Session session = cluster.connect();
    CQLDataLoader dataLoader = new CQLDataLoader(session);
    dataLoader.load(new ClassPathCQLDataSet("config/cql/create-tables.cql", true, "cassandra_unit_keyspace"));
}
 
开发者ID:xetys,项目名称:jhipster-ribbon-hystrix,代码行数:9,代码来源:_AbstractCassandraTest.java

示例5: ensureMockCassandraRunningAndEstablished

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
/**
 * Ensures that the Mock Cassandra instance is up and running. Will reinit
 * the database every time it is called.
 *
 * @param cassandraKeyspace Cassandra keyspace to setup.
 * @return A cluster object.
 * @throws ConfigurationException
 * @throws IOException
 * @throws InterruptedException
 * @throws TTransportException
 */
public static Cluster ensureMockCassandraRunningAndEstablished(String cassandraKeyspace) throws ConfigurationException, IOException, InterruptedException, TTransportException
{
    Cluster cluster;
    long timeout = 60000;
    EmbeddedCassandraServerHelper.startEmbeddedCassandra(timeout);
    cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build();
    //Thread.sleep(20000);//time to let cassandra startup
    final Metadata metadata = cluster.getMetadata();

    Session session = cluster.connect();
    Utils.initDatabase(DB_CQL, session);
    session = cluster.connect(cassandraKeyspace);

    logger.info("Connected to cluster: " + metadata.getClusterName() + '\n');
    return cluster;
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:28,代码来源:Fixtures.java

示例6: test

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@Test
public void test() throws Exception {
    CassandraConnector connector = new CassandraConnector();
    connector.setHosts(new String[] { EmbeddedCassandraServerHelper.getHost() });
    connector.setPort(server.getNativePort());
    connector.setKeyspace(null);
    connector.init();

    ResultSet rs = connector.session().execute("select release_version from system.local");
    Row row = rs.one();
    row.getString("release_version");
    Assert.assertEquals(row.getString("release_version"), "3.11.0");

    connector.session().execute("CREATE KEYSPACE gcplot WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }");

    connector.destroy();

    connector = new CassandraConnector();
    connector.setHosts(new String[] { EmbeddedCassandraServerHelper.getHost() });
    connector.setPort(server.getNativePort());
    connector.setKeyspace("gcplot");
    connector.init();
    connector.destroy();
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:25,代码来源:TestCassandraConnector.java

示例7: setUp

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeMethod(groups = {"system"})
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    EmbeddedCassandraServerHelper.startEmbeddedCassandra();

    // default to using cassandra on localhost, but can be overridden with a system property
    String cassandraHostsString = System.getProperty(CASSANDRA_HOSTS_SYSTEM_PROPERTY, LOCALHOST_IP);
    String[] cassandraHosts = StringUtils.split(cassandraHostsString, ',');
    Cluster.Builder clusterBuilder = Cluster.builder();
    for (String host : cassandraHosts) {
        clusterBuilder.addContactPoint(host);
    }
    cluster = clusterBuilder.withPort(9142).build();
    dropAndCreateSchema();

    // get new session using a default keyspace that we now know exists
    session = cluster.connect(TEST_KEYSPACE);
    session = spy(session);
    daoSupport = new CqlStructuredDataSupport<UUID>(tableName, ConsistencyLevel.QUORUM, session);
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:21,代码来源:CqlStructuredDataSupportSystemTest.java

示例8: setUp

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
    // default to using cassandra on localhost, but can be overridden with a system property
    String cassandraHosts = System.getProperty(CASSANDRA_HOSTS_SYSTEM_PROPERTY, EMBEDDED_CASSANDRA_HOST);
    String[] hosts = StringUtils.split(cassandraHosts, ",");
    numHosts = hosts.length;

    if (EMBEDDED_CASSANDRA_HOST.equals(cassandraHosts)) {
        EmbeddedCassandraServerHelper.startEmbeddedCassandra();
    }

    // default cluster name can also be overridden with a system property
    String clusterName = System.getProperty(CLUSTER_NAME_PROPERTY, TEST_CLUSTER);

    hostConfigurator = new CassandraHostConfigurator(cassandraHosts);
    cluster = HFactory.getOrCreateCluster(clusterName, hostConfigurator);
    keyspace = HFactory.createKeyspace(TEST_KEYSPACE, cluster);

    dropAndCreateSchema();
    sleepAfterSchemaChangeIfNecessary();
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:22,代码来源:AbstractCassandraThriftSystemTest.java

示例9: initTest

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeClass
public static void initTest() throws Exception {

    //this test will be slow because it needs to start Casssandra embedded server.
    // For the test to be run on slow machines,
    // the embedded cassandra start timeout is set bellow to 32s ! (which is pretty slow for a unit test)
    EmbeddedCassandraServerHelper.startEmbeddedCassandra(32000L);
    cluster = new Cluster.Builder().addContactPoint("localhost").withPort(9142).build();
    session = cluster.connect();
    createKeyspace();
    personCassandraDao = new PersonCassandraDao("localhost", "9142", CASS_KEYSPACE);
    personCassandraDao.init(Person.class);
}
 
开发者ID:echauchot,项目名称:bigDataRocks,代码行数:14,代码来源:PersonCassandraDaoTest.java

示例10: stopCassandra

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@AfterClass
public static void stopCassandra() {
    //Sometimes cleaning request to EmbeddedCassandra timeouts but it is not a big deal not to clean embeddedCassandra
    // because keyspace is dropped and recreated in the initialization of this test. It is better not to break the build
    // on slow machines
    try {
        EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
    } catch (OperationTimedOutException e) {
        e.printStackTrace();
    }
}
 
开发者ID:echauchot,项目名称:bigDataRocks,代码行数:12,代码来源:PersonCassandraDaoTest.java

示例11: setUpClass

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws InterruptedException, TTransportException, IOException {
	System.setProperty("para.cassandra.port", "9142");
	System.setProperty("para.app_name", ROOT_APP_NAME);
	System.setProperty("para.cluster_name", ROOT_APP_NAME);
	EmbeddedCassandraServerHelper.startEmbeddedCassandra(15 * 1000);
	CassandraUtils.createTable(ROOT_APP_NAME);
	CassandraUtils.createTable(appid1);
	CassandraUtils.createTable(appid2);
	CassandraUtils.createTable(appid3);
}
 
开发者ID:Erudika,项目名称:para-dao-cassandra,代码行数:12,代码来源:CassandraDAOIT.java

示例12: tearDownClass

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@AfterClass
public static void tearDownClass() {
	CassandraUtils.deleteTable(ROOT_APP_NAME);
	CassandraUtils.deleteTable(appid1);
	CassandraUtils.deleteTable(appid2);
	CassandraUtils.deleteTable(appid3);
	CassandraUtils.shutdownClient();
	EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
}
 
开发者ID:Erudika,项目名称:para-dao-cassandra,代码行数:10,代码来源:CassandraDAOIT.java

示例13: startServer

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeClass
public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException, URISyntaxException  {
    EmbeddedCassandraServerHelper.startEmbeddedCassandra();
    Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(9142).build();
    Session session = cluster.connect();
    CQLDataLoader dataLoader = new CQLDataLoader(session);
    dataLoader.load(new ClassPathCQLDataSet("config/cql/create-tables.cql", true, CASSANDRA_UNIT_KEYSPACE));
    applyScripts(dataLoader, "config/cql/changelog/", "*.cql");
}
 
开发者ID:k8s-for-greeks,项目名称:gpmr,代码行数:10,代码来源:AbstractCassandraTest.java

示例14: startServer

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
@BeforeClass
public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException, URISyntaxException  {
    EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_TIMEOUT);
    Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(9142).build();
    Session session = cluster.connect();
    String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}";
    session.execute(createQuery);
    String useKeyspaceQuery = "USE " + CASSANDRA_UNIT_KEYSPACE;
    session.execute(useKeyspaceQuery);
    CQLDataLoader dataLoader = new CQLDataLoader(session);
    applyScripts(dataLoader, "config/cql/changelog/", "*.cql");
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:13,代码来源:_AbstractCassandraTest.java

示例15: startEmbeddedCassandra

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入依赖的package包/类
private static Session startEmbeddedCassandra(boolean disableCassandra) {
    if (disableCassandra) {
        logger.warn("Embedded cassandra is NOT starting up because your app configuration explicitly requests "
                    + "that it be disabled.");
        return null;
    }

    if (cassandraSession == null) {
        File cassandraWorkDir = new File(embeddedClusterWorkDirectory);
        if (!cassandraWorkDir.exists()) {
            logger.info("Creating the  embedded Cassandra folders...{}", cassandraWorkDir.getAbsolutePath());
            //noinspection ResultOfMethodCallIgnored
            cassandraWorkDir.mkdirs();
        }
        // Start embedded cassandra
        logger.info("Finished Creating the  embedded Cassandra folders...{}",
                    cassandraWorkDir.getAbsolutePath());
        logger.info("Starting embedded Cassandra");

        try {
            EmbeddedCassandraServerHelper.startEmbeddedCassandra(cassandraYamlFile,
                                                                 embeddedClusterWorkDirectory);
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }

        Cluster cassandraCluster = Cluster.builder()
                                          .addContactPoint(embeddedClusterContactPointHost)
                                          .withPort(embeddedClusterContactPointPort)
                                          .build();
        cassandraSession = cassandraCluster.connect();
    }

    return cassandraSession;
}
 
开发者ID:Nike-Inc,项目名称:riposte-microservice-template,代码行数:37,代码来源:ExampleCassandraAsyncEndpoint.java


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