Package org.springframework.cassandra.core.keyspace

Examples of org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification


   *
   * @return The {@link CreateKeyspaceSpecification}
   */
  private CreateKeyspaceSpecification generateCreateKeyspaceSpecification() {

    CreateKeyspaceSpecification create = new CreateKeyspaceSpecification();
    create.name(name).ifNotExists(ifNotExists).with(KeyspaceOption.DURABLE_WRITES, durableWrites);

    Map<Option, Object> replicationStrategyMap = new HashMap<Option, Object>();
    replicationStrategyMap.put(new DefaultOption("class", String.class, true, false, true),
        replicationStrategy.getValue());

    if (replicationStrategy == ReplicationStrategy.SIMPLE_STRATEGY) {
      replicationStrategyMap.put(new DefaultOption("replication_factor", Long.class, true, false, false),
          replicationFactor);
    }

    if (replicationStrategy == ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY) {
      int i = 0;
      for (String datacenter : networkTopologyDataCenters) {
        replicationStrategyMap.put(new DefaultOption(datacenter, Long.class, true, false, false),
            networkTopologyReplicationFactors.get(i++));
      }
    }

    create.with(KeyspaceOption.REPLICATION, replicationStrategyMap);

    return create;
  }
View Full Code Here


    MappingCassandraConverter cassandraConverter = new MappingCassandraConverter();
    CassandraAdminTemplate cassandraTemplate = new CassandraAdminTemplate(AbstractEmbeddedCassandraIntegrationTest
        .cluster().connect(), cassandraConverter);

    CreateKeyspaceSpecification createKeyspaceSpecification = new CreateKeyspaceSpecification(keySpace).ifNotExists();
    cassandraTemplate.execute(createKeyspaceSpecification);
    cassandraTemplate.execute("USE " + keySpace);

    cassandraTemplate.createTable(true, CqlIdentifier.cqlId("users"), User.class, new HashMap<String, Object>());
View Full Code Here

  @Override
  protected List<CreateKeyspaceSpecification> getKeyspaceCreations() {
    ArrayList<CreateKeyspaceSpecification> list = new ArrayList<CreateKeyspaceSpecification>();

    CreateKeyspaceSpecification specification = CreateKeyspaceSpecification.createKeyspace().name(getKeyspaceName());
    specification.with(KeyspaceOption.REPLICATION, KeyspaceAttributes.newSimpleReplication(1L));

    list.add(specification);
    return list;
  }
View Full Code Here

TOP

Related Classes of org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.