Пример #1
0
 public override void OnCoreSnapshot(CoreSnapshot coreSnapshot)
 {
     if (!_requestOutcomeSignal.Cancelled)
     {
         RecordLastResponse();
         @delegate.onCoreSnapshot(_requestOutcomeSignal, coreSnapshot);
     }
 }
Пример #2
0
 internal virtual void InstallSnapshot(CoreSnapshot coreSnapshot)
 {
     lock (this)
     {
         _coreStateMachines.installSnapshots(coreSnapshot);
         _sessionTracker.installSnapshot(coreSnapshot.Get(CoreStateType.SESSION_TRACKER));
     }
 }
Пример #3
0
 internal virtual void AugmentSnapshot(CoreSnapshot coreSnapshot)
 {
     lock (this)
     {
         _coreStateMachines.addSnapshots(coreSnapshot);
         coreSnapshot.Add(CoreStateType.SESSION_TRACKER, _sessionTracker.snapshot());
     }
 }
Пример #4
0
        /// <summary>
        /// The cluster binding process tries to establish a common cluster ID. If there is no common cluster ID
        /// then a single instance will eventually create one and publish it through the underlying topology service.
        /// </summary>
        /// <exception cref="IOException"> If there is an issue with I/O. </exception>
        /// <exception cref="InterruptedException"> If the process gets interrupted. </exception>
        /// <exception cref="TimeoutException"> If the process times out. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public BoundState bindToCluster() throws Throwable
        public virtual BoundState BindToCluster()
        {
            DatabaseName newName = new DatabaseName(_dbName);

            _dbNameStorage.writeOrVerify(newName, existing =>
            {
                if (!newName.Equals(existing))
                {
                    throw new System.InvalidOperationException(format("Your configured database name has changed. Found %s but expected %s in %s.", _dbName, existing.name(), CausalClusteringSettings.database.name()));
                }
            });

            long endTime            = _clock.millis() + _timeout.toMillis();
            bool shouldRetryPublish = false;

            if (_clusterIdStorage.exists())
            {
                _clusterId = _clusterIdStorage.readState();
                do
                {
                    shouldRetryPublish = PublishClusterId(_clusterId);
                } while (shouldRetryPublish && _clock.millis() < endTime);
                _monitor.boundToCluster(_clusterId);
                return(new BoundState(_clusterId));
            }

            CoreSnapshot snapshot = null;
            CoreTopology topology;

            do
            {
                topology = _topologyService.localCoreServers();

                if (topology.ClusterId() != null)
                {
                    _clusterId = topology.ClusterId();
                    _monitor.boundToCluster(_clusterId);
                }
                else if (HostShouldBootstrapCluster(topology))
                {
                    _clusterId = new ClusterId(System.Guid.randomUUID());
                    snapshot   = _coreBootstrapper.bootstrap(topology.Members().Keys);
                    _monitor.bootstrapped(snapshot, _clusterId);
                    shouldRetryPublish = PublishClusterId(_clusterId);
                }

                _retryWaiter.apply();
            } while ((_clusterId == null || shouldRetryPublish) && _clock.millis() < endTime);

            if (_clusterId == null || shouldRetryPublish)
            {
                throw new TimeoutException(format("Failed to join a cluster with members %s. Another member should have published " + "a clusterId but none was detected. Please restart the cluster.", topology));
            }

            _clusterIdStorage.writeState(_clusterId);
            return(new BoundState(_clusterId, snapshot));
        }
Пример #5
0
 internal BoundState(ClusterId clusterId, CoreSnapshot snapshot)
 {
     this._clusterId = clusterId;
     this._snapshot  = snapshot;
 }
Пример #6
0
 public override void OnCoreSnapshot(CompletableFuture <T> signal, CoreSnapshot response)
 {
     UnimplementedMethod(signal, response);
 }