public async Task <ActionResult> CreateAccountForInstructor(InstructorAccountViewModel viewModel) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = viewModel.EmailAdress, Email = viewModel.EmailAdress }; var result = await UserManager.CreateAsync(user); if (result.Succeeded) { var identityResult = UserManager.AddToRole(user.Id, RoleName.IsAnInstructor); if (identityResult.Succeeded) { using (var schedulingContext = new SchedulingContext()) { var instructorInDb = schedulingContext.Instructors.SingleOrDefault(i => i.Id == viewModel.InstructorId); if (instructorInDb != null) { instructorInDb.AccountId = user.Id; schedulingContext.SaveChanges(); } } } } if (!result.Succeeded) { viewModel = new InstructorAccountViewModel { ErrorMessages = result.Errors }; return(View("CreateAccountForInstructor", viewModel)); } } return(RedirectToAction("CreateAccountForInstructor")); }
/// <summary> /// Handle an incoming message and queue/invoke appropriate handler /// </summary> /// <param name="message"></param> /// <param name="targetActivation"></param> public void HandleIncomingRequest(Message message, ActivationData targetActivation) { lock (targetActivation) { if (targetActivation.State == ActivationState.Invalid) { ProcessRequestToInvalidActivation(message, targetActivation.Address, targetActivation.ForwardingAddress, "HandleIncomingRequest"); return; } // Now we can actually scheduler processing of this request targetActivation.RecordRunning(message); var context = new SchedulingContext(targetActivation); if (Message.WriteMessagingTraces) { message.AddTimestamp(Message.LifecycleTag.EnqueueWorkItem); } MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedOk(message); Scheduler.QueueWorkItem(new InvokeWorkItem(targetActivation, message, context), context); } }
public async Task <ActionResult> CreateAccount(CreateLabAssistantAccountViewModel model) { var user = new ApplicationUser { UserName = model.EmailAddress, Email = model.EmailAddress }; var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())); var result = await userManager.CreateAsync(user); if (result.Succeeded) { var identityResult = userManager.AddToRole(user.Id, RoleName.IsALabAssistant); if (identityResult.Succeeded) { using (var schedulingContext = new SchedulingContext()) { var labAssistantInDb = schedulingContext.LabAssistances.SingleOrDefault(i => i.Id == model.LabAssistantId); if (labAssistantInDb != null) { labAssistantInDb.AccountId = user.Id; schedulingContext.SaveChanges(); } } } } if (!result.Succeeded) { model.Errors = result.Errors; return(View("CreateAccount", model)); } return(RedirectToAction("Index")); }
private async Task OnActiveStart(CancellationToken ct) { var stopWatch = Stopwatch.StartNew(); if (this.reminderService != null) { await StartAsyncTaskWithPerfAnalysis("Start reminder service", StartReminderService, stopWatch); async Task StartReminderService() { // so, we have the view of the membership in the consistentRingProvider. We can start the reminder service this.reminderServiceContext = (this.reminderService as SystemTarget)?.SchedulingContext ?? this.fallbackScheduler.SchedulingContext; await this.scheduler.QueueTask(this.reminderService.Start, this.reminderServiceContext) .WithTimeout(this.initTimeout, $"Starting ReminderService failed due to timeout {initTimeout}"); this.logger.Debug("Reminder service started successfully."); } } foreach (var grainService in grainServices) { await StartGrainService(grainService); } }
/// <summary> /// Construct a <see cref="RemoteScheduler" /> instance to proxy the given /// RemoteableQuartzScheduler instance, and with the given /// <see cref="SchedulingContext" />. /// </summary> public RemoteScheduler(SchedulingContext schedCtxt, string schedId) { this.schedCtxt = schedCtxt; this.schedId = schedId; }
public AcademicCalendarsController() { _context = new SchedulingContext(); }
public void SendRequest( GrainReference target, InvokeMethodRequest request, TaskCompletionSource <object> context, string debugContext, InvokeMethodOptions options, string genericArguments = null) { var message = this.messageFactory.CreateMessage(request, options); // fill in sender if (message.SendingSilo == null) { message.SendingSilo = MySilo; } if (!String.IsNullOrEmpty(genericArguments)) { message.GenericGrainType = genericArguments; } SchedulingContext schedulingContext = RuntimeContext.CurrentActivationContext as SchedulingContext; ActivationData sendingActivation = null; if (schedulingContext == null) { var clientAddress = this.HostedClient.ClientAddress; message.SendingGrain = clientAddress.Grain; message.SendingActivation = clientAddress.Activation; } else { switch (schedulingContext.ContextType) { case SchedulingContextType.SystemThread: throw new ArgumentException( String.Format( "Trying to send a message {0} on a silo not from within grain and not from within system target (RuntimeContext is of SchedulingContextType.SystemThread type)", message), "context"); case SchedulingContextType.Activation: message.SendingActivation = schedulingContext.Activation.ActivationId; message.SendingGrain = schedulingContext.Activation.Grain; sendingActivation = schedulingContext.Activation; break; case SchedulingContextType.SystemTarget: message.SendingActivation = schedulingContext.SystemTarget.ActivationId; message.SendingGrain = ((ISystemTargetBase)schedulingContext.SystemTarget).GrainId; break; } } // fill in destination var targetGrainId = target.GrainId; message.TargetGrain = targetGrainId; SharedCallbackData sharedData; if (targetGrainId.IsSystemTarget) { SiloAddress targetSilo = (target.SystemTargetSilo ?? MySilo); message.TargetSilo = targetSilo; message.TargetActivation = ActivationId.GetSystemActivation(targetGrainId, targetSilo); message.Category = targetGrainId.Equals(Constants.MembershipOracleId) ? Message.Categories.Ping : Message.Categories.System; sharedData = this.systemSharedCallbackData; } else { sharedData = this.sharedCallbackData; } if (target.IsObserverReference) { message.TargetObserverId = target.ObserverId; } if (debugContext != null) { message.DebugContext = debugContext; } var oneWay = (options & InvokeMethodOptions.OneWay) != 0; if (context is null && !oneWay) { this.logger.Warn(ErrorCode.IGC_SendRequest_NullContext, "Null context {0}: {1}", message, Utils.GetStackTrace()); } if (message.IsExpirableMessage(this.messagingOptions.DropExpiredMessages)) { message.TimeToLive = sharedData.ResponseTimeout; } if (!oneWay) { var callbackData = new CallbackData(sharedData, context, message); callbacks.TryAdd(message.Id, callbackData); } this.messagingTrace.OnSendRequest(message); if (targetGrainId.IsSystemTarget) { // Messages to system targets bypass the task system and get sent "in-line" this.Dispatcher.TransportMessage(message); } else { this.Dispatcher.SendMessage(message, sendingActivation); } }
public AppointmentRepository(SchedulingContext context) { this._context = context; }
public NewSection() { InitializeComponent(); _context = new SchedulingContext(); }
/// <summary> /// Initialize the factory, providing a handle to the <see cref="IScheduler" /> /// that should be made available within the <see cref="JobRunShell" /> and /// the <see cref="JobExecutionContext" /> s within it, and a handle to the /// <see cref="SchedulingContext" /> that the shell will use in its own /// operations with the <see cref="IJobStore" />. /// </summary> public virtual void Initialize(IScheduler sched, SchedulingContext ctx) { scheduler = sched; schedCtxt = ctx; }
public ScheduleRepository(SchedulingContext context) { this._context = context; }
public AccountController() { _context = new SchedulingContext(); }
public CourseOfferingsController() { _context = new SchedulingContext(); }
public virtual async Task <T> GetById(int id) { using SchedulingContext _context = _contextFactory.CreateDbContext(); return(await _context.Set <T>().FindAsync(id)); }
public virtual async Task <List <T> > GetAll() { using SchedulingContext _context = _contextFactory.CreateDbContext(); return(await _context.Set <T>().ToListAsync()); }
public AppointmentRepository(SchedulingContext context) { this._context = context; }
private async Task OnRuntimeGrainServicesStart(CancellationToken ct) { var stopWatch = Stopwatch.StartNew(); // Load and init grain services before silo becomes active. await StartAsyncTaskWithPerfAnalysis("Init grain services", () => CreateGrainServices(), stopWatch); this.membershipOracleContext = (this.membershipOracle as SystemTarget)?.SchedulingContext ?? this.fallbackScheduler.SchedulingContext; await StartAsyncTaskWithPerfAnalysis("Starting local silo status oracle", StartMembershipOracle, stopWatch); async Task StartMembershipOracle() { await scheduler.QueueTask(() => this.membershipOracle.Start(), this.membershipOracleContext) .WithTimeout(initTimeout, $"Starting MembershipOracle failed due to timeout {initTimeout}"); logger.Debug("Local silo status oracle created successfully."); } var versionStore = Services.GetService <IVersionStore>(); await StartAsyncTaskWithPerfAnalysis("Init type manager", () => scheduler .QueueTask(() => this.typeManager.Initialize(versionStore), this.typeManager.SchedulingContext) .WithTimeout(this.initTimeout, $"TypeManager Initializing failed due to timeout {initTimeout}"), stopWatch); //if running in multi cluster scenario, start the MultiClusterNetwork Oracle if (this.multiClusterOracle != null) { await StartAsyncTaskWithPerfAnalysis("Start multicluster oracle", StartMultiClusterOracle, stopWatch); async Task StartMultiClusterOracle() { logger.Info("Starting multicluster oracle with my ServiceId={0} and ClusterId={1}.", this.clusterOptions.ServiceId, this.clusterOptions.ClusterId); this.multiClusterOracleContext = (multiClusterOracle as SystemTarget)?.SchedulingContext ?? this.fallbackScheduler.SchedulingContext; await scheduler.QueueTask(() => multiClusterOracle.Start(), multiClusterOracleContext) .WithTimeout(initTimeout, $"Starting MultiClusterOracle failed due to timeout {initTimeout}"); logger.Debug("multicluster oracle created successfully."); } } try { StatisticsOptions statisticsOptions = Services.GetRequiredService <IOptions <StatisticsOptions> >().Value; StartTaskWithPerfAnalysis("Start silo statistics", () => this.siloStatistics.Start(statisticsOptions), stopWatch); logger.Debug("Silo statistics manager started successfully."); // Finally, initialize the deployment load collector, for grains with load-based placement await StartAsyncTaskWithPerfAnalysis("Start deployment load collector", StartDeploymentLoadCollector, stopWatch); async Task StartDeploymentLoadCollector() { var deploymentLoadPublisher = Services.GetRequiredService <DeploymentLoadPublisher>(); await this.scheduler.QueueTask(deploymentLoadPublisher.Start, deploymentLoadPublisher.SchedulingContext) .WithTimeout(this.initTimeout, $"Starting DeploymentLoadPublisher failed due to timeout {initTimeout}"); logger.Debug("Silo deployment load publisher started successfully."); } // Start background timer tick to watch for platform execution stalls, such as when GC kicks in this.platformWatchdog = new Watchdog(statisticsOptions.LogWriteInterval, this.healthCheckParticipants, this.executorService, this.loggerFactory); this.platformWatchdog.Start(); if (this.logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Silo platform watchdog started successfully."); } } catch (Exception exc) { this.SafeExecute(() => this.logger.Error(ErrorCode.Runtime_Error_100330, String.Format("Error starting silo {0}. Going to FastKill().", this.SiloAddress), exc)); throw; } if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Silo.Start complete: System status = {0}", this.SystemStatus); } }
public DoctorsController(SchedulingContext db) { this.db = db; }
public SchedulingViewModel() { context = new SchedulingContext(); context.Appointments.Load(); context.Resources.Load(); }
public override async Task <List <City> > GetAll() { using SchedulingContext _context = _contextFactory.CreateDbContext(); return(await _context.Cities.Include(pr => pr.Country).ToListAsync()); }
private void ReceiveMessage(Message msg) { MessagingProcessingStatisticsGroup.OnImaMessageReceived(msg); ISchedulingContext context; // Find the activation it targets; first check for a system activation, then an app activation if (msg.TargetGrain.IsSystemTarget) { SystemTarget target = directory.FindSystemTarget(msg.TargetActivation); if (target == null) { MessagingStatisticsGroup.OnRejectedMessage(msg); Message response = this.messageFactory.CreateRejectionResponse(msg, Message.RejectionTypes.Unrecoverable, String.Format("SystemTarget {0} not active on this silo. Msg={1}", msg.TargetGrain, msg)); messageCenter.SendMessage(response); Log.Warn(ErrorCode.MessagingMessageFromUnknownActivation, "Received a message {0} for an unknown SystemTarget: {1}", msg, msg.TargetAddress); return; } context = target.SchedulingContext; switch (msg.Direction) { case Message.Directions.Request: MessagingProcessingStatisticsGroup.OnImaMessageEnqueued(context); scheduler.QueueWorkItem(new RequestWorkItem(target, msg), context); break; case Message.Directions.Response: MessagingProcessingStatisticsGroup.OnImaMessageEnqueued(context); scheduler.QueueWorkItem(new ResponseWorkItem(target, msg), context); break; default: Log.Error(ErrorCode.Runtime_Error_100097, "Invalid message: " + msg); break; } } else { // Run this code on the target activation's context, if it already exists ActivationData targetActivation = directory.FindTarget(msg.TargetActivation); if (targetActivation != null) { lock (targetActivation) { var target = targetActivation; // to avoid a warning about nulling targetActivation under a lock on it if (target.State == ActivationState.Valid) { var overloadException = target.CheckOverloaded(Log); if (overloadException != null) { // Send rejection as soon as we can, to avoid creating additional work for runtime dispatcher.RejectMessage(msg, Message.RejectionTypes.Overloaded, overloadException, "Target activation is overloaded " + target); return; } // Run ReceiveMessage in context of target activation context = new SchedulingContext(target); } else { // Can't use this activation - will queue for another activation target = null; context = null; } EnqueueReceiveMessage(msg, target, context); } } else { // No usable target activation currently, so run ReceiveMessage in system context EnqueueReceiveMessage(msg, null, null); } } }
public ScheduleRepository(SchedulingContext context) { this._context = context; }
public GeneticAlgorithm(int id) { _context = new SchedulingContext(); this.SectionId = id; IntializePopulation(SectionId); }
public RequestManager(SchedulingContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
/// <summary> /// Creates a scheduler using the specified thread pool and job store and /// binds it to RMI. /// </summary> /// <param name="schedulerName">The name for the scheduler.</param> /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param> /// <param name="threadPool">The thread pool for executing jobs</param> /// <param name="jobStore">The type of job store</param> /// <param name="schedulerPluginMap"></param> /// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for /// the default value, which is currently 30000 ms.</param> /// <param name="dbFailureRetryInterval">The db failure retry interval.</param> public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool, IJobStore jobStore, IDictionary schedulerPluginMap, TimeSpan idleWaitTime, TimeSpan dbFailureRetryInterval) { // Currently only one run-shell factory is available... IJobRunShellFactory jrsf = new StdJobRunShellFactory(); // Fire everything up // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var schedCtxt = new SchedulingContext(); schedCtxt.InstanceId = schedulerInstanceId; var qrs = new QuartzSchedulerResources(); qrs.Name = schedulerName; qrs.InstanceId = schedulerInstanceId; qrs.JobRunShellFactory = jrsf; qrs.ThreadPool = threadPool; qrs.JobStore = jobStore; // add plugins if (schedulerPluginMap != null) { foreach (ISchedulerPlugin plugin in schedulerPluginMap.Values) { qrs.AddSchedulerPlugin(plugin); } } var qs = new QuartzScheduler(qrs, schedCtxt, idleWaitTime, dbFailureRetryInterval); ITypeLoadHelper cch = new CascadingClassLoadHelper(); cch.Initialize(); jobStore.Initialize(cch, qs.SchedulerSignaler); IScheduler scheduler = new StdScheduler(qs, schedCtxt); // Initialize plugins now that we have a Scheduler instance. if (schedulerPluginMap != null) { foreach (DictionaryEntry pluginEntry in schedulerPluginMap) { ((ISchedulerPlugin)pluginEntry.Value).Initialize( (string)pluginEntry.Key, scheduler); } } jrsf.Initialize(scheduler, schedCtxt); Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler '{0}", scheduler.SchedulerName)); Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler version: {0}", qs.Version)); var schedRep = SchedulerRepository.Instance; qs.AddNoGCObject(schedRep); // prevents the repository from being // garbage collected schedRep.Bind(scheduler); }
public ClientsController(SchedulingContext db) { this.db = db; }
public void GetClientReferenceList() { var db = new SchedulingContext(); Assert.IsNotNull(db.Clients.ToList()); }
public DepartmentsController() { _context = new SchedulingContext(); }
private async Task OnRuntimeServicesStart(CancellationToken ct) { //TODO: Setup all (or as many as possible) of the class started in this call to work directly with lifecyce // The order of these 4 is pretty much arbitrary. scheduler.Start(); messageCenter.Start(); incomingPingAgent.Start(); incomingSystemAgent.Start(); incomingAgent.Start(); LocalGrainDirectory.Start(); // Set up an execution context for this thread so that the target creation steps can use asynch values. RuntimeContext.InitializeMainThread(); // Initialize the implicit stream subscribers table. var implicitStreamSubscriberTable = Services.GetRequiredService <ImplicitStreamSubscriberTable>(); var grainTypeManager = Services.GetRequiredService <GrainTypeManager>(); implicitStreamSubscriberTable.InitImplicitStreamSubscribers(grainTypeManager.GrainClassTypeData.Select(t => t.Value.Type).ToArray()); var siloProviderRuntime = Services.GetRequiredService <SiloProviderRuntime>(); runtimeClient.CurrentStreamProviderRuntime = siloProviderRuntime; statisticsProviderManager = this.Services.GetRequiredService <StatisticsProviderManager>(); string statsProviderName = await statisticsProviderManager.LoadProvider(GlobalConfig.ProviderConfigurations) .WithTimeout(initTimeout); if (statsProviderName != null) { LocalConfig.StatisticsProviderName = statsProviderName; } // can call SetSiloMetricsTableDataManager only after MessageCenter is created (dependency on this.SiloAddress). await siloStatistics.SetSiloStatsTableDataManager(this, LocalConfig).WithTimeout(initTimeout); await siloStatistics.SetSiloMetricsTableDataManager(this, LocalConfig).WithTimeout(initTimeout); // This has to follow the above steps that start the runtime components CreateSystemTargets(); await InjectDependencies(); // Validate the configuration. GlobalConfig.Application.ValidateConfiguration(logger); // Initialize storage providers once we have a basic silo runtime environment operating storageProviderManager = this.Services.GetRequiredService <StorageProviderManager>(); await scheduler.QueueTask( () => storageProviderManager.LoadStorageProviders(GlobalConfig.ProviderConfigurations), providerManagerSystemTarget.SchedulingContext) .WithTimeout(initTimeout); ITransactionAgent transactionAgent = this.Services.GetRequiredService <ITransactionAgent>(); ISchedulingContext transactionAgentContext = (transactionAgent as SystemTarget)?.SchedulingContext; await scheduler.QueueTask(transactionAgent.Start, transactionAgentContext) .WithTimeout(initTimeout); var versionStore = Services.GetService <IVersionStore>() as GrainVersionStore; versionStore?.SetStorageManager(storageProviderManager); logger.Debug("Storage provider manager created successfully."); // Initialize log consistency providers once we have a basic silo runtime environment operating logConsistencyProviderManager = this.Services.GetRequiredService <LogConsistencyProviderManager>(); await scheduler.QueueTask( () => logConsistencyProviderManager.LoadLogConsistencyProviders(GlobalConfig.ProviderConfigurations), providerManagerSystemTarget.SchedulingContext) .WithTimeout(initTimeout); logger.Debug("Log consistency provider manager created successfully."); // Load and init stream providers before silo becomes active var siloStreamProviderManager = (StreamProviderManager)this.Services.GetRequiredService <IStreamProviderManager>(); await scheduler.QueueTask( () => siloStreamProviderManager.LoadStreamProviders(GlobalConfig.ProviderConfigurations, siloProviderRuntime), providerManagerSystemTarget.SchedulingContext) .WithTimeout(initTimeout); runtimeClient.CurrentStreamProviderManager = siloStreamProviderManager; logger.Debug("Stream provider manager created successfully."); // Load and init grain services before silo becomes active. await CreateGrainServices(GlobalConfig.GrainServiceConfigurations); this.membershipOracleContext = (this.membershipOracle as SystemTarget)?.SchedulingContext ?? this.providerManagerSystemTarget.SchedulingContext; await scheduler.QueueTask(() => this.membershipOracle.Start(), this.membershipOracleContext) .WithTimeout(initTimeout); logger.Debug("Local silo status oracle created successfully."); await scheduler.QueueTask(this.membershipOracle.BecomeActive, this.membershipOracleContext) .WithTimeout(initTimeout); logger.Debug("Local silo status oracle became active successfully."); await scheduler.QueueTask(() => this.typeManager.Initialize(versionStore), this.typeManager.SchedulingContext) .WithTimeout(this.initTimeout); //if running in multi cluster scenario, start the MultiClusterNetwork Oracle if (GlobalConfig.HasMultiClusterNetwork) { logger.Info("Starting multicluster oracle with my ServiceId={0} and ClusterId={1}.", GlobalConfig.ServiceId, GlobalConfig.ClusterId); this.multiClusterOracleContext = (multiClusterOracle as SystemTarget)?.SchedulingContext ?? this.providerManagerSystemTarget.SchedulingContext; await scheduler.QueueTask(() => multiClusterOracle.Start(), multiClusterOracleContext) .WithTimeout(initTimeout); logger.Debug("multicluster oracle created successfully."); } try { this.siloStatistics.Start(this.LocalConfig); logger.Debug("Silo statistics manager started successfully."); // Finally, initialize the deployment load collector, for grains with load-based placement var deploymentLoadPublisher = Services.GetRequiredService <DeploymentLoadPublisher>(); await this.scheduler.QueueTask(deploymentLoadPublisher.Start, deploymentLoadPublisher.SchedulingContext) .WithTimeout(this.initTimeout); logger.Debug("Silo deployment load publisher started successfully."); // Start background timer tick to watch for platform execution stalls, such as when GC kicks in this.platformWatchdog = new Watchdog(this.LocalConfig.StatisticsLogWriteInterval, this.healthCheckParticipants, this.executorService, this.loggerFactory); this.platformWatchdog.Start(); if (this.logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Silo platform watchdog started successfully."); } if (this.reminderService != null) { // so, we have the view of the membership in the consistentRingProvider. We can start the reminder service this.reminderServiceContext = (this.reminderService as SystemTarget)?.SchedulingContext ?? this.providerManagerSystemTarget.SchedulingContext; await this.scheduler.QueueTask(this.reminderService.Start, this.reminderServiceContext) .WithTimeout(this.initTimeout); this.logger.Debug("Reminder service started successfully."); } this.bootstrapProviderManager = this.Services.GetRequiredService <BootstrapProviderManager>(); await this.scheduler.QueueTask( () => this.bootstrapProviderManager.LoadAppBootstrapProviders(siloProviderRuntime, this.GlobalConfig.ProviderConfigurations), this.providerManagerSystemTarget.SchedulingContext) .WithTimeout(this.initTimeout); this.BootstrapProviders = this.bootstrapProviderManager.GetProviders(); // Data hook for testing & diagnotics logger.Debug("App bootstrap calls done successfully."); // Start stream providers after silo is active (so the pulling agents don't start sending messages before silo is active). // also after bootstrap provider started so bootstrap provider can initialize everything stream before events from this silo arrive. await this.scheduler.QueueTask(siloStreamProviderManager.StartStreamProviders, this.providerManagerSystemTarget.SchedulingContext) .WithTimeout(this.initTimeout); logger.Debug("Stream providers started successfully."); // Now that we're active, we can start the gateway var mc = this.messageCenter as MessageCenter; mc?.StartGateway(this.Services.GetRequiredService <ClientObserverRegistrar>()); logger.Debug("Message gateway service started successfully."); this.SystemStatus = SystemStatus.Running; } catch (Exception exc) { this.SafeExecute(() => this.logger.Error(ErrorCode.Runtime_Error_100330, String.Format("Error starting silo {0}. Going to FastKill().", this.SiloAddress), exc)); throw; } if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Silo.Start complete: System status = {0}", this.SystemStatus); } }
public SchedulingRepository(SchedulingContext context, ILogger <SchedulingRepository> logger) : base(context, logger) { }
private void SendRequestMessage( GrainReference target, Message message, TaskCompletionSource <object> context, Action <Message, TaskCompletionSource <object> > callback, string debugContext, InvokeMethodOptions options, string genericArguments = null) { // fill in sender if (message.SendingSilo == null) { message.SendingSilo = MySilo; } if (!String.IsNullOrEmpty(genericArguments)) { message.GenericGrainType = genericArguments; } SchedulingContext schedulingContext = RuntimeContext.Current != null ? RuntimeContext.Current.ActivationContext as SchedulingContext : null; ActivationData sendingActivation = null; if (schedulingContext == null) { throw new InvalidOperationException( String.Format("Trying to send a message {0} on a silo not from within grain and not from within system target (RuntimeContext is not set to SchedulingContext) " + "RuntimeContext.Current={1} TaskScheduler.Current={2}", message, RuntimeContext.Current == null ? "null" : RuntimeContext.Current.ToString(), TaskScheduler.Current)); } switch (schedulingContext.ContextType) { case SchedulingContextType.SystemThread: throw new ArgumentException( String.Format("Trying to send a message {0} on a silo not from within grain and not from within system target (RuntimeContext is of SchedulingContextType.SystemThread type)", message), "context"); case SchedulingContextType.Activation: message.SendingActivation = schedulingContext.Activation.ActivationId; message.SendingGrain = schedulingContext.Activation.Grain; sendingActivation = schedulingContext.Activation; break; case SchedulingContextType.SystemTarget: message.SendingActivation = schedulingContext.SystemTarget.ActivationId; message.SendingGrain = ((ISystemTargetBase)schedulingContext.SystemTarget).GrainId; break; } // fill in destination var targetGrainId = target.GrainId; message.TargetGrain = targetGrainId; if (targetGrainId.IsSystemTarget) { SiloAddress targetSilo = (target.SystemTargetSilo ?? MySilo); message.TargetSilo = targetSilo; message.TargetActivation = ActivationId.GetSystemActivation(targetGrainId, targetSilo); message.Category = targetGrainId.Equals(Constants.MembershipOracleId) ? Message.Categories.Ping : Message.Categories.System; } if (target.IsObserverReference) { message.TargetObserverId = target.ObserverId; } if (debugContext != null) { message.DebugContext = debugContext; } var oneWay = (options & InvokeMethodOptions.OneWay) != 0; if (context == null && !oneWay) { logger.Warn(ErrorCode.IGC_SendRequest_NullContext, "Null context {0}: {1}", message, Utils.GetStackTrace()); } if (message.IsExpirableMessage(Config.Globals)) { message.TimeToLive = ResponseTimeout; } if (!oneWay) { var callbackData = new CallbackData( callback, tryResendMessage, context, message, unregisterCallback, Config.Globals); callbacks.TryAdd(message.Id, callbackData); callbackData.StartTimer(ResponseTimeout); } if (targetGrainId.IsSystemTarget) { // Messages to system targets bypass the task system and get sent "in-line" this.Dispatcher.TransportMessage(message); } else { this.Dispatcher.SendMessage(message, sendingActivation); } }
protected BaseRepository(SchedulingContext context, ILogger logger) { Context = context; Logger = logger; }