Permalink
Browse files

moved from the obsolete property replication_factor on the KsDef obje…

…ct to the StrategyOptions to fix issue #32, as of right now this is a step backwords for the intended easy setup
  • Loading branch information...
1 parent ea9226f commit 3b61e2b541a13c2e2e04bb9eb04da430a17ea9ec @nberardi nberardi committed May 24, 2012
@@ -32,14 +32,6 @@ public CassandraObject Name
public CassandraType NameType { get; set; }
public CassandraType ValueType { get; set; }
- public static implicit operator ColumnDef(CassandraColumnSchema schema)
- {
- return new ColumnDef {
- Name = schema.Name.ToBigEndian(),
- Validation_class = schema.ValueType.DatabaseType
- };
- }
-
public static implicit operator CassandraColumnSchema(ColumnDef def)
{
return new CassandraColumnSchema(def, CassandraType.BytesType);
View
@@ -62,8 +62,9 @@ public void TryCreateSelf()
string result = _context.AddKeyspace(schema);
Debug.WriteLine(result, "keyspace setup");
}
- catch
+ catch(Exception exc)
{
+ Debug.WriteLine(exc);
Debug.WriteLine(schema.Name + " already exists", "keyspace setup");
}
}
@@ -77,8 +78,9 @@ public void TryCreateColumnFamily(CassandraColumnFamilySchema schema)
string result = _context.AddColumnFamily(schema);
Debug.WriteLine(result, "column family setup");
}
- catch
+ catch (Exception exc)
{
+ Debug.WriteLine(exc);
Debug.WriteLine(schema.FamilyName + " already exists", "column family setup");
}
}
@@ -13,22 +13,25 @@ public class CassandraKeyspaceSchema
public CassandraKeyspaceSchema()
{
- Strategy = ReplicaPlacementStrategyNetworkTopology;
- ReplicationFactor = 1;
+ Strategy = ReplicaPlacementStrategySimple;
+ StrategyOptions = new Dictionary<string, string>() { { "replication_factor", "1" } };
ColumnFamilies = new List<CassandraColumnFamilySchema>();
+ DurableWrites = true;
}
public CassandraKeyspaceSchema(KsDef def)
{
Name = def.Name;
Strategy = def.Strategy_class;
- ReplicationFactor = def.Replication_factor;
+ StrategyOptions = def.Strategy_options ?? new Dictionary<string, string>();
ColumnFamilies = def.Cf_defs.Select(family => new CassandraColumnFamilySchema(family)).ToList();
+ DurableWrites = def.Durable_writes;
}
public string Name { get; set; }
public string Strategy { get; set; }
- public int ReplicationFactor { get; set; }
+ public Dictionary<string,string> StrategyOptions { get; private set; }
+ public bool DurableWrites { get; set; }
public IList<CassandraColumnFamilySchema> ColumnFamilies { get; set; }
@@ -37,7 +40,8 @@ public CassandraKeyspaceSchema(KsDef def)
return new KsDef {
Name = schema.Name,
Strategy_class = schema.Strategy,
- Replication_factor = schema.ReplicationFactor,
+ Strategy_options = schema.StrategyOptions,
+ Durable_writes = schema.DurableWrites,
Cf_defs = new List<CfDef>(0)
};
}
@@ -21,8 +21,7 @@ private static void SetupKeyspace()
var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema {
Name = KeyspaceName,
- Strategy = CassandraKeyspaceSchema.ReplicaPlacementStrategySimple,
- ReplicationFactor = 1 }, db);
+ }, db);
keyspace.TryCreateSelf();
@@ -58,7 +58,9 @@ public CassandraDatabaseSetup(bool reset = false)
if (exists)
DB.DropKeyspace(keyspaceName);
- var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = keyspaceName, Strategy = CassandraKeyspaceSchema.ReplicaPlacementStrategySimple, ReplicationFactor = 1 }, DB);
+ var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema {
+ Name = keyspaceName
+ }, DB);
DB.Keyspace = keyspace;
keyspace.TryCreateSelf();

0 comments on commit 3b61e2b

Please sign in to comment.