// PUT: odata/Projects(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <ApplicationList> patch)
        {
            Validate(patch.GetInstance());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ApplicationList app = db.ApplicationLists.Find(key);

            if (app == null)
            {
                return(NotFound());
            }

            patch.Put(app);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(app));
        }
Exemple #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // Load view settings
            View view = (View)Settings.GetValue(this, "ListsView", View.Tile);

            if (view == View.Tile)
            {
                mnuTileView.PerformClick();
            }
            else
            {
                mnuDetailsView.PerformClick();
            }

            // Item for all apps
            ApplicationList allApps = new ApplicationList("All applications", true);

            allApps.Applications.AddRange(DbManager.GetJobs());
            AddAppToList(allApps);

            // By default, all apps should be selected
            foreach (ApplicationJob job in allApps.Applications)
            {
                this.checkedApps[job] = true;
            }

            // Item for each category
            Dictionary <string, ApplicationList> categoryLists = new Dictionary <string, ApplicationList>();

            foreach (ApplicationJob job in allApps.Applications)
            {
                if (string.IsNullOrEmpty(job.Category))
                {
                    continue;
                }

                if (!categoryLists.ContainsKey(job.Category))
                {
                    categoryLists[job.Category] = new ApplicationList(job.Category, true);
                    lists.Add(categoryLists[job.Category]);
                }

                categoryLists[job.Category].Applications.Add(job);
            }

            foreach (ApplicationList list in categoryLists.Values)
            {
                imlLists.Images.Add(list.GetIcon());
            }

            // Now add custom lists
            foreach (ApplicationList list in DbManager.GetSetupLists(allApps.Applications))
            {
                AddAppToList(list);
            }

            olvLists.SetObjects(lists);
            olvLists.SelectedIndex = 0;
        }
Exemple #3
0
        private void bNewList_Click(object sender, EventArgs e)
        {
            ApplicationList newList = new ApplicationList("New list", false);

            CreateNewAppList(newList, true);
        }
Exemple #4
0
 /// <summary>
 /// Updates the icon of an application list.
 /// </summary>
 private void UpdateAppList(ApplicationList list)
 {
     imlLists.Images[this.lists.IndexOf(list)] = list.GetIcon();
     olvLists.RefreshObject(list);
 }
Exemple #5
0
 public void Add(ApplicationVM obj)
 {
     ApplicationList.Add(obj);
 }
 public CommonChange(ApplicationList applicationList) => ApplicationList = applicationList;
        public static async Task Update()
        {
            try
            {
                var routes   = new ConcurrentBag <ProxyRoute>();
                var clusters = new ConcurrentBag <Cluster>();

                ApplicationList apps = null;
                do
                {
                    apps = await _fabricClient.QueryManager.GetApplicationPagedListAsync(new System.Fabric.Description.ApplicationQueryDescription()
                    {
                        MaxResults = Int32.MaxValue
                    });

                    await apps.AsyncParallelForEach(async app =>
                    {
                        ServiceList services = null;

                        do
                        {
                            services = await _fabricClient.QueryManager.GetServicePagedListAsync(new System.Fabric.Description.ServiceQueryDescription(app.ApplicationName)
                            {
                                MaxResults = Int32.MaxValue
                            });

                            await services.AsyncParallelForEach(async service =>
                            {
                                var cluster     = new Cluster();
                                var serviceName = service.ServiceName.ToString().Replace("fabric:/", "");
                                cluster.Id      = serviceName;
                                clusters.Add(cluster);
                                var destinations = new ConcurrentDictionary <string, Destination>();

                                { // Add Catch All
                                    var route        = new ProxyRoute();
                                    route.RouteId    = serviceName + ":catch-all";
                                    route.ClusterId  = serviceName;
                                    route.Match.Path = serviceName + "/{**catch-all}";
                                    route.Transforms = new List <IDictionary <string, string> >();
                                    route.AddTransformPathRemovePrefix(new AspNetCore.Http.PathString("/" + serviceName));
                                    route.AddTransformRequestHeader("X-Forwarded-PathBase", "/" + serviceName);

                                    routes.Add(route);
                                }
                                { // Add root match
                                    var route        = new ProxyRoute();
                                    route.RouteId    = serviceName + ":root-match";
                                    route.ClusterId  = serviceName;
                                    route.Match.Path = serviceName;
                                    route.Transforms = new List <IDictionary <string, string> >();
                                    route.AddTransformPathRemovePrefix(new AspNetCore.Http.PathString("/" + serviceName));
                                    route.AddTransformRequestHeader("X-Forwarded-PathBase", "/" + serviceName);
                                    routes.Add(route);
                                }

                                ServicePartitionList partitions = null;

                                do
                                {
                                    partitions = partitions == null ?
                                                 await _fabricClient.QueryManager.GetPartitionListAsync(service.ServiceName) :
                                                 await _fabricClient.QueryManager.GetPartitionListAsync(app.ApplicationName, services.ContinuationToken);

                                    await partitions.AsyncParallelForEach(async partition =>
                                    {
                                        var partitionId             = partition.PartitionInformation.Id;
                                        ServiceReplicaList replicas = null;

                                        do
                                        {
                                            replicas = replicas == null ?
                                                       await _fabricClient.QueryManager.GetReplicaListAsync(partitionId) :
                                                       await _fabricClient.QueryManager.GetReplicaListAsync(partitionId, services.ContinuationToken);

                                            await replicas.AsyncParallelForEach(async replica =>
                                            {
                                                var endpointSet = JsonSerializer.Deserialize <ReplicaAddress>(replica.ReplicaAddress);
                                                foreach (var endpoint in endpointSet.Endpoints)
                                                {
                                                    var destination     = new Destination();
                                                    destination.Address = endpoint.Value;
                                                    destinations.TryAdd($"{partitionId}:{replica.Id}", destination);
                                                }
                                            });
                                        }while (!string.IsNullOrEmpty(replicas.ContinuationToken));
                                    });
                                }while (!string.IsNullOrEmpty(partitions.ContinuationToken));
                                foreach (var dest in destinations)
                                {
                                    cluster.Destinations.Add(dest);
                                }
                            });
                        }while (!string.IsNullOrEmpty(services.ContinuationToken));
                    });
                }while (!string.IsNullOrEmpty(apps.ContinuationToken));


                var config    = new ServiceFabricConfig(clusters.ToList(), routes.ToList());
                var oldConfig = _config;
                _config = config;
                oldConfig.SignalChange();
            }catch (Exception ex)
            {
            }
        }
