Example #1
0
 public FailoverClusterClient(RemoteClientConfiguration configuration)
 {
     Configuration = configuration;
     MasterNode    = (RemoteEngineClient <T>)configuration.GetClient <T>();
     // Todo move to config
     _dispatchStrategy = new RoundRobinQueryDispatchStrategy <T>(Nodes);
 }
Example #2
0
        public static FailoverClusterClient <T> CreateFromNetwork(RemoteClientConfiguration baseConfiguration)
        {
            var client     = new FailoverClusterClient <T>(baseConfiguration);
            var initClient = (RemoteEngineClient <T>)baseConfiguration.GetClient <T>();
            var response   = initClient.SendAndRecieve <ClusterInfoResponse>(new ClusterInfoRequest());

            client.UpdateClusterInformation(response.ClusterInfo);
            return(client);
        }
Example #3
0
        RemoteEngineClient <T> CreateNode(string host, int port)
        {
            var nodeConfig = new RemoteClientConfiguration();

            nodeConfig.DedicatedPool  = Configuration.DedicatedPool;
            nodeConfig.MaxConnections = Configuration.MaxConnections;
            nodeConfig.Host           = host;
            nodeConfig.Port           = port;
            var node = (RemoteEngineClient <T>)nodeConfig.GetClient <T>();

            Nodes.Add(node);
            return(node);
        }
Example #4
0
        public static ConnectionPool PoolFor(RemoteClientConfiguration configuration)
        {
            lock (_connectionPools)
            {
                ConnectionPool pool;
                var            key = configuration.ToString();
                if (configuration.DedicatedPool)
                {
                    key += Guid.NewGuid();
                }

                if (!_connectionPools.TryGetValue(key, out pool))
                {
                    var host           = configuration.Host;
                    var port           = configuration.Port;
                    var maxConnections = configuration.MaxConnections;
                    pool = new ConnectionPool(() => new RemoteConnection(host, port), maxConnections, host, port);
                    _connectionPools[key] = pool;
                }
                return(pool);
            }
        }
Example #5
0
        static ClientConfiguration CreateConfigFromConnectionString(string connectionstring)
        {
            var configDictionary = ConfigDictionary.FromDelimitedString(connectionstring);


            var mode = configDictionary.Get("mode", () => Mode.Embedded);

            Func <string, bool> keyFilter = key => key.ToLowerInvariant() != "mode";

            if (mode == Mode.Embedded)
            {
                var config = new EngineConfiguration();
                configDictionary.MapTo(config, keyFilter: keyFilter);
                return(new LocalClientConfiguration(config));
            }
            else //Mode.Remote
            {
                var config = new RemoteClientConfiguration();
                configDictionary.MapTo(config, keyFilter: keyFilter);
                return(new FailoverClusterClientConfiguration(config));
            }
        }
Example #6
0
 public FailoverClusterClientConfiguration(RemoteClientConfiguration baseConfig)
 {
     _baseConfig = baseConfig;
 }