Example #1
0
        public async Task <bool> Notify(Dictionary <DeltaOpType, List <long> > modelChanges)
        {
            logger.LogDebug($"{baseLogString } Notify method.");

            //while (!ReliableDictionariesInitialized)
            //{
            //    await Task.Delay(1000);
            //}

            //var tasks = new List<Task>();

            //foreach (var element in modelChanges)
            //{
            //    tasks.Add(ModelChanges.SetAsync((byte)element.Key, element.Value));
            //}

            //Task.WaitAll(tasks.ToArray());


            ITransactionEnlistmentContract transactionEnlistmentClient = TransactionEnlistmentClient.CreateClient();

            logger.LogDebug($"{baseLogString } Notify calling enlist.");
            bool success = await transactionEnlistmentClient.Enlist(DistributedTransactionNames.NetworkModelUpdateTransaction, MicroserviceNames.CeModelProviderService);

            if (success)
            {
                Logger.LogInformation($"{baseLogString} Notify => CE SUCCESSFULLY notified about network model update.");
            }
            else
            {
                Logger.LogInformation($"{baseLogString} Notify => CE UNSUCCESSFULLY notified about network model update.");
            }

            return(success);
        }
Example #2
0
        public async Task <bool> Notify(Dictionary <DeltaOpType, List <long> > modelChanges)
        {
            logger.LogDebug($"{baseLogString } Notify method.");

            ITransactionEnlistmentContract transactionEnlistmentClient = TransactionEnlistmentClient.CreateClient();

            logger.LogDebug($"{baseLogString } Notify calling enlist.");
            bool success = await transactionEnlistmentClient.Enlist(DistributedTransactionNames.NetworkModelUpdateTransaction, MicroserviceNames.CeModelProviderService);

            if (success)
            {
                Logger.LogInformation($"{baseLogString} Notify => CE SUCCESSFULLY notified about network model update.");
            }
            else
            {
                Logger.LogInformation($"{baseLogString} Notify => CE UNSUCCESSFULLY notified about network model update.");
            }

            return(success);
        }
Example #3
0
        public TransactionManagerService(StatefulServiceContext context)
            : base(context)
        {
            this.baseLogString = $"{this.GetType()} [{this.GetHashCode()}] =>{Environment.NewLine}";
            Logger.LogDebug($"{baseLogString} Ctor => Logger initialized");

            try
            {
                //DONE THIS WAY (in this order) BECAUSE: there is a mechanism that tracks the initialization process of reliable collections, which is set in constructors of these classes
                this.transactionCoordinatorProvider = new TransactionCoordinatorProvider(this.StateManager);
                this.transactionEnlistmentProvider  = new TransactionEnlistmentProvider(this.StateManager);

                string infoMessage = $"{baseLogString} Ctor => Contract providers initialized.";
                Logger.LogInformation(infoMessage);
                ServiceEventSource.Current.ServiceMessage(this.Context, $"[TransactionManagerService | Information] {infoMessage}");
            }
            catch (Exception e)
            {
                string errorMessage = $"{baseLogString} Ctor => Exception caught: {e.Message}.";
                Logger.LogError(errorMessage, e);
                ServiceEventSource.Current.ServiceMessage(this.Context, $"[TransactionManagerService | Error] {errorMessage}");
            }
        }