/// <summary> /// <para>Gets the status of compose deployments created that match filters specified in query description (if any). /// If the compose deployments do not fit in a page, one page of results is returned as well as a continuation token which can be used to get the next page.</para> /// </summary> /// <param name="composeDeploymentQueryDescription"> /// <para>The <see cref="Description.ComposeDeploymentStatusQueryDescription" /> that determines which compose deployments should be queried.</para> /// </param> /// <param name="client"><see cref="System.Fabric.FabricClient"/> object.</param> /// <param name="timeout"> /// <para>Defines the maximum amount of time the system will allow this operation to continue before returning <see cref="System.TimeoutException" />.</para> /// </param> /// <returns> /// <para>A <see cref="System.Threading.Tasks.Task" /> that represents the asynchronous query operation. /// The value of TResult parameter is an <see cref="Microsoft.ServiceFabric.Preview.Client.Query.ComposeDeploymentStatusList" /> that represents the list of compose deployments that respect the filters in the <see cref="Description.ComposeDeploymentStatusQueryDescription" /> and fit the page. /// If the provided query description has no matching compose deployments, it will return a list of 0 entries.</para> /// </returns> /// <exception cref="System.Fabric.FabricObjectClosedException"> /// <para> /// See <see href="https://azure.microsoft.com/documentation/articles/service-fabric-errors-and-exceptions/"/> for handling common FabricClient failures.</para> /// </exception> /// <exception cref="System.TimeoutException"> /// <para> /// See <see href="https://azure.microsoft.com/documentation/articles/service-fabric-errors-and-exceptions/"/> for handling common FabricClient failures.</para> /// </exception> /// <exception cref="System.Fabric.FabricException"> /// <para> /// See also <see href="https://azure.microsoft.com/documentation/articles/service-fabric-errors-and-exceptions/"/> for handling common FabricClient failures.</para> /// </exception> public static Task <ComposeDeploymentStatusList> GetComposeDeploymentStatusPagedListAsync( this FabricClient.QueryClient client, ComposeDeploymentStatusQueryDescription composeDeploymentQueryDescription, TimeSpan timeout) { return(Task <ComposeDeploymentStatusList> .Run(() => { return ComposeDeploymentStatusListConverter(client.GetComposeDeploymentStatusPagedListAsync(composeDeploymentQueryDescription.ToWrapper(), timeout).Result); })); }
public void FabricClientRetryPolicyClientRetryShouldBeCancelled() { FabricClientRetryPolicy rp = new FabricClientRetryPolicy(5, FixedWaitingPolicy.Default, AllErrorsTransientDetectionStrategy.Instance); Stopwatch sp = Stopwatch.StartNew(); bool operationCanceled = false; int attempts = 0; FabricClient.QueryClient qc = null; try { // Force the object to be disposed. rp.Client.Dispose(); using (CancellationTokenSource cts = new CancellationTokenSource(50)) { rp.ExecuteWithRetriesAsync((ct) => Task.Run(async() => { attempts++; qc = rp.Client.QueryManager; await Task.Delay(Timeout.Infinite, ct); }), TimeSpan.Zero, cts.Token).GetAwaiter().GetResult(); } } catch (OperationCanceledException) { Assert.IsTrue(sp.Elapsed < TimeSpan.FromSeconds(5), sp.Elapsed.ToString()); operationCanceled = true; } Assert.IsNotNull(rp.Client); Assert.IsNotNull(qc); Assert.AreEqual(1, attempts); Assert.AreEqual(true, operationCanceled); }
public async Task <IActionResult> Get(String pc, String hp) { List <String> applicationsList = new List <String>(); FabricClient fabricClient; try { fabricClient = new FabricClient(pc + ":" + GetClientConnectionEndpoint(pc + ":" + hp)); } catch (Exception e) { ServiceEventSource.Current.Message("Web Service: Exception while trying to connect securely: {0}", e); throw; } FabricClient.QueryClient queryClient = fabricClient.QueryManager; ApplicationList appsList = await queryClient.GetApplicationListAsync(); foreach (Application application in appsList) { string applicationName = application.ApplicationName.ToString(); applicationsList.Add(applicationName); } return(this.Json(applicationsList)); }
public async Task <IActionResult> Get(String pc, String hp) { List <String> applicationsList = new List <String>(); FabricClient fabricClient = new FabricClient(pc + ":" + GetClientConnectionEndpoint(pc + ":" + hp)); FabricClient.QueryClient queryClient = fabricClient.QueryManager; ApplicationList appsList = await queryClient.GetApplicationListAsync(); foreach (Application application in appsList) { string applicationName = application.ApplicationName.ToString(); applicationsList.Add(applicationName); } return(this.Json(applicationsList)); }
public QueryManagerWrapper(FabricClient fc) { QueryClient = fc.QueryManager; }
/// <summary> /// Initializes a new instance of the <see cref="QueryClientWrapper"/> class. /// </summary> public QueryClientWrapper(ILogger <QueryClientWrapper> logger, IFabricClientWrapper fabricClientWrapper) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _queryClient = fabricClientWrapper.FabricClient.QueryManager; }
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); }
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)); }