Ejemplo n.º 1
0
 protected virtual void Initialize(StatefulService instance, IStartable starter)
 {
     var path = Utility.GetDefaultPath(instance);
     this.Path = Util.GetWcfUri(path);
     this.Stateful = instance;
     this.Starter = starter;
 }
Ejemplo n.º 2
0
		private void cmdTestStateRight_Click(object sender, EventArgs e)
		{
			StatefulService proxy = new StatefulService();
			proxy.CookieContainer = cookieContainer;

			proxy.StoreName("John Smith");
			MessageBox.Show("You set: " + proxy.GetName());

		}
        public ICommunicationListener CreateCommunicationListener(StatefulService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            return new AspNetCoreCommunicationListener(this, service);
        }
Ejemplo n.º 4
0
		private void cmdTestStateWrong_Click(object sender, EventArgs e)
		{
			// Create the proxy.
			StatefulService proxy = new StatefulService();


			// Set a name.
			proxy.StoreName("John Smith");

			// Try to retrieve the name.
			MessageBox.Show("You set: " + proxy.GetName());

		}
 public void ServiceMessage(StatefulService service, string message, params object[] args)
 {
     if (this.IsEnabled())
     {
         string finalMessage = string.Format(message, args);
         this.ServiceMessage(
             service.Context.ServiceName.ToString(),
             service.Context.ServiceTypeName,
             service.Context.ReplicaId,
             service.Context.PartitionId,
             service.Context.CodePackageActivationContext.ApplicationName,
             service.Context.CodePackageActivationContext.ApplicationTypeName,
             service.Context.NodeContext.NodeName,
             finalMessage);
     }
 }
Ejemplo n.º 6
0
 public void ServiceMessage(StatefulService service, string message, params object[] args)
 {
     if (this.IsEnabled())
     {
         string finalMessage = string.Format(message, args);
         ServiceMessage(
             service.ServiceInitializationParameters.ServiceName.ToString(),
             service.ServiceInitializationParameters.ServiceTypeName,
             service.ServiceInitializationParameters.ReplicaId,
             service.ServiceInitializationParameters.PartitionId,
             service.ServiceInitializationParameters.CodePackageActivationContext.ApplicationName,
             service.ServiceInitializationParameters.CodePackageActivationContext.ApplicationTypeName,
             FabricRuntime.GetNodeContext().NodeName,
             finalMessage);
     }
 }
        public void ServiceMessage(StatefulService service, string message, params object[] args)
        {
            // System.IO.File.AppendAllText("jotadebug.txt", string.Format("{0} : {1}{2}", service.ServiceInitializationParameters.ServiceName.ToString(), string.Format(message, args), System.Environment.NewLine));

            if (this.IsEnabled())
            {
                string finalMessage = string.Format(message, args);
                ServiceMessage(
                    service.ServiceInitializationParameters.ServiceName.ToString(),
                    service.ServiceInitializationParameters.ServiceTypeName,
                    service.ServiceInitializationParameters.ReplicaId,
                    service.ServiceInitializationParameters.PartitionId,
                    service.ServiceInitializationParameters.CodePackageActivationContext.ApplicationName,
                    service.ServiceInitializationParameters.CodePackageActivationContext.ApplicationTypeName,
                    FabricRuntime.GetNodeContext().NodeName,
                    finalMessage);
            }
        }
Ejemplo n.º 8
0
 public Task RegisterMessageTypeAsync(StatefulService service, Type messageType, Uri brokerServiceName = null,
                                      string listenerName = null)
 {
     return(Task.CompletedTask);
 }
Ejemplo n.º 9
0
 protected internal RestorePointOperation(string fabricRequestHeader, string serviceName, string apiVersion, StatefulService statefulService) : base(apiVersion)
 {
     this.StatefulService     = statefulService;
     this.FabricRequestHeader = fabricRequestHeader;
 }
 public static IMessageConsumer CreateConsumer(this StatefulService service, ServicePartitionInformation partition)
 {
     return(service.Context.CreateConsumer(partition));
 }
Ejemplo n.º 11
0
 internal Startup(StatefulService statefulService, SecuritySetting securitySetting, CancellationToken cancellationToken)
 {
     this.controllerSetting        = new ControllerSetting(statefulService, cancellationToken);
     this.fabricBrsSecuritySetting = securitySetting;
 }
Ejemplo n.º 12
0
 public Handler(StatefulService service)
 {
     _service = service;
 }
Ejemplo n.º 13
0
 private RestoreStore(IReliableDictionary <string, RestoreStatus> reliableDictionary,
                      StatefulService statefulService)
     : base(reliableDictionary, statefulService, TraceRestoreStoreType)
 {
 }
