Example #1
0
        /// <summary>
        /// Not Aspect Wrapped
        /// </summary>
        protected static TWorker EnsureWorker <TWorker>(IFoundation foundation, string workerName, int millisecondInterval = 5000)
            where TWorker : WorkerBase <TRequest>
        {
            IDaemonManager daemonManager = foundation.GetDaemonManager();
            IDaemonTask    daemonTask    = daemonManager.GetRegisteredDaemonTask(workerName);

            if (daemonTask == null)
            {
                lock (_RegistrationLock)
                {
                    daemonTask = daemonManager.GetRegisteredDaemonTask(workerName);
                    if (daemonTask == null)
                    {
                        if (millisecondInterval <= 1000)
                        {
                            millisecondInterval = 5000; // if you give bad data, we force to 5 seconds.
                        }
                        DaemonConfig config = new DaemonConfig()
                        {
                            InstanceName           = workerName,
                            ContinueOnError        = true,
                            IntervalMilliSeconds   = millisecondInterval,
                            StartDelayMilliSeconds = 0,
                            TaskConfiguration      = string.Empty
                        };
                        TWorker worker = (TWorker)foundation.Container.Resolve(typeof(TWorker), null);
                        daemonManager.RegisterDaemon(config, worker, true);
                    }
                }
                daemonTask = daemonManager.GetRegisteredDaemonTask(workerName);
            }
            return(daemonTask as TWorker);
        }
        public void RegisterCustomRouting(System.Web.Routing.RouteCollection routes)
        {
            base.ExecuteMethod("RegisterCustomRouting", delegate()
            {
                this.IFoundation.Container.RegisterInstance <INotifySynchronizer>(new ElasticSyncNotifySynchronizer(this.IFoundation));

                IDaemonManager daemonManager       = this.IFoundation.GetDaemonManager();
                ISettingsResolver settingsResolver = this.IFoundation.Resolve <ISettingsResolver>();
                bool isBackPane = settingsResolver.IsBackPane();
                bool isHydrate  = settingsResolver.IsHydrate();
                if (isBackPane)
                {
                    DaemonConfig config = new DaemonConfig()
                    {
                        InstanceName           = string.Format(ElasticSearchDaemon.DAEMON_NAME_FORMAT, Agents.AGENT_DEFAULT),
                        ContinueOnError        = true,
                        IntervalMilliSeconds   = (int)TimeSpan.FromSeconds(30).TotalMilliseconds,
                        StartDelayMilliSeconds = 15,
                        TaskConfiguration      = string.Empty
                    };
                    daemonManager.RegisterDaemon(config, new ElasticSearchDaemon(this.IFoundation, Agents.AGENT_DEFAULT), true);

                    config = new DaemonConfig()
                    {
                        InstanceName           = string.Format(ElasticSearchDaemon.DAEMON_NAME_FORMAT, Agents.AGENT_STATS),
                        ContinueOnError        = true,
                        IntervalMilliSeconds   = (int)TimeSpan.FromSeconds(30).TotalMilliseconds,
                        StartDelayMilliSeconds = 25,
                        TaskConfiguration      = string.Empty
                    };
                    daemonManager.RegisterDaemon(config, new ElasticSearchDaemon(this.IFoundation, Agents.AGENT_STATS), true);
                }
            });
        }
Example #3
0
        public ActionResult Index(string name = "", string op = "")
        {
            return(base.ExecuteFunction("Index", delegate()
            {
                string message = string.Empty;
                IDaemonManager daemonManager = this.IFoundation.GetDaemonManager();
                if (op == "removeall")
                {
                    daemonManager.UnRegisterAllDaemons();
                    message = "RemovedAll";
                }
                else if (op == "remove")
                {
                    daemonManager.UnRegisterDaemon(name);
                    message = "Removed: " + name;
                }
                else if (op == "stop")
                {
                    daemonManager.StopDaemon(name);
                    message = "Stopped: " + name;
                }
                else if (op == "start")
                {
                    daemonManager.StartDaemon(name);
                    message = "Started: " + name;
                }

                ViewBag.Message = message;
                return View(daemonManager.GetAllTimerDetails().OrderBy(x => x.Name).ToList());
            }));
        }
Example #4
0
 public TcpServer(IDaemonManager daemonManager)
 {
     if (daemonManager == null)
     {
         throw new ArgumentNullException("daemonManager");
     }
     _daemonManager = daemonManager;
 }
