Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
make changesProcessed and changesTotal private and change TDPusher an…
Browse files Browse the repository at this point in the history
…d TDPuller to use the access methods. This ensures that Observers get called with replication changes.
  • Loading branch information
pegli committed Aug 2, 2012
1 parent ade012c commit 58ab949
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void changeTrackerReceivedChange(Map<String, Object> change) {
rev.setSequence(++nextFakeSequence);
addToInbox(rev);
}
changesTotal+= changes.size();
setChangesTotal(getChangesTotal() + changes.size());
}

@Override
Expand Down Expand Up @@ -158,7 +158,7 @@ public void processInbox(TDRevisionList inbox) {
// Ask the local database which of the revs are not known to it:
//Log.w(TDDatabase.TAG, String.format("%s: Looking up %s", this, inbox));
String lastInboxSequence = ((TDPulledRevision)inbox.get(inbox.size()-1)).getRemoteSequenceID();
int total = changesTotal - inbox.size();
int total = getChangesTotal() - inbox.size();
if(!db.findMissingRevisions(inbox)) {
Log.w(TDDatabase.TAG, String.format("%s failed to look up local revs", this));
inbox = null;
Expand All @@ -168,8 +168,8 @@ public void processInbox(TDRevisionList inbox) {
if(inbox != null) {
inboxCount = inbox.size();
}
if(changesTotal != total + inboxCount) {
changesTotal = total + inboxCount;
if(getChangesTotal() != total + inboxCount) {
setChangesTotal(total + inboxCount);
}

if(inboxCount == 0) {
Expand Down Expand Up @@ -260,13 +260,13 @@ public void onCompletion(Object result, Throwable e) {
asyncTaskStarted();
} else {
Log.w(TDDatabase.TAG, this + ": Missing revision history in response from " + pathInside);
changesProcessed++;
setChangesProcessed(getChangesProcessed() + 1);
}
} else {
if(e != null) {
error = e;
}
changesProcessed++;
setChangesProcessed(getChangesProcessed() + 1);
}

// Note that we've finished this task; then start another one if there
Expand Down Expand Up @@ -343,7 +343,7 @@ public int compare(List<Object> list1, List<Object> list2) {
asyncTaskFinished(revs.size());
}

changesProcessed += revs.size();
setChangesProcessed(getChangesProcessed() + revs.size());
}

List<String> knownCurrentRevIDs(TDRevision rev) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void onCompletion(Object response, Throwable e) {
bulkDocsBody.put("new_edits", false);
Log.i(TDDatabase.TAG, String.format("%s: Sending %d revisions", this, numDocsToSend));
Log.v(TDDatabase.TAG, String.format("%s: Sending %s", this, inbox));
changesTotal += numDocsToSend;
setChangesTotal(getChangesTotal() + numDocsToSend);
asyncTaskStarted();
sendAsyncRequest("POST", "/_bulk_docs", bulkDocsBody, new TDRemoteRequestCompletionBlock() {

Expand All @@ -221,7 +221,7 @@ public void onCompletion(Object result, Throwable e) {
Log.v(TDDatabase.TAG, String.format("%s: Sent %s", this, inbox));
setLastSequence(String.format("%d", lastInboxSequence));
}
changesProcessed += numDocsToSend;
setChangesProcessed(getChangesProcessed() + numDocsToSend);
asyncTaskFinished(1);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public abstract class TDReplicator extends Observable {
protected String sessionID;
protected TDBatcher<TDRevision> batcher;
protected int asyncTaskCount;
protected int changesProcessed;
protected int changesTotal;
private int changesProcessed;
private int changesTotal;
protected final HttpClientFactory clientFacotry;
protected String filterName;
protected Map<String,Object> filterParams;
Expand Down

0 comments on commit 58ab949

Please sign in to comment.