Ejemplo n.º 1
0
        public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true, string[] jvmArgs = null, bool useSsl = false)
        {
            CcmBridge ccmBridge       = new CcmBridge(name, localIpPrefix);
            string    clusterStartStr = "";

            if (startTheCluster)
            {
                clusterStartStr = "-s";
            }
            var jvmArgsParams = "";

            if (jvmArgs != null && jvmArgs.Length > 0)
            {
                jvmArgsParams = String.Join(" ", jvmArgs.Select(a => "--jvm_arg=" + a));
            }
            var sslParams = "";

            if (useSsl)
            {
                var sslPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "ssl");
                if (!File.Exists(Path.Combine(sslPath, "keystore.jks")))
                {
                    throw new Exception(string.Format("In order to use SSL with CCM you must provide have the keystore.jks and cassandra.crt files located in your {0} folder", sslPath));
                }
                sslParams = "--ssl " + sslPath;
            }
            ccmBridge.ExecuteCcm(string.Format("create {0} -n {1} {2} -i {3} -b -v {4} {5} {6}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion, jvmArgsParams, sslParams));
            return(ccmBridge);
        }
Ejemplo n.º 2
0
 public void Remove()
 {
     Trace.TraceInformation(string.Format("Removing Cluster with Name: '{0}', InitialContactPoint: {1}, and CcmDir: {2}", Name, InitialContactPoint, CcmBridge.CcmDir));
     CcmBridge.SwitchToThis();
     CcmBridge.Remove();
     IsRemoved = true;
 }
Ejemplo n.º 3
0
 public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true)
 {
     CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix);
     string clusterStartStr = "";
     if (startTheCluster)
         clusterStartStr = "-s";
     ccmBridge.ExecuteCcm(string.Format("Create {0} -n {1} {2} -i {3} -b -v {4}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion));
     return ccmBridge;
 }
Ejemplo n.º 4
0
 public void Create(int nodeLength, TestClusterOptions options = null)
 {
     if (options == null)
     {
         options = TestClusterOptions.Default;
     }
     _ccm = new CcmBridge(Name, ClusterIpPrefix);
     _ccm.Create(_version, options.UseSsl);
     _ccm.Populate(nodeLength, options.Dc2NodeLength, options.UseVNodes);
 }
Ejemplo n.º 5
0
 public void Create(int nodeLength, TestClusterOptions options = null)
 {
     if (options == null)
     {
         options = TestClusterOptions.Default;
     }
     _ccm = new CcmBridge(Name, ClusterIpPrefix);
     _ccm.Create(_version, options.UseSsl);
     _ccm.Populate(nodeLength, options.Dc2NodeLength, options.UseVNodes);
 }
Ejemplo n.º 6
0
 public void UpdateConfig(params string[] yamlChanges)
 {
     if (yamlChanges == null)
     {
         return;
     }
     foreach (var setting in yamlChanges)
     {
         CcmBridge.ExecuteCcm($"updateconf \"{setting}\"");
     }
 }
Ejemplo n.º 7
0
        public static CcmBridge Create(string name, string localIpPrefix, int nodeCountDc1, int nodeCountDc2, string cassandraVersion, bool startTheCluster = true, bool throwOnError = false)
        {
            CcmBridge ccmBridge       = new CcmBridge(name, localIpPrefix);
            string    clusterStartStr = "";

            if (startTheCluster)
            {
                clusterStartStr = "-s";
            }
            ccmBridge.ExecuteCcm(string.Format("Create {0} -n {1}:{2} {3} -i {4} -b -v {5}", name, nodeCountDc1, nodeCountDc2, clusterStartStr, localIpPrefix, cassandraVersion), DefaultCmdTimeout, throwOnError);
            return(ccmBridge);
        }
Ejemplo n.º 8
0
        public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true)
        {
            CcmBridge ccmBridge       = new CcmBridge(name, localIpPrefix);
            string    clusterStartStr = "";

            if (startTheCluster)
            {
                clusterStartStr = "-s";
            }
            ccmBridge.ExecuteCcm(string.Format("Create {0} -n {1} {2} -i {3} -b -v {4}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion));
            return(ccmBridge);
        }
Ejemplo n.º 9
0
 public void UseVNodes(string nodesToPopulate)
 {
     try
     {
         CcmBridge.ExecuteCcm("remove");
     }
     catch
     {
         //Don't mind
     }
     CcmBridge.ExecuteCcm(String.Format("create {0} -v {1}", CcmBridge.Name, _version));
     CcmBridge.ExecuteCcm(String.Format("populate -n {0} -i {1} --vnodes", nodesToPopulate, CcmBridge.IpPrefix), CcmBridge.DefaultCmdTimeout, true);
     CcmBridge.ExecuteCcm("start", CcmBridge.DefaultCmdTimeout, true);
 }
 /// <summary>
 /// Removes the current ccm cluster, without throwing exceptions if it fails
 /// </summary>
 public static void TryRemove()
 {
     try
     {
         CcmBridge.ExecuteCcm("remove");
     }
     catch (Exception ex)
     {
         if (Diagnostics.CassandraTraceSwitch.Level == TraceLevel.Verbose)
         {
             Trace.TraceError("ccm test cluster could not be removed: {0}", ex);
         }
     }
 }
Ejemplo n.º 11
0
        public void ShutDown()
        {
            if (!IsStarted)
            {
                return;
            }

            if (Cluster != null)
            {
                Cluster.Shutdown();
            }
            CcmBridge.Stop();
            IsStarted = false;
        }
Ejemplo n.º 12
0
 public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true, string[] jvmArgs = null)
 {
     CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix);
     string clusterStartStr = "";
     if (startTheCluster)
         clusterStartStr = "-s";
     var jvmArgsParams = "";
     if (jvmArgs != null && jvmArgs.Length > 0)
     {
         jvmArgsParams = String.Join(" ", jvmArgs.Select(a => "--jvm_arg=" + a));
     }
     ccmBridge.ExecuteCcm(string.Format("create {0} -n {1} {2} -i {3} -b -v {4} {5}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion, jvmArgsParams));
     return ccmBridge;
 }
Ejemplo n.º 13
0
        private static ProcessOutput ExecCommand(bool throwOnProcessError, string executable, string args, IReadOnlyDictionary <string, string> envVars = null, string workDir = null)
        {
            Trace.TraceInformation($"{executable} {args}");
            var output = CcmBridge.ExecuteProcess(executable, args, timeout: 300000, envVariables: envVars, workDir: workDir);

            if (!throwOnProcessError)
            {
                return(output);
            }

            if (output.ExitCode != 0)
            {
                throw new TestInfrastructureException($"Process exited in error {output}");
            }

            return(output);
        }
Ejemplo n.º 14
0
        public void Create(int nodeLength, TestClusterOptions options = null)
        {
            _nodeLength = nodeLength;
            options     = options ?? TestClusterOptions.Default;
            _ccm        = new CcmBridge(Name, ClusterIpPrefix, DsePath, Version, _executor);
            _ccm.Create(options.UseSsl);
            _ccm.Populate(nodeLength, options.Dc2NodeLength, options.UseVNodes);
            _ccm.UpdateConfig(options.CassandraYaml);

            if (TestClusterManager.IsDse)
            {
                _ccm.UpdateDseConfig(options.DseYaml);
                _ccm.SetWorkloads(nodeLength, options.Workloads);
            }

            if (TestClusterManager.Executor is WslCcmProcessExecuter)
            {
                _ccm.UpdateConfig(new []
                {
                    "read_request_timeout_in_ms: 20000",
                    "counter_write_request_timeout_in_ms: 20000",
                    "write_request_timeout_in_ms: 20000",
                    "request_timeout_in_ms: 20000",
                    "range_request_timeout_in_ms: 30000"
                });
                if (TestClusterManager.IsDse)
                {
                    if (TestClusterManager.CheckDseVersion(new Version(6, 7), Comparison.LessThan))
                    {
                        _ccm.UpdateConfig(new[]
                        {
                            "user_defined_function_fail_timeout: 20000"
                        });
                    }
                    else
                    {
                        _ccm.UpdateConfig(new[]
                        {
                            "user_defined_function_fail_micros: 20000"
                        });
                    }
                }
            }
        }
Ejemplo n.º 15
0
 public static void Setup(int nbNodesDC1, int nbNodesDC2, string ipPrefix, string cassandraVersion, string clusterName = "test")
 {
     if (nbNodesDC2 == 0)
     {
         if (nbNodesDC1 != NbNodesDC1)
         {
             Trace.TraceInformation("Cassandra:" + cassandraVersion);
             CCMBridge  = CcmBridge.Create(clusterName, ipPrefix, nbNodesDC1, cassandraVersion);
             NbNodesDC1 = nbNodesDC1;
             NbNodesDC2 = 0;
         }
     }
     else
     {
         if (nbNodesDC1 != NbNodesDC1 || nbNodesDC2 != NbNodesDC2)
         {
             CCMBridge  = CcmBridge.Create(clusterName, ipPrefix, nbNodesDC1, nbNodesDC2, cassandraVersion);
             NbNodesDC1 = nbNodesDC1;
             NbNodesDC2 = nbNodesDC2;
         }
     }
 }
Ejemplo n.º 16
0
        public void Create(bool startTheCluster = true)
        {
            // if it's already being created in another thread, then wait until this step is complete
            if (!IsBeingCreated)
            {
                IsBeingCreated = true;
                if (Dc2NodeCount > 0)
                {
                    CcmBridge = CcmBridge.Create(Name, ClusterIpPrefix, Dc1NodeCount, Dc2NodeCount, CassandraVersion.ToString(), startTheCluster);
                }
                else
                {
                    CcmBridge = CcmBridge.Create(Name, ClusterIpPrefix, Dc1NodeCount, CassandraVersion.ToString(), startTheCluster);
                }
                IsBeingCreated = false;
                IsCreated      = true;
                if (startTheCluster)
                {
                    IsStarted = true;
                }
            }
            int sleepMs      = 300;
            int sleepMsMax   = 60000;
            int totalMsSlept = 0;

            while (IsBeingCreated || !IsCreated)
            {
                Trace.TraceInformation(string.Format("Cluster with name: {0}, CcmDir: {1} is being created. Sleeping another {2} MS ... ", Name,
                                                     CcmBridge.CcmDir.FullName, sleepMs));
                Thread.Sleep(sleepMs);
                totalMsSlept += sleepMs;
                if (totalMsSlept > sleepMsMax)
                {
                    throw new Exception("Failed to create cluster in " + sleepMsMax + " MS!");
                }
            }
        }
Ejemplo n.º 17
0
 public static CcmBridge Create(string name, string localIpPrefix, int nodeCount, string cassandraVersion, bool startTheCluster = true, string[] jvmArgs = null, bool useSsl = false)
 {
     CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix);
     string clusterStartStr = "";
     if (startTheCluster)
         clusterStartStr = "-s";
     var jvmArgsParams = "";
     if (jvmArgs != null && jvmArgs.Length > 0)
     {
         jvmArgsParams = String.Join(" ", jvmArgs.Select(a => "--jvm_arg=" + a));
     }
     var sslParams = "";
     if (useSsl)
     {
         var sslPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "ssl");
         if (!File.Exists(Path.Combine(sslPath, "keystore.jks")))
         {
             throw new Exception(string.Format("In order to use SSL with CCM you must provide have the keystore.jks and cassandra.crt files located in your {0} folder", sslPath));
         }
         sslParams = "--ssl " + sslPath;
     }
     ccmBridge.ExecuteCcm(string.Format("create {0} -n {1} {2} -i {3} -b -v {4} {5} {6}", name, nodeCount, clusterStartStr, localIpPrefix, cassandraVersion, jvmArgsParams, sslParams));
     return ccmBridge;
 }
