Creates a Keyspace with the given consistency level. For a reference
to the consistency level, please refer to http://wiki.apache.org/cassandra/API.

@param keyspace
@param cluster
@param consistencyLevelPolicy
@return
502155
public static Keyspace createKeyspace(String keyspace, Cluster cluster,
      ConsistencyLevelPolicy consistencyLevelPolicy) {
    return createKeyspace(keyspace, cluster, consistencyLevelPolicy,
        FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE);
  }
236080
@NonNull
  public static CreateTypeStart createType(@Nullable String keyspace, @NonNull String typeName) {
    return createType(
        keyspace == null ? null : CqlIdentifier.fromCql(keyspace), CqlIdentifier.fromCql(typeName));
  }
371860
@NonNull
  public SelfT withKeyspace(@Nullable String keyspaceName) {
    return withKeyspace(keyspaceName == null ? null : CqlIdentifier.fromCql(keyspaceName));
  }
38699
public T withSerialConsistencyLevel(ConsistencyLevel serialConsistencyLevel) {
        getOptions().setSerialCL(Optional.of(serialConsistencyLevel));
        return getThis();
    }
1244957
public static KSMetaData newKeyspace(String name, String strategyName, Map<String, String> options, boolean durableWrites) throws ConfigurationException
    {
        Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(strategyName);
        if (cls.equals(LocalStrategy.class))
            throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use.");

        return newKeyspace(name, cls, options, durableWrites, Collections.<CFMetaData>emptyList());
    }
114755
public void putKeyspace(KeyspaceImpl keyspace) {
        if (containsKeyspace(keyspace)) return;

        try (TransactionOLTP tx = systemKeyspaceSession.transaction().write()) {
            AttributeType<String> keyspaceName = tx.getSchemaConcept(KEYSPACE_RESOURCE);
            if (keyspaceName == null) {
                throw GraknServerException.initializationException(keyspace);
            }
            Attribute<String> attribute = keyspaceName.create(keyspace.name());
            if (attribute.owner() == null) {
                tx.<EntityType>getSchemaConcept(KEYSPACE_ENTITY).create().has(attribute);
            }
            tx.commit();

            // add to cache
            existingKeyspaces.add(keyspace);
        } catch (InvalidKBException e) {
            throw new RuntimeException("Could not add keyspace [" + keyspace + "] to system graph", e);
        }
    }
410181
@Override
    public KeyComponent createClusteringColumnReferenceComponent(Facet parent, PojoBinding<?> pojoBinding, NamingStrategy namingStrategy) {
        throw new HecateException("@ClusteringColumn facet \"%s\" references class with composite keys", parent.getName());
    }
569291
public static ConsistencyLevel from(org.apache.cassandra.db.ConsistencyLevel cl)
    {
        switch (cl)
        {
            case ANY:
                return com.datastax.driver.core.ConsistencyLevel.ANY;
            case ONE:
                return com.datastax.driver.core.ConsistencyLevel.ONE;
            case TWO:
                return com.datastax.driver.core.ConsistencyLevel.TWO;
            case THREE:
                return com.datastax.driver.core.ConsistencyLevel.THREE;
            case QUORUM:
                return com.datastax.driver.core.ConsistencyLevel.QUORUM;
            case ALL:
                return com.datastax.driver.core.ConsistencyLevel.ALL;
            case LOCAL_QUORUM:
                return com.datastax.driver.core.ConsistencyLevel.LOCAL_QUORUM;
            case EACH_QUORUM:
                return com.datastax.driver.core.ConsistencyLevel.EACH_QUORUM;
            case SERIAL:
                return com.datastax.driver.core.ConsistencyLevel.SERIAL;
            case LOCAL_SERIAL:
                return com.datastax.driver.core.ConsistencyLevel.LOCAL_SERIAL;
            case LOCAL_ONE:
                return com.datastax.driver.core.ConsistencyLevel.LOCAL_ONE;
        }
        throw new AssertionError();
    }
929585
@NonNull
  public static CreateTableStart createTable(
      @Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier tableName) {
    return new DefaultCreateTable(keyspace, tableName);
  }
1356657
@SuppressWarnings({ "unchecked", "rawtypes" })
    @Override
    public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
        LOG.info("Making new CassandraState object for cluster " + cassandraClusterId + ": partition [" + partitionIndex + "] of [" + numPartitions + "]");
        AstyanaxClient client = AstyanaxClientFactory.getInstance(cassandraClusterId, (Map)conf.get(cassandraClusterId));
        int batchMaxSize = Utils.getInt(Utils.get(conf, StormCassandraConstants.CASSANDRA_BATCH_MAX_SIZE,
                CassandraState.DEFAULT_MAX_BATCH_SIZE));
        return new CassandraState(client, batchMaxSize, this.exceptionHandler);
    }
