コード例 #1
0
        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);
        }
コード例 #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;
 }
コード例 #3
0
 private void Initialize(ClientConfig clientConfig)
 {
     if (clientConfig != null)
     {
         ClientConfig = clientConfig;
     }
     else
     {
         Logger.Warn("ClientConfig is null.");
     }
 }
コード例 #4
0
        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.");
        }
コード例 #5
0
 public ClientConfigManager(ClientConfig clientConfig)
 {
     Initialize(clientConfig);
 }