public void OneTimeSetUp()
        {
            var templateDirectory = SingleCassandraNodeSetUpFixture.FindCassandraTemplateDirectory(AppDomain.CurrentDomain.BaseDirectory);
            var deployDirectory   = Path.Combine(Path.GetTempPath(), "deployed_cassandra_with_authentication_v3.11.x");

            node = new LocalCassandraNode(templateDirectory, deployDirectory, Authenticator.PasswordAuthenticator)
            {
                LocalNodeName = "local_node_with_authentication",
                RpcPort       = 10360,
                CqlPort       = 10343,
                JmxPort       = 8399,
                GossipPort    = 8400
            };
            node.Restart(TimeSpan.FromMinutes(1));

            Waiter.Wait(() =>
            {
                try
                {
                    using (var cluster = GetClusterBuilder().Build())
                        using (cluster.Connect())
                            return(true);
                }
                catch
                {
                    return(false);
                }
            }, timeout: TimeSpan.FromSeconds(30));
        }
Ejemplo n.º 2
0
        private static void StartLocalCassandra(string cassandraTemplateVersion, int instanceId)
        {
            var templateDirectory = DirectoryHelpers.FindDirectory(AppDomain.CurrentDomain.BaseDirectory, $@"cassandra-local/cassandra/v{cassandraTemplateVersion}");

            Console.Out.WriteLine($"templateDirectory: {templateDirectory}");

            var deployDirectory = Path.Combine(Path.GetTempPath(), $"deployed_cassandra_v{cassandraTemplateVersion}");

            Console.Out.WriteLine($"deployDirectory: {deployDirectory}");

            var localNodeName = Guid.NewGuid().ToString("N");
            var node          = new LocalCassandraNode(templateDirectory, deployDirectory)
            {
                LocalNodeName = localNodeName,
                ClusterName   = cassandraTemplateVersion,
                RpcPort       = 9160 + instanceId,
                CqlPort       = 9042 + instanceId,
                JmxPort       = 7199 + instanceId,
                GossipPort    = 7000 + instanceId,
            };

            node.Deploy();

            var actualLocalNodeName = LocalCassandraProcessManager.StartLocalCassandraProcess(node.DeployDirectory);

            Assert.That(actualLocalNodeName, Is.EqualTo(localNodeName));

            LocalCassandraProcessManager.WaitForLocalCassandraPortsToOpen(node.RpcPort, node.CqlPort);
        }
        public void Restart(string cassandraTemplateVersion)
        {
            var templateDirectory = DirectoryHelpers.FindDirectory(AppDomain.CurrentDomain.BaseDirectory, $@"cassandra-local/cassandra/v{cassandraTemplateVersion}");

            Console.Out.WriteLine($"templateDirectory: {templateDirectory}");

            var deployDirectory = Path.Combine(Path.GetTempPath(), $"deployed_cassandra_v{cassandraTemplateVersion}");

            Console.Out.WriteLine($"deployDirectory: {deployDirectory}");

            var beforeStartTimestamp = DateTime.Now;
            var node = new LocalCassandraNode(templateDirectory, deployDirectory)
            {
                LocalNodeName = Guid.NewGuid().ToString("N")
            };

            node.Restart();

            Assert.That(Directory.Exists(deployDirectory));
            var nodePid     = LocalCassandraProcessManager.GetAllLocalCassandraProcessIds().Single();
            var nodeProcess = Process.GetProcessById(nodePid);

            Console.Out.WriteLine($"cassandra node process: [{nodePid}] {nodeProcess.ProcessName}");
            Assert.That(nodeProcess.StartTime > beforeStartTimestamp);

            node.Stop();

            Assert.That(nodeProcess.HasExited);
        }
 public static ICassandraClusterSettings CreateSettings(this LocalCassandraNode node, int attempts = 5, TimeSpan?timeout = null)
 {
     return(new SingleNodeCassandraClusterSettings(new IPEndPoint(IPAddress.Parse(node.RpcAddress), node.RpcPort))
     {
         ClusterName = node.ClusterName,
         Attempts = attempts,
         Timeout = (int)(timeout ?? TimeSpan.FromSeconds(6)).TotalMilliseconds,
     });
 }
        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");

            Node = new LocalCassandraNode(templateDirectory, deployDirectory)
            {
                RpcPort    = 9360,
                CqlPort    = 9343,
                JmxPort    = 7399,
                GossipPort = 7400,
            };
            Node.Restart(timeout: TimeSpan.FromMinutes(1));
        }
        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);
        }
Ejemplo n.º 7
0
        public static SingleNodeCassandraClusterSettings CreateSettings(this LocalCassandraNode node)
        {
            var thriftEndpoint = new IPEndPoint(IPAddress.Parse(node.RpcAddress), node.RpcPort);

            return(new SingleNodeCassandraClusterSettings
            {
                ClusterName = node.ClusterName,
                ReadConsistencyLevel = ConsistencyLevel.QUORUM,
                WriteConsistencyLevel = ConsistencyLevel.QUORUM,
                Endpoints = new[] { thriftEndpoint },
                EndpointForFierceCommands = thriftEndpoint,
                AllowNullTimestamp = false,
                Attempts = 5,
                Timeout = (int)TimeSpan.FromSeconds(6).TotalMilliseconds,
                FierceTimeout = (int)TimeSpan.FromSeconds(10).TotalMilliseconds,
                ConnectionIdleTimeout = TimeSpan.FromSeconds(30),
                EnableMetrics = false
            });
        }
Ejemplo n.º 8
0
        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);
        }