Exemple #1
0
 public static void CcmBootstrapNode(CcmClusterInfo info, int node, string dc = null)
 {
     if (dc == null)
     {
         ExecuteLocalCcm(string.Format("add node{0} -i {1}{2} -j {3} -b", node, Options.Default.IP_PREFIX, node, 7000 + 100 * node), info.ConfigDir);
     }
     else
     {
         ExecuteLocalCcm(string.Format("add node{0} -i {1}{2} -j {3} -b -d {4}", node, Options.Default.IP_PREFIX, node, 7000 + 100 * node, dc), info.ConfigDir);
     }
 }
Exemple #2
0
 public static void CcmRemove(CcmClusterInfo info)
 {
     if (UseRemoteCcm)
     {
         CCMBridge.ReusableCCMCluster.Drop();
     }
     else
     {
         //Remove the cluster
         TestUtils.ExecuteLocalCcmClusterRemove(info.ConfigDir);
     }
 }
Exemple #3
0
        public static CcmClusterInfo CcmSetup(int nodeLength, Builder builder = null, string keyspaceName = null, int secondDcNodeLength = 0, bool connect = true)
        {
            var clusterInfo = new CcmClusterInfo();

            if (builder == null)
            {
                builder = Cluster.Builder();
            }
            if (UseRemoteCcm)
            {
                CCMBridge.ReusableCCMCluster.Setup(nodeLength);
                clusterInfo.Cluster = CCMBridge.ReusableCCMCluster.Build(builder);
                if (keyspaceName != null)
                {
                    clusterInfo.Session = CCMBridge.ReusableCCMCluster.Connect(keyspaceName);
                }
            }
            else
            {
                //Create a local instance
                clusterInfo.ConfigDir = TestUtils.CreateTempDirectory();
                var output = TestUtils.ExecuteLocalCcmClusterStart(clusterInfo.ConfigDir, Options.Default.CASSANDRA_VERSION, nodeLength, secondDcNodeLength);

                if (output.ExitCode != 0)
                {
                    throw new TestInfrastructureException("Local ccm could not start: " + output.ToString());
                }
                try
                {
                    if (connect)
                    {
                        clusterInfo.Cluster = builder
                                              .AddContactPoint("127.0.0.1")
                                              .Build();
                        clusterInfo.Session = clusterInfo.Cluster.Connect();
                        if (keyspaceName != null)
                        {
                            clusterInfo.Session.CreateKeyspaceIfNotExists(keyspaceName);
                            WaitForSchemaAgreement(clusterInfo.Cluster);
                            clusterInfo.Session.ChangeKeyspace(keyspaceName);
                        }
                    }
                }
                catch
                {
                    CcmRemove(clusterInfo);
                    throw;
                }
            }
            return(clusterInfo);
        }
Exemple #4
0
        public static void CcmBootstrapNode(CcmClusterInfo info, int node, string dc = null)
        {
            ProcessOutput output = null;

            if (dc == null)
            {
                output = ExecuteLocalCcm(string.Format("add node{0} -i {1}{2} -j {3} -b", node, Options.Default.IP_PREFIX, node, 7000 + 100 * node), info.ConfigDir);
            }
            else
            {
                output = ExecuteLocalCcm(string.Format("add node{0} -i {1}{2} -j {3} -b -d {4}", node, Options.Default.IP_PREFIX, node, 7000 + 100 * node, dc), info.ConfigDir);
            }
            if (output.ExitCode != 0)
            {
                throw new TestInfrastructureException("Local ccm could not add node: " + output.ToString());
            }
        }
Exemple #5
0
 public static void WaitForSchemaAgreement(CcmClusterInfo clusterInfo)
 {
     WaitForSchemaAgreement(clusterInfo.Cluster.AllHosts().Count);
 }
Exemple #6
0
 public static void CcmDecommissionNode(CcmClusterInfo info, int node)
 {
     ExecuteLocalCcm(string.Format("node{0} decommission", node), info.ConfigDir);
 }
Exemple #7
0
 /// <summary>
 /// Stops a node (not gently) in the cluster with the provided index (1 based)
 /// </summary>
 public static void CcmStopForce(CcmClusterInfo info, int n)
 {
     ExecuteLocalCcm(string.Format("node{0} stop --not-gently", n), info.ConfigDir, 2000);
 }
