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


Java CQLDataLoader类代码示例

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


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

示例1: startServer

import org.cassandraunit.CQLDataLoader; //导入依赖的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

示例2: applyScripts

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
private static void applyScripts(CQLDataLoader dataLoader, String cqlDir, String pattern) throws IOException, URISyntaxException {
    URL dirUrl = ClassLoader.getSystemResource(cqlDir);
    if (dirUrl == null) { // protect for empty directory
        return;
    }

    List<String> scripts = new ArrayList<>();
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(dirUrl.toURI()), pattern)) {
        for (Path entry : stream) {
            scripts.add(entry.getFileName().toString());
        }
    }
    Collections.sort(scripts);

    for (String fileName : scripts) {
        dataLoader.load(new ClassPathCQLDataSet(cqlDir + fileName, false, false, CASSANDRA_UNIT_KEYSPACE));
    }
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:19,代码来源:AbstractCassandraTest.java

示例3: testSavingAndLoadingDecisionTree

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
@Test
public void testSavingAndLoadingDecisionTree() {
    final CQLDataLoader dataLoader = new CQLDataLoader(this.session);
    dataLoader.load(new ClassPathCQLDataSet(CQL_RESOURCE, "loadSavedecisiontree"));

    this.cassandraLoader = CassandraLoader.instanceOf(this.cluster, "loadSavedecisiontree", RULE_SET_NAME);
    final DecisionTreeRuleSet commissions = CommisionRuleSetSupplier.getCommisionRuleSet().build();
    assertNotNull(commissions);

    this.cassandraLoader.put(commissions);
    final Result<DecisionTreeRuleSet> decisionTreeRuleSetResult = this.cassandraLoader.get();
    assertTrue(decisionTreeRuleSetResult.isSuccess());
    final DecisionTreeRuleSet decisionTreeRuleSet = decisionTreeRuleSetResult.getData();
    assertNotNull(decisionTreeRuleSet);
    assertNotNull(decisionTreeRuleSet.getRules());
    assertThat(decisionTreeRuleSet, DecisionTreeRuleSetMatcher.isSame(commissions));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:18,代码来源:CassandraLoaderStandaloneTest.java

示例4: startServer

import org.cassandraunit.CQLDataLoader; //导入依赖的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: testNoRuleSetInKeySpace

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
@Test
public void testNoRuleSetInKeySpace() {
    // Try to load a missing ruleset and confirm it reports a failure.
    final CQLDataLoader dataLoader = new CQLDataLoader(this.session);
    dataLoader.load(new ClassPathCQLDataSet(CQL_RESOURCE, "not_a_ruleset"));
    this.cassandraLoader = CassandraLoader.instanceOf(this.cluster, "not_a_ruleset", "NOT_A_RULESET");

    final Result<DecisionTreeRuleSet> results = this.cassandraLoader.get();
    assertFalse(results.isSuccess());
    assertFalse(this.cassandraLoader.test(results));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:12,代码来源:CassandraLoaderStandaloneTest.java

示例6: testPersistingChangeSets

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
@Test
public void testPersistingChangeSets() {
    final CQLDataLoader dataLoader = new CQLDataLoader(this.session);
    dataLoader.load(new ClassPathCQLDataSet(CQL_RESOURCE, "decisiontreechange"));

    this.cassandraLoader = CassandraLoader.instanceOf(this.cluster, "decisiontreechange", RULE_SET_NAME);

    final DecisionTreeRuleSet commissions = CommisionRuleSetSupplier.getCommisionRuleSet().build();
    assertNotNull(commissions);

    // Find default UK rule, id 5 and increase output rate to 1.3
    final DecisionTreeRule ukRule = commissions.getRules().get(new UUID(0, 5));
    assertNotNull(ukRule);

    // change is created for the date range of the UK rule - this is the change period
    final Builder<ChangeBuilder, Change> builder = ChangeBuilder.creator(commissions);
    builder.with(ChangeBuilder::changeRange, new DateRange(ukRule.getStart(), ukRule.getEnd()));
    builder.with(ChangeBuilder::audit, new Audit("USER1", NOW, "USER2", NOW));
    builder.with(ChangeBuilder::activation, NOW);

    builder.with(ChangeBuilder::ruleChange, RuleChangeBuilder.creator(ukRule.getRuleCode())
            .with(RuleChangeBuilder::output, Collections.singletonList("Rate:1.3")));

    final ChangeSet change = new ChangeSet(UUID.randomUUID(), "updateUKRate",
            Collections.singleton(builder.build()));

    this.cassandraLoader.put(change);

    final Result<ChangeSet> loadedChange = this.cassandraLoader.getChange("updateUKRate");
    assertNotNull(loadedChange);
    if (!loadedChange.isSuccess()) {
        assertTrue(loadedChange.getException().getMessage(), loadedChange.isSuccess());
    }
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:35,代码来源:CassandraLoaderStandaloneTest.java

示例7: startServer

import org.cassandraunit.CQLDataLoader; //导入依赖的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

示例8: applyScripts

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
private static void applyScripts(CQLDataLoader dataLoader, String cqlDir, String pattern) throws IOException, URISyntaxException {
    URL dirUrl = ClassLoader.getSystemResource(cqlDir);
    if (dirUrl == null) { // protect for empty directory
        return;
    }

    try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(dirUrl.toURI()), pattern)) {
        for (Path entry : stream) {
            String fileName = entry.getFileName().toString();
            dataLoader.load(new ClassPathCQLDataSet(cqlDir + fileName, false, false, CASSANDRA_UNIT_KEYSPACE));
        }
    }
}
 
开发者ID:k8s-for-greeks,项目名称:gpmr,代码行数:14,代码来源:AbstractCassandraTest.java

示例9: startServer

import org.cassandraunit.CQLDataLoader; //导入依赖的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

示例10: load

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
@Override
protected void load() {
    String hostIp = EmbeddedCassandraServerHelper.getHost();
    int port = EmbeddedCassandraServerHelper.getNativeTransportPort();
    cluster = new Cluster.Builder().addContactPoints(hostIp).withPort(port).withSocketOptions(getSocketOptions())
            .build();
    session = cluster.connect();
    CQLDataLoader dataLoader = new CQLDataLoader(session);
    dataSets.forEach(dataLoader::load);
    session = dataLoader.getSession();
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:12,代码来源:CustomCassandraCQLUnit.java

示例11: loadScripts

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
/**
 * Loads additional CQL data sets, specified as a list of files in the classpath.
 */
public void loadScripts(String... cqlScriptPaths) {
	Arrays.stream(cqlScriptPaths).forEach(cqlScriptPath -> {
		CQLDataLoader dataLoader = new CQLDataLoader(session);
		ClassPathCQLDataSet dataSet = new ClassPathCQLDataSet(cqlScriptPath);
		dataLoader.load(dataSet);
	});
}
 
开发者ID:codesandnotes,项目名称:cassandra-cql3-pagination,代码行数:11,代码来源:EmbeddedCassandra.java

示例12: start

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
/**
 * Starts this instance of an embedded cassandra and executes the CQL commands in the specified CSL file.
 *
 * @param cqlScriptPath The path (from the classpath) to the CQL script to execute at startup.
 */
public void start(String cqlScriptPath) {
	this.start();

	CQLDataLoader dataLoader = new CQLDataLoader(session);
	ClassPathCQLDataSet dataSet = new ClassPathCQLDataSet(cqlScriptPath, true, true, keyspace);
	dataLoader.load(dataSet);
}
 
开发者ID:codesandnotes,项目名称:cassandra-cql3-pagination,代码行数:13,代码来源:EmbeddedCassandra.java

示例13: load

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
@Override
protected void load() {
  String hostIp = EmbeddedCassandraServerHelper.getHost();
  int port = EmbeddedCassandraServerHelper.getNativeTransportPort();
  cluster = new Cluster.Builder().addContactPoints(hostIp).withPort(port).withSocketOptions(getSocketOptions())
      .build();
  session = cluster.connect();
  CQLDataLoader dataLoader = new CQLDataLoader(session);
  dataLoader.load(dataSet);
  session = dataLoader.getSession();
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:12,代码来源:CustomCassandraCQLUnit.java

示例14: startServer

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
@BeforeClass
public static void startServer() throws 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:jhipster,项目名称:generator-jhipster,代码行数:16,代码来源:_AbstractCassandraTest.java

示例15: persistingChangeSetsWithValueGroups

import org.cassandraunit.CQLDataLoader; //导入依赖的package包/类
@Test
public void persistingChangeSetsWithValueGroups() {
    final CQLDataLoader dataLoader = new CQLDataLoader(this.session);
    dataLoader.load(new ClassPathCQLDataSet(CQL_RESOURCE, "decisiontreechangegroup"));

    this.cassandraLoader = CassandraLoader.instanceOf(this.cluster, "decisiontreechangegroup", RULE_SET_NAME);
    final DecisionTreeRuleSet commissions = CommisionRuleSetSupplier.getCommisionRuleSet().build();
    assertNotNull(commissions);
    final DecisionTreeRuleSet ruleSet = commissions;
    this.cassandraLoader.put(ruleSet);

    final Set<ValueGroup> current = ruleSet.getValueGroups();
    final Optional<ValueGroup> matching = current.stream().filter(valueGroup ->
            valueGroup.getId().equals(new UUID(0, 1))).findFirst();

    assertTrue(matching.isPresent());

    final ValueGroup group = matching.get();
    final Instant end = group.getRange().getFinish();
    final DateRange changeRange = new DateRange(NOW.minus(Period.ofWeeks(20)), NOW.plus(Period.ofWeeks(20)));
    final List<String> drivers = Arrays.asList("CME", "KCBOT");

    // Change the value groups
    final Builder<ValueGroupChangeBuilder, List<ValueGroupChange>> valueGroupChangeBuilder =
            ValueGroupChangeBuilder.creator(group.getName());
    valueGroupChangeBuilder.with(ValueGroupChangeBuilder::ruleSet, ruleSet);
    valueGroupChangeBuilder.with(ValueGroupChangeBuilder::drivers, drivers);
    valueGroupChangeBuilder.with(ValueGroupChangeBuilder::changeRange, changeRange);

    // persist the change...
    final Builder<ChangeBuilder, Change> changeBuilder = ChangeBuilder.creator(ruleSet);
    changeBuilder.with(ChangeBuilder::changeRange, changeRange);
    changeBuilder.with(ChangeBuilder::audit, new Audit("USER1", NOW, "USER2", NOW));
    changeBuilder.with(ChangeBuilder::activation, NOW);
    changeBuilder.with(ChangeBuilder::valueGroupChange, valueGroupChangeBuilder);

    final ChangeSet changeSet = new ChangeSet(UUID.randomUUID(), "updateValueGroups",
            Collections.singleton(changeBuilder.build()));
    this.cassandraLoader.put(changeSet);

    final Result<ChangeSet> loadedChange = this.cassandraLoader.getChange("updateValueGroups");
    assertNotNull(loadedChange);
    if (!loadedChange.isSuccess()) {
        assertTrue(loadedChange.getException().getMessage(), loadedChange.isSuccess());
    }
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:47,代码来源:CassandraLoaderStandaloneTest.java


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