// --- Class methods ---
        public static InstanceManager New(DekiWikiService dekiService) {
            InstanceManager mgr = null;
            string srcString = dekiService.Config["wikis/@src"].AsText;
            if(!string.IsNullOrEmpty(srcString)) {
                XUri remoteDirUri = null;
                if(!XUri.TryParse(srcString, out remoteDirUri)) {

                    //TODO: build a specialized exception out of this
                    throw new ApplicationException(string.Format("Configuration is not valid. wikis/@src ({0})is not a valid url!", srcString));
                }
                mgr = new RemoteInstanceManager(dekiService, remoteDirUri);
            } else {
                mgr = new LocalInstanceManager(dekiService);
            }

            mgr.maxInstances = dekiService.Config["wikis/@max"].AsUInt ?? 0;
            uint timeoutSecs = dekiService.Config["wikis/@ttl"].AsUInt ?? uint.MaxValue;
            if(timeoutSecs == 0 || timeoutSecs == uint.MaxValue) {
                mgr._inactiveInstanceTimeOut = TimeSpan.MaxValue;
            } else {
                mgr._inactiveInstanceTimeOut = TimeSpan.FromSeconds(timeoutSecs);
            }

            return mgr;
        }
示例#2
0
        //--- Class methods ---
        public static InstanceManager New(DekiWikiService dekiService, TaskTimerFactory timerFactory) {
            InstanceManager mgr;
            var srcString = dekiService.Config["wikis/@src"].AsText;
            if(!string.IsNullOrEmpty(srcString)) {
                XUri remoteDirUri;
                if(!XUri.TryParse(srcString, out remoteDirUri)) {

                    //TODO: build a specialized exception out of this
                    throw new ApplicationException(string.Format("Configuration is not valid. wikis/@src ({0})is not a valid url!", srcString));
                }
                mgr = new RemoteInstanceManager(dekiService, timerFactory, remoteDirUri, dekiService.TempPath);
            } else {
                mgr = new LocalInstanceManager(dekiService, timerFactory);
            }

            mgr._maxInstances = dekiService.Config["wikis/@max"].AsInt ?? int.MaxValue;
            var timeoutSecs = dekiService.Config["wikis/@ttl"].AsDouble;
            if(timeoutSecs == null || timeoutSecs == 0) {
                mgr._inactiveInstanceTimeOut = TimeSpan.MaxValue;
            } else {
                mgr._inactiveInstanceTimeOut = TimeSpan.FromSeconds(timeoutSecs.Value);
            }
            var retryInterval = dekiService.Config["wikis/@retry-interval"].AsDouble ?? 10;
            mgr._abandonedInstanceRetryInterval = TimeSpan.FromSeconds(retryInterval);
            mgr._minInstanceIdletime = TimeSpan.FromSeconds(dekiService.Config["wikis/@idletime"].AsDouble ?? 60);
            return mgr;
        }
        //--- Class methods ---
        public static InstanceManager New(DekiWikiService dekiService, TaskTimerFactory timerFactory)
        {
            InstanceManager mgr;
            var             srcString = dekiService.Config["wikis/@src"].AsText;

            if (!string.IsNullOrEmpty(srcString))
            {
                XUri remoteDirUri;
                if (!XUri.TryParse(srcString, out remoteDirUri))
                {
                    //TODO: build a specialized exception out of this
                    throw new ApplicationException(string.Format("Configuration is not valid. wikis/@src ({0})is not a valid url!", srcString));
                }
                mgr = new RemoteInstanceManager(dekiService, timerFactory, remoteDirUri, dekiService.TempPath);
            }
            else
            {
                mgr = new LocalInstanceManager(dekiService, timerFactory);
            }

            mgr._maxInstances = dekiService.Config["wikis/@max"].AsInt ?? int.MaxValue;
            var timeoutSecs = dekiService.Config["wikis/@ttl"].AsDouble;

            if (timeoutSecs == null || timeoutSecs == 0)
            {
                mgr._inactiveInstanceTimeOut = TimeSpan.MaxValue;
            }
            else
            {
                mgr._inactiveInstanceTimeOut = TimeSpan.FromSeconds(timeoutSecs.Value);
            }
            var retryInterval = dekiService.Config["wikis/@retry-interval"].AsDouble ?? 10;

            mgr._abandonedInstanceRetryInterval = TimeSpan.FromSeconds(retryInterval);
            mgr._minInstanceIdletime            = TimeSpan.FromSeconds(dekiService.Config["wikis/@idletime"].AsDouble ?? 60);
            return(mgr);
        }