Example #1
0
        public Task <IMethodEntityWithPropagator> GetMethodEntityAsync(MethodDescriptor methodDescriptor)
        {
            //StatsHelper.RegisterMsg("SolutionGrain::GetMethodEntity:"+methodDescriptor, this.GrainFactory);
            StatsHelper.RegisterMsg("SolutionGrain::GetMethodEntity", this.GrainFactory);

            return(this.solutionManager.GetMethodEntityAsync(methodDescriptor));
        }
Example #2
0
        public async Task DispatchEffectsAsync(PropagationEffects effects)
        {
            await StatsHelper.RegisterMsg("EffectsDispatcherGrain::DispatchEffects", this.GrainFactory);

            Logger.LogInfoForDebug(this.GetLogger(), "@@[Dispatcher {0}] Dequeuing effects", this.GetPrimaryKey());

            this.lastProcessingTime   = DateTime.UtcNow;
            this.isDispatchingEffects = true;

            if (this.status != EffectsDispatcherStatus.Busy)
            {
                Logger.LogForRelease(this.GetLogger(), "@@[Dispatcher {0}] Becoming busy (before was {1})", this.GetPrimaryKey(), this.status);

                var oldStatus = this.status;
                this.status = EffectsDispatcherStatus.Busy;

                if (oldStatus == EffectsDispatcherStatus.Idle)
                {
                    // Notify that the dispatcher is busy
                    this.subscriptionManager.Notify(s => s.OnEffectsDispatcherStatusChanged(this, this.status));
                }
            }

            await this.effectsDispatcher.DispatchEffectsAsync(effects);

            this.lastProcessingTime   = DateTime.UtcNow;
            this.isDispatchingEffects = false;
        }
        public async Task <PropagationEffects> PropagateAsync(PropagationKind propKind)
        {
            await StatsHelper.RegisterMsg("MethodEntityGrain::Propagate", this.GrainFactory);

            //if (status.Equals(EntityGrainStatus.Busy))
            //{
            //	await Task.Delay(WAIT_TIME);
            //	if (status.Equals(EntityGrainStatus.Busy))
            //	{
            //		return new PropagationEffects();
            //	}
            //}

            Logger.LogVerbose(this.GetLogger(), "MethodEntityGrain", "Propagate", "Propagation for {0} ", this.methodEntity.MethodDescriptor);

            var sw = new Stopwatch();

            sw.Start();
            var propagationEffects = await this.methodEntityPropagator.PropagateAsync(propKind);

            sw.Stop();
            propagationEffects.SiloAddress = StatsHelper.GetMyIPAddr();

            Logger.LogInfo(this.GetLogger(), "MethodEntityGrain", "Propagate", "End Propagation for {0}. Time elapsed {1} Effects size: {2}", this.methodEntity.MethodDescriptor, sw.Elapsed, propagationEffects.CalleesInfo.Count);
            await StatsHelper.RegisterPropagationUpdates(propagationEffects.NumberOfUpdates, propagationEffects.WorkListInitialSize, this.GrainFactory);

            return(propagationEffects);
        }
        public async Task <IDictionary <AnalysisCallNode, ISet <MethodDescriptor> > > GetCalleesInfoAsync()
        {
            await StatsHelper.RegisterMsg("MethodEntityGrain::GetCalleesInfo", this.GrainFactory);

            var result = await this.methodEntityPropagator.GetCalleesInfoAsync();

            return(result);
        }
        public async Task <ISet <MethodDescriptor> > GetCalleesAsync()
        {
            await StatsHelper.RegisterMsg("MethodEntityGrain::GetCallees", this.GrainFactory);

            var result = await this.methodEntityPropagator.GetCalleesAsync();

            return(result);
        }
        public Task <MethodDescriptor> FindMethodImplementationAsync(MethodDescriptor methodDescriptor, TypeDescriptor typeDescriptor)
        {
            StatsHelper.RegisterMsg("ProjectGrain::FindMethodImplementation", this.GrainFactory);

            //var methodImplementationDescriptor = this.projectCodeProvider.FindMethodImplementation(methodDescriptor, typeDescriptor);
            //return Task.FromResult<MethodDescriptor>(methodImplementationDescriptor);
            return(this.projectCodeProvider.FindMethodImplementationAsync(methodDescriptor, typeDescriptor));
        }
        public async Task ReplaceDocumentSourceAsync(string source, string documentPath)
        {
            await StatsHelper.RegisterMsg("ProjectGrain::ReplaceDocumentSource", this.GrainFactory);

            this.State.Source = source;
            await this.WriteStateAsync();

            await this.projectCodeProvider.ReplaceDocumentSourceAsync(source, documentPath);
        }
        public async Task PropagateAndProcessAsync(ReturnMessageInfo returnMessageInfo)
        {
            await StatsHelper.RegisterMsg("MethodEntityGrain::PropagateAndProcess", this.GrainFactory);

            var effects = await this.methodEntityPropagator.PropagateAsync(returnMessageInfo);             //await this.PropagateAsync(returnMessageInfo);

            await StatsHelper.RegisterPropagationUpdates(effects.NumberOfUpdates, effects.WorkListInitialSize, this.GrainFactory);

            await ProcessEffectsAsync(effects);
        }
        public async Task PropagateAndProcessAsync(PropagationKind propKind, IEnumerable <PropGraphNodeDescriptor> reWorkSet)
        {
            await StatsHelper.RegisterMsg("MethodEntityGrain::PropagateAndProcess", this.GrainFactory);

            var effects = await this.methodEntityPropagator.PropagateAsync(propKind, reWorkSet);             // await this.PropagateAsync(propKind, reWorkSet);

            await StatsHelper.RegisterPropagationUpdates(effects.NumberOfUpdates, effects.WorkListInitialSize, this.GrainFactory);

            await ProcessEffectsAsync(effects);
        }
        public async Task RelocateAsync(string projectPath)
        {
            await StatsHelper.RegisterMsg("ProjectGrain::Relocate", this.GrainFactory);

            this.State.ProjectPath = projectPath;

            await this.WriteStateAsync();

            await this.projectCodeProvider.RelocateAsync(projectPath);
        }
        public Task <bool> IsSubtypeAsync(TypeDescriptor typeDescriptor1, TypeDescriptor typeDescriptor2)
        {
            StatsHelper.RegisterMsg("ProjectGrain::IsSubtype", this.GrainFactory);

            //if (GrainClient.IsInitialized)
            //{
            //	Logger.LogWarning(GrainClient.Logger, "ProjectGrain", "IsSubtypeAsync", "type1={0}, type2={1}", typeDescriptor1, typeDescriptor2);
            //}

            //Console.WriteLine("ProjectGrain::IsSubtypeAsync type1={0}, type2={1}", typeDescriptor1, typeDescriptor2);

            return(this.projectCodeProvider.IsSubtypeAsync(typeDescriptor1, typeDescriptor2));
        }
