Esempio n. 1
0
        public async Task InitializeOnDemandOrleansAnalysis()
        {
            SolutionAnalyzer.MessageCounter = 0;
            //GrainClient.ClientInvokeCallback = OnClientInvokeCallBack;

            // For orleans we cannot use the strategy to create a solution
            // The solution grain creates an internal strategy and contain an internal
            // solution manager. We obtain the solution grain that handles everything
            var solutionGrain = OrleansSolutionManager.GetSolutionGrain(GrainClient);

            this.SolutionManager = solutionGrain;

            if (this.source != null)
            {
                await solutionGrain.SetSolutionSourceAsync(this.source);
            }
            else if (this.testName != null)
            {
                await solutionGrain.SetSolutionFromTestAsync(this.testName);
            }
            else if (this.solutionPath != null)
            {
                await solutionGrain.SetSolutionPathAsync(this.solutionPath);

                Logger.LogWarning(GrainClient.Logger, "SolutionAnalyzer", "InitializeOnDemandOrleansAsync", "Exit SetSolutionPath");
            }
            else
            {
                throw new Exception("We need a solutionPath, source code or testName to analyze");
            }
        }
        public static async Task <OrleansProjectCodeProvider> CreateFromTestAsync(IGrainFactory grainFactory, string testName, string assemblyName)
        {
            var solutionGrain = OrleansSolutionManager.GetSolutionGrain(grainFactory);
            var rtaGain       = OrleansRtaManager.GetRtaGrain(grainFactory);
            var provider      = new OrleansProjectCodeProvider(grainFactory, solutionGrain, rtaGain);
            await provider.LoadTestAsync(testName, assemblyName);

            return(provider);
        }
        public static async Task <OrleansProjectCodeProvider> CreateFromProjectAsync(IGrainFactory grainFactory, string projectPath)
        {
            var solutionGrain = OrleansSolutionManager.GetSolutionGrain(grainFactory);
            var rtaGain       = OrleansRtaManager.GetRtaGrain(grainFactory);
            var provider      = new OrleansProjectCodeProvider(grainFactory, solutionGrain, rtaGain);
            await provider.LoadProjectAsync(projectPath);

            return(provider);
        }
Esempio n. 4
0
        public override async Task OnActivateAsync()
        {
            await StatsHelper.RegisterActivation("EffectsDispatcherGrain", this.GrainFactory);

            this.isDispatchingEffects = false;
            this.status             = EffectsDispatcherStatus.Inactive;
            this.lastProcessingTime = DateTime.UtcNow;             // DateTime.MinValue; // DateTime.MaxValue;
            this.solutionGrain      = OrleansSolutionManager.GetSolutionGrain(this.GrainFactory);
            this.effectsDispatcher  = new OrleansEffectsDispatcherManager(this.GrainFactory, this.solutionGrain);

            this.subscriptionManager = new ObserverSubscriptionManager <IAnalysisObserver>();

            var streamProvider = this.GetStreamProvider(AnalysisConstants.StreamProvider);
            var stream         = streamProvider.GetStream <PropagationEffects>(this.GetPrimaryKey(), AnalysisConstants.StreamNamespace);
            //await stream.SubscribeAsync(this);

            // Explicit subscription code
            var subscriptionHandles = await stream.GetAllSubscriptionHandles();

            if (subscriptionHandles != null && subscriptionHandles.Count > 0)
            {
                var tasks = new List <Task>();

                foreach (var subscriptionHandle in subscriptionHandles)
                {
                    var task = subscriptionHandle.ResumeAsync(this);
                    //await task;
                    tasks.Add(task);
                }

                await Task.WhenAll(tasks);
            }
            else
            {
                await stream.SubscribeAsync(this);
            }

            var period = TimeSpan.FromMilliseconds(AnalysisConstants.DispatcherTimerPeriod);

            this.timer = this.RegisterTimer(this.OnTimerTick, null, period, period);

            await base.OnActivateAsync();
        }
        private async Task CreateMethodEntityAsync(MethodDescriptor methodDescriptor)
        {
            // This is a private method. We must not register this as a grain callee
            // await StatsHelper.RegisterMsg("MethodEntityGrain::CreateMethodEntity", this.GrainFactory);

            this.solutionGrain = OrleansSolutionManager.GetSolutionGrain(this.GrainFactory);

            this.State.MethodDescriptor = methodDescriptor;
            var methodDescriptorToSearch = methodDescriptor.BaseDescriptor;

            var codeProviderGrain = await solutionGrain.GetProjectCodeProviderAsync(methodDescriptorToSearch);

            // This wrapper caches some of the queries to codeProvider
            //this.codeProvider = new ProjectCodeProviderWithCache(codeProviderGrain);
            this.codeProvider = codeProviderGrain;

            //Logger.LogWarning(this.GetLogger(), "MethodEntityGrain", "CreateMethodEntity", "{0} calls to proivder {1}", methodDescriptor, this.codeProvider);
            var sw = new Stopwatch();

            sw.Start();

            this.methodEntity = (MethodEntity)await codeProvider.CreateMethodEntityAsync(methodDescriptorToSearch);

            sw.Stop();

            Logger.LogInfo(this.GetLogger(), "MethodEntityGrain", "CreateMethodEntity", "{0};call to provider;{1};ms;{2};ticks", methodDescriptor, sw.ElapsedMilliseconds, sw.ElapsedTicks);

            if (methodDescriptor.IsAnonymousDescriptor)
            {
                this.methodEntity = this.methodEntity.GetAnonymousMethodEntity((AnonymousMethodDescriptor)methodDescriptor);
            }

            //// this is for RTA analysis
            //await solutionGrain.AddInstantiatedTypesAsync(this.methodEntity.InstantiatedTypes);

            // This take cares of doing the progation of types
            this.methodEntityPropagator = new MethodEntityWithPropagator(methodEntity, codeProvider);

            await this.WriteStateAsync();

            //Logger.LogWarning(this.GetLogger(), "MethodEntityGrain", "CreateMethodEntity", "Exit {0}", methodDescriptor);
        }