Exemple #8
0
        /// <summary>
        /// Stops a node in the cluster with the provided index (1 based)
        /// </summary>
        public static void CcmStopNode(CcmClusterInfo info, int n)
        {
            var cmd = string.Format("node{0} stop", n);

            ExecuteLocalCcm(cmd, info.ConfigDir, 2000);
        }
Exemple #9
0
 /// <summary>
 /// Stops a node in the cluster with the provided index (1 based)
 /// </summary>
 public static void CcmStopNode(CcmClusterInfo info, int n)
 {
     var cmd = string.Format("node{0} stop", n);
     ExecuteLocalCcm(cmd, info.ConfigDir, 2000);
 }
Exemple #10
0
 /// <summary>
 /// Stops a node (not gently) in the cluster with the provided index (1 based)
 /// </summary>
 public static void CcmStopForce(CcmClusterInfo info, int n)
 {
     ExecuteLocalCcm(string.Format("node{0} stop --not-gently", n), info.ConfigDir, 2000);
 }
Exemple #11
0
        public static CcmClusterInfo CcmSetup(int nodeLength, Builder builder = null, string keyspaceName = null, int secondDcNodeLength = 0, bool connect = true)
        {
            var clusterInfo = new CcmClusterInfo();
            if (builder == null)
            {
                builder = Cluster.Builder();
            }
            if (UseRemoteCcm)
            {
                CCMBridge.ReusableCCMCluster.Setup(nodeLength);
                clusterInfo.Cluster = CCMBridge.ReusableCCMCluster.Build(builder);
                if (keyspaceName != null)
                {
                    clusterInfo.Session = CCMBridge.ReusableCCMCluster.Connect(keyspaceName);
                }
            }
            else
            {
                //Create a local instance
                clusterInfo.ConfigDir = TestUtils.CreateTempDirectory();
                var output = TestUtils.ExecuteLocalCcmClusterStart(clusterInfo.ConfigDir, Options.Default.CASSANDRA_VERSION, nodeLength, secondDcNodeLength);

                if (output.ExitCode != 0)
                {
                    throw new TestInfrastructureException("Local ccm could not start: " + output.ToString());
                }
                try
                {
                    if (connect)
                    {
                        clusterInfo.Cluster = builder
                            .AddContactPoint("127.0.0.1")
                            .Build();
                        clusterInfo.Session = clusterInfo.Cluster.Connect();
                        if (keyspaceName != null)
                        {
                            clusterInfo.Session.CreateKeyspaceIfNotExists(keyspaceName);
                            clusterInfo.Session.ChangeKeyspace(keyspaceName);
                        }
                    }
                }
                catch
                {
                    CcmRemove(clusterInfo);
                    throw;
                }
            }
            return clusterInfo;
        }
Exemple #12
0
 public static void CcmRemove(CcmClusterInfo info)
 {
     if (UseRemoteCcm)
     {
         CCMBridge.ReusableCCMCluster.Drop();
     }
     else
     {
         //Remove the cluster
         TestUtils.ExecuteLocalCcmClusterRemove(info.ConfigDir);
     }
 }
Exemple #13
0
 public static void CcmDecommissionNode(CcmClusterInfo info, int node)
 {
     ExecuteLocalCcm(string.Format("node{0} decommission", node), info.ConfigDir);
 }
Exemple #14
0
 public static void CcmBootstrapNode(CcmClusterInfo info, int node, string dc = null)
 {
     ProcessOutput output = null;
     if (dc == null)
     {
         output = ExecuteLocalCcm(string.Format("add node{0} -i {1}{2} -j {3} -b", node, Options.Default.IP_PREFIX, node, 7000 + 100 * node), info.ConfigDir);
     }
     else
     {
         output = ExecuteLocalCcm(string.Format("add node{0} -i {1}{2} -j {3} -b -d {4}", node, Options.Default.IP_PREFIX, node, 7000 + 100 * node, dc), info.ConfigDir);
     }
     if (output.ExitCode != 0)
     {
         throw new TestInfrastructureException("Local ccm could not add node: " + output.ToString());
     }
 }
Exemple #15
0
 public static void WaitForSchemaAgreement(CcmClusterInfo clusterInfo)
 {
     WaitForSchemaAgreement(clusterInfo.Cluster);
 }