public override void SetUp() { base.SetUp(); var cfName = Guid.NewGuid().ToString("N").Substring(10); cassandraSchemaActualizer.ActualizeKeyspaces(new[] { new KeyspaceSchema { Name = KeyspaceName, Configuration = new KeyspaceConfiguration { ReplicationStrategy = SimpleReplicationStrategy.Create(1), ColumnFamilies = new[] { new ColumnFamily { Name = cfName, ComparatorType = new ColumnComparatorType(DataType.TimeUUIDType) } } } } }, changeExistingKeyspaceMetadata: false); cfConnection = cassandraCluster.RetrieveTimeBasedColumnFamilyConnection(KeyspaceName, cfName); }
public void TestActualizeColumnFamily() { var keyspaceName = Guid.NewGuid().ToString("N"); const string columnFamilyName = "1"; var keyspaceScheme = new KeyspaceScheme { Name = keyspaceName, Configuration = new KeyspaceConfiguration { ReplicationStrategy = SimpleReplicationStrategy.Create(1), ColumnFamilies = new[] { new ColumnFamily { Name = columnFamilyName, BloomFilterFpChance = null } } } }; cassandraCluster.ActualizeKeyspaces(new[] { keyspaceScheme }); var actualColumnFamily = cassandraCluster.RetrieveClusterConnection().RetrieveKeyspaces().First(x => x.Name == keyspaceName).ColumnFamilies[columnFamilyName]; Assert.AreEqual(0.01d, actualColumnFamily.BloomFilterFpChance); keyspaceScheme.Configuration.ColumnFamilies.First().BloomFilterFpChance = 0.02; cassandraCluster.ActualizeKeyspaces(new[] { keyspaceScheme }); actualColumnFamily = cassandraCluster.RetrieveClusterConnection().RetrieveKeyspaces().First(x => x.Name == keyspaceName).ColumnFamilies[columnFamilyName]; Assert.AreEqual(0.02d, actualColumnFamily.BloomFilterFpChance); }
public virtual void SetUp() { KeyspaceName = $"TestKeyspace_{Guid.NewGuid():N}"; var cassandraClusterSettings = SingleCassandraNodeSetUpFixture.Node.CreateSettings(); cassandraClusterSettings.AllowNullTimestamp = true; cassandraClusterSettings.ReadConsistencyLevel = ConsistencyLevel.ALL; cassandraClusterSettings.WriteConsistencyLevel = ConsistencyLevel.ALL; cassandraCluster = new CassandraCluster(cassandraClusterSettings, Logger.Instance); columnFamilyConnection = cassandraCluster.RetrieveColumnFamilyConnection(KeyspaceName, Constants.ColumnFamilyName); columnFamilyConnectionDefaultTtl = cassandraCluster.RetrieveColumnFamilyConnection(KeyspaceName, Constants.DefaultTtlColumnFamilyName); cassandraCluster.ActualizeKeyspaces(new[] { new KeyspaceScheme { Name = KeyspaceName, Configuration = new KeyspaceConfiguration { ReplicationStrategy = SimpleReplicationStrategy.Create(1), ColumnFamilies = new[] { new ColumnFamily { Name = Constants.ColumnFamilyName }, new ColumnFamily { Name = Constants.DefaultTtlColumnFamilyName, DefaultTtl = 1 } } } } }); }
public void TestTryAddKeyspaceWithInvalidName() { var clusterConnection = cluster.RetrieveClusterConnection(); var createdKeyspace = new Keyspace { Name = "Keyspace-123-123", ReplicationStrategy = SimpleReplicationStrategy.Create(1) }; Assert.Throws <CassandraClientInvalidRequestException>(() => clusterConnection.AddKeyspace(createdKeyspace)); }
public void SetUp() { cluster = new CassandraCluster(SingleCassandraNodeSetUpFixture.Node.CreateSettings(), Logger.Instance); var clusterConnection = cluster.RetrieveClusterConnection(); var keyspaceName = TestSchemaUtils.GetRandomKeyspaceName(); var createdKeyspace = new Keyspace { Name = keyspaceName, ReplicationStrategy = SimpleReplicationStrategy.Create(1) }; clusterConnection.AddKeyspace(createdKeyspace); keyspaceConnection = cluster.RetrieveKeyspaceConnection(keyspaceName); }
public void AddNewColumnFamilies() { var keyspaceShemas = cassandraMetadataProvider.GetColumnFamilies().GroupBy(x => x.KeyspaceName).Select(x => new KeyspaceSchema { Name = x.Key, Configuration = new KeyspaceConfiguration { ReplicationStrategy = SimpleReplicationStrategy.Create(cassandraInitializerSettings.ReplicationFactor), ColumnFamilies = x.ToDictionary(y => y.ColumnFamilyName, y => new ColumnFamily { Name = y.ColumnFamilyName, Caching = cassandraInitializerSettings.RowCacheSize == 0 ? ColumnFamilyCaching.KeysOnly : ColumnFamilyCaching.All }).Values.ToArray(), }, }).ToArray(); cassandraSchemaActualizer.ActualizeKeyspaces(keyspaceShemas, changeExistingKeyspaceMetadata: false); }
public static void SetUp() { var templateDirectory = Path.Combine(FindCassandraTemplateDirectory(AppDomain.CurrentDomain.BaseDirectory), @"v3.11.x"); var deployDirectory = Path.Combine(Path.GetTempPath(), "deployed_cassandra_v3.11.x"); cassandraNode = new LocalCassandraNode(templateDirectory, deployDirectory) { RpcPort = 9360, CqlPort = 9343, JmxPort = 7399, GossipPort = 7400, }; cassandraNode.Restart(timeout: TimeSpan.FromMinutes(1)); cassandraCluster = new CassandraCluster(cassandraNode.CreateSettings(), Logger.Instance); var cassandraSchemaActualizer = new CassandraSchemaActualizer(cassandraCluster, null, Logger.Instance); cassandraSchemaActualizer.ActualizeKeyspaces(new[] { new KeyspaceSchema { Name = ksName, Configuration = new KeyspaceConfiguration { ReplicationStrategy = SimpleReplicationStrategy.Create(replicationFactor: 1), ColumnFamilies = new[] { new ColumnFamily { Name = minTicksCfName, CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(sstableSizeInMb: 160), Caching = ColumnFamilyCaching.All }, new ColumnFamily { Name = maxTicksCfName, CompactionStrategy = CompactionStrategy.LeveledCompactionStrategy(sstableSizeInMb: 160), Caching = ColumnFamilyCaching.KeysOnly } } } }, }, changeExistingKeyspaceMetadata: false); }
public void TestAddKeyspace(bool durableWrites) { var clusterConnection = cluster.RetrieveClusterConnection(); var keyspaceName = TestSchemaUtils.GetRandomKeyspaceName(); var createdKeyspace = new Keyspace { Name = keyspaceName, DurableWrites = durableWrites, ReplicationStrategy = SimpleReplicationStrategy.Create(1) }; clusterConnection.AddKeyspace(createdKeyspace); var keyspaces = clusterConnection.RetrieveKeyspaces(); var actualKeyspace = keyspaces.First(x => x.Name == keyspaceName); AssertKeyspacePropertiesEquals(createdKeyspace, actualKeyspace); }
public static void SetUp() { Log4NetConfiguration.InitializeOnce(); var templateDirectory = Path.Combine(FindCassandraTemplateDirectory(AppDomain.CurrentDomain.BaseDirectory), @"v3.11.x"); var deployDirectory = Path.Combine(Path.GetTempPath(), "deployed_cassandra_v3.11.x"); node = new LocalCassandraNode(templateDirectory, deployDirectory) { RpcPort = 9360, CqlPort = 9343, JmxPort = 7399, GossipPort = 7400, }; node.Restart(timeout: TimeSpan.FromMinutes(1)); var logger = Log4NetConfiguration.RootLogger.ForContext(nameof(SingleCassandraNodeSetUpFixture)); cassandraCluster = new CassandraCluster(CreateCassandraClusterSettings(), logger); var cassandraSchemaActualizer = new CassandraSchemaActualizer(cassandraCluster, eventListener: null, logger); cassandraSchemaActualizer.ActualizeKeyspaces(new[] { new KeyspaceSchema { Name = RemoteLockKeyspace, Configuration = new KeyspaceConfiguration { ReplicationStrategy = SimpleReplicationStrategy.Create(replicationFactor: 1), ColumnFamilies = new[] { new ColumnFamily { Name = RemoteLockColumnFamily, Caching = ColumnFamilyCaching.KeysOnly } } } } }, changeExistingKeyspaceMetadata: false); }
public override void SetUp() { base.SetUp(); cassandraCluster.ActualizeKeyspaces(new[] { new KeyspaceScheme { Name = KeyspaceName, Configuration = new KeyspaceConfiguration { ReplicationStrategy = SimpleReplicationStrategy.Create(1), ColumnFamilies = new[] { new ColumnFamily { Name = Constants.ColumnFamilyName } } } } }); }
public static void ResetCassandraState(this IContainer container, ColumnFamily[] columnFamilies) { var logger = container.Get <ILog>(); var cassandraCluster = container.Get <ICassandraCluster>(); var schemaActualizer = new CassandraSchemaActualizer(cassandraCluster, eventListener: null, logger); schemaActualizer.ActualizeKeyspaces(new[] { new KeyspaceSchema { Name = TestRtqSettings.QueueKeyspaceName, Configuration = { ReplicationStrategy = SimpleReplicationStrategy.Create(1), ColumnFamilies = columnFamilies, }, }, }, changeExistingKeyspaceMetadata: false); foreach (var columnFamily in columnFamilies) { cassandraCluster.RetrieveColumnFamilyConnection(TestRtqSettings.QueueKeyspaceName, columnFamily.Name).Truncate(); } }
public void TestUpdateKeyspace(bool durableWrites) { var keyspaceName = Guid.NewGuid().ToString("N"); cassandraCluster.ActualizeKeyspaces(new[] { new KeyspaceScheme { Name = keyspaceName, Configuration = new KeyspaceConfiguration { DurableWrites = durableWrites, ReplicationStrategy = SimpleReplicationStrategy.Create(1), ColumnFamilies = new[] { new ColumnFamily { Name = "1" }, new ColumnFamily { Name = "2" }, new ColumnFamily { Name = "3" } } } } }); var keyspaces = cassandraCluster.RetrieveClusterConnection().RetrieveKeyspaces().ToArray(); AssertKeyspacesEquals(new Keyspace { Name = keyspaceName, DurableWrites = durableWrites, ReplicationStrategy = SimpleReplicationStrategy.Create(1), ColumnFamilies = new Dictionary <string, ColumnFamily> { { "1", new ColumnFamily { Name = "1" } }, { "2", new ColumnFamily { Name = "2" } }, { "3", new ColumnFamily { Name = "3" } } } }, keyspaces.Single(keyspace1 => keyspace1.Name == keyspaceName)); cassandraCluster.RetrieveClusterConnection().UpdateKeyspace(new Keyspace { Name = keyspaceName, DurableWrites = durableWrites, ReplicationStrategy = NetworkTopologyReplicationStrategy.Create(new[] { new DataCenterReplicationFactor("dc1", 3) }) }); var keyspace = cassandraCluster.RetrieveClusterConnection().RetrieveKeyspaces().ToArray().Single(keyspace1 => keyspace1.Name == keyspaceName); AssertKeyspacesEquals(new Keyspace { Name = keyspaceName, DurableWrites = durableWrites, ReplicationStrategy = NetworkTopologyReplicationStrategy.Create(new[] { new DataCenterReplicationFactor("dc1", 3) }), ColumnFamilies = new Dictionary <string, ColumnFamily> { { "1", new ColumnFamily { Name = "1" } }, { "2", new ColumnFamily { Name = "2" } }, { "3", new ColumnFamily { Name = "3" } } } }, keyspace); }