Exemple #1
0
 /// <summary>
 /// Creates a new single-node connection.  Internal usage only (Factory pattern on the base class).
 /// </summary>
 /// <param name="settings">Connection settings to use to connect to the node.</param>
 /// <param name="callbackExecutor">The callback executor provided by the factory creator that will execute all
 /// callbacks</param>
 internal VoltNodeConnection(ConnectionSettings settings, CallbackExecutor callbackExecutor)
     : base(settings)
 {
     this.ExecutionCache = new ExecutionCache(settings.MaxOutstandingTxns);
     // Reference to the global callback executor
     this.CallbackExecutor = callbackExecutor;
 }
 /// <summary>
 /// Creates a new cluster connection (load-balanced multi-node connection).
 /// Internal usage only (Factory pattern on the base class).
 /// </summary>
 /// <param name="settings">Connection settings to use to connect to the cluster.</param>
 /// <param name="callbackExecutor">Reference to the executor that will execute all callbacks.</param>
 internal VoltClusterConnection(ConnectionSettings settings, CallbackExecutor callbackExecutor)
     : base(settings)
 {
     // Faster than looking up the settings property all the time
     this.LoadBalancingBatchSize = this.Settings.LoadBalancingBatchSize;
     // Reference to the global callback executor
     this.CallbackExecutor = callbackExecutor;
 }
        /// <summary>
        /// Builds a connection for the given settings.  If the settings point to a single server, a VoltNodeConnection
        /// is returned.  If the settings point to multiple servers, a VoltClusterConnection is returned.  Both
        /// connection types offer identical signatures, tagged on the base VoltConnection class.  The only difference
        /// is that the VoltClusterConnection will embed automatic validation that all connected nodes belong to the
        /// same cluster, pointing to the same catalog, and perform load balancing between the different servers.
        /// Transparently, the Cluster connection will aggregate statistics accross all connections, defer Trace events
        /// to each sub-Node connection and perform Round-Robin load balancing (for now this is the only algorithm)
        /// between them for actual execution.  The cluster connection offers additional control over its behavior upon
        /// a node failure (should the conection be re-established, etc.) through the connection settings.
        /// </summary>
        /// <param name="settings">Connection settings to use to establish the connection.</param>
        /// <returns>A VoltConnection object (either a single-node VoltNodeConnection or pooled
        /// VoltClusterConnection.</returns>
        public static VoltConnection Create(ConnectionSettings settings)
        {
            CallbackExecutor callbackExecutor = new CallbackExecutor();

            switch (settings.HostAddresses.Length)
            {
            case 0:
                throw new ArgumentException(
                          string.Format(
                              Resources.InvalidConnectionStringHostList
                              , settings.HostList
                              )
                          );

            case 1:
                return(new VoltNodeConnection(settings, callbackExecutor, true));

            default:
                return(new VoltClusterConnection(settings, callbackExecutor));
            }
        }
Exemple #4
0
 /// <summary>
 /// Creates a new single-node connection.  Internal usage only (Factory pattern on the base class).
 /// </summary>
 /// <param name="settings">Connection settings to use to connect to the node.</param>
 /// <param name="callbackExecutor">The callback executor provided by the factory creator that will execute all
 /// callbacks</param>
 /// <param name="ownsCallbackExecutor">Flag indicating this connection owns the callback executor and should
 /// stop it when it terminates.</param>
 internal VoltNodeConnection(ConnectionSettings settings, CallbackExecutor callbackExecutor, bool ownsCallbackExecutor)
     : this(settings, callbackExecutor)
 {
     this.OwnsCallbackExecutor = ownsCallbackExecutor;
 }