Exemple #8
0
        /// <summary>
        /// Returns a sorted list of all setup lists.
        /// </summary>
        public static ApplicationList[] GetSetupLists(IEnumerable<ApplicationJob> applicationsToAttach)
        {
            List<ApplicationList> lists = new List<ApplicationList>();

            using (IDbCommand command = Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM setuplists ORDER BY Name";

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ApplicationList appList = new ApplicationList();
                        appList.Hydrate(reader);
                        lists.Add(appList);
                    }
                }
            }

            // Attach applications to lists
            foreach (ApplicationList list in lists)
            {
                using (IDbCommand command = Connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM setuplists_applications WHERE ListGuid = @ListGuid";
                    command.Parameters.Add(new SQLiteParameter("@ListGuid", DbManager.FormatGuid(list.Guid)));

                    using (IDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Guid jobGuid = new Guid(reader["JobGuid"] as string);
                            // Find application and add to list
                            foreach (ApplicationJob app in applicationsToAttach)
                            {
                                if (app.Guid == jobGuid)
                                {
                                    list.Applications.Add(app);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            return lists.ToArray();
        }
Exemple #9
0
    private static void AddAppMock(Mock <QueryManagerWrapper> queryManagerMock, string appName, ApplicationList appList)
    {
        appList.Add(MockQueryApplicationFactory.CreateApplication(appName));

        queryManagerMock.Setup(i => i.GetServiceListAsync(It.Is <Uri>(uri => uri.AbsoluteUri == $"fabric:/{appName}")))
        .ReturnsAsync(new ServiceList()
        {
            CreateStatelessServiceInstance(new Uri($"fabric:/{appName}Service"), "apiServiceType", "1.0", HealthState.Ok,
                                           ServiceStatus.Active)
        });


        var partGuid = Guid.NewGuid();

        var partition = CreateServicePartition(partGuid);

        queryManagerMock
        .Setup(i => i.GetPartitionListAsync(It.Is <Uri>(uri => uri.AbsoluteUri == $"fabric:/{appName}Service")))
        .ReturnsAsync(new ServicePartitionList()
        {
            partition
        });

        queryManagerMock.Setup(i => i.GetReplicaListAsync(It.Is <Guid>(g => g == partGuid))).ReturnsAsync(
            new ServiceReplicaList()
        {
            new MockedReplica(ServiceKind.Stateless, 1, ServiceReplicaStatus.Ready, HealthState.Ok,
                              GetReplicaAddressJson($"http://{appName}:1234"), "nodeA", TimeSpan.MinValue)
        });
    }
        public async Task <Dictionary <String, List <List <String> > > > GetApplicationsServices(FabricClient primaryfc, String primarycs, FabricClient secondaryfc, String secondarycs)
        {
            Dictionary <String, List <List <String> > > applicationsServicesMap = new Dictionary <String, List <List <String> > >();

            FabricClient.QueryClient queryClient = primaryfc.QueryManager;
            ApplicationList          appsList    = await queryClient.GetApplicationListAsync();

            HashSet <String> configuredApplications = await GetConfiguredApplications(primarycs, secondarycs);

            HashSet <String> configuredServices = await GetConfiguredServices();

            HashSet <String> secServices = new HashSet <string>();

            foreach (Application application in appsList)
            {
                string applicationName   = application.ApplicationName.ToString();
                string applicationStatus = "NotConfigured";

                ServiceList services = await primaryfc.QueryManager.GetServiceListAsync(new Uri(applicationName));

                ServiceList secondaryServices;

                try
                {
                    secondaryServices = await secondaryfc.QueryManager.GetServiceListAsync(new Uri(applicationName));

                    foreach (Service service in secondaryServices)
                    {
                        secServices.Add(service.ServiceName.ToString());
                    }
                }
                catch (System.Fabric.FabricElementNotFoundException e)
                {
                    ServiceEventSource.Current.Message("Web Service: Could not find application on secondary cluster: {0}", e);
                    applicationStatus = "NotExist";
                }
                catch (Exception e)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception with Fabric Client Query Manager {0}", e);
                    throw;
                }

                if (configuredApplications.Contains(applicationName))
                {
                    applicationStatus = "Configured";
                }

                List <List <String> > serviceList   = new List <List <String> >();
                List <String>         appStatusList = new List <String>();

                appStatusList.Add(applicationName);
                appStatusList.Add(applicationStatus);

                serviceList.Add(appStatusList);

                foreach (Service service in services)
                {
                    List <String> serviceInfo = new List <String>();
                    string        serviceName = service.ServiceName.ToString();

                    if (secServices.Contains(serviceName))
                    {
                        if (configuredServices.Contains(serviceName))
                        {
                            //Configured
                            serviceInfo.Add(serviceName);
                            serviceInfo.Add("Configured");
                        }
                        else if (service.ServiceKind == ServiceKind.Stateless)
                        {
                            //Stateless
                            serviceInfo.Add(serviceName);
                            serviceInfo.Add("Stateless");
                        }
                        else
                        {
                            //NotConfigured
                            serviceInfo.Add(serviceName);
                            serviceInfo.Add("NotConfigured");
                        }
                    }
                    else
                    {
                        //NotExist
                        serviceInfo.Add(serviceName);
                        serviceInfo.Add("NotExist");
                    }


                    serviceList.Add(serviceInfo);
                }

                applicationsServicesMap.Add(applicationName, serviceList);
            }


            return(applicationsServicesMap);
        }
Exemple #11
0
        private async Task <IDictionary <string, IEnumerable <OrphanInfo> > > DetectDetachedServices(ApplicationList applicationList, GetInstancesResponse usage, bool incrementCount, int timesSeenBeforeOrphaned)
        {
            var detachedServices = (await GetServicesAsync(applicationList, usage))
                                   .Where(s => usage.VacantInstances.All(i => s.ServiceName.AbsoluteUri.EndsWith(i.ToString()) == false))
                                   .Where(s => usage.OccupiedInstances.All(i => s.ServiceName.AbsoluteUri.EndsWith(i.ToString()) == false))
                                   .ToList();

            var possibleOrphans = _detachedServices.ContainsKey(usage.ServiceTypeUri) ? _detachedServices[usage.ServiceTypeUri] : new Dictionary <Uri, int>();

            // First remove all previously detected detached services that are no longer detached for the service type
            possibleOrphans.Keys.Except(detachedServices.Select(x => x.ServiceName)).ToList().ForEach(key => possibleOrphans.Remove(key));

            if (incrementCount && possibleOrphans.Any())
            {
                possibleOrphans.Keys.ToList().ForEach(x => possibleOrphans[x] += 1);
            }

            // Add in newly detected detached services
            detachedServices.Select(x => x.ServiceName).Except(possibleOrphans.Keys).ToList().ForEach(name => possibleOrphans.Add(name, 1));

            _detachedServices[usage.ServiceTypeUri] = possibleOrphans;

            return(new Dictionary <string, IEnumerable <OrphanInfo> >
            {
                {
                    usage.ServiceTypeUri,
                    detachedServices.Where(s => possibleOrphans[s.ServiceName] >= timesSeenBeforeOrphaned)
                    .Select(s => new OrphanInfo(s.ServiceName.AbsoluteUri, usage.ServiceTypeUri, s.HealthState, s.ServiceStatus))
                }
            });
        }
        public static void ImportFromFile(string filename)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(filename);

            // Import settings from file as dictionary
            XmlElement settingsElem = doc.SelectSingleNode("//Settings/dictionary") as XmlElement ??
                                      doc.SelectSingleNode("//dictionary") as XmlElement;

            if (settingsElem != null)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary <string, string>));

                using (StringReader textReader = new StringReader(settingsElem.OuterXml))
                {
                    DbManager.SetSettings(serializer.Deserialize(textReader) as Dictionary <string, string>);
                }
            }

            // Import global variables
            XmlElement varNodes = doc.SelectSingleNode("//GlobalVariables") as XmlElement;

            if (varNodes != null)
            {
                UrlVariable.GlobalVariables.Clear();

                foreach (XmlElement varElem in doc.SelectNodes("//GlobalVariables/Variable"))
                {
                    UrlVariable newVar = new UrlVariable
                    {
                        Name          = varElem.GetAttribute("Name"),
                        CachedContent = varElem.GetAttribute("Content")
                    };
                    UrlVariable.GlobalVariables[newVar.Name] = newVar;
                }

                UrlVariable.GlobalVariables.Save();
            }

            // Import code snippets
            XmlElement snippetNodes = doc.SelectSingleNode("//CodeSnippets") as XmlElement;

            if (snippetNodes != null)
            {
                using (SQLiteCommand comm = DbManager.Connection.CreateCommand())
                {
                    comm.CommandText = "DELETE FROM snippets";
                    comm.ExecuteNonQuery();
                }

                foreach (XmlElement snippetElem in doc.SelectNodes("//CodeSnippets/Snippet"))
                {
                    Snippet snippet = new Snippet
                    {
                        Guid = new Guid(snippetElem.GetAttribute("Guid")),
                        Name = snippetElem.GetAttribute("Name"),
                        Type = (ScriptType)Convert.ToInt32(snippetElem.GetAttribute("Type")),
                        Text = snippetElem.InnerText
                    };
                    snippet.Save();
                }
            }

            XmlElement setupNodes = doc.SelectSingleNode("//SetupLists") as XmlElement;

            if (setupNodes != null)
            {
                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists_applications";
                    command.ExecuteNonQuery();
                }

                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists";
                    command.ExecuteNonQuery();
                }

                foreach (XmlElement listElem in doc.SelectNodes("//SetupLists/List"))
                {
                    ApplicationList list = new ApplicationList
                    {
                        Name = listElem.GetAttribute("Name"),
                        Guid = new Guid(listElem.GetAttribute("Guid"))
                    };

                    foreach (XmlElement appListElem in listElem.SelectNodes("Applications/Application"))
                    {
                        Guid guid = new Guid(appListElem.GetAttribute("Guid"));

                        ApplicationJob job = DbManager.GetJob(guid);
                        if (job != null)
                        {
                            list.Applications.Add(job);
                        }
                    }

                    list.Save();
                }
            }
        }
        private void MainWindow_Load(object sender, EventArgs e)
        {
            dtGridHeight = dtGridApps.Height;
            if (isHidden)
            {
                dtGridApps.Hide();
                Size = new Size(Size.Width, this.Size.Height - dtGridHeight);
            }

            BackgroundWorker bwApplicationLoad = new BackgroundWorker();

            bwApplicationLoad.WorkerReportsProgress = true;

            bwApplicationLoad.DoWork += new DoWorkEventHandler(
                delegate(object o, DoWorkEventArgs args)
            {
                BackgroundWorker b = o as BackgroundWorker;

                try
                {
                    ApplicationList appList = FetchApplicationList();
                    foreach (ApplicationInstall app in appList.Applications)
                    {
                        app.Status = "Waiting...";
                        ApplicationVersion version = GetPlatformVersion(app);
                        app.Version = version.Version;
                    }
                    args.Result = appList;
                }
                catch (WebException)
                {
                    args.Cancel = true;
                    return;
                }
            });

            bwApplicationLoad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
                delegate(object o, RunWorkerCompletedEventArgs args)
            {
                if (args.Cancelled)
                {
                    lblProgress.Text = "Cannot progress. Do you have a working internet connection?";
                    pbProgress.Style = ProgressBarStyle.Continuous;
                    pbProgress.Value = 0;
                }
                else
                {
                    ApplicationList appList = (ApplicationList)args.Result;
                    dtGridApps.DataSource   = appList.Applications;
                    dtGridApps.Refresh();
                    lblProgress.Text = "Initialize complete!";
                    pbProgress.Style = ProgressBarStyle.Continuous;
                    pbProgress.Value = 0;

                    ProcessApplication(index);
                }
            });

            lblProgress.Text = string.Format("Initializing...");
            pbProgress.Style = ProgressBarStyle.Marquee;
            dtGridApps.AutoGenerateColumns = false;

            bwApplicationLoad.RunWorkerAsync();
        }