Example #12
0
        //public Task AddInstantiatedTypesAsync(IEnumerable<TypeDescriptor> types)
        //{
        //	StatsHelper.RegisterMsg("SolutionGrain::AddInstantiatedTypes", this.GrainFactory);

        //	return solutionManager.AddInstantiatedTypesAsync(types);
        //}

        //public Task<ISet<TypeDescriptor>> GetInstantiatedTypesAsync()
        //{
        //	StatsHelper.RegisterMsg("SolutionGrain::GetInstantiatedTypes", this.GrainFactory);

        //	return this.solutionManager.GetInstantiatedTypesAsync();
        //}

        public async Task <IEnumerable <MethodDescriptor> > GetRootsAsync(AnalysisRootKind rootKind = AnalysisRootKind.Default)
        {
            await StatsHelper.RegisterMsg("SolutionGrain::GetRoots", this.GrainFactory);

            Logger.LogVerbose(this.GetLogger(), "SolutionGrain", "GetRoots", "Enter");

            var sw = new Stopwatch();

            sw.Start();
            var roots = await this.solutionManager.GetRootsAsync(rootKind);

            Logger.LogInfo(this.GetLogger(), "SolutionGrain", "GetRoots", "End Time elapsed {0}", sw.Elapsed);

            return(roots);
        }
        public Task <PropagationEffects> PropagateAsync(PropagationKind propKind, IEnumerable <PropGraphNodeDescriptor> reWorkSet)
        {
            StatsHelper.RegisterMsg("MethodEntityGrain::PropagateWithRework", this.GrainFactory);

            //if (status.Equals(EntityGrainStatus.Busy))
            //{
            //	await Task.Delay(WAIT_TIME);
            //	if (status.Equals(EntityGrainStatus.Busy))
            //	{
            //		return new PropagationEffects();
            //	}
            //}

            return(this.methodEntityPropagator.PropagateAsync(propKind, reWorkSet));
        }
        public Task <IEntity> CreateMethodEntityAsync(MethodDescriptor methodDescriptor)
        {
            StatsHelper.RegisterMsg("ProjectGrain::CreateMethodEntity", this.GrainFactory);

            Logger.LogVerbose(this.GetLogger(), "ProjectGrain", "CreateMethodEntity", "Enter");

            var timer = new Stopwatch();

            timer.Start();

            var result = this.projectCodeProvider.CreateMethodEntityAsync(methodDescriptor);

            timer.Stop();
            Logger.LogInfo(this.GetLogger(), "ProjectGrain", "CreateMethodEntity:" + methodDescriptor, "Exit; took;{0};ms;{1};ticks", timer.ElapsedMilliseconds, timer.ElapsedTicks);
            return(result);
        }
        public async Task <IMethodEntityWithPropagator> GetMethodEntityAsync(MethodDescriptor methodDescriptor)
        {
            //await StatsHelper.RegisterMsg("ProjectGrain::GetMethodEntity"+":"+methodDescriptor, this.GrainFactory);
            await StatsHelper.RegisterMsg("ProjectGrain::GetMethodEntity", this.GrainFactory);


            var methodEntity = await this.projectCodeProvider.GetMethodEntityAsync(methodDescriptor);

            // Force Activation
            //var isReachable = await this.projectCodeProvider.IsReachableAsync(methodDescriptor);

            //if (!isReachable)
            //{
            //	await methodEntity.IsInitializedAsync();
            //}

            return(methodEntity);
        }
        public async Task <PropagationEffects> PropagateAsync(ReturnMessageInfo returnMessageInfo)
        {
            await StatsHelper.RegisterMsg("MethodEntityGrain::PropagateReturn", this.GrainFactory);

            //if (status.Equals(EntityGrainStatus.Busy))
            //{
            //	await Task.Delay(WAIT_TIME);
            //	if (status.Equals(EntityGrainStatus.Busy))
            //	{
            //		return new PropagationEffects();
            //	}
            //}

            var propagationEffects = await this.methodEntityPropagator.PropagateAsync(returnMessageInfo);

            propagationEffects.SiloAddress = StatsHelper.GetMyIPAddr();
            await StatsHelper.RegisterPropagationUpdates(propagationEffects.NumberOfUpdates, propagationEffects.WorkListInitialSize, this.GrainFactory);

            return(propagationEffects);
        }
        public async Task SetProjectPathAsync(string fullPath)
        {
            //await StatsHelper.RegisterMsg("ProjectGrain::SetProjectPath", this.GrainFactory);
            await StatsHelper.RegisterMsg("ProjectGrain::SetProjectPath:" + fullPath, this.GrainFactory);

            Logger.LogInfo(this.GetLogger(), "ProjectGrain", "SetProjectPath", "Enter:" + fullPath);

            this.State.ProjectPath  = fullPath;
            this.State.AssemblyName = null;
            this.State.Source       = null;
            this.State.TestName     = null;

            await this.WriteStateAsync();

            //Task.Run(async () =>
            //await Task.Factory.StartNew(async () =>
            //{
            try
            {
                this.RaiseStateChangedEvent(EntityGrainStatus.Busy);

                this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromProjectAsync(this.GrainFactory, this.State.ProjectPath);

                this.RaiseStateChangedEvent(EntityGrainStatus.Ready);
            }
            catch (Exception ex)
            {
                var inner = ex;
                while (inner is AggregateException)
                {
                    inner = inner.InnerException;
                }

                Logger.LogError(this.GetLogger(), "ProjectGrain", "SetProjectPath", "Error:\n{0}\nInner:\n{1}", ex, inner);
                throw ex;
            }
            //});

            Logger.LogInfo(this.GetLogger(), "ProjectGrain", "SetProjectPath", "Exit");
        }
