예제 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public LeaseBasedQueueBalancer(string name, LeaseBasedQueueBalancerOptions options, ILeaseProvider leaseProvider, ITimerRegistry timerRegistry, IServiceProvider services, ILoggerFactory loggerFactory)
     : base(services, loggerFactory.CreateLogger($"{typeof(LeaseBasedQueueBalancer).FullName}.{name}"))
 {
     this.options       = options;
     this.leaseProvider = leaseProvider;
     this.timerRegistry = timerRegistry;
 }
예제 #2
0
 public GrainRuntime(string siloId, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager)
 {
     SiloIdentity = siloId;
     GrainFactory = grainFactory;
     TimerRegistry = timerRegistry;
     ReminderRegistry = reminderRegistry;
     StreamProviderManager = streamProviderManager;
 }
예제 #3
0
 public TestGrainRuntime(IGrainFactory grainFactory, ITimerRegistry timerRegistry, IStreamProviderManager streamProviderManager, IReminderRegistry reminderRegistry, IServiceProvider serviceProvider)
 {
     GrainFactory          = grainFactory;
     TimerRegistry         = timerRegistry;
     StreamProviderManager = streamProviderManager;
     ReminderRegistry      = reminderRegistry;
     ServiceProvider       = serviceProvider;
 }
예제 #4
0
 public TestGrainRuntime(IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IServiceProvider serviceProvider, StorageManager storageManager)
 {
     GrainFactory     = grainFactory ?? throw new ArgumentNullException(nameof(grainFactory));
     TimerRegistry    = timerRegistry ?? throw new ArgumentNullException(nameof(timerRegistry));
     ReminderRegistry = reminderRegistry ?? throw new ArgumentNullException(nameof(reminderRegistry));
     ServiceProvider  = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     _storageManager  = storageManager ?? throw new ArgumentNullException(nameof(storageManager));
 }
예제 #5
0
 public GrainRuntime(string siloId, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager)
 {
     SiloIdentity          = siloId;
     GrainFactory          = grainFactory;
     TimerRegistry         = timerRegistry;
     ReminderRegistry      = reminderRegistry;
     StreamProviderManager = streamProviderManager;
 }
예제 #6
0
 public GrainRuntime(string id, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager)
 {
     this.id                    = id;
     this.grainFactory          = grainFactory;
     this.timerRegistry         = timerRegistry;
     this.reminderRegistry      = reminderRegistry;
     this.streamProviderManager = streamProviderManager;
 }
예제 #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 public LeaseBasedQueueBalancer(string name, LeaseBasedQueueBalancerOptions options, ILeaseProvider leaseProvider, ITimerRegistry timerRegistry, IServiceProvider services, ILoggerFactory loggerFactory)
     : base(services, loggerFactory.CreateLogger($"{nameof(LeaseBasedQueueBalancer)}-{name}"))
 {
     this.options       = options;
     this.leaseProvider = leaseProvider;
     this.timerRegistry = timerRegistry;
     this.executor      = new AsyncSerialExecutor();
     this.myQueues      = new List <AcquiredQueue>();
 }
예제 #8
0
 public GrainRuntime(Guid serviceId, string siloId, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager, IServiceProvider serviceProvider)
 {
     ServiceId = serviceId;
     SiloIdentity = siloId;
     GrainFactory = grainFactory;
     TimerRegistry = timerRegistry;
     ReminderRegistry = reminderRegistry;
     StreamProviderManager = streamProviderManager;
     ServiceProvider = serviceProvider;
 }
예제 #9
0
 public GrainRuntime(Guid serviceId, string siloId, IGrainFactory grainFactory, ITimerRegistry timerRegistry, IReminderRegistry reminderRegistry, IStreamProviderManager streamProviderManager, IServiceProvider serviceProvider)
 {
     ServiceId             = serviceId;
     SiloIdentity          = siloId;
     GrainFactory          = grainFactory;
     TimerRegistry         = timerRegistry;
     ReminderRegistry      = reminderRegistry;
     StreamProviderManager = streamProviderManager;
     ServiceProvider       = serviceProvider;
 }
예제 #10
0
 public GrainRuntime(
     ILocalSiloDetails localSiloDetails,
     IGrainFactory grainFactory,
     ITimerRegistry timerRegistry,
     IReminderRegistry reminderRegistry,
     IServiceProvider serviceProvider,
     ILoggerFactory loggerFactory)
 {
     SiloAddress           = localSiloDetails.SiloAddress;
     SiloIdentity          = SiloAddress.ToLongString();
     this.grainFactory     = grainFactory;
     this.timerRegistry    = timerRegistry;
     this.reminderRegistry = reminderRegistry;
     this.serviceProvider  = serviceProvider;
     this.loggerFactory    = loggerFactory;
 }