Ejemplo n.º 18
0
 public void DecommissionNode(int nodeId)
 {
     CcmBridge.DecommissionNode(nodeId);
 }
 /// <summary>
 /// Removes the current ccm cluster
 /// </summary>
 public static void Remove()
 {
     CcmBridge.ExecuteCcm("remove");
 }
Ejemplo n.º 20
0
 public void SwitchToThisCluster()
 {
     CcmBridge.SwitchToThis();
 }
Ejemplo n.º 21
0
 public void StopForce(int nodeIdToStop)
 {
     CcmBridge.StopForce(nodeIdToStop);
 }
Ejemplo n.º 22
0
 public void ResumeNode(int nodeId)
 {
     CcmBridge.ExecuteCcm($"node{nodeId} resume");
 }
Ejemplo n.º 23
0
 public void Start(int nodeIdToStart, string additionalArgs = null)
 {
     CcmBridge.Start(nodeIdToStart, additionalArgs);
 }
Ejemplo n.º 24
0
 public static void Setup(int nbNodesDC1, int nbNodesDC2, string ipPrefix, string cassandraVersion, string clusterName = "test")
 {
     if (nbNodesDC2 == 0)
     {
         if (nbNodesDC1 != NbNodesDC1)
         {
             Trace.TraceInformation("Cassandra:" + cassandraVersion);
             CCMBridge = CcmBridge.Create(clusterName, ipPrefix, nbNodesDC1, cassandraVersion);
             NbNodesDC1 = nbNodesDC1;
             NbNodesDC2 = 0;
         }
     }
     else
     {
         if (nbNodesDC1 != NbNodesDC1 || nbNodesDC2 != NbNodesDC2)
         {
             CCMBridge = CcmBridge.Create(clusterName, ipPrefix, nbNodesDC1, nbNodesDC2, cassandraVersion);
             NbNodesDC1 = nbNodesDC1;
             NbNodesDC2 = nbNodesDC2;
         }
     }
 }
