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


Java EmbeddedCassandraServerHelper.startEmbeddedCassandra方法代码示例

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


在下文中一共展示了EmbeddedCassandraServerHelper.startEmbeddedCassandra方法的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: 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

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

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

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

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

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

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

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

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

示例12: setUp

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    // create the embedded cassandra instance and connect to it
    EmbeddedCassandraServerHelper.startEmbeddedCassandra();
    sut.host = "localhost";
    sut.port = 9142;
    sut.connect();
}
 
开发者ID:lookout,项目名称:cassandra-health-check,代码行数:9,代码来源:HealthCheckTest.java

示例13: setup

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

    initializeTestData(DATE);

    String connectorId = "cassandra-test";
    CassandraConnectorFactory connectorFactory = new CassandraConnectorFactory(
            connectorId,
            ImmutableMap.<String, String>of());

    Connector connector = connectorFactory.create(connectorId, ImmutableMap.of(
            "cassandra.contact-points", HOSTNAME,
            "cassandra.native-protocol-port", Integer.toString(PORT)));

    metadata = connector.getMetadata(CassandraTransactionHandle.INSTANCE);
    assertInstanceOf(metadata, CassandraMetadata.class);

    splitManager = connector.getSplitManager();
    assertInstanceOf(splitManager, CassandraSplitManager.class);

    recordSetProvider = connector.getRecordSetProvider();
    assertInstanceOf(recordSetProvider, CassandraRecordSetProvider.class);

    database = KEYSPACE_NAME.toLowerCase();
    table = new SchemaTableName(database, TABLE_NAME.toLowerCase());
    tableUnpartitioned = new SchemaTableName(database, "presto_test_unpartitioned");
    invalidTable = new SchemaTableName(database, "totally_invalid_table_name");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:32,代码来源:TestCassandraConnector.java

示例14: createCassandraQueryRunner

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入方法依赖的package包/类
public static DistributedQueryRunner createCassandraQueryRunner(Iterable<TpchTable<?>> tables)
        throws Exception
{
    EmbeddedCassandraServerHelper.startEmbeddedCassandra();

    try (Cluster cluster = CassandraTestingUtils.getCluster();
            com.datastax.driver.core.Session session = cluster.connect()) {
        createOrReplaceKeyspace(session, "tpch");
        createOrReplaceKeyspace(session, "tpch_sampled");
    }

    DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 4);

    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");

    queryRunner.installPlugin(new SampledTpchPlugin());
    queryRunner.createCatalog("tpch_sampled", "tpch_sampled");

    queryRunner.installPlugin(new CassandraPlugin());
    queryRunner.createCatalog("cassandra", "cassandra", ImmutableMap.of(
            "cassandra.contact-points", "localhost",
            "cassandra.native-protocol-port", "9142",
            "cassandra.allow-drop-table", "true"));

    copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
    copyTpchTables(queryRunner, "tpch_sampled", TINY_SCHEMA_NAME, createSampledSession(), tables);

    return queryRunner;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:31,代码来源:CassandraQueryRunner.java

示例15: setupCassandra

import org.cassandraunit.utils.EmbeddedCassandraServerHelper; //导入方法依赖的package包/类
@BeforeClass
public static void setupCassandra() throws ConfigurationException, IOException, TTransportException, InterruptedException {
    EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.CASSANDRA_RNDPORT_YML_FILE);
    binaryPort = EmbeddedCassandraServerHelper.getNativeTransportPort();

    cluster = Cluster.builder()
            .addContactPoints(CASSANDRA_HOSTS)
            .withPort(binaryPort)
            .withCredentials(username, password)
            .build();
    session = cluster.connect();
}
 
开发者ID:sky-uk,项目名称:cqlmigrate,代码行数:13,代码来源:CqlMigratorHealthCheckTest.java


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