Exemple #14
0
        public async Task <IActionResult> GetApplications(String primarycs, String primaryThumbprint, String secondarycs, String secondaryThumbprint)
        {
            Dictionary <String, List <List <String> > > applicationsServicesMap = new Dictionary <String, List <List <String> > >();

            FabricClient primaryfc   = GetSecureFabricClient(primarycs, primaryThumbprint);
            FabricClient secondaryfc = GetSecureFabricClient(secondarycs, secondaryThumbprint);

            FabricClient.QueryClient queryClient = primaryfc.QueryManager;
            ApplicationList          appsList    = await queryClient.GetApplicationListAsync();

            HashSet <String> configuredServices = await GetConfiguredServices();

            HashSet <String> secServices = new HashSet <string>();

            foreach (Application application in appsList)
            {
                string applicationName = application.ApplicationName.ToString();

                ServiceList services = await primaryfc.QueryManager.GetServiceListAsync(new Uri(applicationName));

                ServiceList secondaryServices = await secondaryfc.QueryManager.GetServiceListAsync(new Uri(applicationName));

                foreach (Service service in secondaryServices)
                {
                    secServices.Add(service.ServiceName.ToString());
                }



                List <List <String> > serviceList = new List <List <String> >();
                foreach (Service service in services)
                {
                    List <String> serviceInfo = new List <String>();
                    string        serviceName = service.ServiceName.ToString();

                    if (secServices.Contains(serviceName))
                    {
                        if (configuredServices.Contains(serviceName))
                        {
                            //Configured
                            serviceInfo.Add(serviceName);
                            serviceInfo.Add("Configured");
                        }
                        else if (service.ServiceKind == ServiceKind.Stateless)
                        {
                            //Stateless
                            serviceInfo.Add(serviceName);
                            serviceInfo.Add("Stateless");
                        }
                        else
                        {
                            //NotConfigured
                            serviceInfo.Add(serviceName);
                            serviceInfo.Add("NotConfigured");
                        }
                    }
                    else
                    {
                        //NotExist
                        serviceInfo.Add(serviceName);
                        serviceInfo.Add("NotExist");
                    }


                    serviceList.Add(serviceInfo);
                }

                applicationsServicesMap.Add(applicationName, serviceList);
            }

            return(this.Json(applicationsServicesMap));
        }
