예제 #1
0
        protected void Shard_Command(object sender, CommandEventArgs e)
        {
            var data          = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
            var workloadGroup = TableGroupConfig.LoadCurrent(data["WorkgroupConfigName"]);

            switch (e.CommandName)
            {
            case "UpdateMap":
            {
                workloadGroup.UpdateShardMap();
                workloadGroup.Save();
                lastMessage = "Proposed Shard Map updated";
                break;
            }

            case "DeployMap":
            {
                workloadGroup.DeployShardMap(true);
                lastMessage = "Shard Map deployment sent to the queue";
                break;
            }

            case "PublishMap":
            {
                workloadGroup.PublishShardMap(true);
                lastMessage = "Shard Map publishing sent to the Queue";
                break;
            }
            }
            dataForm.DataBind();
        }
예제 #2
0
        public TableGroupConfig GetItem([QueryString] string id)
        {
            var item = TableGroupConfig.LoadCurrent(id);

            Title       = item.TableGroupName + " Details";
            currentItem = item;
            return(item);
        }
예제 #3
0
        protected void ServerItem_Command(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "RemoveServer":
            {
                var data          = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
                var workloadGroup = TableGroupConfig.LoadCurrent(data["WorkgroupConfigName"]);
                if (workloadGroup != null)
                {
                    var servername = data["ServerInstanceName"];
                    var server     = workloadGroup.Servers.FirstOrDefault(x => x.ServerInstanceName == servername);
                    if (server != null)
                    {
                        workloadGroup.Servers.Remove(server);
                        workloadGroup.Save();
                        currentItem = workloadGroup;
                        dataForm.DataBind();
                    }
                }
                break;
            }

            case "AddServer":
            {
                var data          = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
                var workloadGroup = TableGroupConfig.LoadCurrent(data["WorkgroupConfigName"]);
                var servername    =
                    ((DropDownList)((WebControl)sender).Parent.FindControl("editServerList")).SelectedValue;
                if (workloadGroup != null)
                {
                    if (workloadGroup.Servers.Count(x => x.ServerInstanceName == servername) == 0)
                    {
                        var server = Data.Elasticity.Models.Server.Load(servername);
                        if (server != null)
                        {
                            workloadGroup.Servers.Add(server);
                            workloadGroup.Save();
                            currentItem = workloadGroup;
                            dataForm.DataBind();
                        }
                    }
                }
                break;
            }
            }
        }
예제 #4
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void UpdateItem(string WorkloadGroupName)
        {
            var item = TableGroupConfig.LoadCurrent(WorkloadGroupName);

            // Load the item here, e.g. item = MyDataLayer.Find(id);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", WorkloadGroupName));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                item.Save();
            }
        }
        private bool HasPointerShards()
        {
            var workloadGroup = TableGroupConfig.LoadCurrent(_workloadGroupName);

            if (workloadGroup.PointerShards.Count() > 0)
            {
                ddlNewShard.Items.Clear();
                foreach (var pointerShard in workloadGroup.PointerShards)
                {
                    ddlNewShard.Items.Add(new ListItem
                    {
                        Text  = string.Format("{0} - {1}", pointerShard.ServerInstanceName, pointerShard.Catalog),
                        Value = pointerShard.PointerShardID.ToString(),
                    });
                }
                return(true);
            }
            return(false);
        }
예제 #6
0
        protected void PointerShard_Command(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "AddShard":
            {
                var data          = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
                var workloadGroup = TableGroupConfig.LoadCurrent(data["WorkgroupConfigName"]);
                var servername    =
                    ((DropDownList)((WebControl)sender).Parent.FindControl("newPointerShardList")).SelectedValue;
                var catalog     = ((TextBox)((WebControl)sender).Parent.FindControl("newCatalogName")).Text;
                var description = ((TextBox)((WebControl)sender).Parent.FindControl("newDescription")).Text;
                if (workloadGroup != null)
                {
                    if (
                        workloadGroup.PointerShards.Count(
                            x => x.ServerInstanceName == servername && x.Catalog == catalog) == 0)
                    {
                        workloadGroup.PointerShards.Add(new PointerShard
                            {
                                Catalog            = catalog,
                                Description        = description,
                                ServerInstanceName = servername,
                            });
                        workloadGroup.Save();
                        dataForm.DataBind();
                    }
                }
                break;
            }

            case "UpdateShard":
            {
                var data          = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
                var workloadGroup = TableGroupConfig.LoadCurrent(data["WorkgroupConfigName"]);
                var description   = ((TextBox)((WebControl)sender).Parent.FindControl("description")).Text;
                int pointerShard;
                if (workloadGroup != null)
                {
                    if (int.TryParse(data["PointerShardID"], out pointerShard))
                    {
                        var shard = workloadGroup.PointerShards.FirstOrDefault(x => x.PointerShardID == pointerShard);
                        if (shard != null)
                        {
                            shard.Description = description;
                            workloadGroup.Save();
                            dataForm.DataBind();
                        }
                    }
                }
                break;
            }

            case "DeleteShard":
            {
                var data          = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
                var workloadGroup = TableGroupConfig.LoadCurrent(data["WorkgroupConfigName"]);
                int pointerShard;
                if (workloadGroup != null)
                {
                    if (int.TryParse(data["PointerShardID"], out pointerShard))
                    {
                        var shard = workloadGroup.PointerShards.FirstOrDefault(x => x.PointerShardID == pointerShard);
                        if (shard != null)
                        {
                            workloadGroup.PointerShards.Remove(shard);
                            workloadGroup.Save();
                            dataForm.DataBind();
                        }
                    }
                }
                break;
            }

            case "DeployMap":
            {
                var data          = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
                var workloadGroup = TableGroupConfig.LoadCurrent(data["WorkgroupConfigName"]);
                if (workloadGroup != null)
                {
                    if (workloadGroup.PointerShards.Count > 0)
                    {
                        lastMessage = "Pointer Shards queued for deployment.";
                        workloadGroup.DeployPointerShards(true);
                    }
                    else
                    {
                        lastMessage = "No pointer shards to deploy.";
                    }
                }
                break;
            }

            case "MoveTenant":
            {
                var data = HttpUtility.ParseQueryString(e.CommandArgument.ToString());
                Response.Redirect(string.Format("~/WorkloadGroupConfigs/MoveTenant.aspx?id={0}",
                                                data["WorkgroupConfigName"]));
                break;
            }
            }
        }