public Registration(IActorRef replicator, VectorTime currentTargetVersionVector, ReplicationFilter filter, DateTime registrationTime) { Replicator = replicator; CurrentTargetVersionVector = currentTargetVersionVector; Filter = filter; RegistrationTime = registrationTime; }
public ReplicationRead(long fromSequenceNr, int max, int scanLimit, ReplicationFilter filter, string targetLogId, IActorRef replicator, VectorTime currentTargetVersionVector) { FromSequenceNr = fromSequenceNr; Max = max; ScanLimit = scanLimit; Filter = filter; TargetLogId = targetLogId; Replicator = replicator; CurrentTargetVersionVector = currentTargetVersionVector; }
public override void BeginReplicating() { Log.D(Log.TagSync, "%s: beginReplicating() called", this); // If we're still waiting to create the remote db, do nothing now. (This method will be // re-invoked after that request finishes; see maybeCreateRemoteDB() above.) if (creatingTarget) { Log.D(Log.TagSync, "%s: creatingTarget == true, doing nothing", this); return; } pendingSequences = Sharpen.Collections.SynchronizedSortedSet(new TreeSet <long>()); try { maxPendingSequence = long.Parse(lastSequence); } catch (FormatException) { Log.W(Log.TagSync, "Error converting lastSequence: %s to long. Using 0", lastSequence ); maxPendingSequence = System.Convert.ToInt64(0); } if (filterName != null) { filter = db.GetFilter(filterName); } if (filterName != null && filter == null) { Log.W(Log.TagSync, "%s: No ReplicationFilter registered for filter '%s'; ignoring" , this, filterName); } // Process existing changes since the last push: long lastSequenceLong = 0; if (lastSequence != null) { lastSequenceLong = long.Parse(lastSequence); } ChangesOptions options = new ChangesOptions(); options.SetIncludeConflicts(true); RevisionList changes = db.ChangesSince(lastSequenceLong, options, filter); if (changes.Count > 0) { batcher.QueueObjects(changes); batcher.Flush(); } // Now listen for future changes (in continuous mode): if (continuous) { observing = true; db.AddChangeListener(this); } }
public override void BeginReplicating() { // If we're still waiting to create the remote db, do nothing now. (This method will be // re-invoked after that request finishes; see maybeCreateRemoteDB() above.) Log.D(Database.Tag, this + "|" + Sharpen.Thread.CurrentThread() + ": beginReplicating() called" ); if (creatingTarget) { Log.D(Database.Tag, this + "|" + Sharpen.Thread.CurrentThread() + ": creatingTarget == true, doing nothing" ); return; } else { Log.D(Database.Tag, this + "|" + Sharpen.Thread.CurrentThread() + ": creatingTarget != true, continuing" ); } if (filterName != null) { filter = db.GetFilter(filterName); } if (filterName != null && filter == null) { Log.W(Database.Tag, string.Format("%s: No ReplicationFilter registered for filter '%s'; ignoring" , this, filterName)); } // Process existing changes since the last push: long lastSequenceLong = 0; if (lastSequence != null) { lastSequenceLong = long.Parse(lastSequence); } ChangesOptions options = new ChangesOptions(); options.SetIncludeConflicts(true); RevisionList changes = db.ChangesSince(lastSequenceLong, options, filter); if (changes.Count > 0) { batcher.QueueObjects(changes); batcher.Flush(); } // Now listen for future changes (in continuous mode): if (continuous) { observing = true; db.AddChangeListener(this); Log.D(Database.Tag, this + "|" + Sharpen.Thread.CurrentThread() + ": pusher.beginReplicating() calling asyncTaskStarted()" ); AsyncTaskStarted(); } }
public void SetFilter(string filterName, ReplicationFilter filter) { if (filters == null) { filters = new Dictionary<string, ReplicationFilter>(); } if (filter != null) { filters.Put(filterName, filter); } else { Sharpen.Collections.Remove(filters, filterName); } }
public bool RunFilter(ReplicationFilter filter, IDictionary<string, object> paramsIgnored , RevisionInternal rev) { if (filter == null) { return true; } SavedRevision publicRev = new SavedRevision(this, rev); return filter.Filter(publicRev, null); }
public RevisionList ChangesSince(long lastSeq, ChangesOptions options, ReplicationFilter filter) { // http://wiki.apache.org/couchdb/HTTP_database_API#Changes if (options == null) { options = new ChangesOptions(); } bool includeDocs = options.IsIncludeDocs() || (filter != null); string additionalSelectColumns = string.Empty; if (includeDocs) { additionalSelectColumns = ", json"; } string sql = "SELECT sequence, revs.doc_id, docid, revid, deleted" + additionalSelectColumns + " FROM revs, docs " + "WHERE sequence > ? AND current=1 " + "AND revs.doc_id = docs.doc_id " + "ORDER BY revs.doc_id, revid DESC"; string[] args = new string[] { System.Convert.ToString(lastSeq) }; Cursor cursor = null; RevisionList changes = null; try { cursor = database.RawQuery(sql, args); cursor.MoveToNext(); changes = new RevisionList(); long lastDocId = 0; while (!cursor.IsAfterLast()) { if (!options.IsIncludeConflicts()) { // Only count the first rev for a given doc (the rest will be losing conflicts): long docNumericId = cursor.GetLong(1); if (docNumericId == lastDocId) { cursor.MoveToNext(); continue; } lastDocId = docNumericId; } RevisionInternal rev = new RevisionInternal(cursor.GetString(2), cursor.GetString (3), (cursor.GetInt(4) > 0), this); rev.SetSequence(cursor.GetLong(0)); if (includeDocs) { ExpandStoredJSONIntoRevisionWithAttachments(cursor.GetBlob(5), rev, options.GetContentOptions ()); } IDictionary<string, object> paramsFixMe = null; // TODO: these should not be null if (RunFilter(filter, paramsFixMe, rev)) { changes.AddItem(rev); } cursor.MoveToNext(); } } catch (SQLException e) { Log.E(Database.Tag, "Error looking for changes", e); } finally { if (cursor != null) { cursor.Close(); } } if (options.IsSortBySequence()) { changes.SortBySequence(); } changes.Limit(options.GetLimit()); return changes; }
public _AsyncTask_965(ReplicationFilter filter, Validator validation, Mapper map, Reducer reduce) { this.filter = filter; this.validation = validation; this.map = map; this.reduce = reduce; }
public override void BeginReplicating() { Log.D(Log.TagSync, "%s: beginReplicating() called", this); // If we're still waiting to create the remote db, do nothing now. (This method will be // re-invoked after that request finishes; see maybeCreateRemoteDB() above.) if (creatingTarget) { Log.D(Log.TagSync, "%s: creatingTarget == true, doing nothing", this); return; } pendingSequences = Sharpen.Collections.SynchronizedSortedSet(new TreeSet<long>()); try { maxPendingSequence = long.Parse(lastSequence); } catch (FormatException) { Log.W(Log.TagSync, "Error converting lastSequence: %s to long. Using 0", lastSequence ); maxPendingSequence = System.Convert.ToInt64(0); } if (filterName != null) { filter = db.GetFilter(filterName); } if (filterName != null && filter == null) { Log.W(Log.TagSync, "%s: No ReplicationFilter registered for filter '%s'; ignoring" , this, filterName); } // Process existing changes since the last push: long lastSequenceLong = 0; if (lastSequence != null) { lastSequenceLong = long.Parse(lastSequence); } ChangesOptions options = new ChangesOptions(); options.SetIncludeConflicts(true); RevisionList changes = db.ChangesSince(lastSequenceLong, options, filter); if (changes.Count > 0) { batcher.QueueObjects(changes); batcher.Flush(); } // Now listen for future changes (in continuous mode): if (continuous) { observing = true; db.AddChangeListener(this); } }