/// <summary> /// Initiates the logics for the pseudonodes runner. /// </summary> /// <param name="port">The port for this replica if it were the primary. It assumes all replicas listen at the same port</param> /// <param name="ssl">SSL wrapping object</param> /// <param name="monitor">the optional object to use to synchronize executions</param> public void SetupPseudoNodes(int port, SslWrapping ssl, object monitor = null) { this.SetupPseudoNodes( () => { return(this.GetClientToPrimary(port, ssl)); }, monitor); }
/// <summary> /// Set the SSL configuration. /// </summary> /// <param name="ssl">SslWrapping object</param> public void SetSsl(SslWrapping ssl) { if (ssl != null) { this.transportConfiguration.UseSecureConnection = true; this.transportConfiguration.Identities = ssl.Identities; this.transportConfiguration.MustCheckCertificateRevocation = ssl.MustCheckCertificateRevocation; this.transportConfiguration.MustCheckCertificateTrustChain = ssl.MustCheckCertificateTrustChain; } else { this.transportConfiguration.UseSecureConnection = false; } this.client?.Close(); this.client?.Dispose(); this.client = null; }
/// <summary> /// Gets a client to the primary /// </summary> /// <param name="port">Port number</param> /// <param name="ssl">SSL wrapping object</param> /// <returns>New clien to the primary</returns> internal RingMaster GetClientToPrimary(int port, SslWrapping ssl) { return(PseudoNodes.GetClientToPrimary(this.backend, port, ssl)); }
/// <summary> /// Gets a client to the primary. /// </summary> /// <param name="backend">The backend.</param> /// <param name="port">The port.</param> /// <param name="ssl">The SSL.</param> /// <returns>the new client to the primary</returns> internal static RingMaster GetClientToPrimary(RingMasterBackendCore backend, int port, SslWrapping ssl) { if (backend == null) { throw new ArgumentNullException("backend"); } // addr will contain the list of peers, or '127.0.0.1' if none is there string addr = string.Empty; ClusterMember[] cm = backend.Factory.GetAgreedMembers(); if (cm != null) { foreach (ClusterMember m in cm) { if (addr == string.Empty) { addr = string.Format("{0}:{1}", m.Address, port); } else { addr = string.Format("{0};{1}:{2}", addr, m.Address, port); } } } else { // nothing on cm, just us. addr = "127.0.0.1:" + port; } Trace.TraceInformation("SetupPseudoNodes {0} ", addr); RingMaster rm = new RingMaster(addr, 1000, null); rm.AddAuthInfo(AuthSchemes.Digest, "root"); rm.SetSsl(ssl); return(rm); }