Exemplo n.º 1
0
        public ActionResult InstanceSummary(string node, string type)
        {
            var i = RedisInstance.Get(node);

            if (i == null)
            {
                return(ContentNotFound("Could not find instance " + node));
            }

            switch (type)
            {
            case "config":
                return(View("Instance.Config", i));

            case "clients":
                return(View("Instance.Clients", i));

            case "info":
                return(View("Instance.Info", i));

            case "slow-log":
                return(View("Instance.SlowLog", i));

            default:
                return(ContentNotFound("Unknown summary view requested"));
            }
        }
        public async Task <ActionResult> PromoteToMaster(string node)
        {
            var i = RedisInstance.Get(node);

            if (i == null)
            {
                return(JsonNotFound());
            }

            var oldMaster = i.Master;

            try
            {
                var message = i.PromoteToMaster();
                // We want these to be synchronous
                await i.PollAsync(true).ConfigureAwait(false);

                await oldMaster?.PollAsync(true);

                return(Json(new { message }));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
Exemplo n.º 3
0
        public ActionResult DownloadConfiguration(string host, int port)
        {
            var instance  = RedisInstance.Get(host, port);
            var configZip = instance.GetConfigZip();

            return(new FileContentResult(configZip, "application/zip"));
        }
        public ActionResult InstanceActions(string node)
        {
            var i = RedisInstance.Get(node);

            if (i == null)
            {
                return(JsonNotFound());
            }

            return(View("Instance.Actions", i));
        }
Exemplo n.º 5
0
        public ActionResult Analysis(string node, int db, bool runOnMaster = false)
        {
            var instance = RedisInstance.Get(node);

            if (instance == null)
            {
                return(TextPlain("Instance not found"));
            }
            var analysis = instance.GetDatabaseMemoryAnalysis(db, runOnMaster);

            return(View("Instance.Analysis.Memory", analysis));
        }
Exemplo n.º 6
0
        public ActionResult ClearAnalysis(string node, int db)
        {
            var instance = RedisInstance.Get(node);

            if (instance == null)
            {
                return(TextPlain("Instance not found"));
            }
            instance.ClearDatabaseMemoryAnalysisCache(db);

            return(RedirectToAction(nameof(Analysis), new { node, db }));
        }
Exemplo n.º 7
0
        public ActionResult Instance(string node)
        {
            var instance = RedisInstance.Get(node);

            var vd = new DashboardModel
            {
                Instances          = RedisModule.Instances,
                CurrentInstance    = instance,
                View               = RedisViews.Instance,
                CurrentRedisServer = node,
                Refresh            = true
            };

            return(View(vd));
        }
        public ActionResult InstanceActions(string node)
        {
            var h = RedisHost.Get(node);

            if (h != null)
            {
                return(PartialView("Server.Actions", h));
            }
            var i = RedisInstance.Get(node);

            if (i != null)
            {
                return(PartialView("Instance.Actions", i));
            }
            return(JsonNotFound());
        }
        public async Task <ActionResult> KeyPurge(string node, int db, string key)
        {
            var i = RedisInstance.Get(node);

            if (i == null)
            {
                return(JsonNotFound());
            }

            try
            {
                var removed = await i.KeyPurge(db, key).ConfigureAwait(false);

                return(Json(new { removed }));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
Exemplo n.º 10
0
        private async Task <ActionResult> Deslave(string node, bool promote)
        {
            var i = RedisInstance.Get(node);

            if (i == null)
            {
                return(JsonNotFound());
            }

            var oldMaster = i.Master;

            try
            {
                var message = i.PromoteToMaster();
                if (promote)
                {
                    await i.SetSERedisTiebreakerAsync().ConfigureAwait(false);

                    await oldMaster?.ClearSERedisTiebreakerAsync();

                    await oldMaster?.SlaveToAsync(i.HostAndPort);
                }
                else
                {
                    await i.ClearSERedisTiebreakerAsync().ConfigureAwait(false);
                }
                // We want these to be synchronous
                await i.PollAsync(true).ConfigureAwait(false);

                await oldMaster?.PollAsync(true);

                return(Json(new { message }));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
        private async Task <ActionResult> PerformInstanceAction(string node, Func <RedisInstance, Task <bool> > action, bool poll = false)
        {
            var i = RedisInstance.Get(node);

            if (i == null)
            {
                return(JsonNotFound());
            }

            try
            {
                var success = await action(i).ConfigureAwait(false);

                if (poll)
                {
                    await i.PollAsync(true).ConfigureAwait(false);
                }
                return(Json(new { success }));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }