Exemplo n.º 1
0
        private void UpdateSchedulerState()
        {
            bool mustenable = true;

            // Every iteration we will make sure that, if we are primary and we are not in lockdown,
            // there is a SchedulerCommand, and it is started.
            // and if we are not primary or we are in lockdown, make sure there is no scheduler running anymore.
            if (this.backend == null)
            {
                mustenable = false;
            }
            else
            {
                if (this.backend.IsInFullLockDown)
                {
                    mustenable = false;
                }
                else if (!this.backend.IsPrimary())
                {
                    mustenable = false;
                }
            }

            if (mustenable)
            {
                if (this.scheduler == null)
                {
                    this.scheduler = new ScheduledCommand(
                        () => { return(this.backend != null && this.backend.IsPrimary()); },
                        new LoopbackRingMaster(this.backend),
                        new MarshallerChannel(null));
                }

                this.scheduler.Start();
            }
            else if (this.scheduler != null)
            {
                this.scheduler.Close();
                this.scheduler = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// initializes the pseudonodes tree structure
        /// </summary>
        /// <param name="rm">the rm object to use</param>
        private void InitializePseudoNodesStructure(AbstractRingMaster rm)
        {
            // ensure the tree structure is built
            if (!this.pseudosInitialized)
            {
                rm.Create("/$bulkwatcher", null, null, CreateMode.Persistent);
                rm.Create("/$metadata", null, null, CreateMode.Persistent);

                foreach (string path in ScheduledCommand.GetPaths())
                {
                    rm.Create(path, null, null, CreateMode.PersistentAllowPathCreation);
                }

                rm.Delete("/$metadata/ring", -1);
                rm.Create("/$metadata/clusterreplicaset", null, null, CreateMode.Persistent);
                rm.Create("/$metadata/health", null, null, CreateMode.Persistent);
                rm.Create("/$metadata/servicehealing", null, null, CreateMode.Persistent);
                rm.Create("/$metadata/primary", null, null, CreateMode.Persistent);
                rm.Create("/$metadata/synchronization/$syncpoint", null, null, CreateMode.PersistentAllowPathCreation);

                Trace.TraceInformation("PseudoNodes initialized");
                this.pseudosInitialized = true;
            }
        }