Exemple #15
0
 public void Remove(ApplicationVM obj)
 {
     ApplicationList.Remove(obj);
 }
Exemple #16
0
 // Get  /Private/ListApps
 public ActionResult ListApps(string serchMessage, int? page, int? pageSize)
 {
     ApplicationList model = new ApplicationList
     {
         SerchMessage = serchMessage
     };
     model.AppList = ApplicationHelper.FilterApplicationList(serchMessage, page ?? 1, pageSize ?? 30);
     return View(model);
 }
        public static void ImportFromFile(string filename)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(filename);

            // Import settings from file as dictionary
            XmlElement settingsElem = doc.SelectSingleNode("//Settings/dictionary") as XmlElement;
            if (settingsElem == null)
            {
                // Backward compatibility
                settingsElem = doc.SelectSingleNode("//dictionary") as XmlElement;
            }

            if (settingsElem != null)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary<string, string>));

                using (StringReader textReader = new StringReader(settingsElem.OuterXml))
                {
                    DbManager.SetSettings(serializer.Deserialize(textReader) as Dictionary<string, string>);
                }
            }
            
            // Import global variables
            XmlElement varNodes = doc.SelectSingleNode("//GlobalVariables") as XmlElement;
            if (varNodes != null)
            {
                UrlVariable.GlobalVariables.Clear();

                foreach (XmlElement varElem in doc.SelectNodes("//GlobalVariables/Variable"))
                {
                    UrlVariable newVar = new UrlVariable();
                    newVar.Name = varElem.GetAttribute("Name");
                    newVar.CachedContent = varElem.GetAttribute("Content");
                    UrlVariable.GlobalVariables[newVar.Name] = newVar;
                }

                UrlVariable.GlobalVariables.Save();
            }

            // Import code snippets
            XmlElement snippetNodes = doc.SelectSingleNode("//CodeSnippets") as XmlElement;
            if (snippetNodes != null)
            {
                using (SQLiteCommand comm = DbManager.Connection.CreateCommand())
                {
                    comm.CommandText = "DELETE FROM snippets";
                    comm.ExecuteNonQuery();
                }

                foreach (XmlElement snippetElem in doc.SelectNodes("//CodeSnippets/Snippet"))
                {
                    Snippet snippet = new Snippet();
                    snippet.Guid = new Guid(snippetElem.GetAttribute("Guid"));
                    snippet.Name = snippetElem.GetAttribute("Name");
                    snippet.Type = (ScriptType)Convert.ToInt32(snippetElem.GetAttribute("Type"));
                    snippet.Text = snippetElem.InnerText;
                    snippet.Save();
                }
            }

            XmlElement setupNodes = doc.SelectSingleNode("//SetupLists") as XmlElement;
            if (setupNodes != null)
            {
                ApplicationJob[] apps = DbManager.GetJobs();

                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists_applications";
                    command.ExecuteNonQuery();
                }

                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists";
                    command.ExecuteNonQuery();
                }

                foreach (XmlElement listElem in doc.SelectNodes("//SetupLists/List"))
                {
                    ApplicationList list = new ApplicationList();
                    list.Name = listElem.GetAttribute("Name");
                    list.Guid = new Guid(listElem.GetAttribute("Guid"));

                    foreach (XmlElement appListElem in listElem.SelectNodes("Applications/Application"))
                    {
                        Guid guid = new Guid(appListElem.GetAttribute("Guid"));

                        ApplicationJob job = DbManager.GetJob(guid);
                        if (job != null)
                        {
                            list.Applications.Add(job);
                        }
                    }

                    list.Save();
                }
            }            
        }
 public void TestInitialize()
 {
     this.applicationList = new ApplicationList();
 }
        /// <summary>
        /// This function gathers the state of the cluster on startup and caches the information
        /// Changes to cluster state are handled through notifications.
        ///
        /// Capture information for each replica for every service running in the cluster.
        /// </summary>
        /// <returns></returns>
        public static async Task InitializePartitionData()
        {
            EnvoyDefaults.LogMessage("InitializePartitionData started");

            // Populate data locally
            Dictionary <Guid, SF_Partition> partitionData = new Dictionary <Guid, SF_Partition>();

            var queryManager = client.QueryManager;

            ApplicationList applications = null;

            try
            {
                applications = await queryManager.GetApplicationListAsync();
            }
            catch (Exception e)
            {
                EnvoyDefaults.LogMessage("GetApplicationListAsync failed");
                EnvoyDefaults.LogMessage(String.Format("Error={0}", e.Message));
                EnvoyDefaults.LogMessage(String.Format("Error={0}", e.StackTrace));
                Environment.FailFast("GetApplicationListAsync failed");
            }
            EnvoyDefaults.LogMessage("GetApplicationListAsync Succeeded");
            foreach (var application in applications)
            {
                var services = await queryManager.GetServiceListAsync(application.ApplicationName);

                foreach (var service in services)
                {
                    var partitions = await queryManager.GetPartitionListAsync(service.ServiceName);

                    foreach (var partition in partitions)
                    {
                        List <SF_Endpoint> listeners = new List <SF_Endpoint>();

                        var replicas = await queryManager.GetReplicaListAsync(partition.PartitionInformation.Id);

                        foreach (var replica in replicas)
                        {
                            if (replica.ReplicaAddress.Length == 0)
                            {
                                continue;
                            }
                            JObject addresses;
                            try
                            {
                                addresses = JObject.Parse(replica.ReplicaAddress);
                            }
                            catch
                            {
                                continue;
                            }

                            var replicaListeners = addresses["Endpoints"].Value <JObject>();
                            foreach (var replicaListener in replicaListeners)
                            {
                                var role = ServiceEndpointRole.Stateless;
                                if (partition.ServiceKind == ServiceKind.Stateful)
                                {
                                    var statefulRole = ((StatefulServiceReplica)replica).ReplicaRole;
                                    switch (statefulRole)
                                    {
                                    case ReplicaRole.Primary:
                                        role = ServiceEndpointRole.StatefulPrimary;
                                        break;

                                    case ReplicaRole.ActiveSecondary:
                                        role = ServiceEndpointRole.StatefulSecondary;
                                        break;

                                    default:
                                        role = ServiceEndpointRole.Invalid;
                                        break;
                                    }
                                }
                                int listenerIndex = listeners.FindIndex(x => x.Name == replicaListener.Key);
                                if (listenerIndex == -1)
                                {
                                    listeners.Add(new SF_Endpoint(replicaListener.Key));
                                    listenerIndex = listeners.Count - 1;
                                }
                                try
                                {
                                    var listenerAddressString = replicaListener.Value.ToString();
                                    if (!listenerAddressString.StartsWith("http") &&
                                        !listenerAddressString.StartsWith("https"))
                                    {
                                        continue;
                                    }
                                    var listenerAddress = new Uri(replicaListener.Value.ToString());
                                    if (listenerAddress.HostNameType == UriHostNameType.Dns)
                                    {
                                        var ipaddrs = Dns.GetHostAddresses(listenerAddress.Host);
                                        foreach (var ipaddr in ipaddrs)
                                        {
                                            if (ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                                            {
                                                var saddrstring = ipaddr.ToString();
                                                if (saddrstring.StartsWith("172"))
                                                {
                                                    listenerAddress = new Uri(listenerAddress.Scheme + "://" +
                                                                              saddrstring +
                                                                              ":" + listenerAddress.Port + listenerAddress.PathAndQuery);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    listeners[listenerIndex].AddInstance(role, listenerAddress);
                                }
                                catch (System.Exception e)
                                {
                                    EnvoyDefaults.LogMessage(String.Format("Error={0}", e));
                                }
                            }
                        }

                        // Remove any listeners without active endpoints
                        listeners.RemoveAll(x => x.InstanceCount() == 0);

                        if (listeners.Count == 0)
                        {
                            continue;
                        }

                        var partitionInfo = new SF_Partition(service.ServiceName,
                                                             service.ServiceKind,
                                                             partition.PartitionInformation,
                                                             null,
                                                             listeners);

                        partitionData[partition.PartitionInformation.Id] = partitionInfo;
                    }
                }
            }

            // Process changes received through notifications
            lock (lock_)
            {
                foreach (var partition in partitionsAdd_)
                {
                    partitionData[partition.Key] = partition.Value;
                }
                foreach (var partition in partitionsRemove_)
                {
                    partitionData.Remove(partition.Key);
                }

                // Finally update global state, populate Service List and log details
                partitions_ = partitionData;
                services_   = new Dictionary <string, ServicePartitions>();
                foreach (var partition in partitionData)
                {
                    AddPartitionToService(partition.Key, partition.Value);
                    EnvoyDefaults.LogMessage(String.Format("Added: {0}={1}", partition.Key,
                                                           JsonConvert.SerializeObject(partition.Value)));
                }

                partitionsRemove_ = null;
                partitionsAdd_    = null;
            }
        }
Exemple #20
0
        public JsonResult FindApplication(ApplicationListFilterModel filters, GridDescriptor request)
        {
            ApplicationList model = HomeBuilder.FilterApplications(Db, request, filters);

            return(Json(ResponseStatus.Success, RenderPartialViewToString("ApplicationList", model)));
        }
Exemple #21
0
        private void InitializeQueries()
        {
            // Initialize the queries
            logger.Info("Entering baseline evaluation");

            bool zoomIsSet = PlotModels[0].DefaultXAxis != null;

            double xstart = 0;
            double xend   = 0;

            if (zoomIsSet)
            {
                xstart = PlotModels[0].DefaultXAxis.ActualMinimum;
                xend   = PlotModels[0].DefaultXAxis.ActualMaximum;
                if (xstart < 0)
                {
                    xstart = 0;
                }
            }

            var baseline = from t in _baselineWorkloadAnalysis.Points
                           where ApplicationList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.ApplicationName) &&
                           HostList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.HostName) &&
                           DatabaseList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.DatabaseName) &&
                           LoginList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.LoginName) &&
                           (!zoomIsSet || t.OffsetMinutes >= xstart) &&
                           (!zoomIsSet || t.OffsetMinutes <= xend)
                           group t by new
            {
                query = t.NormalizedQuery
            }
            into grp
                select new
            {
                query           = grp.Key.query,
                sum_duration_us = grp.Sum(t => t.SumDurationUs),
                avg_duration_us = grp.Average(t => t.AvgDurationUs),
                sum_cpu_us      = grp.Sum(t => t.SumCpuUs),
                avg_cpu_us      = grp.Average(t => t.AvgCpuUs),
                sum_reads       = grp.Sum(t => t.SumReads),
                avg_reads       = grp.Average(t => t.AvgReads),
                execution_count = grp.Sum(t => t.ExecutionCount)
            };

            logger.Info("Baseline evaluation completed");
            logger.Info("Entering benchmark evaluation");

            var benchmark = from t in baseline where false select new { t.query, t.sum_duration_us, t.avg_duration_us, t.sum_cpu_us, t.avg_cpu_us, t.sum_reads, t.avg_reads, t.execution_count };

            if (_benchmarkWorkloadAnalysis != null)
            {
                benchmark = from t in _benchmarkWorkloadAnalysis.Points
                            where ApplicationList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.ApplicationName) &&
                            HostList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.HostName) &&
                            DatabaseList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.DatabaseName) &&
                            LoginList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.LoginName) &&
                            (!zoomIsSet || t.OffsetMinutes >= xstart) &&
                            (!zoomIsSet || t.OffsetMinutes <= xend)
                            group t by new
                {
                    query = t.NormalizedQuery
                }
                into grp
                    select new
                {
                    query           = grp.Key.query,
                    sum_duration_us = grp.Sum(t => t.SumDurationUs),
                    avg_duration_us = grp.Average(t => t.AvgDurationUs),
                    sum_cpu_us      = grp.Sum(t => t.SumCpuUs),
                    avg_cpu_us      = grp.Average(t => t.AvgCpuUs),
                    sum_reads       = grp.Sum(t => t.SumReads),
                    avg_reads       = grp.Average(t => t.AvgReads),
                    execution_count = grp.Sum(t => t.ExecutionCount)
                };
            }

            logger.Info("Benchmark evaluation completed");
            logger.Info("Merging sets");

            var leftOuterJoin =
                from b in baseline
                join k in benchmark
                on b.query.Hash equals k.query.Hash
                into joinedData
                from j in joinedData.DefaultIfEmpty()
                select new
            {
                query_hash       = b.query.Hash,
                query_text       = b.query.ExampleText,
                query_normalized = b.query.NormalizedText,
                b.sum_duration_us,
                b.avg_duration_us,
                b.sum_cpu_us,
                b.avg_cpu_us,
                b.sum_reads,
                b.avg_reads,
                b.execution_count,
                sum_duration_us2     = j == null ? 0 : j.sum_duration_us,
                diff_sum_duration_us = j == null ? 0 : j.sum_duration_us - b.sum_duration_us,
                avg_duration_us2     = j == null ? 0 : j.avg_duration_us,
                sum_cpu_us2          = j == null ? 0 : j.sum_cpu_us,
                diff_sum_cpu_us      = j == null ? 0 : j.sum_cpu_us - b.sum_cpu_us,
                avg_cpu_us2          = j == null ? 0 : j.avg_cpu_us,
                sum_reads2           = j == null ? 0 : j.sum_reads,
                avg_reads2           = j == null ? 0 : j.avg_reads,
                execution_count2     = j == null ? 0 : j.execution_count,
                querydetails         = new QueryDetails(b.query, _baselineWorkloadAnalysis, _benchmarkWorkloadAnalysis),
                document             = new ICSharpCode.AvalonEdit.Document.TextDocument()
                {
                    Text = b.query.ExampleText
                }
            };

            var rightOuterJoin =
                from b in benchmark
                join k in baseline
                on b.query.Hash equals k.query.Hash
                into joinedData
                from j in joinedData.DefaultIfEmpty()
                select new
            {
                query_hash       = b.query.Hash,
                query_text       = b.query.ExampleText,
                query_normalized = b.query.NormalizedText,
                b.sum_duration_us,
                b.avg_duration_us,
                b.sum_cpu_us,
                b.avg_cpu_us,
                b.sum_reads,
                b.avg_reads,
                b.execution_count,
                sum_duration_us2     = j == null ? 0 : j.sum_duration_us,
                diff_sum_duration_us = j == null ? 0 : j.sum_duration_us - b.sum_duration_us,
                avg_duration_us2     = j == null ? 0 : j.avg_duration_us,
                sum_cpu_us2          = j == null ? 0 : j.sum_cpu_us,
                diff_sum_cpu_us      = j == null ? 0 : j.sum_cpu_us - b.sum_cpu_us,
                avg_cpu_us2          = j == null ? 0 : j.avg_cpu_us,
                sum_reads2           = j == null ? 0 : j.sum_reads,
                avg_reads2           = j == null ? 0 : j.avg_reads,
                execution_count2     = j == null ? 0 : j.execution_count,
                querydetails         = new QueryDetails(b.query, _baselineWorkloadAnalysis, _benchmarkWorkloadAnalysis),
                document             = new ICSharpCode.AvalonEdit.Document.TextDocument()
                {
                    Text = b.query.ExampleText
                }
            };

            var merged = leftOuterJoin.Union(rightOuterJoin);

            Queries = merged;

            logger.Info("Sets merged");

            RaisePropertyChanged("Queries");
            RaisePropertyChanged("CompareModeVisibility");
            RaisePropertyChanged("CompareMode");

            string sortCol = CompareMode ? "diff_sum_duration_us" : "sum_duration_us";
            var    msg     = new SortColMessage(sortCol, System.ComponentModel.ListSortDirection.Descending);

            Messenger.Default.Send <SortColMessage>(msg);
        }