예제 #11
0
 public GrainRuntime(
     GlobalConfiguration globalConfig,
     ILocalSiloDetails localSiloDetails,
     IGrainFactory grainFactory,
     ITimerRegistry timerRegistry,
     IReminderRegistry reminderRegistry,
     IStreamProviderManager streamProviderManager,
     IServiceProvider serviceProvider,
     IRuntimeClient runtimeClient)
 {
     this.runtimeClient = runtimeClient;
     ServiceId = globalConfig.ServiceId;
     SiloIdentity = localSiloDetails.SiloAddress.ToLongString();
     GrainFactory = grainFactory;
     TimerRegistry = timerRegistry;
     ReminderRegistry = reminderRegistry;
     StreamProviderManager = streamProviderManager;
     ServiceProvider = serviceProvider;
 }
예제 #12
0
 public GrainRuntime(
     GlobalConfiguration globalConfig,
     ILocalSiloDetails localSiloDetails,
     IGrainFactory grainFactory,
     ITimerRegistry timerRegistry,
     IReminderRegistry reminderRegistry,
     IStreamProviderManager streamProviderManager,
     IServiceProvider serviceProvider,
     IRuntimeClient runtimeClient)
 {
     this.runtimeClient    = runtimeClient;
     ServiceId             = globalConfig.ServiceId;
     SiloIdentity          = localSiloDetails.SiloAddress.ToLongString();
     GrainFactory          = grainFactory;
     TimerRegistry         = timerRegistry;
     ReminderRegistry      = reminderRegistry;
     StreamProviderManager = streamProviderManager;
     ServiceProvider       = serviceProvider;
 }
예제 #13
0
 public GrainRuntime(
     IOptions <ClusterOptions> clusterOptions,
     ILocalSiloDetails localSiloDetails,
     IGrainFactory grainFactory,
     ITimerRegistry timerRegistry,
     IReminderRegistry reminderRegistry,
     IServiceProvider serviceProvider,
     ISiloRuntimeClient runtimeClient,
     ILoggerFactory loggerFactory)
 {
     this.runtimeClient    = runtimeClient;
     ServiceId             = clusterOptions.Value.ServiceId;
     SiloAddress           = localSiloDetails.SiloAddress;
     SiloIdentity          = SiloAddress.ToLongString();
     this.grainFactory     = grainFactory;
     this.timerRegistry    = timerRegistry;
     this.reminderRegistry = reminderRegistry;
     this.serviceProvider  = serviceProvider;
     this.loggerFactory    = loggerFactory;
 }
        /// <inheritdoc/>
        public override Task Initialize(IStreamQueueMapper queueMapper)
        {
            if (queueMapper == null)
            {
                throw new ArgumentNullException("queueMapper");
            }
            this.allQueues = new ReadOnlyCollection <QueueId>(queueMapper.GetAllQueues().ToList());
            if (this.allQueues.Count == 0)
            {
                return(Task.CompletedTask);
            }
            this.leaseProvider = this.serviceProvider.GetRequiredService(options.LeaseProviderType) as ILeaseProvider;
            NotifyAfterStart().Ignore();
            //make lease renew frequency to be every half of lease time, to avoid renew failing due to timing issues, race condition or clock difference.
            ITimerRegistry timerRegistry = this.serviceProvider.GetRequiredService <ITimerRegistry>();

            this.renewLeaseTimer = timerRegistry.RegisterTimer(null, this.MaintainAndBalanceQueues, null, this.options.SiloMaturityPeriod, this.options.LeaseLength.Divide(2));
            //try to acquire maximum leases every leaseLength
            this.tryAcquireMaximumLeaseTimer = timerRegistry.RegisterTimer(null, this.AcquireLeaseToMeetMaxResponsibility, null, this.options.SiloMaturityPeriod, this.options.SiloMaturityPeriod);
            //Selector default to round robin selector now, but we can make a further change to make selector configurable if needed.  Selector algorithm could
            //be affecting queue balancing stablization time in cluster initializing and auto-scaling
            this.queueSelector = new RoundRobinSelector <QueueId>(this.allQueues);
            return(MaintainAndBalanceQueues(null));
        }
예제 #15
0
 internal TimerService(Grain grain)
 {
     this.grain    = grain;
     this.registry = grain.Runtime().TimerRegistry;
 }
예제 #16
0
 public PingSelfGrain(ILogger <PingSelfGrain <T> > logger, IGrainContext context, ITimerRegistry timerRegistry)
 {
     this.logger       = logger;
     this.GrainContext = context;
     _timerRegistry    = timerRegistry;
 }
예제 #17
0
 public DistributedCacheGrain(ITimerRegistry timerRegistry)
 {
     this.timerRegistry = timerRegistry;
 }
예제 #18
0
 public TestGrainRuntime(IGrainFactory grainFactory, ITimerRegistry timerRegistry, IStreamProviderManager streamProviderManager)
 {
     GrainFactory          = grainFactory;
     TimerRegistry         = timerRegistry;
     StreamProviderManager = streamProviderManager;
 }