Beispiel #1
0
        public async Task <IEnumerable <SubscriberInfo> > GetSubscribers(string topic, string applicationName)
        {
            ServiceList services = await fabric.QueryManager.GetServiceListAsync(new Uri(applicationName));

            return(services.
                   Where(x => x.ServiceTypeName == Constants.SUBSCRIBER_SERVICE_TYPE_NAME && x.ServiceName.IsTopic(topic))
                   .Select(x => new SubscriberInfo
            {
                ServiceName = x.ServiceName.ToString(),
                ServiceStatus = x.ServiceStatus.ToString()
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> Get()
        {
            ServiceList services = await this.fabric.QueryManager.GetServiceListAsync(new Uri(applicationName));

            return(this.Ok(services
                           .Where(x => x.ServiceTypeName == Constants.TOPIC_SERVICE_TYPE_NAME)
                           .Select(x => new
            {
                ServiceName = x.ServiceName.ToString(),
                ServiceStatus = x.ServiceStatus.ToString()
            })));
        }
Beispiel #3
0
        public async Task <IActionResult> Get()
        {
            ServiceList services =
                await this.fabricClient.QueryManager.GetServiceListAsync(new Uri(this.serviceContext.CodePackageActivationContext.ApplicationName));

            return(this.Ok(
                       services
                       .Where(x => x.ServiceTypeName == ReportProcessingServiceTypeName)
                       .Select(
                           x => new
            {
                name = x.ServiceName.ToString(),
                status = x.ServiceStatus.ToString(),
                version = x.ServiceManifestVersion,
                health = x.HealthState.ToString()
            })));
        }
Beispiel #4
0
        public async Task <IActionResult> Put(string topicName, string name)
        {
            ServiceList services = await this.fabric.QueryManager.GetServiceListAsync(new Uri(applicationName));

            try
            {
                Service topicService = services.Where(x => x.ServiceTypeName == Constants.TOPIC_SERVICE_TYPE_NAME &&
                                                      x.ServiceName.IsTopic(topicName)).Single();
            }
            catch (InvalidOperationException)
            {
                //Topic is not availible
                return(NotFound($"No topic found with name '{topicName}'.  Please create topic before adding subscription."));
            }

            StatefulServiceDescription serviceDescription = new StatefulServiceDescription()
            {
                ApplicationName            = new Uri(this.applicationName),
                MinReplicaSetSize          = 3,
                TargetReplicaSetSize       = 3,
                PartitionSchemeDescription = new SingletonPartitionSchemeDescription(),
                HasPersistedState          = true,
                InitializationData         = Encoding.UTF8.GetBytes(topicName),
                ServiceTypeName            = Constants.SUBSCRIBER_SERVICE_TYPE_NAME,
                ServiceName = this.serviceContext.CreateSubscriptionUri(topicName, name)
            };

            try
            {
                await fabric.ServiceManager.CreateServiceAsync(serviceDescription);
            }
            catch (FabricElementAlreadyExistsException)
            {
                //idempotent so return 200
                return(Ok());
            }

            return(Ok());
        }