예제 #1
0
        public ServantAdapterConfig Load(TarsConfig conf, string adapterName)
        {
            string path = "/tars/application/server/" + adapterName;

            Endpoint     = Endpoint.ParseString(conf.Get(path + "<endpoint>"));
            HandleGroup  = conf.Get(path + "<handlegroup>", null);
            Protocol     = conf.Get(path + "<protocol>", "tars");
            MaxConns     = conf.GetInt(path + "<maxconns>", 128);
            QueueCap     = conf.GetInt(path + "<queuecap>", 1024);
            QueueTimeout = conf.GetInt(path + "<queuetimeout>", 10000);
            Servant      = conf.Get(path + "<servant>");
            Threads      = conf.GetInt(path + "<threads>", 1);
            var info = conf.Get(path + "<classtype>");

            ClassType = Type.GetType(info);
            return(this);
        }
예제 #2
0
        public ServerConfig Load(TarsConfig conf)
        {
            Application = conf.Get("/tars/application/server<app>", "UNKNOWN");
            ServerName  = conf.Get("/tars/application/server<server>", null);

            string localStr = conf.Get("/tars/application/server<local>");

            Local = localStr == null || localStr.Length <= 0 ? null : Endpoint
                    .ParseString(localStr);
            Node     = conf.Get("/tars/application/server<node>");
            BasePath = conf.Get("/tars/application/server<basepath>");
            DataPath = conf.Get("/tars/application/server<datapath>");

            CharsetName = conf.Get("/tars/application/server<charsetname>", "UTF-8");

            Config = conf.Get("/tars/application/server<config>");
            Notify = conf.Get("/tars/application/server<notify>");

            Log      = conf.Get("/tars/application/server<log>");
            LogPath  = conf.Get("/tars/application/server<logpath>", null);
            LogLevel = conf.Get("/tars/application/server<loglevel>");
            LogRate  = conf.GetInt("/tars/application/server<lograte>", 5);

            LocalIP = conf.Get("/tars/application/server<localip>");

            SessionTimeOut = conf.GetInt(
                "/tars/application/server<sessiontimeout>", 120000);
            SessionCheckInterval = conf.GetInt(
                "/tars/application/server<sessioncheckinterval>", 60000);
            UdpBufferSize = conf.GetInt("/tars/application/server<udpbuffersize>",
                                        4096);
            TcpNoDelay = conf
                         .GetBool("/tars/application/server<tcpnodelay>", false);

            ServantAdapterConfMap = new Dictionary <string, ServantAdapterConfig>();
            List <String> adapterNameList = conf
                                            .GetSubTags("/tars/application/server");

            if (adapterNameList != null)
            {
                foreach (string adapterName in adapterNameList)
                {
                    ServantAdapterConfig config = new ServantAdapterConfig();
                    config.Load(conf, adapterName);
                    ServantAdapterConfMap.Add(config.Servant, config);
                }
            }

            ServantAdapterConfig adminServantAdapterConfig = new ServantAdapterConfig
            {
                Endpoint = Local,
                Servant  = $"{Application}.{ServerName}.{Constants.AdminServant}"
            };

            ServantAdapterConfMap.Add(Constants.AdminServant,
                                      adminServantAdapterConfig);

            if (Application != null && ServerName != null && LogPath != null)
            {
                LogPath = LogPath + Path.PathSeparator + Application + Path.PathSeparator
                          + ServerName;
            }
            ClientConfig = new ClientConfig().Load(conf);
            if (LogPath != null)
            {
                ClientConfig.LogPath = LogPath;
            }
            ClientConfig.LogLevel = LogLevel;
            ClientConfig.DataPath = DataPath;
            return(this);
        }
예제 #3
0
파일: ClientConfig.cs 프로젝트: fs7744/Tars
        public ClientConfig Load(TarsConfig conf)
        {
            Locator                 = conf.Get("/tars/application/client<locator>");
            LogPath                 = conf.Get("/tars/application/client<logpath>", null);
            LogLevel                = conf.Get("/tars/application/client<loglevel>", "INFO");
            DataPath                = conf.Get("/tars/application/client<cdatapath>", null);
            SyncInvokeTimeout       = conf.GetInt("/tars/application/client<sync-invoke-timeout>", 3000);
            AsyncInvokeTimeout      = conf.GetInt("/tars/application/client<async-invoke-timeout>", 3000);
            RefreshEndpointInterval = conf.GetInt("/tars/application/client<refresh-endpoint-interval>", 60000);
            Stat           = conf.Get("/tars/application/client<stat>");
            Property       = conf.Get("/tars/application/client<property>");
            ReportInterval = conf.GetInt("/tars/application/client<report-interval>", 60000);
            SampleRate     = conf.GetInt("/tars/application/client<sample-rate>", 1000);
            MaxSampleCount = conf.GetInt("/tars/application/client<max-sample-count>", 100);
            SendThread     = conf.GetInt("/tars/application/client<sendthread>", 1);
            RecvThread     = conf.GetInt("/tars/application/client<recvthread>", 1);
            AsyncThread    = conf.GetInt("/tars/application/client<asyncthread>", 1);
            ModuleName     = conf.Get("/tars/application/client<modulename>", Constants.default_modulename);
            string enableSetStr = conf.Get("/tars/application<enableset>");

            SetDivision = conf.Get("/tars/application<setdivision>");
            if ("Y".Equals(enableSetStr, StringComparison.OrdinalIgnoreCase))
            {
                EnableSet = true;
            }
            else
            {
                EnableSet   = false;
                SetDivision = null;
            }

            Connections    = conf.GetInt("/tars/application/client<connections>", Constants.default_connections);
            ConnectTimeout = conf.GetInt("/tars/application/client<connect-timeout>", Constants.default_connect_timeout);
            CorePoolSize   = conf.GetInt("/tars/application/client<corepoolsize>", Constants.default_core_pool_size);
            MaxPoolSize    = conf.GetInt("/tars/application/client<maxpoolsize>", Constants.default_max_pool_size);
            KeepAliveTime  = conf.GetInt("/tars/application/client<keepalivetime>", Constants.default_keep_alive_time);
            QueueSize      = conf.GetInt("/tars/application/client<queuesize>", Constants.default_queue_size);
            CharsetName    = conf.Get("/tars/application/client<charsetname>", Constants.default_charset_name);
            InterfaceType  = Type.GetType(conf.Get("/tars/application/client<interfacetype>"));
            return(this);
        }