//private ProjectState State; //private Task WriteStateAsync() //{ // return TaskDone.Done; //} //private Task ClearStateAsync() //{ // return TaskDone.Done; //} public override async Task OnActivateAsync() { //this.State = new ProjectState(); await StatsHelper.RegisterActivation("ProjectCodeProviderGrain", this.GrainFactory); Logger.OrleansLogger = this.GetLogger(); Logger.LogInfo(this.GetLogger(), "ProjectGrain", "OnActivate", "Enter"); // Logger.LogWarning(this.GetLogger(), "ProjectGrain", "OnActivate", "Entering Project: {0}", this.GetPrimaryKeyString()); this.observers = new ObserverSubscriptionManager <IEntityGrainObserverNotifications>(); this.State.AssemblyName = this.GetPrimaryKeyString(); //Task.Run(async () => //await Task.Factory.StartNew(async () => //{ try { this.RaiseStateChangedEvent(EntityGrainStatus.Busy); if (!string.IsNullOrEmpty(this.State.ProjectPath)) { this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromProjectAsync(this.GrainFactory, this.State.ProjectPath); } else if (!string.IsNullOrEmpty(this.State.Source) && !String.IsNullOrEmpty(this.State.AssemblyName)) { this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromSourceAsync(this.GrainFactory, this.State.Source, this.State.AssemblyName); } else if (!string.IsNullOrEmpty(this.State.TestName) && !String.IsNullOrEmpty(this.State.AssemblyName)) { this.projectCodeProvider = await OrleansProjectCodeProvider.CreateFromTestAsync(this.GrainFactory, this.State.TestName, this.State.AssemblyName); } else if (this.State.AssemblyName.Equals("DUMMY")) { this.projectCodeProvider = new OrleansDummyProjectCodeProvider(this.GrainFactory); await this.WriteStateAsync(); } this.RaiseStateChangedEvent(EntityGrainStatus.Ready); } catch (Exception ex) { var inner = ex; while (inner is AggregateException) { inner = inner.InnerException; } Logger.LogError(this.GetLogger(), "ProjectGrain", "OnActivate", "Error:\n{0}\nInner:\n{1}", ex, inner); throw ex; } //}); Logger.LogInfo(this.GetLogger(), "ProjectGrain", "OnActivate", "Exit"); }
//private SolutionState State; //private Task WriteStateAsync() //{ // return TaskDone.Done; //} //private Task ClearStateAsync() //{ // return TaskDone.Done; //} public override async Task OnActivateAsync() { //this.State = new SolutionState(); await StatsHelper.RegisterActivation("SolutionGrain", this.GrainFactory); Logger.OrleansLogger = this.GetLogger(); Logger.LogInfo(this.GetLogger(), "SolutionGrain", "OnActivate", "Enter"); this.projectsReadyCount = 0; //Task.Run(async () => //await Task.Factory.StartNew(async () => //{ try { if (!string.IsNullOrEmpty(this.State.SolutionPath)) { this.solutionManager = await OrleansSolutionManager.CreateFromSolutionAsync(this, this.GrainFactory, this.State.SolutionPath); } else if (!string.IsNullOrEmpty(this.State.Source)) { this.solutionManager = await OrleansSolutionManager.CreateFromSourceAsync(this, this.GrainFactory, this.State.Source); } else if (!string.IsNullOrEmpty(this.State.TestName)) { this.solutionManager = await OrleansSolutionManager.CreateFromTestAsync(this, this.GrainFactory, this.State.TestName); } //if (this.solutionManager != null) //{ // await this.WaitForAllProjects(); //} } catch (Exception ex) { var inner = ex; while (inner is AggregateException) { inner = inner.InnerException; } Logger.LogError(this.GetLogger(), "SolutionGrain", "OnActivate", "Error:\n{0}\nInner:\n{1}", ex, inner); throw ex; } //}); Logger.LogInfo(this.GetLogger(), "SolutionGrain", "OnActivate", "Exit"); }
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(); }
public override async Task OnActivateAsync() { this.State = new MethodState(); this.currentStreamIndex = this.GetHashCode() % AnalysisConstants.StreamCount; await StatsHelper.RegisterActivation("MethodEntityGrain", this.GrainFactory); Logger.OrleansLogger = this.GetLogger(); Logger.LogVerbose(this.GetLogger(), "MethodEntityGrain", "OnActivate", "Activation for {0} ", this.GetPrimaryKeyString()); var methodDescriptor = MethodDescriptor.DeMarsall(this.GetPrimaryKeyString()); //if (this.State.MethodDescriptor != null && !this.State.MethodDescriptor.Name.Equals(".")) //{ // methodDescriptor = this.State.MethodDescriptor; //} //Task.Run(async () => //await Task.Factory.StartNew(async () => //{ try { //this.status = EntityGrainStatus.Busy; await this.CreateMethodEntityAsync(methodDescriptor); //this.status = EntityGrainStatus.Ready; } catch (Exception ex) { var inner = ex; while (inner is AggregateException) { inner = inner.InnerException; } Logger.LogError(this.GetLogger(), "MethodEntityGrain", "OnActivate", "Error:\n{0}\nInner:\n{1}", ex, inner); throw ex; } //}); }
public override async Task OnActivateAsync() { await StatsHelper.RegisterActivation("RTAGrain", this.GrainFactory); this.rtaManager = new OrleansRtaManager(); }