Example #18
0
        public async Task SetSolutionFromTestAsync(string testName)
        {
            await StatsHelper.RegisterMsg("SolutionGrain::SetSolutionFromTest", this.GrainFactory);

            Logger.LogVerbose(this.GetLogger(), "SolutionGrain", "SetSolutionFromTest", "Enter");

            this.State.TestName     = testName;
            this.State.SolutionPath = null;
            this.State.Source       = null;

            await this.WriteStateAsync();

            this.projectsReadyCount = 0;

            //Task.Run(async () =>
            //await Task.Factory.StartNew(async () =>
            //{
            try
            {
                this.solutionManager = await OrleansSolutionManager.CreateFromTestAsync(this, this.GrainFactory, this.State.TestName);

                //await this.WaitForAllProjects();
            }
            catch (Exception ex)
            {
                var inner = ex;
                while (inner is AggregateException)
                {
                    inner = inner.InnerException;
                }

                Logger.LogError(this.GetLogger(), "SolutionGrain", "SetSolutionFromTest", "Error:\n{0}\nInner:\n{1}", ex, inner);
                throw ex;
            }
            //});

            Logger.LogVerbose(this.GetLogger(), "SolutionGrain", "SetSolutionFromTest", "Exit");
        }
Example #19
0
        public Task ReloadAsync()
        {
            StatsHelper.RegisterMsg("SolutionGrain::Reload", this.GrainFactory);

            return(this.solutionManager.ReloadAsync());
        }
