private void Initialize(XmlDocument configXml)
        {
            var clientConfig = new ClientConfig();
            if (configXml != null)
            {
                var root = configXml.DocumentElement;

                if (root != null)
                {
                    var domain = BuildDomain(root.GetElementsByTagName("domain"));
                    var servers = BuildServers(root.GetElementsByTagName("servers")).Where(server => server.Enabled).ToList();

                    clientConfig.Domain = domain;
                    servers.ForEach(server =>
                    {
                        clientConfig.Servers.Add(server);
                        Logger.Info("Cat server configured: {0}:{1}", server.Ip, server.Port);
                    });
                }
            }
            else
            {
                Logger.Warn($"configXml is null.");
            }
            Initialize(clientConfig);
        }
Example #2
0
 public TcpMessageSender(ClientConfig clientConfig, IMessageStatistics statistics)
 {
     _clientConfig = clientConfig;
     _statistics = statistics;
     _connPool = new ConcurrentDictionary<Server, TcpClient>();
     _queue = new ConcurrentQueue<IMessageTree>();
     _atomicTress = new ConcurrentQueue<IMessageTree>();
     _codec = new PlainTextMessageCodec();
     _maxQueueSize = clientConfig.Domain.MaxQueueSize;
 }
 private void Initialize(ClientConfig clientConfig)
 {
     if (clientConfig != null)
     {
         ClientConfig = clientConfig;
     }
     else
     {
         Logger.Warn("ClientConfig is null.");
     }
 }
        public virtual void InitializeClient(ClientConfig clientConfig)
        {
            _clientConfig = clientConfig ?? new ClientConfig();

            _hostName = NetworkInterfaceManager.GetLocalHostName();
            _statistics = new DefaultMessageStatistics();
            _sender = new TcpMessageSender(_clientConfig, _statistics);
            _sender.Initialize();
            _factory = new MessageIdFactory();
            _statusUpdateTask = new StatusUpdateTask(_statistics);

            _taggedTransactions = new ConcurrentDictionary<string, ITaggedTransaction>();

            // initialize domain and ip address
            _factory.Initialize(_clientConfig.Domain.Id);

            // start status update task
            ThreadPool.QueueUserWorkItem(_statusUpdateTask.Run);
            Logger.Info("Thread(StatusUpdateTask) started.");
        }
 public ClientConfigManager(ClientConfig clientConfig)
 {
     Initialize(clientConfig);
 }