Ejemplo n.º 25
0
 public static CcmBridge Create(string name, string localIpPrefix, int nodeCountDc1, int nodeCountDc2, string cassandraVersion, bool startTheCluster = true, bool throwOnError = false)
 {
     CcmBridge ccmBridge = new CcmBridge(name, localIpPrefix);
     string clusterStartStr = "";
     if (startTheCluster)
         clusterStartStr = "-s";
     ccmBridge.ExecuteCcm(string.Format("create {0} -n {1}:{2} {3} -i {4} -b -v {5}", name, nodeCountDc1, nodeCountDc2, clusterStartStr, localIpPrefix, cassandraVersion), DefaultCmdTimeout, throwOnError);
     return ccmBridge;
 }
Ejemplo n.º 26
0
 public void ResumeNode(int nodeId)
 {
     CcmBridge.ExecuteCcm(string.Format("node{0} resume", nodeId));
 }
Ejemplo n.º 27
0
 public void PauseNode(int nodeId)
 {
     CcmBridge.ExecuteCcm(string.Format("node{0} pause", nodeId));
 }
Ejemplo n.º 28
0
 public void BootstrapNode(int nodeIdToStart, string dataCenterName)
 {
     CcmBridge.BootstrapNode(nodeIdToStart, dataCenterName);
 }
Ejemplo n.º 29
0
 public void Stop(int nodeIdToStop)
 {
     CcmBridge.Stop(nodeIdToStop);
 }
Ejemplo n.º 30
0
 public void PauseNode(int nodeId)
 {
     CcmBridge.ExecuteCcm($"node{nodeId} pause");
 }
Ejemplo n.º 31
0
 public void BootstrapNode(int nodeIdToStart)
 {
     CcmBridge.BootstrapNode(nodeIdToStart);
 }
Ejemplo n.º 32
0
 public void Start()
 {
     CcmBridge.Start();
     IsStarted = true;
 }