Example #20
0
        public Task <IEnumerable <MethodModification> > GetModificationsAsync(IEnumerable <string> modifiedDocuments)
        {
            StatsHelper.RegisterMsg("SolutionGrain::GetModifications", this.GrainFactory);

            return(this.solutionManager.GetModificationsAsync(modifiedDocuments));
        }
Example #21
0
        public Task <IEnumerable <IProjectCodeProvider> > GetProjectCodeProvidersAsync()
        {
            StatsHelper.RegisterMsg("SolutionGrain::GetProjectCodeProviders", this.GrainFactory);

            return(this.solutionManager.GetProjectCodeProvidersAsync());
        }
Example #22
0
        public Task <IEnumerable <MethodDescriptor> > GetReachableMethodsAsync()
        {
            StatsHelper.RegisterMsg("SolutionGrain::GetReachableMethodsAsync", this.GrainFactory);

            return(this.solutionManager.GetReachableMethodsAsync());
        }
Example #23
0
        public Task AddInstantiatedTypesAsync(IEnumerable <TypeDescriptor> types)
        {
            StatsHelper.RegisterMsg("RtaGrain::AddInstantiatedTypes", this.GrainFactory);

            return(this.rtaManager.AddInstantiatedTypesAsync(types));
        }
Example #24
0
        public Task <IProjectCodeProvider> GetProjectCodeProviderAsync(MethodDescriptor methodDescriptor)
        {
            StatsHelper.RegisterMsg("SolutionGrain::GetProjectCodeProvider", this.GrainFactory);

            return(this.solutionManager.GetProjectCodeProviderAsync(methodDescriptor));
        }
Example #25
0
        public Task <IProjectCodeProvider> GetProjectCodeProviderAsync(string assemblyName)
        {
            StatsHelper.RegisterMsg("SolutionGrain::GetProjectCodeProvider", this.GrainFactory);

            return(this.solutionManager.GetProjectCodeProviderAsync(assemblyName));
        }
Example #26
0
        public Task <ISet <TypeDescriptor> > GetInstantiatedTypesAsync()
        {
            StatsHelper.RegisterMsg("SolutionGrain::GetInstantiatedTypes", this.GrainFactory);

            return(this.rtaManager.GetInstantiatedTypesAsync());
        }
Example #27
0
        public Task <int> GetReachableMethodsCountAsync()
        {
            StatsHelper.RegisterMsg("SolutionGrain::GetReachableMethodsCount", this.GrainFactory);

            return(this.solutionManager.GetReachableMethodsCountAsync());
        }
        public Task UseDeclaredTypesForParameters()
        {
            StatsHelper.RegisterMsg("MethodEntityGrain::UseDeclaredTypesForParameters", this.GrainFactory);

            return(this.methodEntityPropagator.UseDeclaredTypesForParameters());
        }
Example #29
0
        public async Task ProcessMethodAsync(MethodDescriptor method)
        {
            await StatsHelper.RegisterMsg("EffectsDispatcherGrain::ProcessMethod", this.GrainFactory);

            await this.effectsDispatcher.ProcessMethodAsync(method);
        }
        public Task <MethodCalleesInfo> FixUnknownCalleesAsync()
        {
            StatsHelper.RegisterMsg("MethodEntityGrain::FixUnknownCalleesAsync", this.GrainFactory);

            return(this.methodEntityPropagator.FixUnknownCalleesAsync());
        }