1287201
private void setConsistencylevel(Object value)
    {
        if (value instanceof String)
        {
            this.cassandraClientBase.setConsistencyLevel(ConsistencyLevel.valueOf((String) value));
        }
        else if (value instanceof ConsistencyLevel)
        {
            this.cassandraClientBase.setConsistencyLevel((ConsistencyLevel) value);
        }

    }
1181269
@Given("^I create a Cassandra table named '(.+?)' using keyspace '(.+?)' with:$")
    public void createTableWithData(String table, String keyspace, DataTable datatable) {
        try {
            commonspec.getCassandraClient().useKeyspace(keyspace);
            int attrLength = datatable.getPickleRows().get(0).getCells().size();
            Map<String, String> columns = new HashMap<String, String>();
            ArrayList<String> pk = new ArrayList<String>();

            for (int i = 0; i < attrLength; i++) {
                columns.put(datatable.getPickleRows().get(0).getCells().get(i).getValue(),
                        datatable.getPickleRows().get(1).getCells().get(i).getValue());
                if ((datatable.getPickleRows().size() == 3) && datatable.getPickleRows().get(2).getCells().get(i).getValue().equalsIgnoreCase("PK")) {
                    pk.add(datatable.getPickleRows().get(0).getCells().get(i).getValue());
                }
            }
            if (pk.isEmpty()) {
                throw new Exception("A PK is needed");
            }
            commonspec.getCassandraClient().createTableWithData(table, columns, pk);
        } catch (Exception e) {
            commonspec.getLogger().debug("Exception captured");
            commonspec.getLogger().debug(e.toString());
            commonspec.getExceptions().add(e);
        }
    }
1163090
static Cluster buildCluster(CassandraStorage cassandra) {
    Cluster.Builder builder = Cluster.builder().withoutJMXReporting();
    List<InetSocketAddress> contactPoints = parseContactPoints(cassandra);
    int defaultPort = findConnectPort(contactPoints);
    builder.addContactPointsWithPorts(contactPoints);
    builder.withPort(defaultPort); // This ends up protocolOptions.port
    if (cassandra.username() != null && cassandra.password() != null) {
      builder.withCredentials(cassandra.username(), cassandra.password());
    }
    builder.withRetryPolicy(ZipkinRetryPolicy.INSTANCE);
    builder.withLoadBalancingPolicy(
        new TokenAwarePolicy(
            new LatencyAwarePolicy.Builder(
                    cassandra.localDc() != null
                        ? DCAwareRoundRobinPolicy.builder().withLocalDc(cassandra.localDc()).build()
                        : new RoundRobinPolicy()
                    // This can select remote, but LatencyAwarePolicy will prefer local
                    )
                .build()));
    builder.withPoolingOptions(cassandra.poolingOptions());

    builder.withQueryOptions(
        new QueryOptions()
            // if local_dc isn't defined LOCAL_ONE incorrectly sticks to first seed host that
            // connects
            .setConsistencyLevel(
                null != cassandra.localDc() ? ConsistencyLevel.LOCAL_ONE : ConsistencyLevel.ONE)
            // all zipkin cql writes are idempotent
            .setDefaultIdempotence(true));

    if (cassandra.useSsl()) {
      builder = builder.withSSL();
    }

    return builder.build();
  }
994974
@NonNull
  public static CreateTableStart createTable(@Nullable String keyspace, @NonNull String tableName) {
    return createTable(
        keyspace == null ? null : CqlIdentifier.fromCql(keyspace),
        CqlIdentifier.fromCql(tableName));
  }
502411
private KsDef onCreateKeyspace() throws Exception
    {
        try
        {
            createdKeyspaces.add(databaseName);
            createKeyspace();
        }
        catch (InvalidRequestException irex)
        {
            // Ignore and add a log.debug
            // keyspace already exists.
            // remove from list if already created.
            createdKeyspaces.remove(databaseName);
        }
        cassandra_client.set_keyspace(databaseName);
        return cassandra_client.describe_keyspace(databaseName);
    }
1350796
@NonNull
  public static AlterKeyspaceStart alterKeyspace(@NonNull String keyspaceName) {
    return alterKeyspace(CqlIdentifier.fromCql(keyspaceName));
  }
415836
@NonNull
  public static UpdateStart update(@Nullable String keyspace, @NonNull String table) {
    return update(
        keyspace == null ? null : CqlIdentifier.fromCql(keyspace), CqlIdentifier.fromCql(table));
  }