Ejemplo n.º 14
0
        internal static async Task <BaseWorkItemQueue> GetNextWorkItemQueue(WorkItemQueueRunType workItemQueueRunType, StatefulService statefulService)
        {
            BackupRestoreTrace.TraceSource.WriteInfo("BackupRestore.GetNextWorkItemQueue", "workItemQueueRunType {0} ", workItemQueueRunType);
            BaseWorkItemQueue baseWorkItemQueue = null;

            switch (workItemQueueRunType)
            {
            case WorkItemQueueRunType.WorkItemQueue:
                baseWorkItemQueue = await WorkItemQueue1Min.CreateOrGetWorkItemQueue(statefulService);

                break;

            case WorkItemQueueRunType.WorkItemQueue1MinDelay:
                baseWorkItemQueue = await WorkItemQueue2Min.CreateOrGetWorkItemQueue(statefulService);

                break;

            case WorkItemQueueRunType.WorkItemQueue2MinDelay:
                baseWorkItemQueue = await WorkItemQueue4Min.CreateOrGetWorkItemQueue(statefulService);

                break;

            case WorkItemQueueRunType.WorkItemQueue4MinDelay:
                baseWorkItemQueue = await WorkItemQueue8Min.CreateOrGetWorkItemQueue(statefulService);

                break;

            case WorkItemQueueRunType.WorkItemQueue8MinDelay:
                baseWorkItemQueue = await WorkItemQueue8Min.CreateOrGetWorkItemQueue(statefulService);

                break;
            }
            BackupRestoreTrace.TraceSource.WriteInfo("BackupRestore.GetNextWorkItemQueue", "Next WorkItemQueue {0} ", baseWorkItemQueue.GetType());
            return(baseWorkItemQueue);
        }
 internal GetAllBackupPolicyOperation(string apiVersion, StatefulService statefulService, string continuationToken = null, int maxResults = 0) : base(apiVersion, statefulService)
 {
     this.maxResults        = maxResults;
     this.continuationToken = continuationToken;
 }
 public OwinCommunicationListener(StatefulService statefulService, ServiceContext serviceContext)
 {
     this.statefulService = statefulService;
     this.serviceContext  = serviceContext;
 }
 internal void ServiceMessage(StatefulService service, string v)
 {
     //throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 public SuspendBackupController(ControllerSetting controllerSetting)
 {
     this.statefulService = controllerSetting.StatefulService;
 }
Ejemplo n.º 19
0
 private ConfigStore(IReliableDictionary <string, string> reliableDictionary,
                     StatefulService statefulService)
     : base(reliableDictionary, statefulService, TraceConfigStoreType)
 {
 }
Ejemplo n.º 20
0
 private WorkItemQueue1Min(IReliableQueue <WorkItemProcessInfo> workItemReliableQueue, int maxWaitTimeInMinutes,
                           WorkItemQueueRunType workItemQueueRunType,
                           StatefulService statefulService)
     : base(workItemReliableQueue, maxWaitTimeInMinutes, workItemQueueRunType, TraceTypeConst, statefulService)
 {
 }
Ejemplo n.º 21
0
        internal BaseWorkItemQueue(IReliableQueue <WorkItemProcessInfo> workItemReliableQueue, int maxWaitTimeInMinutes,
                                   WorkItemQueueRunType workItemQueueRunType, string traceType, StatefulService statefulService)
        {
            BackupRestoreTrace.TraceSource.WriteInfo(traceType, "Constructing BaseWorkItemQueue with following parameters - workItemReliableQueue: {0}, maxWaitTimeInMinutes: {1}, workItemQueueRunType: {2}",
                                                     workItemReliableQueue.Name,
                                                     maxWaitTimeInMinutes,
                                                     workItemQueueRunType);

            this.WorkItemReliableQueue  = workItemReliableQueue;
            this.StatefulService        = statefulService;
            this.WorkItemStore          = WorkItemStore.CreateOrGetWorkItemStore(this.StatefulService).GetAwaiter().GetResult();
            this.WorkItemInProcessStore =
                WorkItemInProcessStore.CreateOrGetWorkItemInProcessStore(this.StatefulService).GetAwaiter().GetResult();
            this.MaxWaitTimeInMilliSeconds = maxWaitTimeInMinutes == 0 ? FastQueueWaitTime : maxWaitTimeInMinutes * 60 * 1000;
            this.AllowedTicks         = (this.MaxWaitTimeInMilliSeconds * TimeSpan.TicksPerMillisecond) / 20;
            this.workItemQueueRunType = workItemQueueRunType;
            this.TraceType            = traceType;
            this.emptyTraceType       = string.Format("{0}.{1}", traceType, "Empty");

            this.WorkItemHandlerTimer = new Timer(new TimerCallback(this.ProcessWorkItemHandler),
                                                  null,
                                                  this.MaxWaitTimeInMilliSeconds,
                                                  Timeout.Infinite);
        }
Ejemplo n.º 22
0
 internal OwinHttpServer(StatefulService statefulService, SecuritySetting fabricBrSecuritySetting, CancellationToken cancellationToken)
 {
     this.owinStartup = new Startup(statefulService, fabricBrSecuritySetting, cancellationToken);
 }
Ejemplo n.º 23
0
 public static IReceiverConnectionFactory WithServiceFabricIntegration(this EventHubClient client, StatefulService service) =>
 client.UseServiceFabricState(service).WithBatchCheckpointing();
 public BackupPartitionRequestOperation(string fabricRequestHeader, BackupStorageView backupStorage, int backupTimeoutinMinutes, string apiVersion, StatefulService statefulService) : base(apiVersion, statefulService)
 {
     this.fabricRequestHeader    = fabricRequestHeader;
     this.backupStorage          = backupStorage;
     this.backupTimeoutinMinutes = backupTimeoutinMinutes;
 }
Ejemplo n.º 25
0
 internal ServiceFabricEventHubsBuilder(ITestableEventHubClient client, StatefulService service)
 {
     Client  = client;
     Service = service;
 }
Ejemplo n.º 26
0
 private CleanupStore(IReliableDictionary <string, List <string> > reliableDictionary,
                      StatefulService statefulService)
     : base(reliableDictionary, statefulService, TraceRestoreStoreType)
 {
 }
Ejemplo n.º 27
0
 public static ServiceFabricEventHubsBuilder UseServiceFabricState(this EventHubClient client, StatefulService service) =>
 new ServiceFabricEventHubsBuilder(new TestableEventHubClient(client), service);
Ejemplo n.º 28
0
 private WorkItemStore(IReliableDictionary <Guid, WorkItem> reliableDictionary,
                       StatefulService statefulService)
     : base(reliableDictionary, statefulService, TraceWorkItemStoreType)
 {
 }
Ejemplo n.º 29
0
 internal static ServiceFabricEventHubsBuilder UseServiceFabricState(this ITestableEventHubClient client, StatefulService service) =>
 new ServiceFabricEventHubsBuilder(client, service);
Ejemplo n.º 30
0
        private async Task ProcessBackup(StatefulService statefulService, TimeSpan timeout, CancellationToken cancellationToken, string processQueueTypeTrace)
        {
            BackupRestoreTrace.TraceSource.WriteInfo(processQueueTypeTrace, "Processing the Backup for request Uri : {0} , PartitionId {1}", this.ServiceUri, this.PartitionId);
            var timeOutPersecCycle   = 30000;
            var backupPartitionStore = await BackupPartitionStore.CreateOrGetBackupPartitionStore(statefulService);

            var fabricUri = UtilityHelper.GetBackupMappingKey(this.ServiceUri, this.PartitionId);
            BackupPartitionStatus backupPartitionStatus;

            do
            {
                var backupNowConfiguration =
                    new BackupNowConfiguration()
                {
                    StoreInformation             = this.GetBackupStoreInformationFromBackupStorage(this.BackupStorage),
                    OperationTimeoutMilliseconds = (int)this.BackupTimeout.TotalMilliseconds
                };

                await UtilityHelper.InvokeWithRetry(async() =>
                {
                    await
                    Program.ServiceAgent.BackupPartitionAsync(new Uri(UtilityHelper.GetUriFromCustomUri(this.ServiceUri)),
                                                              Guid.Parse(this.PartitionId),
                                                              this.BackupRequestGuid, backupNowConfiguration, timeout, cancellationToken);
                });

                BackupRestoreTrace.TraceSource.WriteInfo(processQueueTypeTrace, "Requested the BackupPartitionAsync Successfully  for Service Uri :  {0} , PartitionId {1}", this.ServiceUri, this.PartitionId);
                await UtilityHelper.InvokeWithRetry(async() =>
                {
                    using (ITransaction transaction = statefulService.StateManager.CreateTransaction())
                    {
                        var currentBackupPartitionStatus = await backupPartitionStore.GetValueWithUpdateLockModeAsync(fabricUri, timeout, cancellationToken, transaction);
                        if (currentBackupPartitionStatus.BackupPartitionStatusState == BackupState.Accepted)
                        {
                            var toUpdateBackupPartitionStatus = currentBackupPartitionStatus.ToBuilder().WithState(BackupState.BackupInProgress).Build();
                            await backupPartitionStore.UpdateValueAsync(fabricUri, toUpdateBackupPartitionStatus,
                                                                        timeout,
                                                                        cancellationToken,
                                                                        transaction);
                            await transaction.CommitAsync();
                            BackupRestoreTrace.TraceSource.WriteInfo(processQueueTypeTrace, "Updated the Backup partition request to BackupInProcss for request Service Uri :  {0} , PartitionId {1}", this.ServiceUri, this.PartitionId);
                        }
                        else
                        {
                            transaction.Abort();
                            BackupRestoreTrace.TraceSource.WriteInfo(processQueueTypeTrace,
                                                                     "Could not Update the  BackupPartition request to BackupInProcess for request Service Uri :  {0} , PartitionId {1} because currentBackupPartitionStatus value is {2}",
                                                                     this.ServiceUri, this.PartitionId, currentBackupPartitionStatus);
                        }
                    }
                }
                                                    );

                await Task.Delay(timeOutPersecCycle, cancellationToken);

                backupPartitionStatus = await backupPartitionStore.GetValueAsync(fabricUri);

                BackupRestoreTrace.TraceSource.WriteInfo(processQueueTypeTrace, "BackupPartitionstatusState {0},isCancellationRequested {1} for Service Uri :  {2} , PartitionId {3}",
                                                         backupPartitionStatus.BackupPartitionStatusState, cancellationToken.IsCancellationRequested, this.ServiceUri, this.PartitionId);
            } while ((backupPartitionStatus.BackupPartitionStatusState == BackupState.Accepted ||
                      backupPartitionStatus.BackupPartitionStatusState == BackupState.BackupInProgress) &&
                     this.BackupRequestGuid.Equals(backupPartitionStatus.OperationId) &&
                     !cancellationToken.IsCancellationRequested);
            cancellationToken.ThrowIfCancellationRequested();
        }
Ejemplo n.º 31
0
 public void Initialize(StatefulService stateful)
 {
     base.Initialize(stateful, service);
     service.Initialize(this.Path, stateful);
 }
 public static IMessageConsumer CreateConsumer(this StatefulService service, ServicePartitionInformation partition, IBrokerServiceLocator serviceLocator)
 {
     return(service.Context.CreateConsumer(partition, serviceLocator));
 }
 /// <summary>
 /// Unregisters this StatefulService as a subscriber for messages of type <typeparam name="T"/> with the <see cref="BrokerService"/>.
 /// </summary>
 /// <param name="brokerClient"></param>
 /// <param name="service"></param>
 /// <returns></returns>
 public static Task UnsubscribeAsync <T>(this IBrokerClient brokerClient, StatefulService service) where T : class
 {
     return(brokerClient.UnsubscribeAsync(CreateReferenceWrapper(service), typeof(T)));
 }
Ejemplo n.º 34
0
 public ServiceReference CreateServiceReference(StatefulService service, string listenerName = null)
 {
     return(new ServiceReference());
 }
 internal static Task SubscribeAsync <T>(this IBrokerClient brokerClient, StatefulService service, Type messageType, Func <T, Task> handler, string listenerName = null, string routingKey = null, bool isOrdered = true) where T : class
 {
     return(brokerClient.SubscribeAsync(CreateReferenceWrapper(service, listenerName, routingKey), messageType, handler, isOrdered));
 }
			public Handler(StatefulService service)
			{
				_service = service;
			}
 internal static Task UnsubscribeAsync(this IBrokerClient brokerClient, StatefulService service, Type messageType)
 {
     return(brokerClient.UnsubscribeAsync(CreateReferenceWrapper(service), messageType));
 }
 /// <summary>
 /// Registers this StatefulService as a subscriber for messages of type <typeparam name="T"/> with the <see cref="BrokerService"/>.
 /// </summary>
 /// <param name="brokerClient"></param>
 /// <param name="service"></param>
 /// <param name="handler"></param>
 /// <param name="isOrdered"></param>
 /// <param name="listenerName"></param>
 /// <param name="routingKey">Optional routing key to filter messages based on content. 'Key=Value' where Key is a message property path and Value is the value to match with message payload content.</param>
 /// <returns></returns>
 public static Task SubscribeAsync <T>(this IBrokerClient brokerClient, StatefulService service, Func <T, Task> handler, bool isOrdered = true, string listenerName = null, string routingKey = null) where T : class
 {
     return(brokerClient.SubscribeAsync(CreateReferenceWrapper(service, listenerName, routingKey), typeof(T), handler, isOrdered));
 }
Ejemplo n.º 39
0
 /// <inheritdoc />
 public void Initialize(StatefulService statefulService)
 {
     this.statefulService = statefulService;
 }