private void OnStatusChange(GrainServiceStatus oldStatus, GrainServiceStatus newStatus)
 {
     if (oldStatus != GrainServiceStatus.Started && newStatus == GrainServiceStatus.Started)
     {
         ring.SubscribeToRangeChangeEvents(this);
     }
     if (oldStatus != GrainServiceStatus.Stopped && newStatus == GrainServiceStatus.Stopped)
     {
         ring.UnSubscribeFromRangeChangeEvents(this);
     }
 }
Example #2
0
        public ConsistentRingQueueBalancer(IConsistentRingProvider consistentRingProvider, ILoggerFactory loggerFactory, IServiceProvider services, ILogger <ConsistentRingQueueBalancer> logger)
            : base(services, logger)
        {
            if (consistentRingProvider == null)
            {
                throw new ArgumentNullException("streamProviderRuntime");
            }

            _myRange = consistentRingProvider.GetMyRange();
            consistentRingProvider.SubscribeToRangeChangeEvents(this);
        }
 internal EquallyDevidedRangeRingProvider(IConsistentRingProvider provider, int mySubRangeIndex, int numSubRanges)
 {
     if (mySubRangeIndex < 0 || mySubRangeIndex >= numSubRanges)
         throw new IndexOutOfRangeException("mySubRangeIndex is out of the range. mySubRangeIndex = " + mySubRangeIndex + " numSubRanges = " + numSubRanges);
     
     ringProvider = provider;
     this.numSubRanges = numSubRanges;
     this.mySubRangeIndex = mySubRangeIndex;
     grainStatusListeners = new List<IAsyncRingRangeListener>();
     ringProvider.SubscribeToRangeChangeEvents(this);
     logger = TraceLogger.GetLogger(typeof(EquallyDevidedRangeRingProvider).Name);
 }
 internal EquallyDividedRangeRingProvider(IConsistentRingProvider provider, ILoggerFactory loggerFactory, int mySubRangeIndex, int numSubRanges)
 {
     if (mySubRangeIndex < 0 || mySubRangeIndex >= numSubRanges)
         throw new IndexOutOfRangeException("mySubRangeIndex is out of the range. mySubRangeIndex = " + mySubRangeIndex + " numSubRanges = " + numSubRanges);
     
     ringProvider = provider;
     this.numSubRanges = numSubRanges;
     this.mySubRangeIndex = mySubRangeIndex;
     grainStatusListeners = new List<IAsyncRingRangeListener>();
     ringProvider.SubscribeToRangeChangeEvents(this);
     logger = loggerFactory.CreateLogger<EquallyDividedRangeRingProvider>();
 }
Example #5
0
        internal EquallyDividedRangeRingProvider(IConsistentRingProvider provider, int mySubRangeIndex, int numSubRanges)
        {
            if (mySubRangeIndex < 0 || mySubRangeIndex >= numSubRanges)
            {
                throw new IndexOutOfRangeException("mySubRangeIndex is out of the range. mySubRangeIndex = " + mySubRangeIndex + " numSubRanges = " + numSubRanges);
            }

            ringProvider         = provider;
            this.numSubRanges    = numSubRanges;
            this.mySubRangeIndex = mySubRangeIndex;
            grainStatusListeners = new List <IAsyncRingRangeListener>();
            ringProvider.SubscribeToRangeChangeEvents(this);
            logger = LogManager.GetLogger(typeof(EquallyDividedRangeRingProvider).Name);
        }