Exemple #22
0
 public CustomList <ApplicationList> GetAllApplicationName(string companyID)
 {
     return(ApplicationList.GetAllApplicationName(companyID));
 }
        private async Task <string> GetDeployedAppsInfoAsync(CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            ApplicationList appList = null;
            var             sb      = new StringBuilder();
            string          clusterManifestXml;

            if (this.IsTestRun)
            {
                clusterManifestXml = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "clusterManifest.xml"));
            }
            else
            {
                appList = await this.FabricClientInstance.QueryManager.GetApplicationListAsync().ConfigureAwait(true);

                clusterManifestXml = await this.FabricClientInstance.ClusterManager.GetClusterManifestAsync().ConfigureAwait(true);
            }

            token.ThrowIfCancellationRequested();

            XmlReader    xreader = null;
            StringReader sreader = null;
            string       ret     = null;

            try
            {
                // Safe XML pattern - *Do not use LoadXml*...
                var xdoc = new XmlDocument {
                    XmlResolver = null
                };
                sreader = new StringReader(clusterManifestXml);
                xreader = XmlReader.Create(sreader, new XmlReaderSettings()
                {
                    XmlResolver = null
                });
                xdoc.Load(xreader);

                // Cluster Information...
                var nsmgr = new XmlNamespaceManager(xdoc.NameTable);
                nsmgr.AddNamespace("sf", "http://schemas.microsoft.com/2011/01/fabric");

                // Failover Manager...
                var fMparameterNodes = xdoc.SelectNodes("//sf:Section[@Name='FailoverManager']//sf:Parameter", nsmgr);
                sb.AppendLine("\nCluster Information:\n");

                foreach (XmlNode node in fMparameterNodes)
                {
                    token.ThrowIfCancellationRequested();

                    sb.AppendLine(node.Attributes.Item(0).Value + ": " + node.Attributes.Item(1).Value);
                }

                token.ThrowIfCancellationRequested();

                // Node Information...
                sb.AppendLine($"\nNode Info:\n");
                sb.AppendLine($"Node Name: {this.NodeName}");
                sb.AppendLine($"Node Id: {this.FabricServiceContext.NodeContext.NodeId}");
                sb.AppendLine($"Node Instance Id: {this.FabricServiceContext.NodeContext.NodeInstanceId}");
                sb.AppendLine($"Node Type: {this.FabricServiceContext.NodeContext.NodeType}");
                Tuple <int, int> portRange = NetworkUsage.TupleGetFabricApplicationPortRangeForNodeType(this.FabricServiceContext.NodeContext.NodeType, clusterManifestXml);

                if (portRange.Item1 > -1)
                {
                    sb.AppendLine($"Application Port Range: {portRange.Item1} - {portRange.Item2}");
                }

                var infraNode = xdoc.SelectSingleNode("//sf:Node", nsmgr);

                if (infraNode != null)
                {
                    sb.AppendLine("Is Seed Node: " + infraNode.Attributes["IsSeedNode"]?.Value);
                    sb.AppendLine("Fault Domain: " + infraNode.Attributes["FaultDomain"]?.Value);
                    sb.AppendLine("Upgrade Domain: " + infraNode.Attributes["UpgradeDomain"]?.Value);
                }

                token.ThrowIfCancellationRequested();

                if (!string.IsNullOrEmpty(this.sFNodeLastBootTime))
                {
                    sb.AppendLine("Last Rebooted: " + this.sFNodeLastBootTime);
                }

                // Stop here for unit testing...
                if (this.IsTestRun)
                {
                    ret = sb.ToString();
                    sb.Clear();

                    return(ret);
                }

                // Application Info...
                // TODO: Emit ETW event for App and Service info...
                if (appList != null)
                {
                    sb.AppendLine("\nDeployed Apps:\n");

                    foreach (var app in appList)
                    {
                        token.ThrowIfCancellationRequested();

                        var appName     = app.ApplicationName.OriginalString;
                        var appType     = app.ApplicationTypeName;
                        var appVersion  = app.ApplicationTypeVersion;
                        var healthState = app.HealthState.ToString();
                        var status      = app.ApplicationStatus.ToString();

                        sb.AppendLine("Application Name: " + appName);
                        sb.AppendLine("Type: " + appType);
                        sb.AppendLine("Version: " + appVersion);
                        sb.AppendLine("Health state: " + healthState);
                        sb.AppendLine("Status: " + status);

                        // App's Service(s)...
                        sb.AppendLine("\n\tServices:");
                        var serviceList = await this.FabricClientInstance.QueryManager.GetServiceListAsync(app.ApplicationName).ConfigureAwait(true);

                        var replicaList = await this.FabricClientInstance.QueryManager.GetDeployedReplicaListAsync(this.NodeName, app.ApplicationName).ConfigureAwait(true);

                        foreach (var service in serviceList)
                        {
                            var kind = service.ServiceKind.ToString();
                            var type = service.ServiceTypeName;
                            var serviceManifestversion = service.ServiceManifestVersion;
                            var serviceName            = service.ServiceName;
                            var serviceDescription     = await this.FabricClientInstance.ServiceManager.GetServiceDescriptionAsync(serviceName).ConfigureAwait(true);

                            var processModel = serviceDescription.ServicePackageActivationMode.ToString();

                            foreach (var rep in replicaList)
                            {
                                if (service.ServiceName != rep.ServiceName)
                                {
                                    continue;
                                }

                                // Get established port count per service...
                                int procId = (int)rep.HostProcessId;
                                int ports = -1, ephemeralPorts = -1;

                                if (procId > -1)
                                {
                                    ports          = NetworkUsage.GetActivePortCount(procId);
                                    ephemeralPorts = NetworkUsage.GetActiveEphemeralPortCount(procId);
                                }

                                sb.AppendLine("\tService Name: " + serviceName.OriginalString);
                                sb.AppendLine("\tTypeName: " + type);
                                sb.AppendLine("\tKind: " + kind);
                                sb.AppendLine("\tProcessModel: " + processModel);
                                sb.AppendLine("\tServiceManifest Version: " + serviceManifestversion);

                                if (ports > -1)
                                {
                                    sb.AppendLine("\tActive Ports: " + ports);
                                }

                                if (ephemeralPorts > -1)
                                {
                                    sb.AppendLine("\tActive Ephemeral Ports: " + ephemeralPorts);
                                }

                                sb.AppendLine();

                                // ETW...
                                if (this.IsEtwEnabled)
                                {
                                    Logger.EtwLogger?.Write(
                                        $"FabricObserverDataEvent",
                                        new
                                    {
                                        Level                  = 0, // Info
                                        Node                   = this.NodeName,
                                        Observer               = this.ObserverName,
                                        AppName                = appName,
                                        AppType                = appType,
                                        AppVersion             = appVersion,
                                        AppHealthState         = healthState,
                                        AppStatus              = status,
                                        ServiceName            = serviceName.OriginalString,
                                        ServiceTypeName        = type,
                                        Kind                   = kind,
                                        ProcessModel           = processModel,
                                        ServiceManifestVersion = serviceManifestversion,
                                        ActivePorts            = ports,
                                        EphemeralPorts         = ephemeralPorts,
                                    });
                                }

                                break;
                            }
                        }
                    }
                }

                ret = sb.ToString();
                sb.Clear();
            }
            finally
            {
                sreader.Dispose();
                xreader.Dispose();
            }

            return(ret);
        }
