/// <inheritdoc />
 public void ChangeKeyspace(string keyspace)
 {
     if (Keyspace != keyspace)
     {
         Execute(new SimpleStatement(CqlQueryTools.GetUseKeyspaceCql(keyspace)));
         Keyspace = keyspace;
     }
 }
Beispiel #2
0
        /// <summary>
        ///  Returns a CQL query representing this keyspace. This method returns a single
        ///  'CREATE KEYSPACE' query with the options corresponding to this name
        ///  definition.
        /// </summary>
        /// <returns>the 'CREATE KEYSPACE' query corresponding to this name.
        ///  <see>#ExportAsString</see></returns>
        public string AsCqlQuery()
        {
            var sb = new StringBuilder();

            sb.Append("CREATE KEYSPACE ").Append(CqlQueryTools.QuoteIdentifier(Name)).Append(" WITH ");
            sb.Append("REPLICATION = { 'class' : '").Append(StrategyClass).Append("'");
            foreach (var rep in Replication)
            {
                if (rep.Key == "class")
                {
                    continue;
                }
                sb.Append(", '").Append(rep.Key).Append("': '").Append(rep.Value).Append("'");
            }
            sb.Append(" } AND DURABLE_WRITES = ").Append(DurableWrites);
            sb.Append(";");
            return(sb.ToString());
        }
 /// <inheritdoc />
 public void DeleteKeyspace(string keyspaceName)
 {
     Execute(CqlQueryTools.GetDropKeyspaceCql(keyspaceName, false));
 }
 /// <inheritdoc />
 public void CreateKeyspace(string keyspace, Dictionary <string, string> replication = null, bool durableWrites = true)
 {
     WaitForSchemaAgreement(Execute(CqlQueryTools.GetCreateKeyspaceCql(keyspace, replication, durableWrites, false)));
     Logger.Info("Keyspace [" + keyspace + "] has been successfully CREATED.");
 }