Пример #1
0
        internal bool AddActiveReplication(Replication replication)
        {
            if (ActiveReplicators == null) {
                Log.W(TAG, "ActiveReplicators is null, so replication will not be added");
                return false;
            }

            if (ActiveReplicators.All(x => x.RemoteCheckpointDocID() != replication.RemoteCheckpointDocID())) {
                ActiveReplicators.Add(replication);
            } else {
                return false;
            }

            replication.Changed += (sender, e) => {
                if (e.Source != null && !e.Source.IsRunning && ActiveReplicators != null)
                {
                    ActiveReplicators.Remove(e.Source);
                }
            };

            return true;
        }
 internal bool HasSameSettingsAs(Replication other)
 {
     return LocalDatabase == other.LocalDatabase &&
     IsPull == other.IsPull &&
     RemoteCheckpointDocID("").Equals(other.RemoteCheckpointDocID(""));
 }
Пример #3
0
        internal bool AddReplication(Replication replication)
        {
            lock (_allReplicatorsLocker) {
                if (AllReplications.All(x => x.RemoteCheckpointDocID() != replication.RemoteCheckpointDocID())) {
                    AllReplicators.Add(replication);
                    return true;
                }

                return false;

            }
        }
Пример #4
0
        internal bool AddActiveReplication(Replication replication)
        {
            if(replication == null) {
                return false;
            }

            var activeReplicators = default(IList<Replication>);
            if(!ActiveReplicators.AcquireTemp(out activeReplicators)) {
                Log.To.Database.W(TAG, "{0} ActiveReplicators is null, so replication will not be added");
                return false;
            }

            lock(_activeReplicatorsLocker) {
                if(activeReplicators.All(x => x != null && x.RemoteCheckpointDocID() != replication.RemoteCheckpointDocID())) {
                    activeReplicators.Add(replication);
                } else {
                    return false;
                }
            }
            
            replication.Changed += (sender, e) =>
            {
                if(e.ReplicationStateTransition != null && (e.ReplicationStateTransition.Trigger == ReplicationTrigger.StopGraceful || e.ReplicationStateTransition.Trigger == ReplicationTrigger.StopImmediate)) {
                    if(ActiveReplicators.AcquireTemp(out activeReplicators)) {
                        lock(_activeReplicatorsLocker) {
                            activeReplicators.Remove(e.Source);
                        }
                    }
                }
            };

            return true;
        }