Exemple #24
0
        public void Init()
        {
            // Application Type
            FABRIC_APPLICATION_TYPE_QUERY_RESULT_ITEM_      = this.random.CreateRandom <ApplicationType>();
            FABRIC_APPLICATION_TYPE_QUERY_RESULT_ITEM_LIST_ = new ApplicationTypeList()
            {
                this.random.CreateRandom <ApplicationType>()
            };

            FABRIC_APPLICATION_TYPE_QUERY_RESULT_ITEM_PAGED_LIST_ = new ApplicationTypePagedList();
            FABRIC_APPLICATION_TYPE_QUERY_RESULT_ITEM_PAGED_LIST_.ContinuationToken = "ContinuationToken342741";
            FABRIC_APPLICATION_TYPE_QUERY_RESULT_ITEM_PAGED_LIST_.Add(this.random.CreateRandom <ApplicationType>());
            FABRIC_APPLICATION_TYPE_QUERY_RESULT_ITEM_PAGED_LIST_.Add(this.random.CreateRandom <ApplicationType>());
            FABRIC_APPLICATION_TYPE_QUERY_RESULT_ITEM_PAGED_LIST_.Add(this.random.CreateRandom <ApplicationType>());

            // Application
            FABRIC_APPLICATION_QUERY_RESULT_ITEM_      = this.random.CreateRandom <Application>();
            FABRIC_APPLICATION_QUERY_RESULT_ITEM_LIST_ = new ApplicationList()
            {
                this.random.CreateRandom <Application>(), this.random.CreateRandom <Application>()
            };

            // Service Type
            FABRIC_SERVICE_TYPE_DESCRIPTION_       = this.random.CreateRandom <ServiceTypeDescription>();
            FABRIC_SERVICE_TYPE_QUERY_RESULT_ITEM_ = this.random.CreateRandom <ServiceType>();
            FABRIC_SERVICE_TYPE_QUERY_RESULT_LIST_ = new ServiceTypeList()
            {
                this.random.CreateRandom <ServiceType>()
            };

            //Replica
            FABRIC_SERVICE_REPLICA_QUERY_RESULT_ITEM_ = this.CreateReplica();

            FABRIC_SERVICE_REPLICA_LIST_RESULT_ = new ServiceReplicaList();
            FABRIC_SERVICE_REPLICA_LIST_RESULT_.ContinuationToken = "4387284";
            FABRIC_SERVICE_REPLICA_LIST_RESULT_.Add(this.CreateReplica());
            FABRIC_SERVICE_REPLICA_LIST_RESULT_.Add(this.CreateReplica());

            // Partition
            FABRIC_SERVICE_PARTITION_INFORMATION_       = this.random.CreateRandom <ServicePartitionInformation>();
            FABRIC_SERVICE_PARTITION_QUERY_RESULT_ITEM_ = CreatePartition();

            FABRIC_SERVICE_PARTITION_LIST_RESULT_ = new ServicePartitionList();
            FABRIC_SERVICE_PARTITION_LIST_RESULT_.ContinuationToken = Guid.NewGuid().ToString();
            FABRIC_SERVICE_PARTITION_LIST_RESULT_.Add(this.CreatePartition());
            FABRIC_SERVICE_PARTITION_LIST_RESULT_.Add(this.CreatePartition());

            //Service
            FABRIC_SERVICE_QUERY_RESULT_ITEM_ = this.CreateServiceQueryItem();
            FABRIC_SERVICE_QUERY_RESULT_LIST_ = new ServiceList()
            {
                this.CreateServiceQueryItem(), this.CreateServiceQueryItem()
            };

            // Node
            FABRIC_NODE_DEACTIVATION_QUERY_RESULT_ITEM_ = this.random.CreateRandom <NodeDeactivationResult>();
            FABRIC_NODE_DEACTIVATION_TASK_ = this.random.CreateRandom <NodeDeactivationTask>();
            FABRIC_NODE_QUERY_RESULT_ITEM_ = this.random.CreateRandom <Node>();

            // NodeList with continuation token
            FABRIC_NODE_LIST_QUERY_RESULT_ = new NodeList();
            FABRIC_NODE_LIST_QUERY_RESULT_.ContinuationToken = "ContinuationToken34274";
            FABRIC_NODE_LIST_QUERY_RESULT_.Add(this.random.CreateRandom <Node>());
            FABRIC_NODE_LIST_QUERY_RESULT_.Add(this.random.CreateRandom <Node>());
            FABRIC_NODE_LIST_QUERY_RESULT_.Add(this.random.CreateRandom <Node>());

            // Deployed Application
            FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_      = this.random.CreateRandom <DeployedApplication>();
            FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_LIST_ = new DeployedApplicationList()
            {
                FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_
            };

            FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_PAGED_LIST_ = new DeployedApplicationPagedList();
            FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_PAGED_LIST_.ContinuationToken = "ContinuationToken342741";
            FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_PAGED_LIST_.Add(this.random.CreateRandom <DeployedApplication>());
            FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_PAGED_LIST_.Add(this.random.CreateRandom <DeployedApplication>());
            FABRIC_DEPLOYED_APPLICATION_QUERY_RESULT_ITEM_PAGED_LIST_.Add(this.random.CreateRandom <DeployedApplication>());

            // Deployed Service
            FABRIC_DEPLOYED_SERVICE_REPLICA_QUERY_RESULT_ITEM_         = this.random.CreateRandom <DeployedStatefulServiceReplica>();
            FABRIC_DEPLOYED_SERVICE_REPLICA_QUERY_RESULT_ITEM2_        = this.random.CreateRandom <DeployedStatelessServiceInstance>();
            FABRIC_DEPLOYED_SERVICE_REPLICA_QUERY_RESULT_ITEM3_        = this.random.CreateRandom <DeployedServiceReplica>();
            FABRIC_DEPLOYED_SERVICE_REPLICA_DETAIL_QUERY_RESULT_ITEM_  = this.random.CreateRandom <DeployedStatefulServiceReplicaDetail>();
            FABRIC_DEPLOYED_SERVICE_REPLICA_DETAIL_QUERY_RESULT_ITEM2_ = this.random.CreateRandom <DeployedStatelessServiceInstanceDetail>();

            // Code Package
            FABRIC_CODE_PACKAGE_ENTRY_POINT_STATISTICS_          = this.random.CreateRandom <CodePackageEntryPointStatistics>();
            FABRIC_CODE_PACKAGE_ENTRY_POINT_                     = this.random.CreateRandom <CodePackageEntryPoint>();
            FABRIC_DEPLOYED_CODE_PACKAGE_QUERY_RESULT_ITEM_      = this.random.CreateRandom <DeployedCodePackage>();
            FABRIC_DEPLOYED_CODE_PACKAGE_QUERY_RESULT_ITEM_LIST_ = new DeployedCodePackageList()
            {
                FABRIC_DEPLOYED_CODE_PACKAGE_QUERY_RESULT_ITEM_
            };
            FABRIC_DEPLOYED_SERVICE_PACKAGE_QUERY_RESULT_ITEM_ = this.random.CreateRandom <DeployedServicePackage>();

            // Replicator
            FABRIC_PRIMARY_REPLICATOR_STATUS_QUERY_RESULT_   = this.random.CreateRandom <PrimaryReplicatorStatus>();
            FABRIC_SECONDARY_REPLICATOR_STATUS_QUERY_RESULT_ = this.random.CreateRandom <SecondaryReplicatorStatus>();

            // Load
            FABRIC_LOAD_METRIC_INFORMATION_      = this.random.CreateRandom <LoadMetricInformation>();
            FABRIC_LOAD_METRIC_REPORT_           = this.random.CreateRandom <LoadMetricReport>();
            FABRIC_NODE_LOAD_METRIC_INFORMATION_ = this.random.CreateRandom <NodeLoadMetricInformation>();
            FABRIC_NODE_LOAD_INFORMATION_        = this.random.CreateRandom <NodeLoadInformation>();
            FABRIC_PARTITION_LOAD_INFORMATION_   = this.random.CreateRandom <PartitionLoadInformation>();
            FABRIC_REPLICA_LOAD_INFORMATION_     = this.random.CreateRandom <ReplicaLoadInformation>();

            // Service Group
            FABRIC_SERVICE_GROUP_TYPE_MEMBER_DESCRIPTION_       = this.random.CreateRandom <ServiceGroupTypeMemberDescription>();
            FABRIC_SERVICE_GROUP_MEMBER_TYPE_QUERY_RESULT_ITEM_ = this.random.CreateRandom <ServiceGroupMemberType>();
        }