Ejemplo n.º 1
0
        /// <summary>
        /// Deletes endpoint on port 5022 from a given server. Noop if endpoint doesn't exist.
        /// </summary>
        /// <param name="server">SMO server from which endpoint needs to be deleted.</param>
        public static void DeleteHadrEndpoint(SMO.Server server)
        {
            Endpoint ep = ARHelper.GetHadrEndpoint(server);

            if (null != ep)
            {
                ep.Drop();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates endpoint on port 5022 on a given server. Skips creation if endpoint already exists.
        /// </summary>
        /// <param name="server">SMO server where endpoint needs to be created.</param>
        /// <returns>Newly created or existing endpoint.</returns>
        public static Endpoint CreateHadrEndpoint(SMO.Server server)
        {
            Endpoint ep = ARHelper.GetHadrEndpoint(server);

            if (null == ep)
            {
                ep = new Endpoint(server, hadrEndpointName);
                ep.EndpointType = EndpointType.DatabaseMirroring;
                ep.ProtocolType = ProtocolType.Tcp;
                ep.Payload.DatabaseMirroring.ServerMirroringRole         = ServerMirroringRole.All;
                ep.Payload.DatabaseMirroring.EndpointEncryption          = EndpointEncryption.Required;
                ep.Payload.DatabaseMirroring.EndpointEncryptionAlgorithm = EndpointEncryptionAlgorithm.Aes;
                ep.Create();
                ep.Start();
                if (ep.EndpointState != EndpointState.Started)
                {
                    throw new Exception(string.Format("Endpoint {0} on server {1} failed to start", ep.Name, server.Name));
                }
            }
            return(ep);
        }