Example #5
0
        /// <summary>
        /// Not aspect wrapped
        /// </summary>
        public static string ProcessAgitateWebHook(IFoundation foundation, string secretkey, string daemonName)
        {
            string result = "";

            if (secretkey == "codeable")
            {
                IDaemonManager daemonManager = foundation.GetDaemonManager();
                if (null != daemonManager.GetRegisteredDaemonTask(daemonName))
                {
                    daemonManager.StartDaemon(daemonName);
                    result = "Agitated";
                }
            }
            return(result);
        }
Example #6
0
 public object AgitateDaemons(string key, string type)
 {
     return(base.ExecuteFunction("AgitateDaemons", delegate()
     {
         if (key == "codeable")
         {
             IDaemonManager daemonManager = this.IFoundation.GetDaemonManager();
             if (type == "photo")
             {
                 daemonManager.StartDaemon(AmazonImageResizeDaemon.DAEMON_NAME);
             }
             if (type == "video")
             {
                 daemonManager.StartDaemon(AmazonEncodingDaemon.DAEMON_NAME);
             }
         }
         return this.Http200("OK", "");
     }));
 }
Example #7
0
        public void RegisterCustomRouting(System.Web.Routing.RouteCollection routes)
        {
            base.ExecuteMethod("RegisterCustomRouting", delegate()
            {
                AmazonUploadFile uploadFile = new AmazonUploadFile(this.IFoundation);
                this.IFoundation.Container.RegisterInstance <IUploadFiles>(uploadFile);
                this.IFoundation.Container.RegisterInstance <INotifyEncoder>(uploadFile);

                this.IFoundation.Container.RegisterInstance <IProcessImage>(new AmazonImageResizeDaemon(this.IFoundation)); // isolated instance, isnt actually ran as a daemon

                IDaemonManager daemonManager       = this.IFoundation.GetDaemonManager();
                ISettingsResolver settingsResolver = this.IFoundation.Resolve <ISettingsResolver>();
                bool isBackPane  = settingsResolver.IsBackPane();
                bool isLocalHost = settingsResolver.IsLocalHost();
                bool isHydrate   = settingsResolver.IsHydrate();
                if (isBackPane && !isLocalHost && !isHydrate)
                {
                    DaemonConfig config = new DaemonConfig()
                    {
                        InstanceName           = AmazonEncodingDaemon.DAEMON_NAME,
                        ContinueOnError        = true,
                        IntervalMilliSeconds   = (int)TimeSpan.FromMinutes(1).TotalMilliseconds,
                        StartDelayMilliSeconds = 15,
                        TaskConfiguration      = string.Empty
                    };
                    daemonManager.RegisterDaemon(config, new AmazonEncodingDaemon(this.IFoundation), true);

                    config = new DaemonConfig()
                    {
                        InstanceName           = AmazonImageResizeDaemon.DAEMON_NAME,
                        ContinueOnError        = true,
                        IntervalMilliSeconds   = (int)TimeSpan.FromMinutes(1).TotalMilliseconds,
                        StartDelayMilliSeconds = 15,
                        TaskConfiguration      = string.Empty
                    };
                    daemonManager.RegisterDaemon(config, new AmazonImageResizeDaemon(this.IFoundation), true);
                }
            });
        }
Example #8
0
        /// <summary>
        /// Not aspect wrapped
        /// </summary>
        public static string ProcessWebHook(IFoundation foundation, string secretkey, string hookType, string entityType, string argument)
        {
            string result = "";

            if (secretkey == "codeable")
            {
                IDaemonManager daemonManager = foundation.GetDaemonManager();

                switch (hookType)
                {
                case "sync":
                case "failed":
                    daemonManager.StartDaemon(string.Format(ElasticSearchDaemon.DAEMON_NAME_FORMAT, Agents.AGENT_DEFAULT));
                    daemonManager.StartDaemon(string.Format(ElasticSearchDaemon.DAEMON_NAME_FORMAT, Agents.AGENT_STATS));
                    result = "Queued Normal Sync";
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
Example #9
0
 public LowLevelTcpServer(IDaemonManager daemonManager)
 {
     _daemonManager = daemonManager;
 }
Example #10
0
 public LowLevelTcpServer(IDaemonManager daemonManager)
 {
     _daemonManager = daemonManager;
 }
Example #11
0
 public HttpServer(IDaemonManager daemonFactory)
 {
     _daemonFactory = daemonFactory;
     _lowLevelTcpServer = new LowLevelTcpServer(daemonFactory);
 }
Example #12
0
 public TcpService(IDaemonManager daemonManager)
 {
     _daemonManager = daemonManager;
 }
Example #13
0
 public HttpServer(IDaemonManager daemonFactory)
 {
     _daemonFactory     = daemonFactory;
     _lowLevelTcpServer = new LowLevelTcpServer(daemonFactory);
 }